From 111ffc68fcf7f5bd6ea4fa6ab503c7489115bbf9 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Mon, 29 Jan 2018 19:32:33 +0530 Subject: [PATCH] course details changes done --- .../application/models/Fees_status_model.php | 221 +++++++++++++++++- 1 file changed, 220 insertions(+), 1 deletion(-) diff --git a/Apollo/api/application/models/Fees_status_model.php b/Apollo/api/application/models/Fees_status_model.php index a58d9dd4..a0c0f837 100755 --- a/Apollo/api/application/models/Fees_status_model.php +++ b/Apollo/api/application/models/Fees_status_model.php @@ -988,13 +988,44 @@ class Fees_status_model extends CI_Model $this->db->where('SFS.CourseID',$row1->CourseID); $this->db->where('SFS.StudentID',$row1->StudentID); $getStudentPaiDetails1 = $this->db->get()->result(); - if($row->Amount < $getStudentPaiDetails1[0]->BillAmount){ + if($row1->Amount < $getStudentPaiDetails1[0]->BillAmount){ $this->smssend($row1->StudentID,$row1->DueDate); } } } + // this is for update details in call track after due date + $yesterdayDate = new DateTime(date("d-m-Y")); + $yesterdayDate->modify('-1 day'); + $preDATE = $yesterdayDate->format('d-m-Y'); + $this->db->distinct(); + $this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID'); + $this->db->from(FEES_INSTALLMENT.' as FIN'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID'); + $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left'); + $this->db->where('FIN.DueDate',$preDATE); + $getStudentDetails2 = $this->db->get(); + if ($getStudentDetails2->result()){ + foreach ($getStudentDetails2->result() as $row2){ + $this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount'); + $this->db->from(STUDENTS_FEES_PAID.' as SFP'); + $this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID'); + $this->db->where('SFS.CourseID',$row2->CourseID); + $this->db->where('SFS.StudentID',$row2->StudentID); + $getStudentPaiDetails2 = $this->db->get()->result(); + + if($row2->Amount > $getStudentPaiDetails2[0]->BillAmount){ + + + $this->updateFeesStatusInCallTrack($row2->StudentID,$row2->CourseID); + } + + + } + } + + return true; } @@ -1033,6 +1064,194 @@ class Fees_status_model extends CI_Model $roleDetails = $this->db->get()->first_row(); return $roleDetails; } + /* + * update followup details for fees pending in call tracking + * created by kms + * */ + public function updateFeesStatusInCallTrack($studentID=null,$courseID=null){ + $now = new DateTime(); + $now->setTimezone(new DateTimezone('Asia/Kolkata')); + $currentDate = new DateTime(date("d-m-Y")); + $afterFormatedDate = $currentDate->format('d-m-Y'); + // get student details + + $this->db->select('PLD.ListCode'); + $this->db->from(PICK_LIST_DETAILS.' as PLD'); + $this->db->where('PLD.ListName','PENDING'); + $this->db->where('PLD.IsActive','1'); + $checkStatus=$this->db->get()->last_row(); + if($checkStatus){ + + + $studentDetails = $this->studentInfoForFeesStatus($studentID,$courseID); + + if($studentDetails){ + $arrayDetails['MobileNumber']=$studentDetails->MobileNumber; + $arrayDetails['LeadName']=$studentDetails->Firstname; + $arrayDetails['University']=$studentDetails->UniversityName; + $arrayDetails['Course']=$studentDetails->CourseName; + $arrayDetails['StatusCode']=$checkStatus->ListCode; + $arrayDetails['CreatedBranch']=$studentDetails->BranchID; + $arrayDetails['CreatedOn']=$now->format('Y-m-d H:i:s'); + $arrayDetails['FollowupOn']=$afterFormatedDate; + $arrayDetails['FollowupComments']="Fees payment for your course is falling."; + // get created by with branch id + + $this->db->select('LO.ID'); + $this->db->from(STAFF_BRANCH.' as STB'); + $this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID'); + $this->db->where('STB.BranchCode',$studentDetails->BranchID); + $this->db->where('LO.ListCode',ADMIN); + $this->db->where('STB.IsActive','1'); + $this->db->where('LO.IsActive','1'); + $assignDet=$this->db->get()->last_row(); + if($assignDet){ + $arrayDetails['CreatedBy']=$assignDet->ID; + } + else{ + $arrayDetails['CreatedBy']=''; + } + + // create activity in call tracking + $this->db->select('ActivityID,ActivityName'); + $this->db->like('ActivityName', 'Fees', 'after'); + $this->db->where('IsActive', '1'); + $activityDetails=$this->db->get(ACTIVITY)->last_row(); + if($activityDetails){ + $this->db->select('LD.LeadID,LT.TrackingID'); + $this->db->from(LEAD_DETAILS.' as LD'); + $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); + $this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']); + $this->db->where('LT.ActivityStatus',$activityDetails->ActivityID); + $this->db->like('LT.University',$arrayDetails['University'],'after'); + $this->db->like('LT.Course',$arrayDetails['Course'],'after'); + $leadDet=$this->db->get()->last_row(); + + if($leadDet){ + + $this->db->select('FollowupOn'); + $this->db->where('TrackingID',$leadDet->TrackingID); + $existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row(); + + // upate tracking status + $changeStatusCode['StatusCode'] = $arrayDetails['StatusCode']; + $changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy']; + $changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn']; + $changeStatusCode['CreatedBranch']=$arrayDetails['CreatedBranch']; + + $this->db->where('TrackingID',$leadDet->TrackingID); + $this->db->update(LEAD_TRACKING, $changeStatusCode); + // end update status + $updateTrackDetails['TrackingID'] = $leadDet->TrackingID; + $updateTrackDetails['FollowupOn'] = $existFollowupOn->FollowupOn; + $updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments']; + $updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy']; + $updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn']; + + $this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails); + + } + + else{ + $this->db->select('LeadID'); + $this->db->where('MobileNumber',$arrayDetails['MobileNumber']); + $checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row(); + if($checkLeadDet){ + $updateLeadDetails['LeadID'] = $checkLeadDet->LeadID; + $updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID; + $updateLeadDetails['University'] = $arrayDetails['University']; + $updateLeadDetails['Course'] = $arrayDetails['Course']; + $updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy']; + $updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode']; + $updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy']; + $updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn']; + $updateLeadDetails['CreatedBranch']=$arrayDetails['CreatedBranch']; + $this->db->insert(LEAD_TRACKING, $updateLeadDetails); + // this if for insert tracking details + if($this->db->affected_rows() == '1'){ + $followup_Details['TrackingID']=$this->db->insert_id(); + $followup_Details['FollowupOn']=$arrayDetails['FollowupOn']; + $followup_Details['FollowupComments']=$arrayDetails['FollowupComments']; + $followup_Details['CreatedBy'] = $arrayDetails['CreatedBy']; + $followup_Details['CreatedOn'] = $arrayDetails['CreatedOn']; + $this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details); + // this if for insert follow up details + + } + + } + else{ + $newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber']; + $newLeadDetails['LeadName'] = $arrayDetails['LeadName']; + $newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy']; + $newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn']; + $this->db->insert(LEAD_DETAILS, $newLeadDetails); + // 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(); + $track_Details['ActivityStatus'] = $activityDetails->ActivityID; + $track_Details['University'] = $arrayDetails['University']; + $track_Details['Course'] = $arrayDetails['Course']; + $track_Details['AssignedTo'] = $arrayDetails['CreatedBy']; + $track_Details['StatusCode'] = $arrayDetails['StatusCode']; + $track_Details['CreatedBy'] = $arrayDetails['CreatedBy']; + $track_Details['CreatedOn'] = $arrayDetails['CreatedOn']; + $track_Details['CreatedBranch']=$arrayDetails['CreatedBranch']; + $this->db->insert(LEAD_TRACKING, $track_Details); + // this if for insert tracking details + if($this->db->affected_rows() == '1'){ + $insertfollowup_Details['TrackingID']=$this->db->insert_id(); + $insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn']; + $insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments']; + $insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy']; + $insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn']; + $this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details); + // this if for insert follow up details + + } + + + } + + } + + + } + + + } + } + + return true; + } + else{ + return false; + } + } + + /* + * get student info for fees due updates + * created by kms + * */ + public function studentInfoForFeesStatus($studentID=null,$courseID=null){ + + $this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName,STC.BranchID'); + $this->db->from(STUDENTCOURSE.' as STC'); + $this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID'); + $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID'); + $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID'); + $this->db->where('ST.StudentID',$studentID); + $this->db->where('STC.CourseID',$courseID); + $leadDet=$this->db->get()->last_row(); + if($leadDet){ + return $leadDet; + } + else{ + return false; + } + + } } \ No newline at end of file