%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/ugotscom/www/BOS/application/modules/salesoverview/models/
Upload File :
Create Path :
Current File : /home/ugotscom/www/BOS/application/modules/salesoverview/models/Salesoverview_model.php

<?php
class Salesoverview_model extends CI_Model{


 public function get_count() {

$this->db->select('*');
$this->db->from('leads');
$query = $this->db->get();  
return $query->num_rows();
         
    }

 public function hot_leads() {

$this->db->select('*');
$this->db->from('leads');
$this->db->where('lead_type_id',1);

$query = $this->db->get();  
return $query->num_rows();
         
    }
         public function warm_leads() {
$branch_id =$_SESSION['branch_id'];
$this->db->select('*');
$this->db->from('leads');
$this->db->where('lead_type_id',2);
$this->db->where('branch_id',$branch_id);
$query = $this->db->get();  
return $query->num_rows();
         
    }
 public function closed_leads() {

$this->db->select('*');
$this->db->from('leads');
$this->db->where('lead_type_id',4);

$query = $this->db->get();  
return $query->num_rows();
         
    }
 public function underprocess() {
$branch_id =$_SESSION['branch_id'];
$this->db->select('*');
$this->db->from('leads');
$this->db->where("lead_type_id !=",5);
$this->db->where("lead_type_id !=",4);
$this->db->where('branch_id',$branch_id);
$query = $this->db->get();  
return $query->num_rows();
         
    }
 public function todaysfollowup() {
$branch_id =$_SESSION['branch_id'];
$today = date("Y-m-d");
$this->db->select('*');
$this->db->from('leads');
$this->db->where('followup_date',$today);
$this->db->where('branch_id',$branch_id);
$query = $this->db->get();  
return $query->num_rows();
         
    }



public function totalno(){

 $this->db->select('leads.branch_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->group_by('branch_id'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}

public function closedtotalno(){
 $this->db->select('leads.branch_id,leads.lead_type_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->where('leads.enquiry_status',"Sold");
  $this->db->group_by('leads.branch_id','leads.lead_type_id'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
 public function soldno() {
$this->db->select('*');
$this->db->from('leads');
$this->db->where('enquiry_status',"Sold");
$query = $this->db->get();  
return $query->num_rows();
         
    }

public function enquirytotal(){
 $branch_id =$_SESSION['branch_id'];
 $this->db->select('leads.enquiry_source,enquiry_source.source, COUNT(enquiry_source) as total');
 $this->db->from('leads');
  $this->db->join('enquiry_source',"enquiry_source.enquiry_id=leads.enquiry_source","left");
 $this->db->where('leads.branch_id',$branch_id);
 $this->db->group_by('enquiry_source'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
public function enquirytotal_search($date1,$date2){
 $branch_id =$_SESSION['branch_id'];
 $this->db->select('leads.enquiry_source,enquiry_source.source, COUNT(enquiry_source) as total');
 $this->db->from('leads');
  $this->db->join('enquiry_source',"enquiry_source.enquiry_id=leads.enquiry_source","left");
 $this->db->where('leads.branch_id',$branch_id);
  $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
 $this->db->group_by('enquiry_source'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
	public function totalnobranchs($date1,$date2){
 	
 $this->db->select('leads.branch_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
  $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
 $this->db->group_by('branch_id'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 return $query->result();
 	

}

	public function totalnobranchsoverall(){
 	
 $this->db->select('leads.branch_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
  $this->db->group_by('branch_id'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 return $query->result();
 	

}
	public function totalnobranchssoldoverall(){
 	
 $this->db->select('leads.branch_id,leads.lead_type_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->group_by('branch_id'); 
 $this->db->where('lead_type_id',5);
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 return $query->result();
 	

}
	public function totalnobranchssold($date1,$date2){
 	
 $this->db->select('leads.branch_id,leads.lead_type_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->group_by('branch_id'); 
$this->db->where('enquiry_status',"Sold");
  $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 return $query->result();
 	

}
	public function totalnoleadsmonths(){
 	
 $this->db->select('lead_id, COUNT(lead_id) as total,MONTHNAME(added_date) AS m');
 $this->db->from('leads');
 $this->db->where('YEAR(added_date)', date('Y'));
 $this->db->group_by('MONTH(added_date), YEAR(added_date)'); 


 $query = $this->db->get();
 return $query->result();
 	

}
	public function closedleadsmonths(){
 	
 $this->db->select('lead_id, COUNT(lead_id) as total,MONTHNAME(added_date) AS m');
 $this->db->from('leads');
$this->db->where('enquiry_status',"Sold");
 $this->db->where('YEAR(added_date)', date('Y'));
 $this->db->group_by('MONTH(added_date), YEAR(added_date)');
 $query = $this->db->get();
 return $query->result();
 	

}
//search overvieww functions
 public function get_count_search($date1,$date2) {

$this->db->select('*');
$this->db->from('leads');
 $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
$query = $this->db->get();  
return $query->num_rows();
         
    }
 public function hot_leads_search($date1,$date2){

$this->db->select('*');
$this->db->from('leads');
$this->db->where('lead_type_id',1);
$this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
$query = $this->db->get();  
return $query->num_rows();
         
    }
             public function warm_leads_search($date1,$date2) {

$this->db->select('*');
$this->db->from('leads');
$this->db->where('lead_type_id',2);
$this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
$query = $this->db->get();  
return $query->num_rows();
         
    }
     public function soldno_search($date1,$date2) {

$this->db->select('*');
$this->db->from('leads');
$this->db->where('enquiry_status',"Sold");
$this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
$query = $this->db->get();  
return $query->num_rows();
         
    }
    public function totalno_search($date1,$date2){

 $this->db->select('leads.branch_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->group_by('branch_id'); 
 $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
public function closedtotalno_search($date1,$date2){
 $this->db->select('leads.branch_id,leads.lead_type_id,branches.branch_name, COUNT(leads.branch_id) as total');
 $this->db->from('leads');
 $this->db->join('branches',"branches.branch_id=leads.branch_id","left");
 $this->db->group_by('branch_id'); 
$this->db->where('enquiry_status',"Sold");
  $this->db->where('added_date BETWEEN "'. date('Y-m-d', strtotime($date1)). '" and "'. date('Y-m-d', strtotime($date2)).'"');
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
}

Zerion Mini Shell 1.0