%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/ugotscom/public_html/dg/application/modules/sales/models/
Upload File :
Create Path :
Current File : /home/ugotscom/public_html/dg/application/modules/sales/models/Sales_model.php

<?php
class Sales_model extends CI_Model{


 public function get_count($date1,$date2) {

  $branch_id =$_SESSION['branch_id'];
$this->db->select('*');
$this->db->from('leads');
$this->db->where('branch_id',$branch_id);
 $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($date1,$date2) {

 $branch_id =$_SESSION['branch_id'];
$this->db->select('*');
$this->db->from('leads');
$this->db->where('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->where('lead_type_id',1);
$query = $this->db->get();  
return $query->num_rows();
         
    }

public function warm_leads($date1,$date2) {
     $branch_id =$_SESSION['branch_id'];
$this->db->select('*');
$this->db->from('leads');
$this->db->where('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->where('lead_type_id',2);
$query = $this->db->get();  
return $query->num_rows();
         
    }
 public function closed_leads($date1,$date2) {
 $branch_id =$_SESSION['branch_id'];
 $date = new DateTime("now");

 $curr_date = $date->format('Y-m-d ');
$this->db->select('*');
$this->db->from('leads');
$this->db->where('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->where('lead_type_id',5);
$query = $this->db->get();  
return $query->num_rows();
         
    }

public function totalno($date1,$date2){

 $branch_id =$_SESSION['branch_id'];	
 $this->db->select('leads.added_by,users.name, COUNT(added_by) as total');
 $this->db->from('leads');
 $this->db->join('users',"users.user_id=leads.added_by","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('added_by'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
public function closedtotalno($date1,$date2){
 	
 $branch_id =$_SESSION['branch_id'];	
  $this->db->select('leads.added_by,users.name, COUNT(added_by) as total');
 $this->db->from('leads');
 $this->db->join('users',"users.user_id=leads.added_by","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->where('leads.lead_type_id',5);
 $this->db->group_by('added_by'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}
public function enquirytotal($date1,$date2){
$branch_id =$_SESSION['branch_id'];
 $this->db->select('enquiry_source, COUNT(enquiry_source) as total');
 $this->db->from('leads');
 $this->db->where('branch_id',$branch_id);
 $this->db->where('DATE(added_date)>=',$date1);
$this->db->where('DATE(added_date)<=',$date1);
 $this->db->group_by('enquiry_source'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 $row = $query->result_array();
 return $row;	

}


 public function get_salescount($date1,$date2) {

 $branch_id =$_SESSION['branch_id'];
 $this->db->select('*');
$this->db->from('leads');
$this->db->where('branch_id',$branch_id);
 $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 ctotalno(){
 $branch_id =$_SESSION['branch_id'];	
 $this->db->select('leads.added_by,users.name, COUNT(added_by) as total');
 $this->db->from('leads');
 $this->db->join('users',"users.user_id=leads.added_by","left");
 $this->db->where('leads.branch_id',$branch_id);
 $this->db->group_by('added_by'); 
 $this->db->order_by('total', 'desc'); 
 $query = $this->db->get();
 return $query->result();
 	

}

}

Zerion Mini Shell 1.0