From c918a764b8bb28cbbe2d24ad399f4f6185425256 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Tue, 21 Nov 2017 16:23:53 +0530 Subject: [PATCH] changed model --- .../application/models/Calltracking_model.php | 105 +++++++++--------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/Apollo/api/application/models/Calltracking_model.php b/Apollo/api/application/models/Calltracking_model.php index ca74bfa7..d1f16b06 100644 --- a/Apollo/api/application/models/Calltracking_model.php +++ b/Apollo/api/application/models/Calltracking_model.php @@ -163,26 +163,20 @@ class Calltracking_model extends CI_Model { public function addleadDetails($lead_Details=null,$track_Details=null,$followup_Details=null) { - $this->db->insert(LEAD_DETAILS, $lead_Details); - // this if for insert lead details + $this->db->insert(LEAD_DETAILS, $lead_Details); + // this if for insert lead details + if($this->db->affected_rows() == '1'){ + // get and store insert id from db + $track_Details['LeadID']=$this->db->insert_id(); + $this->db->insert(LEAD_TRACKING, $track_Details); + // this if for insert tracking details if($this->db->affected_rows() == '1'){ - // get and store insert id from db - $track_Details['LeadID']=$this->db->insert_id(); - $this->db->insert(LEAD_TRACKING, $track_Details); - // this if for insert tracking details + $followup_Details['TrackingID']=$this->db->insert_id(); + $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details); + // this if for insert follow up details if($this->db->affected_rows() == '1'){ - $followup_Details['TrackingID']=$this->db->insert_id(); - $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details); - // this if for insert follow up details - if($this->db->affected_rows() == '1'){ - $result['leadStatus'] = true; - $result['message'] = "Successfully lead details added"; - } - else{ - $result['leadStatus'] = false; - $result['message'] = "Something went wrong.please try again"; - } - + $result['leadStatus'] = true; + $result['message'] = "Successfully lead details added"; } else{ $result['leadStatus'] = false; @@ -190,12 +184,18 @@ class Calltracking_model extends CI_Model { } } - - else { + else{ $result['leadStatus'] = false; $result['message'] = "Something went wrong.please try again"; } + } + + else { + $result['leadStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + return $result; } @@ -219,44 +219,47 @@ class Calltracking_model extends CI_Model { $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $leadDet=$this->db->get(); - if($this->db->affected_rows()==0){ - $result_array['trackingStatus']=false; - $result_array['trackingDetails']=""; - } + if($this->db->affected_rows()==0){ + $result_array['trackingStatus']=false; + $result_array['trackingDetails']=""; + } else{ - if($leadDet){ - $result_array = array(); - $result_array['trackingStatus']=true; + if($leadDet){ + $result_array = array(); + $result_array['trackingStatus']=true; - foreach ($leadDet->result() as $row) - { + foreach ($leadDet->result() as $row) + { - $tracking_array["LeadID"]=$row->LeadID; - $tracking_array["LeadName"]=$row->LeadName; - $tracking_array["MobileNumber"]=$row->MobileNumber; - $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry; - $tracking_array["TrackingID"]=$row->TrackingID; + $tracking_array["LeadID"]=$row->LeadID; + $tracking_array["LeadName"]=$row->LeadName; + $tracking_array["MobileNumber"]=$row->MobileNumber; + $tracking_array["IsNewEnquiry"]=$row->IsNewEnquiry; + $tracking_array["TrackingID"]=$row->TrackingID; $tracking_array["ActivityStatus"]=$row->ActivityStatus; - $tracking_array["AssignedTo"]=$row->AssignedTo; - $tracking_array["Firstname"]=$row->Firstname; - $tracking_array["StatusCode"]=$row->StatusCode; - $tracking_array["statusListName"]=$row->statusListName; - $tracking_array["UniversityID"]=$row->UniversityID; - $tracking_array["UniversityName"]=$row->UniversityName; - $tracking_array["CourseID"]=$row->CourseID; - $tracking_array["CourseName"]=$row->CourseName; - $tracking_array["ListCode"]=$row->ListCode; - $tracking_array["ListName"]=$row->ListName; - $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); - $result[]=$tracking_array; + $tracking_array["AssignedTo"]=$row->AssignedTo; + $tracking_array["Firstname"]=$row->Firstname; + $tracking_array["StatusCode"]=$row->StatusCode; + $tracking_array["statusListName"]=$row->statusListName; + $tracking_array["UniversityID"]=$row->UniversityID; + $tracking_array["UniversityName"]=$row->UniversityName; + $tracking_array["CourseID"]=$row->CourseID; + $tracking_array["CourseName"]=$row->CourseName; + $tracking_array["ListCode"]=$row->ListCode; + $tracking_array["ListName"]=$row->ListName; + // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); + $followupDetails=$this->getTrackingFollowup($row->TrackingID); + $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; + $result[]=$tracking_array; + + + } + $result_array['trackingDetails']=$result; + $result_array['statusDetails']=$this->getStatus(); + $result_array['trackingDetails']=$result; } - $result_array['trackingDetails']=$result; - $result_array['statusDetails']=$this->getStatus(); - $result_array['trackingDetails']=$result; - - } }