db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->where('LD.MobileNumber',$mobileNumber); $this->db->where('LT.CreatedBranch',$branchID); $leadDet=$this->db->get()->last_row(); $result_array = []; if($leadDet){ $result_array['existLeadDetails']=$leadDet; } else{ $this->db->select('ST.MobileNumber,ST.Firstname,ST.AlternateNumber,ST.PresentAddress,US.UniversityName,CU.CourseName'); $this->db->from(STUDENTS.' as ST'); $this->db->join(STUDENTCOURSE.' as STC', 'ST.StudentID = STC.StudentID'); $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID'); $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID'); $this->db->where('ST.MobileNumber',$mobileNumber); $this->db->where('STC.BranchID',$branchID); $this->db->where('US.BranchCode',$branchID); $enrolledStudDet=$this->db->get()->last_row(); if($enrolledStudDet) { $leadDet['LeadName'] = $enrolledStudDet->Firstname; $leadDet['MobileNumber'] = $enrolledStudDet->MobileNumber; $leadDet['IsNewEnquiry'] = "1"; $leadDet['University'] = $enrolledStudDet->UniversityName; $leadDet['Course'] = $enrolledStudDet->CourseName; $leadDet['ActivityStatus'] = ""; $leadDet['AssignedTo'] = ""; $leadDet['StatusCode'] = ""; $leadDet['AlternateMobile'] = $enrolledStudDet->AlternateNumber; $leadDet['Address'] = $enrolledStudDet->PresentAddress; $result_array['existLeadDetails'] = $leadDet; } else{ $leadDet['LeadName'] = ""; $leadDet['MobileNumber'] = ""; $leadDet['IsNewEnquiry'] = "1"; $leadDet['University'] = ""; $leadDet['Course'] = ""; $leadDet['ActivityStatus'] = ""; $leadDet['AssignedTo'] = ""; $leadDet['StatusCode'] = ""; $leadDet['AlternateMobile'] = ""; $leadDet['Address'] = ""; $result_array['existLeadDetails'] = $leadDet; } } // store lead,university and course details in comman array //$result_array['universityDetails']=$this->getUniversityDetails($branchID); $result_array['activityDetails']=$this->getActivityDetails($mobileNumber,$branchID); // $result_array['statusDetails']=$this->getStatus(); $result_array['staffDetails']=$this->getStaff("1",$branchID,$userType,$requestedBy); return $result_array; } /* * get university details * created by kms * */ public function getUniversityDetails($branchID) { $this->db->select('UniversityID,UniversityName'); $this->db->where('IsActive','1'); $this->db->where('BranchCode',$branchID); $this->db->order_by('UniversityID','ASC'); $unviversityDetails = $this->db->get(UNIVERSITY); if($unviversityDetails->result()){ $result_university = array(); foreach ($unviversityDetails->result() as $row) { $university_array['universityStatus'] = true; $university_array['universityID'] = $row->UniversityID; $university_array['universityName'] = $row->UniversityName; $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID,$branchID); $result_university[]=$university_array; } } else { $university_array['universityStatus'] = false; $university_array['message'] = "No records found!"; $university_array['universityID'] = ""; $university_array['universityName'] = ""; $university_array['courseDetails']= ""; $result_university[]=$university_array; } return $result_university; } /* * get course details * @params university id * created by kms * */ public function getCourseDetails($universityID=null,$branchID=null) { $this->db->select('CourseID,CourseName'); $this->db->where('UniversityID',$universityID); $this->db->where('IsActive','1'); $this->db->where('BranchCode',$branchID); $this->db->order_by('CourseID','ASC'); $courseDetails = $this->db->get(COURSE); return $courseDetails->result(); } /* * get activity details * created by kms * */ public function getActivityDetails($mobileNo=null,$branchID=null) { $this->db->distinct(); $this->db->select('LT.ActivityStatus,LT.ActivityStatus'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(PICK_LIST_DETAILS.' as PLD', 'LT.StatusCode = PLD.ListCode'); $this->db->where('PLD.ListName !=','CLOSE'); $this->db->where('LD.MobileNumber',$mobileNo); $this->db->where('LT.CreatedBranch',$branchID); $this->db->where('PLD.BranchCode',$branchID); $getExistActivity=$this->db->get(); $existArrayActivity=array(); if($getExistActivity->result()){ foreach ($getExistActivity->result() as $ActRow){ array_push($existArrayActivity,$ActRow->ActivityStatus); } } else{ $existArrayActivity=array(); } $this->db->select('ActivityID,ActivityName'); $this->db->where('IsActive','1'); $this->db->where('BranchCode',$branchID); if($existArrayActivity){ $this->db->where_not_in('ActivityID',$existArrayActivity); } $this->db->order_by('ActivityID','ASC'); $activity = $this->db->get(ACTIVITY); if($activity->result()){ $result_activity = array(); foreach ($activity->result() as $row) { $activity_array['activityStatus'] = true; $activity_array['activityID'] = $row->ActivityID; $activity_array['activityName'] = $row->ActivityName; $activity_array['activityStatus']= $this->getStatus($row->ActivityID); $result_activity[]=$activity_array; } } else{ $activity_array['activityStatus'] = false; $activity_array['activityID'] = ""; $activity_array['activityName'] = "No activity"; $activity_array['activityStatus']= ""; $result_activity[]=$activity_array; } return $result_activity; } /* * get activity status details * created by kms * */ public function getStatus($activityID=null) { $this->db->select('AVS.StatusID,PLD.ListCode,PLD.ListName'); $this->db->from(ACTIVITY_STATUS .' as AVS'); $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AVS.StatusName'); $this->db->where('AVS.ActivityID',$activityID); $this->db->where('AVS.IsActive','1'); $this->db->where('PLD.IsActive','1'); $status = $this->db->get(); return $status->result(); } /* * get staff details * created by kms * * */ public function getStaff($status=null,$branchID=null,$userType=null,$requestedBy) { // if($userType != SUPER_ADMIN OR $userType== SUPER_ADMIN){ $this->db->select('LO.ID,ST.StaffID,ST.Firstname'); $this->db->from(LOGIN.' as LO'); $this->db->join(STAFF_BRANCH.' as STB', 'STB.StaffID = LO.StaffID'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(BRANCH.' as BR', 'BR.BranchCode = STB.BranchCode'); $this->db->where('ST.IsActive',$status); $this->db->where('STB.IsActive',$status); $this->db->where('BR.IsActive',$status); if($userType== ADMIN){ $this->db->where('STB.BranchCode',$branchID); $this->db->where('LO.ListCode !=',SUPER_ADMIN); } if($userType== EMPLOYEE){ $this->db->where('STB.BranchCode',$branchID); $this->db->where('LO.ID',$requestedBy); } if($userType== SUPER_ADMIN){ $this->db->where('STB.BranchCode',$branchID); } $staffDetails=$this->db->get(); if($staffDetails){ $result_staff = array(); foreach ($staffDetails->result() as $row) { $university_array['loginId'] = $row->ID; $university_array['staffName'] = $row->Firstname.'-'.$row->StaffID; $result_staff[]=$university_array; } } else{ $result_staff[]=""; } /* } else{ $this->db->select('BR.BranchCode,BR.BranchName'); $this->db->from(BRANCH.' as BR'); $this->db->where('BR.IsActive',$status); $branchDetails=$this->db->get(); if($branchDetails->result()){ foreach ($branchDetails->result() as $branchRow){ $branch_array['BranchCode'] = $branchRow->BranchCode; $branch_array['BranchName'] = $branchRow->BranchName.'-'.$branchRow->BranchCode; $branch_array['staffDetails'] = $this->superAdminBranch($branchRow->BranchCode,$status); $result_staff[]=$branch_array; } } else{ $result_staff[]=""; } }*/ return $result_staff; } /* * get staff details based on branch id * created by kms * */ public function superAdminBranch($branchID,$status){ $this->db->select('LO.ID,ST.StaffID,ST.Firstname'); $this->db->from(LOGIN.' as LO'); $this->db->join(STAFF_BRANCH.' as STB', 'STB.StaffID = LO.StaffID'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->where('ST.IsActive',$status); $this->db->where('STB.BranchCode',$branchID); $staffDetails=$this->db->get(); if($staffDetails){ $result_staff = array(); foreach ($staffDetails->result() as $row) { $university_array['loginId'] = $row->ID; $university_array['staffName'] = $row->Firstname.'-'.$row->StaffID; $result_staff[]=$university_array; } } else{ $result_staff[]=""; } return $result_staff; } /* * add lead details * created by kms * */ public function addleadDetails($lead_Details=null,$track_Details=null,$followup_Details=null,$messagecheck=null) { // print_r($lead_Details);die(); $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') { if($messagecheck !=0) { $number = $lead_Details['MobileNumber']; $name = $lead_Details['LeadName']; $CourseName = $track_Details['Course']; $Email = $track_Details['EmailID']; // $msg='Dear '.$name.', Thank for Enquiring with Apollo Distance Education College for the course '.$CourseName.'. Pls Feel free to call us for more information 9962012985,9962012982.Thanks.'; $msg='Dear '.$name.', Thank you for enquiring with Apollo Distance Education College for the course '.$CourseName.'. Pls feel free to call us for more information at 9962012985 or 9962012982.'; $messa = urlencode($msg); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=" . $number . "&SenderID=APODEC&Message=" . $messa . "&ServiceName=TEMPLATE_BASED"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $output = curl_exec($ch); curl_close($ch); $arrss = explode('
', $output); $time = date('Y-m-d H:i:s'); $dateTime = $time; $msgGroup = date('YmdHis'); for ($i = 0, $c = count($arrss);$i < $c;$i++) { if ($arrss[$i] === '') { break; } else { $a = explode(':', $arrss[$i]); $msgIdState = $a[0]; $msgId = $a[1]; $msgNumb = $a[2]; $msgStatus = $a[4]; $data[] = array('MsgId' => $msgId, 'MobileNumber' => $msgNumb, 'MsgBody' => $msg, 'Status' => $msgStatus, 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup); continue; } } $this->mailsend($Email, $msg); $this->db->insert_batch('T_BroadcastStatus', $data); } $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; } public function mailsend($mail, $msg) { // $list = implode(',', $mail); $list = $mail; $sub = 'Enquiry Details'; //Load email library $this->load->library('email'); //SMTP & mail configuration $config = array( 'protocol' => 'smtp', 'smtp_host' => 'smtp.sendgrid.net', 'smtp_port' => 587, 'smtp_user' => 'apikey', 'smtp_pass' => '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', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->set_mailtype("html"); $this->email->set_newline("\r\n"); // print_r($this->email);exit(); //Email content // $htmlContent = '

Sending email via SMTP server

'; $htmlContent = $msg; // Email body load the html template // $body = $this->load->view('emails/anillabs.php',$data,TRUE); $this->email->to($list); $this->email->from('noreply@apollodec.com','Apollo'); $subj = $sub; $this->email->subject($subj); $this->email->message($htmlContent); //Send email 1 $result = $this->email->send(); $time = date('Y-m-d H:i:s'); $dateTime = $time; $msgGroup = date('YmdHis'); $data[] = array('MobileNumber' => $list, 'MsgBody' => $htmlContent, 'Status' => 'success', 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup); $this->db->insert_batch('T_BroadcastStatus', $data); // echo $this->email->print_debugger(); exit(); return $result; } /* * get all tracked details * created by kms * */ public function getTrackingDetails($search=null,$status) { $this->db->select('LTF.FollowupOn,LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,LTF.FollowupComments'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID'); $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('PLD1.ListName !=', 'CLOSE'); $this->db->where('LTF.IsActive', '1'); if($search['CreatedBranch'] !='All' AND $search['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } if ($search['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } if($search['searchDate']!='' OR $search['searchDate']!=null){ /* if(sizeof($search['searchDate']) == '1'){ $this->db->where('LTF.FollowupOn <= ', $search['searchDate'][0]); $this->db->where('PLD1.ListName !=', 'CLOSE'); }*/ $this->db->where_in('LTF.FollowupOn', $search['searchDate']); $this->db->order_by('LTF.FollowupOn','DESC'); $this->db->group_by('LT.TrackingID'); } else{ $this->db->order_by('LTF.FollowupOn','DESC'); $this->db->group_by('LT.TrackingID'); } $leadDet=$this->db->get(); if($this->db->affected_rows()==0){ $result_array['trackingStatus']=false; $result_array['trackingDetails']=""; } else{ if($leadDet){ $result_array = array(); $result_array['trackingStatus']=true; 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["Flag"]=$row->Flag; $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["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["Comments"]=$row->FollowupComments; // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); // $followupDetails=$this->getTrackingFollowup($row->TrackingID); // $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; $tracking_array["followupDetails"]=$row->FollowupOn; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; // $result_array['statusDetails']=$this->getStatus(); } } if($status!=true) { $result_array['pendingTrackingDetails'] = $this->getPrevPendingTrackingDetails($search); // print_r( $result_array['pendingTrackingDetails']); } else { $result_array['pendingTrackingDetails']=1; } // print_r($result_array); // die(); //print_r($this->db->last_query()); return $result_array; } public function getPrevPendingTrackingDetails($search=null) { $this->db->select('LTF.FollowupOn,LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,LTF.FollowupComments'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID'); $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('LTF.IsActive', '1'); $this->db->where('PLD1.ListName !=', 'CLOSE'); if($search['CreatedBranch'] !='All' AND $search['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } if ($search['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } if(($search['searchDate']!='' OR $search['searchDate']!=null) AND sizeof($search['searchDate']) == '1'){ // $this->db->where('LTF.FollowupOn <= ', $search['searchDate'][0]); // $this->db->where('PLD1.ListName !=', 'CLOSE'); $leadDet=$this->db->get(); if($leadDet->result()){ $result_array['trackingStatus']=true; 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["Flag"]=$row->Flag; $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["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["Comments"]=$row->FollowupComments; // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); // $followupDetails=$this->getTrackingFollowup($row->TrackingID); // $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; $tracking_array["followupDetails"]=$row->FollowupOn; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; } else{ $result_array['trackingStatus']=false; } } else{ $result_array['trackingStatus']=false; } return $result_array; } /* * get never closed tracking list by current date * created by kms * */ /* * get tracking followup Details * @params tracking id * created by kms * */ public function getTrackingFollowup($trackingId=null) { $this->db->select('LTF.InteractionId,LTF.TrackingID,LTF.FollowupOn,LTF.FollowupComments,DATE_FORMAT(LTF.CreatedOn, "%d-%m-%Y %h:%i %p") AS CreatedOn,ST.FirstName,ST1.FirstName as AssignedName,PLD.ListName as AssignedStatus'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LOGIN.' as LO', 'LO.ID = LTF.CreatedBy'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(LOGIN.' as LO1', 'LO1.ID = LTF.AssignedStaff','left'); $this->db->join(STAFF.' as ST1', 'ST1.StaffID = LO1.StaffID','left'); $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = LTF.StatusName','left'); $this->db->where('TrackingID',$trackingId); $this->db->order_by('InteractionId','DESC'); $trackingDetails = $this->db->get(); // print_r($trackingDetails); // die(); return $trackingDetails->result(); } /* * update followup details * created by kms * */ public function updateFollowupDetails($updateDetails=null,$insertDetails=null) { $deactivateStatus['IsActive']=false; $this->db->where('TrackingID',$updateDetails['TrackingID']); $this->db->update(LEAD_TRACKING_FOLLOWUP, $deactivateStatus); if($this->db->affected_rows() > '0') { $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertDetails); // this if for insert follow up details if ($this->db->affected_rows() == '1') { $this->db->where('TrackingID', $updateDetails['TrackingID']); $upateStatus = $this->db->update(LEAD_TRACKING, $updateDetails); $result['followupStatus'] = true; $result['trackingID'] = $updateDetails['TrackingID']; $result['message'] = "Successfully followup details updated"; // update pending doc status in student register $this->db->select('ListCode,ListName'); $this->db->where('ListCode',$updateDetails['StatusCode']); $statusDetails=$this->db->get(PICK_LIST_DETAILS)->last_row(); if($statusDetails AND $updateDetails['PendingDocStatus'] !='' AND $updateDetails['PendingDocStatus'] !=null){ $updateStudentPendingDocs['StatusName']=$statusDetails->ListName; $updateStudentPendingDocs['UpdatedBy']=$updateDetails['UpdatedBy']; $updateStudentPendingDocs['UpdatedOn']=$updateDetails['UpdatedOn']; $this->db->where('ID',$updateDetails['PendingDocStatus']); $this->db->update(STUDENTDOCUMENTTRACKDETAILS, $updateStudentPendingDocs); } } else { $result['followupStatus'] = false; $result['message'] = "Something went wrong.please try again"; } } else{ $activateStatus['IsActive']=true; $this->db->where('TrackingID',$updateDetails['TrackingID']); $this->db->update(LEAD_TRACKING_FOLLOWUP, $activateStatus); $result['followupStatus'] = false; $result['message'] = "Something went wrong.please try again"; } return $result; } /* * get tracking information when page is loading * created by kms * */ public function getLoadFollowupDetails($trackingID) { $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.CreatedBranch,LT.PendingDocStatus,BR.BranchName,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.ReferredBy,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->join(BRANCH.' as BR', 'BR.BranchCode = LT.CreatedBranch'); $this->db->where('LT.TrackingID',$trackingID['TrackingID']); if($trackingID['CreatedBranch'] !='All' AND $trackingID['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $trackingID['CreatedBranch']); } if ($trackingID['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $trackingID['UpdatedBy']); $this->db->where('LT.CreatedBranch', $trackingID['CreatedBranch']); } $leadDet=$this->db->get(); if($leadDet){ $result_array = array(); $result_array['followupStatus']=true; foreach ($leadDet->result() as $row) { $activityID = $row->ActivityStatus; $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["CreatedBranch"]=$row->CreatedBranch; $tracking_array["CreatedBranchName"]=$row->BranchName; $tracking_array["Firstname"]=$row->Firstname; $tracking_array["StaffID"]=$row->StaffID; $tracking_array["StatusCode"]=$row->StatusCode; $tracking_array["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["ReferredBy"]=$row->ReferredBy; $tracking_array["PendingDocStatus"]=$row->PendingDocStatus; $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); $tracking_array["collectTrackedID"]=$this->getStudentTrackedID($row->MobileNumber,$trackingID['CreatedBranch'],$trackingID['requestedDept'],$trackingID['UpdatedBy']); $result[]=$tracking_array; } $result_array['trackingDetails']=$result; $result_array['statusDetails']=$this->getStatus($activityID); $result_array['staffDetails']=$this->getStaff("1",$trackingID['CreatedBranch'],$trackingID['requestedDept'],$trackingID['UpdatedBy']); $result_array['trackingDetails']=$result; } else{ $result_array['followupStatus']=false; $result_array['trackingDetails']=""; } return $result_array; } /* * get student tracked id * @params mobile number * created by kms * */ public function getStudentTrackedID($stuMobile=null,$branchId=null,$reqDept=null,$updatedBy=null) { $this->db->distinct(); $this->db->select('LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,PLD.ListName'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = LT.StatusCode'); $this->db->where('LD.MobileNumber',$stuMobile); if($branchId !='All' AND $reqDept != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $branchId); } if ($reqDept == EMPLOYEE){ $this->db->where('LT.AssignedTo', $updatedBy); $this->db->where('LT.CreatedBranch', $branchId); } $this->db->order_by('LT.TrackingID','ASC'); $studeTrackID = $this->db->get(); return $studeTrackID->result(); } /* * used to get dash board call track details * created by kms * */ public function getDashboardTrackingDetails($serach=null) { $now = new DateTime(); $now->setTimezone(new DateTimezone('Asia/Kolkata')); $todayFollowupDate=$now->format('d-m-Y'); $todayDateTime=$now->format('Y-m-d'); // $follouwpDetails=$this->todayFollowupDetails($todayFollowupDate,CLOSE,'1'); $follouwpDetails=$this->todayFollowUp($todayFollowupDate,$serach); if($follouwpDetails){ $result_array['todayStatus']=true; $result_array['todayFolloupDetails']=$follouwpDetails; } else{ $result_array['todayStatus']=false; $result_array['todayFolloupDetails']=""; } // $follouwpPendingDetails=$this->todayFollowupDetails($todayFollowupDate,CLOSE,'2'); $follouwpPendingDetails=$this->tillPendingTrackingDetails(CLOSE,$serach); if($follouwpPendingDetails){ $result_array['todayPendingStatus']=true; $result_array['PendingFolloupDetails']=$follouwpPendingDetails; } else{ $result_array['todayPendingStatus']=false; $result_array['PendingFolloupDetails']=""; } // $todayLeadDetails=$this->todayFollowupDetails($todayDateTime,OPEN,'3'); $todayLeadDetails=$this->todayCreatedLead($todayDateTime,$serach); if($todayLeadDetails){ $result_array['todayLeadStatus']=true; $result_array['todayLeadDetails']=$todayLeadDetails; } else{ $result_array['todayLeadStatus']=false; $result_array['todayLeadDetails']=""; } return $result_array; } /* * get dash board today followupdetails * created by kms * */ public function todayFollowUp($todayDate,$search=null){ $this->db->distinct(); $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID'); $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $search['BranchID']); } if ($search['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); $this->db->where('LT.CreatedBranch', $search['BranchID']); } $this->db->where('LTF.FollowupOn',$todayDate); $trackDetails=$this->db->get(); if($trackDetails->result()){ foreach ($trackDetails->result() as $row1) { $tracking_array["LeadID"]=$row1->LeadID; $tracking_array["LeadName"]=$row1->LeadName; $tracking_array["MobileNumber"]=$row1->MobileNumber; $tracking_array["TrackingID"]=$row1->TrackingID; $tracking_array["FollowupOn"]=$row1->FollowupOn; $tracking_array["StatusCode"]=$row1->StatusCode; $tracking_array["statusName"]=$row1->statusListName; $tracking_array["ActivityID"]=$row1->ActivityID; $tracking_array["ActivityName"]=$row1->ActivityName; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; return $result_array; } else { return false; } } /* * get today lead details * created by kms * */ public function todayCreatedLead($todayDate,$search=null){ $this->db->distinct(); $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID'); $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('LTF.IsActive', '1'); if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $search['BranchID']); } if ($search['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); $this->db->where('LT.CreatedBranch', $search['BranchID']); } $this->db->like('LD.CreatedOn', $todayDate, 'after'); $trackDetails=$this->db->get(); if($trackDetails->result()){ foreach ($trackDetails->result() as $row1) { $tracking_array["LeadID"]=$row1->LeadID; $tracking_array["LeadName"]=$row1->LeadName; $tracking_array["MobileNumber"]=$row1->MobileNumber; $tracking_array["TrackingID"]=$row1->TrackingID; $tracking_array["FollowupOn"]=$row1->FollowupOn; $tracking_array["StatusCode"]=$row1->StatusCode; $tracking_array["statusName"]=$row1->statusListName; $tracking_array["ActivityID"]=$row1->ActivityID; $tracking_array["ActivityName"]=$row1->ActivityName; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; return $result_array; } else { return false; } } /* * get till pending tracking details * created by kms * */ public function tillPendingTrackingDetails($status,$search=null){ $this->db->distinct(); $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->join(LEAD_TRACKING.' as LT','LT.TrackingID=LTF.TrackingID'); $this->db->join(LEAD_DETAILS.' as LD', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('LTF.IsActive', '1'); $this->db->where('PLD1.ListName !=', $status); if($search['BranchID'] !='All' AND $search['requestedDept'] != EMPLOYEE){ $this->db->where('LT.CreatedBranch', $search['BranchID']); } if ($search['requestedDept'] == EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); $this->db->where('LT.CreatedBranch', $search['BranchID']); } $trackDetails=$this->db->get(); if($trackDetails->result()){ foreach ($trackDetails->result() as $row1) { $tracking_array["LeadID"]=$row1->LeadID; $tracking_array["LeadName"]=$row1->LeadName; $tracking_array["MobileNumber"]=$row1->MobileNumber; $tracking_array["TrackingID"]=$row1->TrackingID; $tracking_array["FollowupOn"]=$row1->FollowupOn; $tracking_array["StatusCode"]=$row1->StatusCode; $tracking_array["statusName"]=$row1->statusListName; $tracking_array["ActivityID"]=$row1->ActivityID; $tracking_array["ActivityName"]=$row1->ActivityName; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; return $result_array; } else { return false; } } /* * get date wise followup details * @params date and status and check status * */ public function todayFollowupDetails($todayDate=null,$status=null,$check=null) { $this->db->distinct(); $this->db->select('LT.TrackingID'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->from(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->order_by('LT.TrackingID','ASC'); /* if($check!='3'){ $this->db->where('LT.StatusCode !=',$status); } else if($check=='2'){ $this->db->where('LT.StatusCode !=',$status); }*/ if($check=='3'){ $this->db->like('LD.CreatedOn', $todayDate, 'after'); } $leadDetails=$this->db->get(); if($leadDetails->result()){ $result_array = array(); foreach ($leadDetails->result() as $row){ $this->db->select('LTF.TrackingID,LTF.InteractionId'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->where('LTF.TrackingID',$row->TrackingID); $lastFollowpID=$this->db->get()->last_row(); // get last followup details date wise $this->db->distinct(); $this->db->select('LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LEAD_TRACKING_FOLLOWUP.' as LTF', 'LTF.TrackingID = LT.TrackingID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('LTF.InteractionId',$lastFollowpID->InteractionId); // check today date based follwup details if($check=='1'){ $this->db->where('LTF.FollowupOn',$todayDate); // $this->db->where('LT.StatusCode !=',$status); } // check today date based pending followp details /* else if($check=='2'){ // $this->db->where('LTF.FollowupOn >',$todayDate); $this->db->where('LT.StatusCode !=',$status); }*/ else if($check=='3'){ $this->db->like('LD.CreatedOn', $todayDate, 'after'); } $trackDetails=$this->db->get(); if($trackDetails->result()){ foreach ($trackDetails->result() as $row1) { $tracking_array["LeadID"]=$row1->LeadID; $tracking_array["LeadName"]=$row1->LeadName; $tracking_array["MobileNumber"]=$row1->MobileNumber; $tracking_array["TrackingID"]=$row1->TrackingID; $tracking_array["FollowupOn"]=$row1->FollowupOn; $tracking_array["StatusCode"]=$row1->StatusCode; $tracking_array["statusName"]=$row1->statusListName; $tracking_array["ActivityID"]=$row1->ActivityID; $tracking_array["ActivityName"]=$row1->ActivityName; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; } } return $result_array; } else{ return false; } } /* * get all followup details * created by kms * */ public function getDashboardFollowupDetails($search=null) { $this->db->distinct(); $this->db->select('LT.TrackingID'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->from(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->order_by('LT.TrackingID','ASC'); $leadDetails=$this->db->get(); if($leadDetails->result()){ foreach ($leadDetails->result() as $row){ $this->db->select('LTF.TrackingID,LTF.InteractionId'); $this->db->from(LEAD_TRACKING_FOLLOWUP.' as LTF'); $this->db->where('LTF.TrackingID',$row->TrackingID); $lastFollowpID=$this->db->get()->last_row(); // get last followup details date wise $this->db->distinct(); $this->db->select('DATE_FORMAT(LTF.CreatedOn, "%d-%m-%Y") AS CreatedOn,LD.LeadName,LD.MobileNumber,LT.TrackingID,LT.LeadID,AV.ActivityID,AV.ActivityName,LTF.FollowupOn,LT.StatusCode,PLD1.ListName as statusListName'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LEAD_TRACKING_FOLLOWUP.' as LTF', 'LTF.TrackingID = LT.TrackingID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); $this->db->where('LTF.InteractionId',$lastFollowpID->InteractionId); $result[]=$this->db->get()->result(); } $result_array['details']=$result; $result_array['followupStatus']=true; return $result_array; } else{ $result_array['details']=""; $result_array['followupStatus']=false; } return $result_array; } /* * get recent lead details * params: date * created by kms * */ public function getRecentleadDetails($search=null) { $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); if($search['loadDate'] !='' ) { $this->db->like('LD.CreatedOn', $search['loadDate'], 'after'); } if($search['CreatedBranch'] !='All'){ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } $this->db->order_by('LT.TrackingID', 'DESC'); $leadDet=$this->db->get(); if($this->db->affected_rows()==0){ $result_array['trackingStatus']=false; $result_array['trackingDetails']=""; } else{ if($leadDet){ $result_array = array(); $result_array['trackingStatus']=true; 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["Flag"]=$row->Flag; $tracking_array["ActivityStatus"]=$row->ActivityStatus; $tracking_array["AssignedTo"]=$row->AssignedTo; $tracking_array["Firstname"]=$row->Firstname; $tracking_array["StatusCode"]=$row->StatusCode; $tracking_array["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["CreatedOn"]=$row->CreatedOn; $tracking_array["UpdatedOn"]=$row->UpdatedOn; // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); $followupDetails=$this->getTrackingFollowup($row->TrackingID); // print_r($followupDetails); $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; $tracking_array["FollowupComments"] = $followupDetails[0]->FollowupComments; $result[]=$tracking_array; //print_r($result); } $result_array['trackingDetails']=$result; // $result_array['statusDetails']=$this->getStatus(); $result_array['trackingDetails']=$result; } } // print_r($result_array); // print_r($this->db->last_query()); return $result_array; } /* * get recent track close details * created by kms * */ public function getRecentCloseDetails($search=null) { $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); if($search['loadDate'] !='' ) { $this->db->like('LT.UpdatedOn', $search['loadDate'], 'after'); } if($search['CreatedBranch'] !='All'){ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } // condition check if its is staff if($search['requestedDept']==EMPLOYEE){ $this->db->where('LT.AssignedTo', $search['requestedBy']); } $this->db->like('PLD1.ListName', 'CLOSE', 'after'); $this->db->order_by('LT.TrackingID', 'DESC'); $leadDet=$this->db->get(); if($this->db->affected_rows()==0){ $result_array['trackingStatus']=false; $result_array['trackingDetails']=""; } else{ if($leadDet){ $result_array = array(); $result_array['trackingStatus']=true; 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["Flag"]=$row->Flag; $tracking_array["ActivityStatus"]=$row->ActivityStatus; $tracking_array["AssignedTo"]=$row->AssignedTo; $tracking_array["Firstname"]=$row->Firstname; $tracking_array["StatusCode"]=$row->StatusCode; $tracking_array["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["CreatedOn"]=$row->CreatedOn; $tracking_array["UpdatedOn"]=$row->UpdatedOn; // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); $followupDetails=$this->getTrackingFollowup($row->TrackingID); $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; $tracking_array["FollowupComments"]=$followupDetails[0]->FollowupComments; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; // $result_array['statusDetails']=$this->getStatus(); $result_array['trackingDetails']=$result; } } return $result_array; } /* * get recent pending details * created by kms * */ public function getRecentPendingDetails($search=null) { $this->db->select('LD.LeadID,LD.LeadName,LD.MobileNumber,LD.IsNewEnquiry,LT.TrackingID,LT.ActivityStatus,LT.AssignedTo,LT.StatusCode,LT.University,LT.Course,LT.AlternateMobile,LT.Address,LT.Flag,ST.StaffID,ST.Firstname,PLD1.ListCode as statusListCode,PLD1.ListName as statusListName,AV.ActivityID,AV.ActivityName,DATE_FORMAT(LT.CreatedOn, "%d-%m-%Y") AS CreatedOn,DATE_FORMAT(LT.UpdatedOn, "%d-%m-%Y") AS UpdatedOn'); $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->join(LOGIN.' as LO', 'LO.ID = LT.AssignedTo'); $this->db->join(STAFF.' as ST', 'ST.StaffID = LO.StaffID'); $this->db->join(ACTIVITY.' as AV', 'AV.ActivityID = LT.ActivityStatus'); $this->db->join(PICK_LIST_DETAILS.' as PLD1', 'PLD1.ListCode = LT.StatusCode'); if($search['loadDate'] !='' ){ $this->db->like('LT.UpdatedOn', $search['loadDate'], 'after'); } if($search['CreatedBranch'] !='All'){ $this->db->where('LT.CreatedBranch', $search['CreatedBranch']); } $this->db->where('PLD1.ListName !=', 'CLOSE'); $this->db->order_by('LT.TrackingID', 'DESC'); $leadDet=$this->db->get(); if($this->db->affected_rows()==0){ $result_array['trackingStatus']=false; $result_array['trackingDetails']=""; } else{ if($leadDet){ $result_array = array(); $result_array['trackingStatus']=true; 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["Flag"]=$row->Flag; $tracking_array["ActivityStatus"]=$row->ActivityStatus; $tracking_array["AssignedTo"]=$row->AssignedTo; $tracking_array["Firstname"]=$row->Firstname; $tracking_array["StatusCode"]=$row->StatusCode; $tracking_array["statusName"]=$row->statusListName; $tracking_array["UniversityName"]=$row->University; $tracking_array["CourseName"]=$row->Course; $tracking_array["ActivityID"]=$row->ActivityID; $tracking_array["ActivityName"]=$row->ActivityName; $tracking_array["AlternateMobile"]=$row->AlternateMobile; $tracking_array["Address"]=$row->Address; $tracking_array["CreatedOn"]=$row->CreatedOn; $tracking_array["UpdatedOn"]=$row->UpdatedOn; // $tracking_array["followupDetails"]=$this->getTrackingFollowup($row->TrackingID); $followupDetails=$this->getTrackingFollowup($row->TrackingID); $tracking_array["followupDetails"]=$followupDetails[0]->FollowupOn; $tracking_array["FollowupComments"]=$followupDetails[0]->FollowupComments; $result[]=$tracking_array; } $result_array['trackingDetails']=$result; // $result_array['statusDetails']=$this->getStatus(); $result_array['trackingDetails']=$result; } } return $result_array; } /* * update call track as important * created by kms * */ public function updateFlagStatus($trackID=null,$flagStatus=null){ $updateDetails['Flag']= $flagStatus; $this->db->where('TrackingID',$trackID); $this->db->update(LEAD_TRACKING, $updateDetails); if($this->db->affected_rows() > '0') { $result['updatedStatus']=true; } else{ $result['updatedStatus']=false; } return $result; } /* * delete pending doc details from call tracking * created by kms * */ public function deletePendingDocTrack($docID=null){ $this->db->select('TrackingID,LeadID'); $this->db->where('PendingDocStatus',$docID); $getTrackingID=$this->db->get(LEAD_TRACKING)->last_row(); if($getTrackingID){ $this->db->where('TrackingID', $getTrackingID->TrackingID); $this->db->delete(LEAD_TRACKING_FOLLOWUP); if ($this->db->affected_rows() >= 1) { $this->db->where('PendingDocStatus', $docID); $this->db->where('TrackingID', $getTrackingID->TrackingID); $this->db->delete(LEAD_TRACKING); if ($this->db->affected_rows() >= 1) { $this->db->where('LeadID', $getTrackingID->LeadID); $this->db->delete(LEAD_DETAILS); } } } return true; } /* *Auto Add Call Tracking Function * Sriram */ public function getaddautocall($lead_Details,$track_Details,$followup_Details,$CreatedBy){ $this->db->select('LD.LeadID,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);die; 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['CreatedOn'] = date('Y-m-d H:i:s'); $followup_Details['CreatedBy'] = $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){ $followup_Details['TrackingID'] = $res[0]->TrackingID; //$followup_Details['TrackingID']=$this->db->insert_id(); $this->db->insert(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{ if($track_Details['StatusCode'] == 'S020' || $track_Details['StatusCode'] == 'S002' ||$track_Details['StatusCode'] == 'S001'){ $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; } $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; } }