From f95ecd8f57f994a9ca706a0cce30ce55daea7cae Mon Sep 17 00:00:00 2001 From: sriramv Date: Mon, 2 Jul 2018 16:54:43 +0530 Subject: [PATCH] Auto call tracking issues Fixed Sriram --- .../controllers/Call_Tracking_Controller.php | 19 ++-- .../application/models/Calltracking_model.php | 101 ++++++++++++++++++ .../js/controllers/reregistrationformCtrl.js | 2 +- 3 files changed, 111 insertions(+), 11 deletions(-) diff --git a/Apollo/api/application/controllers/Call_Tracking_Controller.php b/Apollo/api/application/controllers/Call_Tracking_Controller.php index 0a938390..4ec40ade 100755 --- a/Apollo/api/application/controllers/Call_Tracking_Controller.php +++ b/Apollo/api/application/controllers/Call_Tracking_Controller.php @@ -423,12 +423,12 @@ class Call_Tracking_Controller extends REST_Controller { $Student_Id = ''; foreach($student as $student){ - if($Student_Id != $student['Student_id']){ + $lead_details['LeadName'] = $student['Student_name']; $lead_details['MobileNumber'] = $student['Phone_number']; $lead_details['IsNewEnquiry'] = 1; - $lead_details['CreatedBy'] = $this->post('createdBy'); - $lead_details['CreatedOn'] = $now->format('Y-m-d H:i:s'); + $CreatedBy = $this->post('createdBy'); + //store tracking details $tracking_details['University'] = $student['University']; @@ -439,22 +439,21 @@ class Call_Tracking_Controller extends REST_Controller { $tracking_details['ReferredBy'] = $this->post('referedBy'); $tracking_details['AlternateMobile'] = $student['AlternateNumber']; $tracking_details['Address'] = $student['address']; - $tracking_details['CreatedBy'] = $this->post('createdBy'); - $tracking_details['CreatedOn'] = $now->format('Y-m-d H:i:s'); - $tracking_details['UpdatedOn'] = $now->format('Y-m-d H:i:s'); + + $tracking_details['CreatedBranch'] = $this->post('branchId'); //store tracking followup details $tracking_followup_details['FollowupOn'] = $this->post('date'); $tracking_followup_details['FollowupComments'] = $this->post('comments'); - $tracking_followup_details['CreatedBy'] = $this->post('createdBy'); - $tracking_followup_details['CreatedOn'] = $now->format('Y-m-d H:i:s'); + $tracking_followup_details['StatusName'] = $this->post('status'); $tracking_followup_details['AssignedStaff'] = $this->post('assignedTo'); //print_r(array($lead_details,$tracking_details,$tracking_followup_details)); - $leadDetails['leadDetails'] = $this->Calltracking_model->addleadDetails($lead_details,$tracking_details,$tracking_followup_details);// Check if the users data store contains users (in case the database result returns NULL) - } + $leadDetails['leadDetails'] = $this->Calltracking_model->getaddautocall($lead_details,$tracking_details,$tracking_followup_details,$CreatedBy);// Check if the users data store contains users (in case the database result returns NULL) + } + // print_r($leadDetails);die; if (sizeof($leadDetails)>0) { $leadDetails['status'] = REST_Controller::HTTP_OK; diff --git a/Apollo/api/application/models/Calltracking_model.php b/Apollo/api/application/models/Calltracking_model.php index 6bedbb31..38e6600d 100755 --- a/Apollo/api/application/models/Calltracking_model.php +++ b/Apollo/api/application/models/Calltracking_model.php @@ -1328,4 +1328,105 @@ class Calltracking_model extends CI_Model { } + /* + *Auto Add Call Tracking Function + * Sriram + */ + + public function getaddautocall($lead_Details,$track_Details,$followup_Details,$CreatedBy){ + + $this->db->select('LD.LeadID,LTF.InteractionId,LT.TrackingID'); + $this->db->join('T_PickListDetails PD','PD.ListCode = LT.StatusCode','left'); + $this->db->join('T_Lead_Details LD','LD.LeadID = LT.LeadID','left'); + $this->db->join('T_Lead_Tracking_Followup LTF','LTF.TrackingID = LT.TrackingID','left'); + $this->db->join('T_ActivityMaster AM','AM.ActivityID = LT.ActivityStatus','left'); + $this->db->where('PD.ListName!="CLOSE"'); + + $this->db->where('LT.ActivityStatus',$track_Details['ActivityStatus']); + $this->db->where('LD.MobileNumber',$lead_Details['MobileNumber']); + $this->db->order_by('LD.LeadID','DESC'); + $this->db->limit(1); + $query = $this->db->get('T_Lead_Tracking LT'); + $res = $query->result(); + //print_r($res); + if(!empty($res) != 0){ + + $lead_Details['UpdatedOn'] = date('Y-m-d H:i:s'); + $lead_Details['UpdatedBy'] = $CreatedBy; + $track_Details['UpdatedOn'] = date('Y-m-d H:i:s'); + $track_Details['UpdatedBy'] = $CreatedBy; + $followup_Details['UpdatedOn'] = date('Y-m-d H:i:s'); + $followup_Details['UpdatedBy'] = $CreatedBy; + + $this->db->where('LeadID',$res[0]->LeadID); + $this->db->update('T_Lead_Details',$lead_Details); + if($this->db->affected_rows() > 0) { + + $this->db->where('TrackingID',$res[0]->TrackingID); + $this->db->update('T_Lead_Tracking',$track_Details); + if($this->db->affected_rows() >0){ + $this->db->where('InteractionId',$res[0]->InteractionId); + $this->db->update('T_Lead_Tracking_Followup',$followup_Details); + if($this->db->affected_rows() == '1'){ + $result['leadStatus'] = true; + $result['message'] = "Successfully lead details Updated"; + } + else{ + $result['leadStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + }else{ + $result['leadStatus'] = false; + $result['message'] = "Update Something went wrong.please try again"; + } + } else { + $result['leadStatus'] = false; + $result['message'] = "Something went wrong.please try again"; + } + }else{ + $lead_Details['CreatedOn'] = date('Y-m-d H:i:s'); + $followup_Details['CreatedOn'] = date('Y-m-d H:i:s'); + $track_Details['CreatedOn'] = date('Y-m-d H:i:s'); + $lead_Details['CreatedBy'] = $CreatedBy; + $track_Details['CreatedBy'] = $CreatedBy; + $followup_Details['CreatedBy'] = $CreatedBy; + + $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'){ + $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"; + } + + } + 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; + } + } \ No newline at end of file diff --git a/Apollo/assets/js/controllers/reregistrationformCtrl.js b/Apollo/assets/js/controllers/reregistrationformCtrl.js index 252ece13..c0cd7191 100644 --- a/Apollo/assets/js/controllers/reregistrationformCtrl.js +++ b/Apollo/assets/js/controllers/reregistrationformCtrl.js @@ -364,7 +364,7 @@ app.controller('reregistrationformCtrl', ["$scope","$rootScope","toaster", "$fil // str.replace("%20"," "); // str.replace("%2C"," "); $scope.StudnetAddress = "Address: "+ str.replace(" "," "); - $scope.StudentPin = "Pincode: .................. Mobile No: "+Student.MobileNumber+"Email ID: "+Student.EmailID; + $scope.StudentPin = "Pincode: .................. Mobile No: "+Student.MobileNumber+" Email ID: "+Student.EmailID; // var sem1 = doc.autoTableHtmlToJson(document.getElementById(subject)); var universityname = $scope.university.universityName;