diff --git a/Apollo/api/application/models/Calltracking_model.php b/Apollo/api/application/models/Calltracking_model.php index d3e12f15..5826c879 100755 --- a/Apollo/api/application/models/Calltracking_model.php +++ b/Apollo/api/application/models/Calltracking_model.php @@ -2018,7 +2018,7 @@ public function GetStaffCallDetails($branchID,$myDate,$staff) public function GetStaffCountDetails($branchID,$myDate) { - $this->db->select('AssignedStaff,Firstname,Lastname,SD.StaffID,count(InteractionId) as count'); + $this->db->select('AssignedStaff,Firstname,Lastname,SD.StaffID,count(InteractionId) as TotalCount'); $this->db->from('T_Lead_Tracking_Followup LTF'); $this->db->join('T_Login L','L.ID=LTF.AssignedStaff'); $this->db->join('T_StaffDetails SD','SD.StaffID=L.StaffID'); @@ -2029,14 +2029,33 @@ public function GetStaffCountDetails($branchID,$myDate) $this->db->group_by('AssignedStaff'); $Details = $this->db->get()->result(); - - - // print_r($this->db->last_query());die(); - + // print_r($this->db->last_query());exit(); if($Details) { + foreach($Details as $row){ + // print_r($row->AssignedStaff); + $this->db->select('LT.TrackingID'); + $this->db->from('T_Lead_Tracking_Followup LTF'); + $this->db->join('T_Lead_Tracking LT','LT.TrackingID=LTF.TrackingID'); + $this->db->where('LTF.IsActive',1); + $this->db->where("date_format(LTF.CreatedOn,'%Y-%m-%d')=",$myDate); + $this->db->where('LT.CreatedBranch',$branchID); + $this->db->where('LTF.AssignedStaff',$row->AssignedStaff); + $this->db->group_by('InteractionId'); + $leadDet= $this->db->get()->result(); + $leadDetcount = $this->db->affected_rows(); + $row->count = $leadDetcount; + } + $filtered_array = array(); + foreach ($Details as $value) { + if (isset($value->count)) { + if ($value->count != 0) { + $filtered_array[] = $value; + } + } + } $result_array['searchst'] = true; - $result_array['details'] = $Details; + $result_array['details'] = $filtered_array; } else {