diff --git a/Apollo/api/application/models/StatusUpdation_model.php b/Apollo/api/application/models/StatusUpdation_model.php index 6072369b..5dd5b57e 100755 --- a/Apollo/api/application/models/StatusUpdation_model.php +++ b/Apollo/api/application/models/StatusUpdation_model.php @@ -58,11 +58,30 @@ class StatusUpdation_model extends CI_Model { if ($this->db->affected_rows() >= 1) { if ($this->get_ListCode_status($arr[0]['ListCode'])) { $dateToMsg = $arr[0]['AppDate']; + $CmntToMsg = $arr[0]['Comments']; + $studentName = $this->getStudentName($arr[0]['StudentID']); $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']); - $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']); - $getCourseName = $this->get_couser_name($arr[0]['CourseID']); - $mesg = "Status Update : $cerNamtToMsg $getCourseName - $statuToMsg $dateToMsg."; - $this->smssend($arr, $mesg); + if( $statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED'){ + $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']); + $getSemYearMsg = $this->get_couser_name($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Received - Dear $studentName, Your $getSemYearANDType had been received, Please come and collect it."; + $this->smssend($arr, $mesg); + } else if($statuToMsg == 'issued' || $statuToMsg == 'Issued' || $statuToMsg == 'ISSUED') { + $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']); + $getSemYearMsg = $this->get_couser_name($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Despatch - Dear $studentName, Your $getSemYearANDType had been despatched against ($CmntToMsg $statuToMsg) on $dateToMsg."; + $this->smssend($arr, $mesg); + } else { + } + + // $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']); + // $getCourseName = $this->get_couser_name($arr[0]['CourseID']); + // $mesg = "Status Update : $cerNamtToMsg $getCourseName - $statuToMsg $dateToMsg."; + // $this->smssend($arr, $mesg); } $this->updateDocumentStatusInCallTrack($arr, $reqDetails); $result['addStatus'] = true; @@ -80,13 +99,29 @@ class StatusUpdation_model extends CI_Model { if ($this->db->affected_rows() >= 1) { if ($this->get_ListCode_status($arr[0]['ListCode'])) { $dateToMsg = $arr[0]['CDate']; + $studentName = $this->getStudentName($arr[0]['StudentID']); + $CmntToMsg = $arr[0]['Comments']; $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']); // $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']); - $cerNamtToMsg = 'MARK CARD'; - $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); - $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + if( $statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED'){ + $cerNamtToMsg = 'Mark Card'; + $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Received - Dear $studentName, Your $getSemYearANDType had been received, Please come and collect it."; + $this->smssend($arr, $mesg); + } else if($statuToMsg == 'issued' || $statuToMsg == 'Issued' || $statuToMsg == 'ISSUED') { + $cerNamtToMsg = 'Mark Card'; + $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Despatch - Dear $studentName, Your $getSemYearANDType had been despatched against ($CmntToMsg $statuToMsg) on $dateToMsg."; + $this->smssend($arr, $mesg); + } else { + } + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; // $mesg = "Status Update : $cerNamtToMsg - $statuToMsg $dateToMsg."; - $this->smssend($arr, $mesg); + // $this->smssend($arr, $mesg); } $result['addStatus'] = true; $result['message'] = "Successfully Mark Card Status Updated"; @@ -266,17 +301,40 @@ class StatusUpdation_model extends CI_Model { return "$roleDetails->Sem_Year $roleDetails->CourseName"; } + public function getStudentName($stdId) { + $this->db->select('t1.Firstname'); + $this->db->from('' . STUDENTS . ' as t1'); + $this->db->where('StudentID', $stdId); + $nameDetails = $this->db->get()->first_row(); + return "$nameDetails->Firstname"; + + } + // update study material status public function update_semyear($arr) { $this->db->insert_batch(STUDY_MATERIAL_STATUS, $arr); if ($this->db->affected_rows() >= 1) { if ($this->get_ListCode_status($arr[0]['ListCode']) == true) { $dateToMsg = $arr[0]['SDate']; + $CmntToMsg = $arr[0]['Comments']; + $studentName = $this->getStudentName($arr[0]['StudentID']); $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']); - $cerNamtToMsg = 'Study Material'; - $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); - $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; - $this->smssend($arr, $mesg); + if( $statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED'){ + $cerNamtToMsg = 'Study Material'; + $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Received - Dear $studentName, Your $getSemYearANDType had been received, Please come and collect it."; + $this->smssend($arr, $mesg); + } else if($statuToMsg == 'issued' || $statuToMsg == 'Issued' || $statuToMsg == 'ISSUED') { + $cerNamtToMsg = 'Study Material'; + $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']); + $getSemYearANDType = "$getSemYearMsg $cerNamtToMsg"; + // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg."; + $mesg = "$cerNamtToMsg Despatch - Dear $studentName, Your $getSemYearANDType had been despatched against ($CmntToMsg $statuToMsg) on $dateToMsg."; + $this->smssend($arr, $mesg); + } else { + } } $result['addStatus'] = true; $result['message'] = "Successfully Study Material Status Updated"; diff --git a/Apollo/api/application/models/Student_model.php b/Apollo/api/application/models/Student_model.php index 7d111baa..af5af53c 100755 --- a/Apollo/api/application/models/Student_model.php +++ b/Apollo/api/application/models/Student_model.php @@ -521,6 +521,24 @@ class Student_model extends CI_Model { return $result; } + public function getCourseName($cours, $branch) { + $this->db->select('t2.CourseName'); + $this->db->from('' . COURSE . ' as t2'); + $this->db->where('t2.CourseID', $cours); + $this->db->where('t2.BranchCode', $branch); + $courseDetails = $this->db->get()->first_row(); + return "$courseDetails->CourseName"; + } + + public function getUnivName($univ, $branch) { + $this->db->select('t2.UniversityName'); + $this->db->from('' . UNIVERSITY . ' as t2'); + $this->db->where('t2.UniversityID', $univ); + $this->db->where('t2.BranchCode', $branch); + $univDetails = $this->db->get()->first_row(); + return "$univDetails->UniversityName"; + } + // add student public function add_student($Arr, $courseArr, $imagename, $imageSource, $size) { // echo $this->getBranchActiveStatusforStuAdd($courseArr['BranchID'])['branch_active_status'];exit(); @@ -554,6 +572,12 @@ class Student_model extends CI_Model { $loginArr['Password'] = ENCR_PASSWORD; $this->db->insert(LOGIN, $loginArr); if ($this->db->affected_rows() == '1') { + $userId = $Arr['MobileNumber']; + $getUnivName = $this->getUnivName($courseArr['UniversityID'], $courseArr['BranchID']); + $getCourseName = $this->getCourseName($courseArr['CourseID'], $courseArr['BranchID']); + $msg = "Thanks for registering with us for Course $getCourseName -$getUnivName. For more details, please login to www.apollodec.com. User ID :$userId, Password :abc123"; + $arr = $userId; + $this->smssend($arr, $msg); $result['addStudentStatus'] = true; $result['message'] = "Successfully student details added"; } else { @@ -597,6 +621,12 @@ class Student_model extends CI_Model { $loginArr['Password'] = ENCR_PASSWORD; $this->db->insert(LOGIN, $loginArr); if ($this->db->affected_rows() == '1') { + $userId = $Arr['MobileNumber']; + $getUnivName = $this->getUnivName($courseArr['UniversityID'], $courseArr['BranchID']); + $getCourseName = $this->getCourseName($courseArr['CourseID'], $courseArr['BranchID']); + $msg = "Thanks for registering with us for Course $getCourseName -$getUnivName. For more details, please login to www.apollodec.com. User ID :$userId, Password :abc123"; + $arr = $userId; + $this->smssend($arr, $msg); $result['addStudentStatus'] = true; $result['message'] = "Successfully student details added"; } else { @@ -1070,4 +1100,24 @@ class Student_model extends CI_Model { return false; } } + + // http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf + // API Key : xegCdYUIMf3 + // Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login. + // This is the template to be used. + public function smssend($arr, $msg) { + // $number = array(); + // foreach ($arr as $ar) { + // $mobi = $this->get_registered_mobile($ar['StudentID']); + // array_push($number, "91$mobi"); + // } + $mobile = $arr; + $message = urlencode($msg); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=" . $mobile . "&SenderID=APOLLO&Message=" . $message . "&ServiceName=TEMPLATE_BASED"); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + $output = curl_exec($ch); + curl_close($ch); + return $output; + } } \ No newline at end of file