broadcast details update : kdk

This commit is contained in:
dineshkumarkannan 2018-04-26 13:05:00 +05:30
parent 062b103cc1
commit a7a3c03836
2 changed files with 204 additions and 283 deletions

View File

@ -1,11 +1,9 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions // This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */ /** @noinspection PhpIncludeInspection */
require_once APPPATH . '/libraries/REST_Controller.php'; require_once APPPATH . '/libraries/REST_Controller.php';
/** /**
* This is an example of a few basic user interaction methods you could use * This is an example of a few basic user interaction methods you could use
* all done with a hardcoded array * all done with a hardcoded array
@ -18,14 +16,12 @@ require_once APPPATH . '/libraries/REST_Controller.php';
* @link * @link
*/ */
class Broadcast_Controller extends REST_Controller { class Broadcast_Controller extends REST_Controller {
/* /*
* broadcast, sms send functionality * broadcast, sms send functionality
* params: * params:
* created by kdk * created by kdk
* */ * */
function __construct() function __construct() {
{
// Construct the parent class // Construct the parent class
parent::__construct(); parent::__construct();
$this->methods['getUniversity_post']['limit'] = 100; $this->methods['getUniversity_post']['limit'] = 100;
@ -40,20 +36,16 @@ class Broadcast_Controller extends REST_Controller {
$loginUserId = $reqData['localUserID']; $loginUserId = $reqData['localUserID'];
$loginUserBranchId = $reqData['localBranchID']; $loginUserBranchId = $reqData['localBranchID'];
$loginUserType = $reqData['localType']; $loginUserType = $reqData['localType'];
$getUniversityListDetails = $this->broadcast_model->get_university_course_batch();// Check if the employee exist $getUniversityListDetails = $this->broadcast_model->get_university_course_batch($loginUserBranchId); // Check if the employee exist
if ($getUniversityListDetails) if ($getUniversityListDetails) {
{
$getUniversityListDetails['status'] = REST_Controller::HTTP_OK; $getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit // Set the response and exit
$this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code $this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else } else {
{
// Set the response and exit // Set the response and exit
$this->response([ $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
} }
} }
@ -61,22 +53,16 @@ class Broadcast_Controller extends REST_Controller {
public function getStuListForBrodcast_post() { public function getStuListForBrodcast_post() {
$reqSearchData = $this->post('data'); $reqSearchData = $this->post('data');
$reqData = $this->post('requestDetails'); $reqData = $this->post('requestDetails');
// print_r($reqSearchData);exit(); $getSearchDetails = $this->broadcast_model->get_search_result($reqSearchData, $reqData); // Check if the employee exist
if ($getSearchDetails) {
$getSearchDetails = $this->broadcast_model->get_search_result($reqSearchData, $reqData);// Check if the employee exist
if ($getSearchDetails)
{
$getSearchDetails['status'] = REST_Controller::HTTP_OK; $getSearchDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit // Set the response and exit
$this->response($getSearchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code $this->response($getSearchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else } else {
{
// Set the response and exit // Set the response and exit
$this->response([ $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
} }
} }
@ -87,83 +73,60 @@ class Broadcast_Controller extends REST_Controller {
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$dateTime = $time; $dateTime = $time;
$count = count($reqData); $count = count($reqData);
for($i=0; $i < $count; $i++) { for ($i = 0;$i < $count;$i++) {
$data[] = array( $data[] = array('StudentID' => $reqData[$i]['StudentID']);
'StudentID' => $reqData[$i]['StudentID']
);
} }
$sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg, $reqDetails); // Check if the employee exist
$sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg, $reqDetails);// Check if the employee exist if ($sendMsgDetails) {
if ($sendMsgDetails)
{
$sendMsgDetails['status'] = REST_Controller::HTTP_OK; $sendMsgDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit // Set the response and exit
$this->response($sendMsgDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code $this->response($sendMsgDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else } else {
{
// Set the response and exit // Set the response and exit
$this->response([ $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
} }
} }
public function getSMSGroupDetails_post() { public function getSMSGroupDetails_post() {
$reqData = $this->post('data'); $reqData = $this->post('data');
$reqDataBy = $this->post('localReqDetails'); $reqDataBy = $this->post('localReqDetails');
// print_r($reqData);exit(); $getMegDetails = $this->broadcast_model->getSMSGroupDetails($reqData, $reqDataBy); // Check if the employee exist
$getMegDetails = $this->broadcast_model->getSMSGroupDetails($reqData);// Check if the employee exist if ($getMegDetails) {
if ($getMegDetails)
{
$getMegDetails['status'] = REST_Controller::HTTP_OK; $getMegDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit // Set the response and exit
$this->response($getMegDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code $this->response($getMegDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else } else {
{
// Set the response and exit // Set the response and exit
$this->response([ $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
} }
} }
public function getSMSSendReportList_post(){ public function getSMSSendReportList_post() {
$reqData = $this->post('data'); $reqData = $this->post('data');
$reqDataBy = $this->post('localReqDetails'); $reqDataBy = $this->post('requestDetails');
// $time = date('Y-m-d H:i:s'); $getMegCronDetails = $this->broadcast_model->getSmsSendBetweenDate($reqData, $reqDataBy); // Check if the employee exist
// $dateTime = $time; if ($getMegCronDetails) {
// $date1 = $dateTime;
// $date2 = $dateTime;
$getMegCronDetails = $this->broadcast_model->getSmsSendBetweenDate($reqData, $reqDataBy);// Check if the employee exist
if ($getMegCronDetails)
{
$getMegCronDetails['status'] = REST_Controller::HTTP_OK; $getMegCronDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit // Set the response and exit
$this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else } else {
{
// Set the response and exit // Set the response and exit
$this->response([ $this->response(['message' => 'No list were found', 'status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
'message' => 'No list were found',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
} }
} }
public function getCronCall_get() { public function getCronCall_get() {
$getMegCronDetails = $this->broadcast_model->getCronUpdate();// Check if the employee exist $getMegCronDetails = $this->broadcast_model->getCronUpdate(); // Check if the employee exist
// echo $getMegCronDetails;exit(); // echo $getMegCronDetails;exit();
if($getMegCronDetails){ if ($getMegCronDetails) {
echo $getMegCronDetails; echo $getMegCronDetails;
}else { } else {
} }
// if ($getMegCronDetails) // if ($getMegCronDetails)
// { // {
@ -179,5 +142,6 @@ class Broadcast_Controller extends REST_Controller {
// 'status' => REST_Controller::HTTP_NOT_FOUND // 'status' => REST_Controller::HTTP_NOT_FOUND
// ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code // ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
// } // }
} }
} }

View File

@ -4,10 +4,7 @@
* Time: 5:28 PM * Time: 5:28 PM
*/ */
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Broadcast_model extends CI_Model {
class Broadcast_model extends CI_Model
{
/* /*
* status updation details * status updation details
* params: * params:
@ -16,119 +13,105 @@ class Broadcast_model extends CI_Model
// get serach result // get serach result
public function get_search_result($reqData, $req) { public function get_search_result($reqData, $req) {
$localBranch = $req['localBranchID'];
// print_r($reqData['University']);
// print_r($req);
// exit();
$University = $reqData['University']; $University = $reqData['University'];
$Course = $reqData['Course']; $Course = $reqData['Course'];
$Batch = $reqData['Batch']; $Batch = $reqData['Batch'];
if ($University != '' && $Course == '' && $Batch == '') {
if($University != '' && $Course == '' && $Batch == '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName $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 FROM " . STUDENTS . " as S
LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
SC.CourseID = C.CourseID 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 WHERE
SC.UniversityID = '$University' SC.UniversityID = '$University'
AND S.IsActive = '1' AND S.IsActive = '1'
AND SC.IsActive = '1'"; AND SC.IsActive = '1'
AND SC.BranchID = '$localBranch'";
$queryDetails = $this->db->query($subQuery); $queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true; $results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result(); $results['search_result_details'] = $queryDetails->result();
} else if ($University != '' && $Course != '' && $Batch == '' ) { } else if ($University != '' && $Course != '' && $Batch == '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName $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 FROM " . STUDENTS . " as S
LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
SC.CourseID = C.CourseID 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 WHERE
SC.CourseID = '$Course' AND SC.UniversityID = '$University' SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1' AND S.IsActive = '1'
AND SC.IsActive = '1'"; AND SC.IsActive = '1'
AND SC.BranchID = '$localBranch'";
$queryDetails = $this->db->query($subQuery); $queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true; $results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result(); $results['search_result_details'] = $queryDetails->result();
} else if ( $University != '' && $Course == '' && $Batch != '' ) { } else if ($University != '' && $Course == '' && $Batch != '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName ,C.CourseCode, U.UniversityName $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 FROM " . STUDENTS . " as S
LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
SC.CourseID = C.CourseID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode
LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID 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
WHERE SFS.CourseID = SC.CourseID AND WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University' SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
AND S.IsActive = '1' AND S.IsActive = '1'
AND SC.IsActive = '1'"; AND SC.IsActive = '1'
AND SC.BranchID = '$localBranch'";
$queryDetails = $this->db->query($subQuery); $queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true; $results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result(); $results['search_result_details'] = $queryDetails->result();
} else if ( $University != '' && $Course != '' && $Batch != '' ) { } else if ($University != '' && $Course != '' && $Batch != '') {
$subQuery = "SELECT S.* , SC.ID as UNI_ID, SC.CourseID , C.CourseName , C.CourseCode, U.UniversityName $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 FROM " . STUDENTS . " as S
LEFT JOIN ".UNIVERSITY." as U ON SC.UniversityID = U.UniversityID LEFT JOIN ".COURSE." as C ON LEFT JOIN " . STUDENTCOURSE . " as SC ON SC.StudentID = S.StudentID
SC.CourseID = C.CourseID LEFT JOIN " . UNIVERSITY . " as U ON SC.UniversityID = U.UniversityID AND SC.BranchID = U.BranchCode
LEFT JOIN ".STUDENTS_FEES_STATUS." as SFS ON SFS.StudentID = SC.StudentID 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
WHERE SFS.CourseID = SC.CourseID AND WHERE SFS.CourseID = SC.CourseID AND
SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University' SFS.BatchCode = '$Batch' AND SC.CourseID = '$Course' AND SC.UniversityID = '$University'
AND S.IsActive = '1' AND S.IsActive = '1'
AND SC.IsActive = '1'"; AND SC.IsActive = '1'
// AND S.BranchCode = '$branch' AND SC.BranchID = '$localBranch'";
// SC.UniversityID LIKE '%$University%'
// AND SC.CourseID LIKE '%$Course%'
// AND SC.BatchCode LIKE '%$Batch%'
$queryDetails = $this->db->query($subQuery); $queryDetails = $this->db->query($subQuery);
$results['searchResult'] = true; $results['searchResult'] = true;
$results['search_result_details'] = $queryDetails->result(); $results['search_result_details'] = $queryDetails->result();
} }
// $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; return $results;
} }
// get list of universities, course, batch // get list of universities, course, batch
public function get_university_course_batch() { public function get_university_course_batch($branchId) {
$this->db->select('t1.UniversityID, t1.UniversityName'); $this->db->select('t1.UniversityID, t1.UniversityName');
$this->db->order_by('CreatedOn', 'DESC'); $this->db->order_by('CreatedOn', 'DESC');
$this->db->from(''.UNIVERSITY. ' as t1'); $this->db->from('' . UNIVERSITY . ' as t1');
$this->db->where('IsActive', 1); $this->db->where('t1.IsActive', 1);
$this->db->where('t1.BranchCode', $branchId);
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT'); // $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
$univDetails = $this->db->get(); $univDetails = $this->db->get();
$universityDetails = $univDetails->result(); $universityDetails = $univDetails->result();
$endResult = []; $endResult = [];
foreach($universityDetails as $clip){ foreach ($universityDetails as $clip) {
// University Details // University Details
$resultArr['UniversityID'] = $clip->UniversityID; $resultArr['UniversityID'] = $clip->UniversityID;
$resultArr['UniversityName'] = $clip->UniversityName; $resultArr['UniversityName'] = $clip->UniversityName;
// Course Details // Course Details
$this->db->select('t2.CourseID, t2.CourseName'); $this->db->select('t2.CourseID, t2.CourseName');
$this->db->from(''.COURSE. ' as t2'); $this->db->from('' . COURSE . ' as t2');
$this->db->where('t2.UniversityID', $clip->UniversityID); $this->db->where('t2.UniversityID', $clip->UniversityID);
$this->db->where('t2.IsActive', 1); $this->db->where('t2.IsActive', 1);
$this->db->where('t2.BranchCode', $branchId);
$courDetails = $this->db->get(); $courDetails = $this->db->get();
$courseDetails = $courDetails->result(); $courseDetails = $courDetails->result();
$resultArr['Course'] =$courseDetails; $resultArr['Course'] = $courseDetails;
// Batch Details // Batch Details
$this->db->select('t3.BatchName, t3.BatchCode'); $this->db->select('t3.BatchName, t3.BatchCode');
$this->db->from(''.BATCH. ' as t3'); $this->db->from('' . BATCH . ' as t3');
$this->db->where('t3.UniversityID', $clip->UniversityID); $this->db->where('t3.UniversityID', $clip->UniversityID);
$this->db->where('t3.IsActive', 1); $this->db->where('t3.IsActive', 1);
$this->db->where('t3.BranchCode', $branchId);
$batDetails = $this->db->get(); $batDetails = $this->db->get();
$batchDetails = $batDetails->result(); $batchDetails = $batDetails->result();
$resultArr['Batch'] =$batchDetails; $resultArr['Batch'] = $batchDetails;
array_push($endResult, $resultArr); array_push($endResult, $resultArr);
} }
$results['univList'] = true; $results['univList'] = true;
@ -136,11 +119,11 @@ class Broadcast_model extends CI_Model
return $results; return $results;
} }
public function getSMSGroupDetails($reqData) { public function getSMSGroupDetails($reqData ,$reqBy) {
$localBranch = $reqBy['localBranchID'];
$querys = "SELECT t1.*, t2.DeliveredStatus, t2.DeliveredOn FROM T_BroadcastStatus as t1 $querys = "SELECT t1.*, t2.DeliveredStatus, t2.DeliveredOn FROM T_BroadcastStatus as t1
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
WHERE t1.MsgGroup = '$reqData' ORDER BY t1.CreatedOn DESC"; WHERE t1.MsgGroup = '$reqData' AND t1.BranchCode='$localBranch' ORDER BY t1.CreatedOn DESC";
$smsSendGroupDetails = $this->db->query($querys); $smsSendGroupDetails = $this->db->query($querys);
$smsSendGroupDetailsList = $smsSendGroupDetails->result(); $smsSendGroupDetailsList = $smsSendGroupDetails->result();
$results['smsSendGroupDetailsListStatus'] = true; $results['smsSendGroupDetailsListStatus'] = true;
@ -148,44 +131,40 @@ class Broadcast_model extends CI_Model
return $results; return $results;
} }
//get sms sent details
public function getSmsSendBetweenDate($reqData, $reqDataBy) { public function getSmsSendBetweenDate($reqData, $reqDataBy) {
$localBranch = $reqDataBy['localBranchID'];
if($reqData['date'] != '' && $reqData['dateTo'] != '') { if ($reqData['date'] != '' && $reqData['dateTo'] != '') {
$d = new DateTime($reqData['date']); $d = new DateTime($reqData['date']);
$dTo = new DateTime($reqData['dateTo']); $dTo = new DateTime($reqData['dateTo']);
$fromDate = $d->format('Y-m-d'); $fromDate = $d->format('Y-m-d');
$toDate = $dTo->format('Y-m-d'); $toDate = $dTo->format('Y-m-d');
// $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1 // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
// LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
// WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
// AND '$toDate' ORDER BY t1.CreatedOn DESC"; // AND '$toDate' ORDER BY t1.CreatedOn DESC";
$querys = "SELECT t1.*, COUNT(t1.MsgGroup) as MSG_SEND_CNT
$querys = "SELECT t1.*, COUNT(t1.MsgGroup) as MSG_SEND_CNT FROM T_BroadcastStatus as t1 FROM T_BroadcastStatus as t1
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' WHERE t1.BranchCode = '$localBranch' AND STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
AND '$toDate' GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC"; AND '$toDate' GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC";
$smsSendDetails = $this->db->query($querys); $smsSendDetails = $this->db->query($querys);
$smsSendDetailsList = $smsSendDetails->result(); $smsSendDetailsList = $smsSendDetails->result();
$results['smsSendDetailsListStatus'] = true; $results['smsSendDetailsListStatus'] = true;
$results['smsSendDetailsList'] = $smsSendDetailsList; $results['smsSendDetailsList'] = $smsSendDetailsList;
} else { } else {
// $d = new DateTime($d1); // $d = new DateTime($d1);
// $dTo = new DateTime($d2); // $dTo = new DateTime($d2);
// $fromDate = $d->format('Y-m-d'); // $fromDate = $d->format('Y-m-d');
// $toDate = $dTo->format('Y-m-d'); // $toDate = $dTo->format('Y-m-d');
// $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1 // $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
// LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId // LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
// WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate' // WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
// AND '$toDate' ORDER BY t1.CreatedOn DESC"; // AND '$toDate' ORDER BY t1.CreatedOn DESC";
$querys = "SELECT t1.*, COUNT(t1.MsgGroup) FROM T_BroadcastStatus as t1 $querys = "SELECT t1.*, COUNT(t1.MsgGroup) FROM T_BroadcastStatus as t1
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
WHERE t1.BranchCode = '$localBranch'
GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC"; GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC";
$smsSendDetails = $this->db->query($querys); $smsSendDetails = $this->db->query($querys);
$smsSendDetailsList = $smsSendDetails->result(); $smsSendDetailsList = $smsSendDetails->result();
$results['smsSendDetailsListStatus'] = true; $results['smsSendDetailsListStatus'] = true;
@ -196,10 +175,11 @@ class Broadcast_model extends CI_Model
return $results; return $results;
} }
// sms send functionality with update details to T_BroadcastStatus
public function send_msg_students($arr, $msg, $reqDetails) { public function send_msg_students($arr, $msg, $reqDetails) {
$msg_body = $msg['content']; $msg_body = $msg['content'];
$sender = $reqDetails['localUserID']; $sender = $reqDetails['localUserID'];
$localBranch = $reqDetails['localBranchID'];
$mesg = "$msg_body"; $mesg = "$msg_body";
// $mesg = "Status Update : check - check check."; // $mesg = "Status Update : check - check check.";
// $mesg = "Check"; // $mesg = "Check";
@ -217,10 +197,9 @@ class Broadcast_model extends CI_Model
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$dateTime = $time; $dateTime = $time;
$msgGroup = date('YmdHis'); $msgGroup = date('YmdHis');
for ($i = 0, $c = count($arrss);$i < $c;$i++) {
for($i=0, $c = count($arrss) ; $i< $c; $i++){
// echo $arrss[$i];exit(); // echo $arrss[$i];exit();
if( $arrss[$i] === '') { if ($arrss[$i] === '') {
break; break;
} else { } else {
$a = explode(':', $arrss[$i]); $a = explode(':', $arrss[$i]);
@ -228,15 +207,7 @@ class Broadcast_model extends CI_Model
$msgId = $a[1]; $msgId = $a[1];
$msgNumb = $a[2]; $msgNumb = $a[2];
$msgStatus = $a[4]; $msgStatus = $a[4];
$data[] = array( $data[] = array('MsgId' => $msgId, 'MobileNumber' => $msgNumb, 'MsgBody' => $mesg, 'Status' => $msgStatus, 'CreatedOn' => $dateTime, 'CreatedBy' => $sender, 'MsgGroup' => $msgGroup, 'BranchCode' => $localBranch);
'MsgId' => $msgId,
'MobileNumber' => $msgNumb,
'MsgBody' => $mesg,
'Status' => $msgStatus,
'CreatedOn' => $dateTime,
'CreatedBy' => $sender,
'MsgGroup' => $msgGroup
);
continue; continue;
} }
} }
@ -254,7 +225,6 @@ class Broadcast_model extends CI_Model
// $msgSendTime = $arrss[2]; // $msgSendTime = $arrss[2];
// $msgDeleveredNum = $arrss[3]; // $msgDeleveredNum = $arrss[3];
// $msgSendStatus = $arrss[3]; // $msgSendStatus = $arrss[3];
// print_r($data);exit(); // print_r($data);exit();
return $result; return $result;
} }
@ -270,57 +240,46 @@ class Broadcast_model extends CI_Model
// http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf // http://www.24x7sms.com/downloads/24X7SMS_http_API2.0.pdf
// API Key : xegCdYUIMf3 // API Key : xegCdYUIMf3
// Your new password for logging into Apollo student portal is (Password). Please change the password as soon as you login. // 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. // This is the template to be used.
public function smssend($arr, $msg) {
public function smssend($arr, $msg) $number = array();
{ foreach ($arr as $ar) {
$number =array();
foreach($arr as $ar){
$mobi = $this->get_registered_mobile($ar['StudentID']); $mobi = $this->get_registered_mobile($ar['StudentID']);
array_push($number, "91$mobi"); array_push($number, "91$mobi");
} }
$mobile = implode(',', $number); $mobile = implode(',', $number);
// $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login."; // $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
// $mobile = "91$mobile"; // $mobile = "91$mobile";
$message = urlencode($msg); $message = urlencode($msg);
// echo $mobile , $message; $ch = curl_init();
$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=PROMOTIONAL_HIGH");
curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APOLLO&Message=".$message."&ServiceName=PROMOTIONAL_HIGH");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output =curl_exec($ch); $output = curl_exec($ch);
// print_r($output);exit();
curl_close($ch); curl_close($ch);
return $output; return $output;
} }
//get cron job call
public function getCronUpdate() { public function getCronUpdate() {
$date2 = date('Y-m-d'); $date2 = date('Y-m-d');
$quw = "SELECT * FROM T_BroadcastDeliveryCron ORDER BY id DESC LIMIT 1"; $quw = "SELECT * FROM T_BroadcastDeliveryCron ORDER BY id DESC LIMIT 1";
$myext = $this->db->query($quw)->first_row(); $myext = $this->db->query($quw)->first_row();
// print_r($this->db->query($quw)->first_row());exit(); // print_r($this->db->query($quw)->first_row());exit();
if($myext){ if ($myext) {
if($myext->CreatedOn){ if ($myext->CreatedOn) {
$arrsss = explode(' ', $myext->CreatedOn); $arrsss = explode(' ', $myext->CreatedOn);
} }
$date1 = $myext->CreatedOn != '' ? $arrsss[0] : $date2; $date1 = $myext->CreatedOn != '' ? $arrsss[0] : $date2;
} else { } else {
$date1 = $date2; $date1 = $date2;
} }
$ch = curl_init();
$ch=curl_init(); curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/GetReports.aspx?APIKEY=xegCdYUIMf3&StartDate=" . $date1 . "&EndDate=" . $date2 . "");
curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/GetReports.aspx?APIKEY=xegCdYUIMf3&StartDate=".$date1."&EndDate=".$date2."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output =curl_exec($ch); $output = curl_exec($ch);
// print_r($output);exit(); // print_r($output);exit();
curl_close($ch); curl_close($ch);
$arrss = explode('<br>', $output); $arrss = explode('<br>', $output);
array_pop($arrss); array_pop($arrss);
// Array // Array
@ -334,9 +293,9 @@ class Broadcast_model extends CI_Model
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$dateTime = $time; $dateTime = $time;
$c = count($arrss); $c = count($arrss);
for($i=0 ; $i < $c; $i++){ for ($i = 0;$i < $c;$i++) {
// echo $arrss[$i];exit(); // echo $arrss[$i];exit();
if( $i == $c-1) { if ($i == $c - 1) {
break; break;
} else { } else {
$a = explode('|', $arrss[$i]); $a = explode('|', $arrss[$i]);
@ -346,21 +305,19 @@ class Broadcast_model extends CI_Model
$delvOn = $a[3]; $delvOn = $a[3];
$qury1 = "SELECT * FROM T_BroadcastDeliveryCron WHERE MsgId = '$msgId'"; $qury1 = "SELECT * FROM T_BroadcastDeliveryCron WHERE MsgId = '$msgId'";
$choe = $this->db->query($qury1)->first_row(); $choe = $this->db->query($qury1)->first_row();
if ($this->db->query($qury1)->first_row()) {
if($this->db->query($qury1)->first_row()){
$qury2 = "UPDATE T_BroadcastDeliveryCron SET DeliveredStatus = '$delvStatus', DeliveredOn = '$delvOn' WHERE MsgId = '$msgId'"; $qury2 = "UPDATE T_BroadcastDeliveryCron SET DeliveredStatus = '$delvStatus', DeliveredOn = '$delvOn' WHERE MsgId = '$msgId'";
$choe2 = $this->db->query($qury2); $choe2 = $this->db->query($qury2);
// continue; // continue;
} else { } else {
$qury3 = " INSERT INTO T_BroadcastDeliveryCron (MsgId, MobileNumber, DeliveredStatus, DeliveredOn, CreatedOn) VALUES('$msgId', '$msgNumb', '$delvStatus', '$delvOn', '$dateTime')"; $qury3 = " INSERT INTO T_BroadcastDeliveryCron (MsgId, MobileNumber, DeliveredStatus, DeliveredOn, CreatedOn) VALUES('$msgId', '$msgNumb', '$delvStatus', '$delvOn', '$dateTime')";
$choe3 = $this->db->query($qury3); $choe3 = $this->db->query($qury3);
// continue; // continue;
} }
} }
} }
return 'records updated!!'; return 'records updated!!';
} }
} }