367 lines
13 KiB
PHP
Executable File
367 lines
13 KiB
PHP
Executable File
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
|
|
|
|
/** @noinspection PhpIncludeInspection */
|
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
|
/**
|
|
* This is an example of a few basic user interaction methods you could use
|
|
* all done with a hardcoded array
|
|
*
|
|
* @package CodeIgniter
|
|
* @subpackage Rest Server
|
|
* @category Controller
|
|
* @author
|
|
* @license MIT
|
|
* @link
|
|
*/
|
|
class Broadcast_Controller extends REST_Controller {
|
|
/*
|
|
* broadcast, sms send functionality
|
|
* params:
|
|
* created by kdk
|
|
* */
|
|
function __construct() {
|
|
// Construct the parent class
|
|
parent::__construct();
|
|
$this->methods['getUniversity_post']['limit'] = 100;
|
|
$this->methods['chkUnivIdExistDetail_post']['limit'] = 100;
|
|
|
|
$this->methods['addNewGroup_post']['limit'] = 500;
|
|
|
|
// load the broadcast model
|
|
$this->load->model('Broadcast_model', 'broadcast_model');
|
|
$this->load->model('Status_model','status_model');
|
|
}
|
|
|
|
// get University, Course, Branch Detailss
|
|
public function getUniveCourseBatch_post() {
|
|
$reqData = $this->post('data');
|
|
$loginUserId = $reqData['localUserID'];
|
|
$loginUserBranchId = $reqData['localBranchID'];
|
|
$loginUserType = $reqData['localType'];
|
|
$getUniversityListDetails = $this->broadcast_model->get_university_course_batch($loginUserBranchId); // Check if the employee exist
|
|
if ($getUniversityListDetails) {
|
|
$getUniversityListDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getUniversityListDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
// ger Result fot searched keyword details
|
|
public function getStuListForBrodcast_post() {
|
|
$reqSearchData = $this->post('data');
|
|
$reqData = $this->post('requestDetails');
|
|
$getSearchDetails = $this->broadcast_model->get_search_result($reqSearchData, $reqData); // Check if the employee exist
|
|
if ($getSearchDetails) {
|
|
$getSearchDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getSearchDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
public function sendSMSStudentApi_post() {
|
|
$reqData = $this->post('data');
|
|
$reqDetails = $this->post('requestDetails');
|
|
$msg = $this->post('msg');
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$count = count($reqData);
|
|
for ($i = 0;$i < $count;$i++) {
|
|
$data[] = array('StudentID' => $reqData[$i]['StudentID']);
|
|
}
|
|
$sendMsgDetails = $this->broadcast_model->send_msg_students($data, $msg, $reqDetails); // Check if the employee exist
|
|
if ($sendMsgDetails) {
|
|
$sendMsgDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($sendMsgDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
public function getSMSGroupDetails_post() {
|
|
$reqData = $this->post('data');
|
|
$reqDataBy = $this->post('requestDetails');
|
|
$getMegDetails = $this->broadcast_model->getSMSGroupDetails($reqData, $reqDataBy); // Check if the employee exist
|
|
if ($getMegDetails) {
|
|
$getMegDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getMegDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
public function getSMSSendReportList_post() {
|
|
$reqData = $this->post('data');
|
|
$reqDataBy = $this->post('requestDetails');
|
|
$getMegCronDetails = $this->broadcast_model->getSmsSendBetweenDate($reqData, $reqDataBy); // Check if the employee exist
|
|
if ($getMegCronDetails) {
|
|
$getMegCronDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
public function sendPromotionalMsg_post() {
|
|
$reqData = $this->post('data');
|
|
$reqDataBy = $this->post('requestDetails');
|
|
$message = $reqData["message"];
|
|
$numsArr = $reqData["numbers"];
|
|
// print_r($numsArr);exit();
|
|
$getMegCronDetails = $this->broadcast_model->sendPromotionalMsg( $message ,$numsArr, $reqDataBy); // Check if the employee exist
|
|
if ($getMegCronDetails) {
|
|
$getMegCronDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
} else {
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
}
|
|
|
|
public function getCronCall_get() {
|
|
$getMegCronDetails = $this->broadcast_model->getCronUpdate(); // Check if the employee exist
|
|
// echo $getMegCronDetails;exit();
|
|
if ($getMegCronDetails) {
|
|
echo $getMegCronDetails;
|
|
} else {
|
|
}
|
|
// if ($getMegCronDetails)
|
|
// {
|
|
// $getMegCronDetails['status'] = REST_Controller::HTTP_OK;
|
|
// // Set the response and exit
|
|
// $this->response($getMegCronDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
// }
|
|
// else
|
|
// {
|
|
// // Set the response and exit
|
|
// $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
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
public function addNewGroup_post()
|
|
{
|
|
$now = new DateTime();
|
|
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
$det = $this->post('branch');
|
|
|
|
$details['GroupName'] = $this->post('GroupName');
|
|
$details['CreatedBy'] = $this->post('createdBy');
|
|
$details['IsActive'] = '1';
|
|
$details['BranchCode'] = $this->post('branch');
|
|
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
|
|
|
|
$GroupDetails = $this->broadcast_model->addGroup($details);
|
|
if ($GroupDetails)
|
|
{
|
|
$GroupDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($GroupDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'Something went wrong.please try again!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function getGroups_post()
|
|
{
|
|
$reqBranch = $this->post('requestBranch');
|
|
|
|
$getGroupsDetails = $this->broadcast_model->GetAllGroups($reqBranch);
|
|
|
|
if ($getGroupsDetails)
|
|
{
|
|
$getGroupsDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getGroupsDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'Something went wrong.please try again!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
|
}
|
|
}
|
|
|
|
|
|
public function addphone_post()
|
|
{
|
|
|
|
$now = new DateTime();
|
|
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
$det = $this->post('branch');
|
|
|
|
// $reqBranch = $this->post('requestBranch');
|
|
// $PID = $this->post('PId');
|
|
// $Phone = $this->post('Phone');
|
|
// $CreatedBy = $this->post('requestedBy');
|
|
// echo $Phone;
|
|
|
|
$details['Phone_No'] = $this->post('Phone');
|
|
$details['Parent_ID'] = $this->post('PId');
|
|
$details['CreatedBy'] = $this->post('requestedBy');
|
|
$details['IsActive'] = '1';
|
|
$details['BranchCode'] = $this->post('requestBranch');
|
|
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
|
|
|
|
$PhoneDetails = $this->broadcast_model->addPhone($details);
|
|
|
|
if ($PhoneDetails)
|
|
{
|
|
$PhoneDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($PhoneDetails, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$this->response([
|
|
'message' => 'Something went wrong.please try again!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function GetNumbers_post()
|
|
{
|
|
$reqID = $this->post('PId');
|
|
$getphonenum = $this->broadcast_model->GetPhone($reqID);
|
|
|
|
// print_r($getphonenum);
|
|
// die();
|
|
|
|
if($getphonenum)
|
|
{
|
|
$getphonenum['status'] = REST_Controller::HTTP_OK;
|
|
$this->response($getphonenum, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
$this->response([
|
|
'message' => 'No record found!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND);
|
|
}
|
|
}
|
|
|
|
|
|
public function sendGroupMsg_post()
|
|
{
|
|
|
|
$reqDataBy = $this->post('requestDetails');
|
|
|
|
$reqData = $this->post('data');
|
|
|
|
$message = $reqData["message"];
|
|
// $numsArr = $reqData["numbers"];
|
|
|
|
foreach($reqData['numbers'] as $number){
|
|
//echo $number['Phone_No'].'<br/>'.$message;
|
|
$number = $number['Phone_No'];
|
|
|
|
$message_st= $this->broadcast_model->multi_sms($number,$message);
|
|
|
|
|
|
}
|
|
|
|
|
|
if ($message_st) {
|
|
$message_st['status'] = REST_Controller::HTTP_OK;
|
|
$message_st['nu'] = $number;
|
|
// Set the response and exit
|
|
$this->response($message_st, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
|
|
}
|
|
else
|
|
{
|
|
// Set the response and exit
|
|
$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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function getallnumer_post()
|
|
{
|
|
$All_num= $this->broadcast_model->GetAllPhone();
|
|
|
|
if($All_num)
|
|
{
|
|
$All_num['status'] = REST_Controller::HTTP_OK;
|
|
$this->response($All_num, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
|
}
|
|
else
|
|
{
|
|
$this->response([
|
|
'message' => 'No record found!',
|
|
'status' => REST_Controller::HTTP_NOT_FOUND
|
|
], REST_Controller::HTTP_NOT_FOUND);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public function setValue_post()
|
|
{
|
|
$id= $this->post('pid');
|
|
$Parent_ID = $this->post('ParentID');
|
|
$setarray = $this->broadcast_model->SetPhone($id,$Parent_ID);
|
|
|
|
//print_r($setarray);
|
|
}
|
|
|
|
public function setgrpstatus_post()
|
|
{
|
|
$Id= $this->post('Id');
|
|
$IsActive = $this->post('IsActive');
|
|
$arrayact = array('IsActive'=>$IsActive);
|
|
|
|
//print_r($arrayact);die();
|
|
$setgroup =$this->broadcast_model->SetGroupActive($Id,$arrayact);
|
|
|
|
}
|
|
}
|