apollo_developers/api/application/controllers/Status_Controller.php
venbatechnologies@gmail.com 1809bcf9c9 fixed table for student details
2018-04-23 18:34:11 +05:30

180 lines
6.4 KiB
PHP
Executable File

<?php
/**
* Created by Visual Studio Code.
* User: Surendiran
* Date: 12/05/17
* Time: 01:05 PM
*/
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 Status_Controller extends REST_Controller {
function __construct()
{
// Construct the parent class
parent::__construct();
// Configure limits on our controller methods
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
$this->methods['addStatusDetails_get']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['addStatusDetails_post']['limit'] = 100; // 100 requests per hour per user/key
$this->methods['addStatusDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
$this->methods['getStatusDetails_post']['limit'] = 500; // 50 requests per hour per user/key
$this->methods['updateStatusDetails_post']['limit'] = 500;
// load the model
$this->load->model('Status_model', 'status_model');
}
/*
* This method used to add status details
* created by Surendiran
* */
public function addStatusDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['ListName'] = $this->post('statusName');
$details['ListGroup'] = "1";
$details['CreatedBy'] = $this->post('createdBy');
$details['IsActive'] = $this->post('status');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
$statusDetails = $this->status_model->addstatus($details);// Check if the users data store contains users (in case the database result returns NULL)
if ($statusDetails)
{
$statusDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($statusDetails, 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
}
}
/*
* get status details
* created by Surendiran
* */
public function getStatusDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getStatus = $this->status_model->getStatus($requestedBy);
if ($getStatus)
{
$getStatus['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getStatus, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
/*
* update the status details
* created by Surendiran
* */
public function updateStatusDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$ListCode = $this->post('ListCode');
$details['ListName'] = $this->post('ListName');
$details['IsActive'] = $this->post('status');
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
$statusDetails = $this->status_model->update($details,$ListCode);// Check if the users data store contains users (in case the database result returns NULL)
if ($statusDetails)
{
$statusDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($statusDetails, 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 getBranchListStatusUpdate_post() {
$requestedBy = $this->post('requestedBy');
$getStatusBranchList = $this->status_model->getStatusBranchList($requestedBy);
if ($getStatusBranchList)
{
$getStatusBranchList['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getStatusBranchList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
public function getBranchStatusList_post() {
$requestedBy = $this->post('requestedBy');
$branchCode = $this->post('branchCode');
$getBranchStatusList = $this->status_model->getBranchStatusList($branchCode);
if ($getBranchStatusList)
{
$getBranchStatusList['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getBranchStatusList, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
}
else
{
// Set the response and exit
$this->response([
'message' => 'No records found!',
'status' => REST_Controller::HTTP_NOT_FOUND
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
}