%PDF- %PDF-
Direktori : /home/ugotscom/www/boniface/Admin/application/modules/bsales/models/ |
Current File : /home/ugotscom/www/boniface/Admin/application/modules/bsales/models/Bsales_model.php |
<?php class Bsales_model extends CI_Model{ public function get_count($date1,$date2,$branch) { $branch_id =$branch; $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) { $branch_id =$branch; $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) { $branch_id =$branch; $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) { $branch_id =$branch; $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){ $branch_id =$branch; $this->db->select('leads.added_by,users.name,users.status, 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('users.status',1); $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){ $branch_id =$branch; $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){ $branch_id =$branch; $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) { $branch_id =$branch; $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,$date1,$date2){ $branch_id =$branch; $this->db->select('leads.added_by,users.name,users.status, 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('users.status',1); $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(); return $query->result(); } function get_branches(){ $result=$this->db->get('branches'); return $result; } public function get_branch_detail($branch){ $this->db->select('*'); $this->db->from('branches'); $this->db->where('branch_id',$branch); $result = $this->db->get(); return $result; } public function enquirytotals($branch,$date1,$date2){ $branch_id =$branch; $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; } }