164 lines
5.8 KiB
PHP
164 lines
5.8 KiB
PHP
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Broadcast_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* status updation details
|
|
* params:
|
|
* created by kdk
|
|
* */
|
|
|
|
// 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.* , SC.CourseID , C.CourseName , 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 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;
|
|
}
|
|
|
|
|
|
public function send_msg_students($arr, $msg) {
|
|
$msg_body = $msg['content'];
|
|
$mesg = "Status Update : check - check check.";
|
|
$resp = $this->smssend($arr, $mesg);
|
|
// $arrss = explode('<br>', $resp);
|
|
// $results['resp'] = $resp;
|
|
// for($i=0; $i<count($arrss); $i++){
|
|
// echo $arrss[$i];exit();
|
|
// $a = explode(':', $arrss[$i]);
|
|
// Array
|
|
// (
|
|
// [0] => MsgID
|
|
// [1] => 4fad03cf13734a869307b19fcc293570
|
|
// [2] => 919942080003
|
|
// [3] => 201801191700328088
|
|
// [4] => success
|
|
// )
|
|
// $msgId = $a[0];
|
|
// $msgNumb = $a[1];
|
|
// $msgStatus = $a[4];
|
|
// // print_r ($a);exit;
|
|
// // echo $a[1];exit();
|
|
// $data[] = array(
|
|
// 'MsgID' => $msgId,
|
|
// 'MsgNum' => $msgNumb,
|
|
// 'MsgDelvStatus' => $msgStatus
|
|
// );
|
|
// }
|
|
|
|
// $msgID = $arrss[1];
|
|
// $msgSendTime = $arrss[2];
|
|
// $msgDeleveredNum = $arrss[3];
|
|
// $msgSendStatus = $arrss[3];
|
|
|
|
// print_r($data);exit();
|
|
$result['msgStatus'] = true;
|
|
$result['message'] = "Successfully Messages Sended!!";
|
|
return $result;
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
|
|
// 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);
|
|
// echo $mobile , $message;
|
|
$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;
|
|
}
|
|
|
|
} |