627 lines
24 KiB
PHP
Executable File
627 lines
24 KiB
PHP
Executable File
<?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) {
|
|
$localBranch = $req['localBranchID'];
|
|
$University = $reqData['University'];
|
|
$Course = $reqData['Course'];
|
|
$Batch = $reqData['Batch'];
|
|
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 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
|
|
WHERE SFS.CourseID = SC.CourseID AND
|
|
SC.UniversityID = '$University'
|
|
AND S.IsActive = '1'
|
|
AND SC.IsActive = '1'
|
|
AND SC.BranchID = '$localBranch'
|
|
GROUP BY SC.id";
|
|
$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 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
|
|
WHERE SFS.CourseID = SC.CourseID AND
|
|
SC.CourseID = '$Course' AND SC.UniversityID = '$University'
|
|
AND S.IsActive = '1'
|
|
AND SC.IsActive = '1'
|
|
AND SC.BranchID = '$localBranch'
|
|
GROUP BY SC.id";
|
|
$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 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
|
|
WHERE SFS.CourseID = SC.CourseID AND
|
|
SFS.BatchCode = '$Batch' AND SC.UniversityID = '$University'
|
|
AND S.IsActive = '1'
|
|
AND SC.IsActive = '1'
|
|
AND SC.BranchID = '$localBranch'
|
|
GROUP BY SC.id";
|
|
$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 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
|
|
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'
|
|
AND SC.BranchID = '$localBranch'
|
|
GROUP BY SC.id";
|
|
$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($branchId) {
|
|
$this->db->select('t1.UniversityID, t1.UniversityName');
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->from('' . UNIVERSITY . ' as t1');
|
|
$this->db->where('t1.IsActive', 1);
|
|
$this->db->where('t1.BranchCode', $branchId);
|
|
// $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,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', $branchId);
|
|
$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', $branchId);
|
|
$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 getSMSGroupDetails($reqData ,$reqBy) {
|
|
$localBranch = $reqBy['localBranchID'];
|
|
$querys = "SELECT t1.id, t1.MsgId, t1.MsgBody, t1.Status, t1.MobileNumber, t1.CreatedBy, t1.CreatedOn, t1.MsgGroup, t1.BranchCode, t2.DeliveredStatus, t2.DeliveredOn FROM T_BroadcastStatus as t1
|
|
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
|
|
WHERE t1.MsgGroup = '$reqData' AND t1.BranchCode='$localBranch' ORDER BY t1.CreatedOn DESC";
|
|
|
|
$smsSendGroupDetails = $this->db->query($querys);
|
|
$smsSendGroupDetailsList = $smsSendGroupDetails->result();
|
|
$results['smsSendGroupDetailsListStatus'] = true;
|
|
$results['smsSendGroupDetailsList'] = $smsSendGroupDetailsList;
|
|
return $results;
|
|
}
|
|
|
|
public function sendPromotionalMsg($msg, $nums, $reqData){
|
|
// print_r($msg);
|
|
// print_r($nums);
|
|
// print_r($reqData);exit();
|
|
$msg_body = $msg;
|
|
$sender = $reqData['localUserID'];
|
|
$localBranch = $reqData['localBranchID'];
|
|
$mesg = "$msg_body";
|
|
// $mesg = "Status Update : check - check check.";
|
|
// $mesg = "Check";
|
|
$resp = $this->smssendPromotional($nums, $mesg);
|
|
// echo $resp ;exit();
|
|
$arrss = explode('<br>', $resp);
|
|
// Array
|
|
// (
|
|
// [0] => MsgID
|
|
// [1] => 4fad03cf13734a869307b19fcc293570
|
|
// [2] => 919942080003
|
|
// [3] => 201801191700328088
|
|
// [4] => success
|
|
// )
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$msgGroup = date('YmdHis');
|
|
for ($i = 0, $c = count($arrss);$i < $c;$i++) {
|
|
// echo $arrss[$i];exit();
|
|
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' => $mesg, 'Status' => $msgStatus, 'CreatedOn' => $dateTime, 'CreatedBy' => $sender, 'MsgGroup' => $msgGroup, 'BranchCode' => $localBranch);
|
|
continue;
|
|
}
|
|
}
|
|
$this->db->insert_batch('T_BroadcastStatus', $data);
|
|
if ($this->db->affected_rows() >= 1) {
|
|
$result['msgStatus'] = true;
|
|
$result['message'] = "Successfully Messages Sent!!";
|
|
} else {
|
|
$result['msgStatus'] = false;
|
|
$result['message'] = "error!!";
|
|
}
|
|
return $result;
|
|
}
|
|
//get sms sent details
|
|
public function getSmsSendBetweenDate($reqData, $reqDataBy) {
|
|
$localBranch = $reqDataBy['localBranchID'];
|
|
if ($reqData['date'] != '' && $reqData['dateTo'] != '') {
|
|
$d = new DateTime($reqData['date']);
|
|
$dTo = new DateTime($reqData['dateTo']);
|
|
$fromDate = $d->format('Y-m-d');
|
|
$toDate = $dTo->format('Y-m-d');
|
|
// $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
|
|
// LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
|
|
// WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
|
|
// AND '$toDate' ORDER BY t1.CreatedOn DESC";
|
|
$querys = "SELECT t1.*, COUNT(t1.MsgGroup) as MSG_SEND_CNT
|
|
FROM T_BroadcastStatus as t1
|
|
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
|
|
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";
|
|
$smsSendDetails = $this->db->query($querys);
|
|
$smsSendDetailsList = $smsSendDetails->result();
|
|
$results['smsSendDetailsListStatus'] = true;
|
|
$results['smsSendDetailsList'] = $smsSendDetailsList;
|
|
} else {
|
|
// $d = new DateTime($d1);
|
|
// $dTo = new DateTime($d2);
|
|
// $fromDate = $d->format('Y-m-d');
|
|
// $toDate = $dTo->format('Y-m-d');
|
|
// $querys = "SELECT t1.*, t2.* FROM T_BroadcastStatus as t1
|
|
// LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
|
|
// WHERE STR_TO_DATE(t1.CreatedOn, '%Y-%m-%d') BETWEEN '$fromDate'
|
|
// AND '$toDate' ORDER BY t1.CreatedOn DESC";
|
|
$querys = "SELECT t1.*, COUNT(t1.MsgGroup) FROM T_BroadcastStatus as t1
|
|
LEFT JOIN T_BroadcastDeliveryCron as t2 ON t2.MsgId = t1.MsgId
|
|
WHERE t1.BranchCode = '$localBranch'
|
|
GROUP BY t1.MsgGroup ORDER BY t1.CreatedOn DESC";
|
|
$smsSendDetails = $this->db->query($querys);
|
|
$smsSendDetailsList = $smsSendDetails->result();
|
|
$results['smsSendDetailsListStatus'] = true;
|
|
$results['smsSendDetailsList'] = $smsSendDetailsList;
|
|
$results['smsSendDetailsListStatus'] = true;
|
|
$results['smsSendDetailsList'] = $smsSendDetailsList;
|
|
}
|
|
return $results;
|
|
}
|
|
|
|
// sms send functionality with update details to T_BroadcastStatus
|
|
public function send_msg_students($arr, $msg, $reqDetails) {
|
|
$msg_body = $msg['content'];
|
|
$sender = $reqDetails['localUserID'];
|
|
$localBranch = $reqDetails['localBranchID'];
|
|
$mesg = "$msg_body";
|
|
// $mesg = "Status Update : check - check check.";
|
|
// $mesg = "Check";
|
|
$resp = $this->smssend($arr, $mesg);
|
|
// echo $resp ;exit();
|
|
$arrss = explode('<br>', $resp);
|
|
// Array
|
|
// (
|
|
// [0] => MsgID
|
|
// [1] => 4fad03cf13734a869307b19fcc293570
|
|
// [2] => 919942080003
|
|
// [3] => 201801191700328088
|
|
// [4] => success
|
|
// )
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$msgGroup = date('YmdHis');
|
|
for ($i = 0, $c = count($arrss);$i < $c;$i++) {
|
|
// echo $arrss[$i];exit();
|
|
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' => $mesg, 'Status' => $msgStatus, 'CreatedOn' => $dateTime, 'CreatedBy' => $sender, 'MsgGroup' => $msgGroup, 'BranchCode' => $localBranch);
|
|
continue;
|
|
}
|
|
}
|
|
$this->db->db_debug = false;
|
|
$res = $this->db->insert_batch('T_BroadcastStatus', $data);
|
|
|
|
if(!$res)
|
|
{
|
|
$error = $this->db->error();
|
|
//
|
|
$result['msgStatus'] = false;
|
|
$result['error'] = $error;
|
|
$result['message'] = "error!!";
|
|
}
|
|
else
|
|
{
|
|
if ($this->db->affected_rows() >= 1) {
|
|
$result['msgStatus'] = true;
|
|
$result['message'] = "Successfully Messages Sent!!";
|
|
} else {
|
|
$result['msgStatus'] = false;
|
|
$result['message'] = "error!!";
|
|
}
|
|
}
|
|
// print_r($data);
|
|
// exit();
|
|
// $msgID = $arrss[1];
|
|
// $msgSendTime = $arrss[2];
|
|
// $msgDeleveredNum = $arrss[3];
|
|
// $msgSendStatus = $arrss[3];
|
|
// print_r($data);exit();
|
|
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);
|
|
$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=PROMOTIONAL_HIGH");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
$output = curl_exec($ch);
|
|
curl_close($ch);
|
|
return $output;
|
|
}
|
|
|
|
// This is the template to be used.
|
|
public function smssendPromotional($arr, $msg) {
|
|
$number = array();
|
|
// echo $msg;exit();
|
|
foreach ($arr as $ar) {
|
|
$result = substr($ar, 0, 3);
|
|
if($result === '+91'){
|
|
array_push($number, "$ar");
|
|
} else {
|
|
array_push($number, "91$ar");
|
|
}
|
|
}
|
|
$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=APODEC&Message=" . $message . "&ServiceName=PROMOTIONAL_HIGH");
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
$output = curl_exec($ch);
|
|
curl_close($ch);
|
|
return $output;
|
|
}
|
|
|
|
//get cron job call
|
|
public function getCronUpdate() {
|
|
$date2 = date('Y-m-d');
|
|
$quw = "SELECT * FROM T_BroadcastDeliveryCron ORDER BY id DESC LIMIT 1";
|
|
$myext = $this->db->query($quw)->first_row();
|
|
// print_r($this->db->query($quw)->first_row());exit();
|
|
if ($myext) {
|
|
if ($myext->CreatedOn) {
|
|
$arrsss = explode(' ', $myext->CreatedOn);
|
|
}
|
|
$date1 = $myext->CreatedOn != '' ? $arrsss[0] : $date2;
|
|
} else {
|
|
$date1 = $date2;
|
|
}
|
|
$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_RETURNTRANSFER, TRUE);
|
|
$output = curl_exec($ch);
|
|
// print_r($output);exit();
|
|
curl_close($ch);
|
|
$arrss = explode('<br>', $output);
|
|
array_pop($arrss);
|
|
// Array
|
|
// (
|
|
// [0] => MsgID
|
|
// [1] => 4fad03cf13734a869307b19fcc293570
|
|
// [2] => 919942080003
|
|
// [3] => 201801191700328088
|
|
// [4] => success
|
|
// )
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$c = count($arrss);
|
|
for ($i = 0;$i < $c;$i++) {
|
|
// echo $arrss[$i];exit();
|
|
if ($i == $c - 1) {
|
|
break;
|
|
} else {
|
|
$a = explode('|', $arrss[$i]);
|
|
$msgId = $a[0];
|
|
$msgNumb = $a[1];
|
|
$delvStatus = $a[2];
|
|
$delvOn = $a[3];
|
|
$qury1 = "SELECT * FROM T_BroadcastDeliveryCron WHERE MsgId = '$msgId'";
|
|
$choe = $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'";
|
|
$choe2 = $this->db->query($qury2);
|
|
// continue;
|
|
|
|
} else {
|
|
$qury3 = " INSERT INTO T_BroadcastDeliveryCron (MsgId, MobileNumber, DeliveredStatus, DeliveredOn, CreatedOn) VALUES('$msgId', '$msgNumb', '$delvStatus', '$delvOn', '$dateTime')";
|
|
$choe3 = $this->db->query($qury3);
|
|
// continue;
|
|
|
|
}
|
|
}
|
|
}
|
|
return 'records updated!!';
|
|
}
|
|
|
|
|
|
|
|
function multi_sms($number,$msg)
|
|
{
|
|
|
|
$message = urlencode($msg);
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, "https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=" . $number . "&SenderID=APODEC&Message=" . $message . "&ServiceName=PROMOTIONAL_HIGH");
|
|
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');
|
|
//echo count($arrss);die;
|
|
for ($i = 0, $c = count($arrss);$i < $c;$i++) {
|
|
// echo $arrss[$i];exit();
|
|
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' => $message, 'Status' => $msgStatus, 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// print_r($data);die();
|
|
$this->db->insert_batch('T_BroadcastStatus', $data);
|
|
if ($this->db->affected_rows() >= 1) {
|
|
$result['msgStatus'] = true;
|
|
$result['message'] = "Messages Send Successfully!!";
|
|
} else {
|
|
$result['msgStatus'] = false;
|
|
$result['message'] = "error!!";
|
|
}
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addGroup($details=null)
|
|
{
|
|
$this->db->select('ID');
|
|
$this->db->from('T_Groups');
|
|
$this->db->where('GroupName', $details['GroupName']);
|
|
$query = $this->db->get();
|
|
$result['details'] = $query->result();
|
|
if(count($result['details'])>0)
|
|
{
|
|
$result['Status'] = false;
|
|
$result['message'] = "Group name is already exist!";
|
|
}
|
|
|
|
else
|
|
{
|
|
$this->db->select('count(LAST_INSERT_ID(ID)) as LID');
|
|
$this->db->from('T_Groups');
|
|
$qquery = $this->db->get();
|
|
$res =$qquery->result();
|
|
$inID = $res[0]->LID+1;
|
|
$this->db->insert('T_Groups',$details);
|
|
$result['Status'] = true;
|
|
$result['message'] = "Group Created!";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
public function addPhone($details)
|
|
{
|
|
|
|
|
|
$this->db->select('ID');
|
|
$this->db->from('T_Groups_Numbers');
|
|
$this->db->where('Phone_No', $details['Phone_No']);
|
|
$this->db->where('Parent_ID', $details['Parent_ID']);
|
|
$query = $this->db->get();
|
|
$resultt['details'] = $query->result();
|
|
if(count($resultt['details'])>0)
|
|
{
|
|
$res['status']=false;
|
|
$res['message'] = 'Phone Number Already Exists';
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
|
|
|
|
$result= $this->db->insert('T_Groups_Numbers',$details);
|
|
|
|
// print_r($result);
|
|
|
|
if($result>0)
|
|
{
|
|
$res['status']=true;
|
|
$res['message'] = 'Phone Number Added';
|
|
|
|
}
|
|
else
|
|
{
|
|
$res['status']=false;
|
|
$res['message'] = 'Phone Number Adding Failed';
|
|
}
|
|
|
|
}
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function GetAllGroups($reqBranch)
|
|
{
|
|
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('T_Groups');
|
|
$this->db->where('BranchCode',$reqBranch);
|
|
$qquery = $this->db->get();
|
|
|
|
if($qquery->result()){
|
|
|
|
$result['Status'] = true;
|
|
$result['details'] = $qquery->result();
|
|
}
|
|
else {
|
|
$result['Status'] = false;
|
|
$result['message'] = "No records found!";
|
|
}
|
|
|
|
//print_r($result);
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function GetPhone($reqID)
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_Groups_Numbers ');
|
|
$this->db->where('Parent_ID',$reqID);
|
|
$query=$this->db->get();
|
|
if($query->result())
|
|
{
|
|
$result['Status'] = true;
|
|
$result['details'] = $query->result();
|
|
}
|
|
else
|
|
{
|
|
$result['Status'] = false;
|
|
$result['message'] = "No Numbers Found!";
|
|
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function GetAllPhone()
|
|
{
|
|
$this->db->select('*');
|
|
$this->db->from('T_Groups_Numbers ');
|
|
|
|
$query=$this->db->get();
|
|
if($query->result())
|
|
{
|
|
$result['Status'] = true;
|
|
$result['details'] = $query->result();
|
|
}
|
|
else
|
|
{
|
|
$result['Status'] = false;
|
|
$result['message'] = "No records found!";
|
|
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function SetPhone($id,$Parent_ID)
|
|
{
|
|
$this->db->where('ID', $id);
|
|
$this->db->where('Parent_ID', $Parent_ID);
|
|
$this->db->delete('T_Groups_Numbers');
|
|
|
|
return true;
|
|
}
|
|
|
|
public function SetGroupActive($Id,$arrayact)
|
|
{
|
|
$this->db->where('ID', $Id);
|
|
$this->db->update('T_Groups', $arrayact);
|
|
|
|
return TRUE;
|
|
}
|
|
}
|