apollodec/Apollo/api/application/models/StatusUpdation_model.php
2021-04-03 20:36:28 +05:30

1286 lines
63 KiB
PHP
Executable File

<?php
/**
* Date: 11/9/17
* Time: 5:28 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class StatusUpdation_model extends CI_Model {
/*
* status updation details
* params:
* created by kdk
* */
public function get_status_list_code($reqDetails) {
if ($reqDetails == 'STUDY_MATERIAL') {
$searchFor = 'M001';
} else if ($reqDetails == 'APPICATION_STATUS') {
$searchFor = 'A001';
} else if ($reqDetails == 'CERTIFICATION_STATUS') {
$searchFor = 'C001';
} else if ($reqDetails == 'ANSWERBOOKLET_STATUS') {
$searchFor = 'B001';
} else if ($reqDetails == 'APPICATIONFORM_STATUS') {
$searchFor = 'L001';
}
return $searchFor;
}
// get status list
public function get_status_list($reqDetails, $reqBranch) {
$statusCode = $this->get_status_list_code($reqDetails);
$subQuery = "SELECT P.ListCode , P.ListName
FROM " . PICK_LIST_DETAILS . " as P LEFT JOIN " . DEFAULTACTIVITY . " as SM ON SM.StatusCode = P.ListCode
WHERE
SM.StudentActivityCode = '$statusCode'
AND SM.BranchCode = '$reqBranch'
AND SM.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$statusDetails = $queryDetails->result();
if (count($statusDetails) > 0) {
$results['statusList'] = true;
$results['statusList_details'] = $statusDetails;
} else {
$results['statusList'] = false;
$results['message'] = 'No record found';
}
return $results;
}
public function get_couser_name($cours) {
$this->db->select('t2.CourseName');
$this->db->from('' . COURSE . ' as t2');
$this->db->where('t2.CourseID', $cours);
$roleDetails = $this->db->get()->first_row();
return "$roleDetails->CourseName";
}
// update Application status
public function update_applicationStatus($arr, $reqDetails) {
// echo "I am Here";
// echo APPLICATION_STATUS;
// print_r($arr);die();
$this->db->insert_batch(APPLICATION_STATUS, $arr);
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']);
if( $statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED'){
// $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
$cerNamtToMsg = $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. APOLLO DEC";
$this->smssend($arr, $mesg);
$this->mailsend($arr, $mesg, $cerNamtToMsg);
} else if($statuToMsg == 'issued' || $statuToMsg == 'Issued' || $statuToMsg == 'ISSUED') {
// $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
$cerNamtToMsg = $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. APOLLO DEC";
$this->smssend($arr, $mesg);
$this->mailsend($arr, $mesg, $cerNamtToMsg);
} 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;
$result['message'] = "Successfully Documents Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// public function update_certificateStatus($arr) {
// $this->db->insert_batch(CERTIFICATION_STATUS, $arr);
// if ($this->db->affected_rows() >= 1) {
// //If condition for Check ANSWERBOOKLET_STATUS, If it is null or 'Issued to Student' for do not send sms.
// $answerBookletStatus = $this->getAnswerBookletStatus($arr[0]['StudentID'],$arr[0]['CourseID'],$arr[0]['BranchCode'],$arr[0]['Sem']);
// //print_r($answerBookletStatus);
// //echo $answerBookletStatus['ListName'];
// //die();
// //echo "COURSE ====$arr[0]['CourseID']";
// //echo "PARENT -- $answerBookletStatus";
// $getlastansbookstatus = $this->GetLastAns_status($arr[0]['StudentID'],$arr[0]['Sem'],$arr[0]['CourseID']);
// // $latestappstatus='';
// // if(!empty($getlastansbookstatus))
// // {
// // foreach($getlastansbookstatus as $get)
// // {
// // $latestappstatus= $get->ListCode;
// // }
// // }
// $upperresult=strtoupper($getlastansbookstatus);
// $WithoutspaceStatus = preg_replace('/\s+/', '',$upperresult);
// // echo $arr[0]['ListCode'];
// // die();
// if($answerBookletStatus['isIssueToStudentExist'] == 0 && $answerBookletStatus['statusCount'] != 0)
// {
// //echo "SEND SMS";
// if ($this->get_ListCode_status($arr[0]['ListCode'])) {
// //echo 'in';
// $dateToMsg = $arr[0]['CDate'];
// $studentName = $this->getStudentName($arr[0]['StudentID']);
// $CmntToMsg = $arr[0]['Comments'];
// $statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']);
// $issuecheck = strtoupper($statuToMsg);
// $withoutspaceissue = preg_replace('/\s+/', '',$issuecheck);
// //echo $withoutspaceissue;die();
// // $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
// // if( ($statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED') && $WithoutspaceStatus == 'RECEIVEDFROMSTUDENT'){
// if(strpos($WithoutspaceStatus,'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);
// $this->mailsend($arr, $mesg, $cerNamtToMsg);
// }
// else if($withoutspaceissue == 'ISSUEDTOSTUDENT' || $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);
// $this->mailsend($arr, $mesg, $cerNamtToMsg);
// }
// else {}
// // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg.";
// // $mesg = "Status Update : $cerNamtToMsg - $statuToMsg $dateToMsg.";
// // $this->smssend($arr, $mesg);
// }
// }///else {echo "DO NOT SEND SMS";}
// $result['addStatus'] = true;
// $result['message'] = "Successfully Mark Card Status Updated";
// } else {
// $result['addStatus'] = false;
// $result['message'] = "Something went wrong.please try again";
// }
// return $result;
// }
// update certificate stauts
public function update_certificateStatus($arr) {
// print_r($arr);
// exit();
$this->db->insert_batch(CERTIFICATION_STATUS, $arr);
if ($this->db->affected_rows() >= 1) {
//If condition for Check ANSWERBOOKLET_STATUS, If it is null or 'Issued to Student' for do not send sms.
$answerBookletStatus = $this->getAnswerBookletStatus($arr[0]['StudentID'],$arr[0]['CourseID'],$arr[0]['BranchCode'],$arr[0]['Sem']);
// print_r($answerBookletStatus);
// echo $answerBookletStatus['ListName'];
// echo "COURSE ====$arr[0]['CourseID']";
// echo "PARENT -- $answerBookletStatus";
$getlastansbookstatus = $this->GetLastAns_status($arr[0]['StudentID'],$arr[0]['Sem'],$arr[0]['CourseID']);
// $latestappstatus='';
// if(!empty($getlastansbookstatus))
// {
// foreach($getlastansbookstatus as $get)
// {
// $latestappstatus= $get->ListCode;
// }
// }
$upperresult=strtoupper($getlastansbookstatus);
$WithoutspaceStatus = preg_replace('/\s+/', '',$upperresult);
//If condition for Check ANSWERBOOKLET_STATUS, If it is null or 'Issued to Student' for do not send sms.
// if($answerBookletStatus['isIssueToStudentExist'] == 0 && $answerBookletStatus['statusCount'] != 0)
if($answerBookletStatus['isIssueToStudentExist'] == 0 )
{
// 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']);
$issuecheck = strtoupper($statuToMsg);
$withoutspaceissue = preg_replace('/\s+/', '',$issuecheck);
// print_r($WithoutspaceStatus);
// exit;
// $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
if( ($statuToMsg == 'received' || $statuToMsg == 'Received' || $statuToMsg == 'RECEIVED') && $WithoutspaceStatus == 'RECEIVEDFROMSTUDENT'){
// if($WithoutspaceStatus == 'SENTTOUNIVERSITY'){
// if condition for answerbookletstatus
// if(strpos($WithoutspaceStatus,'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. APOLLO DEC";
$this->smssend($arr, $mesg);
$this->mailsend($arr, $mesg, $cerNamtToMsg);
// echo $statuToMsg;
// die();
}
// else if($withoutspaceissue == 'ISSUEDTOSTUDENT' || $statuToMsg == 'Issued' || $statuToMsg == 'ISSUED') {
// /// echo 'else if';die();
// $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);
// $this->mailsend($arr, $mesg, $cerNamtToMsg);
// }
else {
}
// $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg.";
// $mesg = "Status Update : $cerNamtToMsg - $statuToMsg $dateToMsg.";
// $this->smssend($arr, $mesg);
// }//
}///else {echo "DO NOT SEND SMS";}
$result['addStatus'] = true;
$result['message'] = "Successfully Mark Card Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// get certificate list
public function get_certificate_list($branchId, $sutendDetail, $courseDetails) {
// echo $sutendDetail, $courseDetails;exit();
$this->db->select('SFS.FeesType as certificateData');
$this->db->order_by('CreatedOn', 'DESC');
$this->db->from('T_Students_Fees_Status as SFS');
// $this->db->join('T_Course_Fees_Details as CFD', 'CFD.ID = SFS.FeeType');
// $this->db->join('T_Students_Fees_Status as SFS', 'SFS.StudentID = $sutendDetail');
// $this->db->join( '' . CERTIFICATION . ' as CFR', 'CFR.CertificateName = SFS.FeesType');
$where = '(SFS.FeesType="PPC" or SFS.FeesType = "DC" or SFS.FeesType = "TC" or SFS.FeesType = "MC" or SFS.FeesType = "OTHER" or SFS.FeesType="PC")';
$this->db->where($where);
$this->db->where('SFS.StudentID',$sutendDetail);
$this->db->where('SFS.CourseID',$courseDetails);
$this->db->where('SFS.BranchCode', $branchId);
$cerfDetails = $this->db->get();
$certificateDetails = $cerfDetails->result();
// print_r($this->db->last_query());
// die();
if (count($certificateDetails) > 0) {
$results['certificateStatus'] = true;
$results['certificate_details'] = $certificateDetails;
} else {
$results['certificateStatus'] = false;
$results['message'] = 'No record found';
}
return $results;
}
// self function for getting registered mobile for sms
public function get_registered_mobile($num) {
$this->db->select('MobileNumber');
$this->db->from(STUDENTS);
$this->db->where('StudentID', $num);
$roleDetails = $this->db->get()->first_row();
return $roleDetails->MobileNumber;
}
// self function for getting registered email for mail send
public function get_registered_email($num) {
$this->db->select('EmailID');
$this->db->from(STUDENTS);
$this->db->where('StudentID', $num);
$roleDetails = $this->db->get()->first_row();
return $roleDetails->EmailID;
}
// self function for getting the status for the LISTCODE
public function get_ListCode_status($listCode) {
$this->db->select('ListName');
$this->db->from(PICK_LIST_DETAILS);
$this->db->where('ListCode', $listCode);
$statusDetails = $this->db->get()->first_row();
if ($statusDetails->ListName == 'SENT TO UNIVERSITY'){
return false;
} else if ($statusDetails->ListName == 'RECEIVED' || $statusDetails->ListName == 'ISSUED TO STUDENT') {
return true;
}else if(strpos($statusDetails->ListName,'RECEIVED')){
return true;
}
else{
return false;
}
}
public function get_prev_status_list($reqDetailsFor, $reqDetails) {
if ($reqDetailsFor == 'STUDY_MATERIAL') {
// echo 'in stu';die();
$searchFor = 'M001';
$searchTableFor = STUDY_MATERIAL_STATUS;
$this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
$this->db->from('' . $searchTableFor . ' as t1');
$this->db->where('t1.StudentID', $reqDetails['student']);
$this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
$this->db->where('t2.CourseID', $reqDetails['CourseID']);
$this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
$this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
$this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
$this->db->order_by('t1.CreatedOn', 'DESC');
$statusDetails = $this->db->get();
$prevStatusDetails = $statusDetails->result();
if (count($prevStatusDetails) > 0) {
$results['preStatusDetails'] = true;
$results['preStatus_details_list'] = $prevStatusDetails;
} else {
$results['preStatusDetails'] = false;
$results['message'] = 'No record found';
}
} else if ($reqDetailsFor == 'APPICATION_STATUS') {
//echo 'in app';die();
$searchFor = 'A001';
$searchTableFor = APPLICATION_STATUS;
$this->db->select('t1.*, t4.Firstname, t5.ListName, t1.CertificationType as CertificateName');
$this->db->from('' . $searchTableFor . ' as t1');
$this->db->where('t1.StudentID', $reqDetails['student']);
$this->db->where('t1.CourseID',$reqDetails['CourseID']);
$this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
$this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
$this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
// $this->db->join('' . CERTIFICATION . ' as t6', 't6.CertificationID = t1.CertificationType', 'LEFT');
$this->db->order_by('t1.CreatedOn', 'DESC');
$statusDetails = $this->db->get();
$prevStatusDetails = $statusDetails->result();
if (count($prevStatusDetails) > 0) {
$results['preStatusDetails'] = true;
$results['preStatus_details_list'] = $prevStatusDetails;
} else {
$results['preStatusDetails'] = false;
$results['message'] = 'No record found';
}
//print_r($this->db->last_query());
} else if ($reqDetailsFor == 'CERTIFICATION_STATUS') {
// echo 'in cer';die();
$searchFor = 'C001';
$searchTableFor = CERTIFICATION_STATUS;
$this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
$this->db->from('' . $searchTableFor . ' as t1');
$this->db->where('t1.StudentID', $reqDetails['student']);
$this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
$this->db->where('t2.CourseID', $reqDetails['CourseID']);
$this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
$this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
$this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
$this->db->order_by('t1.CreatedOn', 'DESC');
$statusDetails = $this->db->get();
$prevStatusDetails = $statusDetails->result();
if (count($prevStatusDetails) > 0) {
$results['preStatusDetails'] = true;
$results['preStatus_details_list'] = $prevStatusDetails;
} else {
$results['preStatusDetails'] = false;
$results['message'] = 'No record found';
}
} else if ($reqDetailsFor == 'ANSWERBOOKLET_STATUS') {
// echo 'in ans';die();
$searchFor = 'B001';
$searchTableFor = ANSWER_BOOKLET;
$this->db->select('t1.*, t4.Firstname, t5.ListName, t2.Sem_Year, t2.ProgramType');
$this->db->from('' . $searchTableFor . ' as t1');
$this->db->where('t1.StudentID', $reqDetails['student']);
$this->db->join('' . COURSE_FEES . ' as t2', 't2.ID = t1.CourseID', 'LEFT');
$this->db->where('t2.CourseID', $reqDetails['CourseID']);
$this->db->join('' . LOGIN . ' as t3', 't3.ID = t1.CreatedBy', 'LEFT');
$this->db->join('' . STAFF . ' as t4', 't4.StaffID = t3.StaffID', 'LEFT');
$this->db->join('' . PICK_LIST_DETAILS . ' as t5', 't5.ListCode = t1.ListCode', 'LEFT');
$this->db->order_by('t1.CreatedOn', 'DESC');
$statusDetails = $this->db->get();
$prevStatusDetails = $statusDetails->result();
if (count($prevStatusDetails) > 0) {
$results['preStatusDetails'] = true;
$results['preStatus_details_list'] = $prevStatusDetails;
} else {
$results['preStatusDetails'] = false;
$results['message'] = 'No record found';
}
}
return $results;
}
public function get_status_name_ListCode($listCode) {
//echo $listCode;die();
$this->db->select('ListName');
$this->db->from(PICK_LIST_DETAILS);
$this->db->where('ListCode', $listCode);
$statusDetails = $this->db->get()->first_row();
return $statusDetails->ListName;
}
// self function for getting certificate name for the CERTIFICATECODE
public function get_certificate_name($listCode) {
$this->db->select('CertificateName');
$this->db->from(CERTIFICATION);
$this->db->where('CertificationID', $listCode);
$cerfDetails = $this->db->get()->first_row();
return $cerfDetails->CertificateName;
}
// update answer booklet status
public function update_answerbooklet($arr, $reqDetails) {
$this->db->insert_batch(ANSWER_BOOKLET, $arr);
if ($this->db->affected_rows() >= 1) {
$this->updateBookletStatusInCallTrack($arr, $reqDetails);
$studentName = $this->getStudentName($arr[0]['StudentID']);
$statuToMsg = $this->get_status_name_ListCode($arr[0]['ListCode']);
$UpperstatusToMsg = strtoupper($statuToMsg);
$WithoutspaceStatus = preg_replace('/\s+/', '', $UpperstatusToMsg);
// $cerNamtToMsg = $this->get_certificate_name($arr[0]['CertificationType']);
if( $WithoutspaceStatus == 'RECEIVEDFROMSTUDENT'){
// $cerNamtToMsg = 'Answer booklet';
// $getSemYearMsg = $this->get_couser_sem_yr_msg($arr[0]['CourseID']);
// $getSemYearANDType = "$getSemYearMsg";
// // $mesg = "Status Update : $cerNamtToMsg $getSemYearMsg - $statuToMsg $dateToMsg.";
// // $mesg = "$cerNamtToMsg Received - Dear $studentName, Your $getSemYearANDType had been received.";
// $mesg = "Answer booklet Received - Dear $studentName, Your answer booklet for $getSemYearANDType has been received.";
// $this->smssend($arr, $mesg);
// $this->mailsend($arr, $mesg, $cerNamtToMsg);
$result['addStatus'] = true;
$result['message'] = "Successfully Answer Booklet Status Updated";
}else{
$result['addStatus'] = true;
$result['message'] = "Successfully Answer Booklet Status Updated";
}
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
public function get_couser_sem_yr_msg($cours) {
$this->db->select('t1.Sem_Year, t2.CourseName');
$this->db->from('' . COURSE_FEES . ' as t1');
$this->db->join('' . COURSE . ' as t2', 't2.CourseID = t1.CourseID', 'LEFT');
$this->db->where('ID', $cours);
$roleDetails = $this->db->get()->first_row();
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']);
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. APOLLO DEC";
$this->smssend($arr, $mesg);
$this->mailsend($arr, $mesg, $cerNamtToMsg);
} 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. APOLLO DEC";
$this->smssend($arr, $mesg);
$this->mailsend($arr, $mesg, $cerNamtToMsg);
} else {
}
}
$result['addStatus'] = true;
$result['message'] = "Successfully Study Material Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// get sem/Year for the course
public function get_semyear_result($reqData, $stuFor, $reqBranch) {
$subQuery = "SELECT CF.Sem_Year, CF.ID , IF(CF.ProgramType = 'Y001', '0', '1') as SEM_YEAR_TYPE
FROM " . COURSE_FEES . " as CF LEFT JOIN " . STUDENTS_FEES_STATUS . " as SFS ON SFS.FeesType = CF.ID
WHERE
SFS.CourseID = '$reqData'
AND SFS.StudentID = '$stuFor'";
$queryDetails = $this->db->query($subQuery);
$results['semYearResult'] = true;
$results['semYear_result_details'] = $queryDetails->result();
return $results;
}
// get serach result
public function get_search_result($reqData, $req) {
$University = $reqData['University'];
$Course = $reqData['Course'];
$Batch = $reqData['Batch'];
$branch = $req['localBranchID'];
if ($branch == 'All') {
if ($University != '' && $Course == '' && $Batch == '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID
WHERE
SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course != '' && $Batch == '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID
WHERE
SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course == '' && $Batch != '') {
// echo 'i am in 3';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID
LEFT JOIN " . STUDENTS_FEES_STATUS . " as SFS ON SFS.StudentID = SC.StudentID
WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course != '' && $Batch != '') {
// echo 'i am in 4';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID
LEFT JOIN " . STUDENTS_FEES_STATUS . " as SFS ON SFS.StudentID = SC.StudentID
WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
}
} else {
if ($University != '' && $Course == '' && $Batch == '') {
// echo 'i am in 5.1';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID AND SC.BranchID = C.BranchCode
WHERE
SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.BranchID = '$branch'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course != '' && $Batch == '') {
// echo 'i am in 5.2';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID AND SC.BranchID = C.BranchCode
WHERE
SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.BranchID = '$branch'
AND SC.IsActive = '1'";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course == '' && $Batch != '') {
// echo 'i am in 5.3';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode
LEFT JOIN " . COURSE . " as C ON C.CourseID = SC.CourseID AND SC.BranchID = C.BranchCode
LEFT JOIN " . STUDENTS_FEES_STATUS . " as SFS ON SFS.StudentID = SC.StudentID AND SC.BranchID = SFS.BranchCode
WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.BranchID = '$branch'
AND SC.IsActive = '1' GROUP BY SFS.StudentID ";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course != '' && $Batch != '') {
// echo 'i am in 5.4';
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName
FROM " . STUDENTS . " as S LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode LEFT JOIN " . COURSE . " as C ON
SC.CourseID = C.CourseID AND SC.BranchID = C.BranchCode
LEFT JOIN " . STUDENTS_FEES_STATUS . " as SFS ON SFS.StudentID = SC.StudentID AND SC.BranchID = SFS.BranchCode AND SFS.CourseID = C.CourseID
WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1'
AND SC.BranchID = '$branch'
AND SC.IsActive = '1' GROUP BY SFS.StudentID";
$queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result();
}
}
return $results;
}
// get list of universities, course, batch
public function get_university_course_batch($branch) {
$this->db->select('t1.UniversityID, t1.UniversityName');
$this->db->order_by('CreatedOn', 'DESC');
$this->db->from('' . UNIVERSITY . ' as t1');
$this->db->where('BranchCode', $branch);
$this->db->where('IsActive', 1);
$univDetails = $this->db->get();
$universityDetails = $univDetails->result();
$endResult = [];
foreach ($universityDetails as $clip) {
// University Details
$resultArr['UniversityID'] = $clip->UniversityID;
$resultArr['UniversityName'] = $clip->UniversityName;
// Course Details
$this->db->select('t2.CourseID, t2.CourseName, t2.CourseCode');
$this->db->from('' . COURSE . ' as t2');
$this->db->where('t2.UniversityID', $clip->UniversityID);
$this->db->where('t2.IsActive', 1);
$this->db->where('t2.BranchCode', $branch);
$courDetails = $this->db->get();
$courseDetails = $courDetails->result();
$resultArr['Course'] = $courseDetails;
// Batch Details
$this->db->select('t3.BatchName, t3.BatchCode,t3.BatchDate');
$this->db->from('' . BATCH . ' as t3');
$this->db->where('t3.UniversityID', $clip->UniversityID);
// $this->db->where('t3.IsActive', 1);
$this->db->where('t3.BranchCode', $branch);
$batDetails = $this->db->get();
$batchDetails = $batDetails->result();
$resultArr['Batch'] = $batchDetails;
array_push($endResult, $resultArr);
}
$results['univList'] = true;
$results['university_details'] = $endResult;
return $results;
}
// 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 = implode(',', $number);
$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=APODEC&Message=" . $message . "&ServiceName=TEMPLATE_BASED");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);
curl_close($ch);
$arrss = explode('<br>', $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->db->insert_batch('T_BroadcastStatus', $data);
// return $output;
$res = $this->db->insert_batch('T_BroadcastStatus', $data);
if(!$res)
{
$error = $this->db->error();
return $error;
}else{
return $output;
}
}
public function mailsend($arr, $msg, $sub) {
$emails = array();
foreach ($arr as $ar) {
$mobi = $this->get_registered_email($ar['StudentID']);
array_push($emails, "$mobi");
}
$list = implode(',', $emails);
//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 = '<h1>Sending email via SMTP server</h1>';
$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;
}
/*
* update followup details for booklet details in call tracking
* created by kms
* */
public function updateBookletStatusInCallTrack($fromDetails = null, $reqDetails = null) {
// get student details
$this->db->select('PLD.ListCode');
$this->db->from(PICK_LIST_DETAILS . ' as PLD');
$this->db->like('PLD.ListName', 'ISSUED TO STUDENT','after');
$this->db->where('PLD.ListCode', $fromDetails[0]['ListCode']);
$this->db->where('PLD.IsActive', '1');
$this->db->where('PLD.BranchCode', $reqDetails['localBranchID']);
$checkStatus = $this->db->get()->last_row();
if ($checkStatus) {
$studentDetails = $this->studentInfo($fromDetails);
if ($studentDetails) {
$arrayDetails['MobileNumber'] = $studentDetails->MobileNumber;
$arrayDetails['LeadName'] = $studentDetails->Firstname;
$arrayDetails['University'] = $studentDetails->UniversityName;
$arrayDetails['Course'] = $studentDetails->CourseName;
$arrayDetails['StatusCode'] = $fromDetails[0]['ListCode'];
$arrayDetails['CreatedBranch'] = $fromDetails[0]['BranchCode'];
$arrayDetails['CreatedOn'] = $fromDetails[0]['CreatedOn'];
$arrayDetails['FollowupOn'] = $fromDetails[0]['AnsDate'];
$arrayDetails['FollowupComments'] = $fromDetails[0]['Comments'];
if ($reqDetails['localType'] == SUPER_ADMIN) {
$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', $fromDetails[0]['BranchCode']);
$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'] = $fromDetails[0]['CreatedBy'];
}
} else {
$arrayDetails['CreatedBy'] = $fromDetails[0]['CreatedBy'];
}
// create activity in call tracking
$this->db->select('ActivityID,ActivityName');
$this->db->like('ActivityName', 'Answer Booklet', 'after');
$this->db->where('IsActive', '1');
$this->db->where('BranchCode', $reqDetails['localBranchID']);
$activityDetails = $this->db->get(ACTIVITY)->last_row();
if ($activityDetails) {
$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['UpdatedOn'] = $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'];
$insertfollowup_Details['StatusName'] = $arrayDetails['StatusCode'];
$insertfollowup_Details['AssignedStaff'] = $arrayDetails['CreatedBy'];
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
// this if for insert follow up details
}
}
}
}
return true;
} else {
return false;
}
}
/*
* update followup details for application status in call tracking
* created by kms
* */
public function updateDocumentStatusInCallTrack($fromDetails = null, $reqDetails = null) {
// check certificate type
$this->db->select('CFM.CertificationID');
$this->db->from(CERTIFICATION_MASTER . ' as CFM');
$this->db->where('CFM.CertificateName', 'APPLICATION');
$this->db->where('CFM.CertificationID', $fromDetails[0]['CertificationType']);
$this->db->where('CFM.IsActive', '1');
$this->db->where('CFM.BranchCode', $reqDetails['localBranchID']);
$checkApplicationStatus = $this->db->get()->last_row();
if ($checkApplicationStatus) {
// 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.ListCode', $fromDetails[0]['ListCode']);
$this->db->where('PLD.IsActive', '1');
$this->db->where('PLD.BranchCode', $reqDetails['localBranchID']);
$checkStatus = $this->db->get()->last_row();
if ($checkStatus) {
$studentDetails = $this->studentInfoForDocumentStatus($fromDetails);
if ($studentDetails) {
$arrayDetails['MobileNumber'] = $studentDetails->MobileNumber;
$arrayDetails['LeadName'] = $studentDetails->Firstname;
$arrayDetails['University'] = $studentDetails->UniversityName;
$arrayDetails['Course'] = $studentDetails->CourseName;
$arrayDetails['StatusCode'] = $fromDetails[0]['ListCode'];
$arrayDetails['CreatedBranch'] = $fromDetails[0]['BranchCode'];
$arrayDetails['CreatedOn'] = $fromDetails[0]['CreatedOn'];
$arrayDetails['FollowupOn'] = $fromDetails[0]['AppDate'];
$arrayDetails['FollowupComments'] = $fromDetails[0]['Comments'];
if ($reqDetails['localType'] == SUPER_ADMIN) {
$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', $fromDetails[0]['BranchCode']);
$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'] = $fromDetails[0]['CreatedBy'];
}
} else {
$arrayDetails['CreatedBy'] = $fromDetails[0]['CreatedBy'];
}
// create activity in call tracking
$this->db->select('ActivityID,ActivityName');
$this->db->like('ActivityName', 'Application', 'after');
$this->db->where('IsActive', '1');
$this->db->where('BranchCode', $reqDetails['localBranchID']);
$activityDetails = $this->db->get(ACTIVITY)->last_row();
if ($activityDetails) {
$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['UpdatedOn'] = $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'];
$insertfollowup_Details['StatusName'] = $arrayDetails['StatusCode'];
$insertfollowup_Details['AssignedStaff'] = $arrayDetails['CreatedBy'];
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
// this if for insert follow up details
}
}
}
}
return true;
} else {
return false;
}
} else {
return false;
}
}
/*
* get student info
* created by kms
* */
public function studentInfo($details = null) {
$this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName');
$this->db->from(COURSE_FEES . ' as CF');
$this->db->join(STUDENTCOURSE . ' as STC', 'STC.CourseID = CF.CourseID');
$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 AND STC.BranchID=US.BranchCode');
$this->db->where('ST.StudentID', $details[0]['StudentID']);
$this->db->where('CF.ID', $details[0]['CourseID']);
$leadDet = $this->db->get()->last_row();
if ($leadDet) {
return $leadDet;
} else {
return false;
}
}
/*
* get student info for documet updates
* created by kms
* */
public function studentInfoForDocumentStatus($details = null) {
$this->db->select('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName');
$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 AND STC.BranchID=US.BranchCode');
$this->db->where('ST.StudentID', $details[0]['StudentID']);
$this->db->where('STC.CourseID', $details[0]['CourseID']);
$leadDet = $this->db->get()->last_row();
if ($leadDet) {
return $leadDet;
} else {
return false;
}
}
//Get AnswerBooklet Status based on StudentID,CourseID,BranchCode,Sem
function getAnswerBookletStatus($StudentID,$CourseID,$BranchCode,$Sem)
{
//echo "MODEL - $StudentID,$CourseID,$BranchCode,$Sem";
$this->db->select("max(T_AnswerBookletStatus.ListCode)as ListCode,max(T_PickListDetails.ListName) as ListName");
$this->db->from("T_AnswerBookletStatus");
$this->db->join("T_PickListDetails","T_AnswerBookletStatus.BranchCode = T_PickListDetails.BranchCode
AND T_AnswerBookletStatus.ListCode = T_PickListDetails.ListCode");
$this->db->where("T_AnswerBookletStatus.BranchCode",$BranchCode);
$this->db->where("T_AnswerBookletStatus.StudentID",$StudentID);
$this->db->where("T_AnswerBookletStatus.CourseID",$CourseID);
$this->db->where("T_AnswerBookletStatus.Sem",$Sem);
$res = $this->db->get();
// print_r($res->result());
$data['isIssueToStudentExist'] = 0;
$data['statusCount'] = 0;
$data['statusCount'] = count($res->result());
// Echo "COUNT OF ANSBOOKLET". $data['statusCount'];
//print_r($res->result());
foreach($res->result() as $status)
{
$isExist = strcasecmp(trim($status->ListName),'ISSUED TO STUDENT');
if( $isExist == 0)
{
$data['isIssueToStudentExist'] = $data['isIssueToStudentExist'] + 1;
}
}
//echo "FINAL RES SEND TO PARENT";
// print_r($data);
// die();
// print_r($this->db->last_query());
// die();
return $data;
}
function getFinalSemAnswerBookletStatus($CourseID,$StudentID,$BranchCode)
{
//echo "MODEL - $StudentID,$CourseID,$BranchCode,$Sem";
$this->db->select("CourierDetails, ListCode, AnsDate, Comments");
$this->db->from("T_AnswerBookletStatus");
$this->db->where("T_AnswerBookletStatus.BranchCode",$BranchCode);
$this->db->where("T_AnswerBookletStatus.StudentID",$StudentID);
$this->db->where("T_AnswerBookletStatus.CourseID",$CourseID);
$this->db->order_by('T_AnswerBookletStatus.CreatedOn', 'DESC');
$res = $this->db->get();
// print_r($res->result());
$finalSemDetails = $res->result();
if($finalSemDetails){
// print_r($formTypeDetails);exit();
$resultArr['finalSemDetails'] = $finalSemDetails;
$resultArr['message'] = "Successfully data generated";
} else {
// print_r($formTypeDetails);exit();
$resultArr['finalSemDetails'] = [];
$resultArr['message'] = "No record found";
}
return $resultArr;
}
//get application form details
public function get_applicationFrom_details($reqData, $reqBranch) {
$studentId = $reqData['studId'];
$courseId = $reqData['courseId'];
// $searchTableFor = APPLICATION_FORM;
$this->db->select('t1.ID, t1.Student_Fee_Status_Id, t1.BatchCode, t1.FeeType as SemID, CFD.Sem_Year as Sem_Year, t1.RegistrationMode, t1.RegistrationType,BM.BatchName,t1.CreatedOn');
$this->db->from('T_Registration_Details as t1');
$this->db->join('T_Students_Fees_Status as SFS', 'SFS.FeesID = t1.Student_Fee_Status_Id');
$this->db->join('T_Course_Fees_Details as CFD', 'CFD.ID = t1.FeeType');
$this->db->join('T_BatchMaster as BM', 'BM.BatchCode = t1.BatchCode');
$this->db->where('t1.StudentID', $studentId);
$this->db->where('t1.CourseID', $courseId);
$this->db->group_by('t1.ID');
$fromTypes = $this->db->get();
$formTypeDetails = $fromTypes->result();
// print_r($this->db->last_query());
// die();
if($formTypeDetails){
// print_r($formTypeDetails);exit();
$resultArr['formTypeDetails'] = $formTypeDetails;
$resultArr['formTypeStatus'] = true;
$resultArr['message'] = "Successfully data generated";
} else {
// print_r($formTypeDetails);exit();
$resultArr['formTypeDetails'] = [];
$resultArr['formTypeStatus'] = false;
$resultArr['message'] = "No record found";
}
return $resultArr;
}
public function update_applicationForm_status($reqData, $reqBranch){
$arr['Registration_Details_ID'] = $reqData[0]['register_details_id'];
$arr['ListCode'] = $reqData[0]['ListCode'];
$arr['Comments'] = $reqData[0]['Comments'];
$arr['AppFormDate'] = $reqData[0]['SDate'];
$arr['BranchCode'] = $reqBranch['localBranchID'];
$arr['CreatedBy'] = $reqBranch['localUserID'];
$time = date('Y-m-d H:i:s');
$dateTime = $time;
$arr['CreatedOn'] = $dateTime;
// print_r($arr);exit();
$this->db->insert('T_ApplicationFormStatus', $arr);
if ($this->db->affected_rows() >= 1) {
$result['addStatus'] = true;
$result['message'] = "Successfully Application Form Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
public function get_ApplicationFormStatusDetails($reqData, $reqBranch){
$studentId = $reqData['studId'];
$courseId = $reqData['courseId'];
// echo $studentId;exit();
// $searchTableFor = APPLICATION_FORM;
$this->db->select('t1.ID, t2.BatchCode, t2.FeeType as SemID, CFD.Sem_Year as Sem_Year, t2.RegistrationMode, t2.RegistrationType, t1.AppFormDate as StatusUpdateDate,if(t3.ListCode = "U001","-",t3.ListName) as ListName ,t1.Comments');
$this->db->from('T_ApplicationFormStatus as t1');
$this->db->join('T_Registration_Details as t2', 't2.ID = t1.Registration_Details_ID');
$this->db->join('T_Course_Fees_Details as CFD', 'CFD.ID = t2.FeeType');
$this->db->join('' . PICK_LIST_DETAILS . ' as t3', 't3.ListCode = t1.ListCode', 'LEFT');
$this->db->join('T_Students_Fees_Status as SFS','SFS.FeesID = t2.Student_Fee_Status_Id');
$this->db->where('t2.StudentID', $studentId);
$this->db->where('t2.CourseID', $courseId);
$this->db->group_by('t1.ID');
$fromTypes = $this->db->get();
$formTypeDetails = $fromTypes->result();
if($formTypeDetails){
// print_r($formTypeDetails);exit();
$resultArr['formTypeDetails'] = $formTypeDetails;
$resultArr['formTypeStatus'] = true;
$resultArr['message'] = "Successfully data generated";
} else {
// print_r($formTypeDetails);exit();
$resultArr['formTypeDetails'] = [];
$resultArr['formTypeStatus'] = false;
$resultArr['message'] = "No record found";
}
//print_r($this->db->last_query());die();
return $resultArr;
}
public function GetLastAns_status($StudentID,$Sem,$CourseID)
{
$subQuery = 'select T_AnswerBookletStatus.ListCode,ListName from T_AnswerBookletStatus
join T_PickListDetails on T_AnswerBookletStatus.ListCode=T_PickListDetails.ListCode
where T_AnswerBookletStatus.StudentID=? and
T_AnswerBookletStatus.CreatedOn=(select max(CreatedOn) from T_AnswerBookletStatus
where StudentID= ? and Sem=?) and Sem=? and CourseID=?';
$query = $this->db->query($subQuery,array($StudentID,$StudentID,$Sem,$Sem,$CourseID));
$expense = $query->result();
// print_r($expense);die();
// print_r($this->db->last_query());
$latestappstatus='';
if(!empty($expense))
{
foreach($expense as $get)
{
$latestappstatus= $get->ListCode;
}
}
//echo $latestappstatus;die();
$this->db->select('ListCode,ListName');
$this->db->from('T_PickListDetails');
$this->db->where('T_PickListDetails.ListCode',$latestappstatus);
$Type = $this->db->get();
$TypeName = $Type->result();
$LastListname='';
foreach($TypeName as $ty)
{
$LastListname= $ty->ListName;
}
// echo $LastListname;die();
return $LastListname;
}
}