apollodec/Apollo/api/application/models/StatusUpdation_model.php
2017-12-18 13:39:58 +05:30

286 lines
11 KiB
PHP

<?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
* */
// get status list
public function get_status_list() {
$this->db->select('ListCode, ListName');
$this->db->order_by('CreatedOn', 'DESC');
$this->db->from('T_PickListDetails');
$this->db->where('ListCode', 'S034');
$staDetails = $this->db->get();
$statusDetails = $staDetails->result();
if (count($statusDetails) > 0) {
$results['statusList'] = true;
$results['statusList_details'] = $statusDetails;
} else {
$results['statusList'] = false;
$results['message'] = 'No record found';
}
return $results;
}
// update Application status
public function update_applicationStatus($arr) {
$this->db->insert_batch('T_ApplicationStatus', $arr);
if ($this->db->affected_rows() >= 1) {
$result['addStatus'] = true;
$result['message'] = "Successfully Application Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// update certificate stauts
public function update_certificateStatus($arr) {
// $dateToMsg = $arr[0]['CDate'];
$this->db->insert_batch('T_CertificationStatus', $arr);
if ($this->db->affected_rows() >= 1) {
if((get_status_name_ListCode($arr[0]['ListCode'] == 'Received' || 'received') || (get_status_name_ListCode($arr[0]['ListCode'] == 'Issued' || 'issued') ) {
$dateToMsg = $arr[0]['CDate'];
$mesg = "Your new password for logging into Apollo student portal is $dateToMsg'. Please change the password as soon as you login.";
$this->smssend($arr, $mesg);
}
$result['addStatus'] = true;
$result['message'] = "Successfully Certification Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// get certificate list
public function get_certificate_list() {
$this->db->select('*');
$this->db->order_by('CreatedOn', 'DESC');
$this->db->from('T_CertificationMaster');
$this->db->where('IsActive', 1);
$cerfDetails = $this->db->get();
$certificateDetails = $cerfDetails->result();
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 the status for the LISTCODE
public function get_status_name_ListCode($listCode) {
$this->db->select('ListName');
$this->db->from(PICK_LIST_DETAILS);
$this->db->where('ListCode', $listCode);
$statusDetails = $this->db->get()->first_row();
return $statusDetails->ListName;
}
// update answer booklet status
public function update_answerbooklet($arr) {
// print_r($arr);exit();
$this->db->insert_batch('T_AnswerBookletStatus', $arr);
if ($this->db->affected_rows() >= 1) {
// $this->smssend($arr);
$result['addStatus'] = true;
$result['message'] = "Successfully Answer Booklet Status Updated";
} else {
$result['addStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
// update study material status
public function update_semyear($arr) {
$this->db->insert_batch('T_StudyMaterialStatus', $arr);
if ($this->db->affected_rows() >= 1) {
if((get_status_name_ListCode($arr[0]['ListCode'] == 'Received' || 'received') || (get_status_name_ListCode($arr[0]['ListCode'] == 'Issued' || 'issued') ) {
$dateToMsg = $arr[0]['SDate'];
$mesg = "Your new password for logging into Apollo student portal is $dateToMsg'. Please change the password as soon as you login.";
$this->smssend($arr, $mesg);
}
// $this->smssend($arr);
$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) {
$subQuery = "SELECT CF.Sem_Year, CF.ID
FROM ".COURSE_FEES." as CF
WHERE
CF.CourseID = '$reqData'
AND CF.ProgramType ='Y001'";
$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) {
// print_r($reqData['University']);
// print_r($req);
// exit();
$University = $reqData['University'];
$Course = $reqData['Course'];
$Batch = $reqData['Batch'];
$subQuery = "SELECT S.*
FROM ".STUDENTS." as S LEFT JOIN ".STUDENTCOURSE." as SC ON SC.StudentID = S.StudentID
WHERE
SC.UniversityID LIKE '%$University%'
AND SC.CourseID LIKE '%$Course%'
AND SC.BatchCode LIKE '%$Batch%'
AND S.IsActive = '1'
AND SC.IsActive = '1'";
$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() {
$this->db->select('t1.UniversityID, t1.UniversityName');
$this->db->order_by('CreatedOn', 'DESC');
$this->db->from(''.UNIVERSITY. ' as t1');
$this->db->where('IsActive', 1);
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
$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');
$this->db->from(''.COURSE. ' as t2');
$this->db->where('t2.UniversityID', $clip->UniversityID);
$this->db->where('t2.IsActive', 1);
$courDetails = $this->db->get();
$courseDetails = $courDetails->result();
$resultArr['Course'] =$courseDetails;
// Batch Details
$this->db->select('t3.BatchName, t3.BatchCode');
$this->db->from(''.BATCH. ' as t3');
$this->db->where('t3.UniversityID', $clip->UniversityID);
$this->db->where('t3.IsActive', 1);
$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 ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
// $mobile = "91$mobile";
$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);
// print_r($output);exit();
curl_close($ch);
return $output;
}
// public function mailsend() {
// //Load email library
// $this->load->library('email');
// //SMTP & mail configuration
// $config = array(
// 'protocol' => 'smtp',
// 'smtp_host' => 'ssl://smtp.example.com',
// 'smtp_port' => 465,
// 'smtp_user' => 'email@example.com',
// 'smtp_pass' => 'email_password',
// 'mailtype' => 'html',
// 'charset' => 'utf-8'
// );
// $this->email->initialize($config);
// $this->email->set_mailtype("html");
// $this->email->set_newline("\r\n");
// //Email content
// $htmlContent = '<h1>Sending email via SMTP server</h1>';
// $htmlContent .= '<p>This email has sent via SMTP server from CodeIgniter application.</p>';
// // Email body load the html template
// // $body = $this->load->view('emails/anillabs.php',$data,TRUE);
// $this->email->to('recipient@example.com');
// $this->email->from('sender@example.com','MyWebsite');
// $this->email->subject('How to send email via SMTP server in CodeIgniter');
// $this->email->message($htmlContent);
// //Send email
// $this->email->send();
// }
}