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

135 lines
4.7 KiB
PHP
Executable File

<?php
/**
* Created by VisualCodeStudio.
* User: Subaram
* Date: 15/1/18
* Time: 12:55 PM
*/
class Center_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['addCenterDetails_get']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['addCenterDetails_post']['limit'] = 100; // 100 requests per hour per user/key
$this->methods['addCenterDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
$this->methods['getCenterDetails_post']['limit'] = 500; // 50 requests per hour per user/key
$this->methods['updateCenterDetails_post']['limit'] = 500;// 500 requests per hour per user/key
// load the model
$this->load->model('Center_model', 'center_model');
}
/*
* Add Center details
* created by srk
* */
public function addCenterDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['CenterCode'] = $this->post('CenterCode');
$details['CenterName'] = $this->post('CenterName');
$details['CenterAddress'] = $this->post('Address');
$details['Comments'] = $this->post('Comments');
$details['CreatedBy'] = $this->post('createdBy');
$details['IsActive'] = $this->post('status');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
$centerDetails = $this->center_model->addCenter($details);// Check if the users data store contains users (in case the database result returns NULL)
if ($centerDetails)
{
$centerDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($centerDetails, 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 Batch details
* created by srk
*/
public function getCenterDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getCenter = $this->center_model->getCenter($requestedBy);
// print_r($getCenter);
// die;
if ($getCenter)
{
$getCenter['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getCenter, 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 Center details
* created by srk
*/
public function updateCenterDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['CenterCode'] = $this->post('CenterCode');
$details['CenterName'] = $this->post('CenterName');
$details['CenterAddress'] = $this->post('Address');
$details['Comments'] = $this->post('Comments');
$CenterID=$this->post('CenterID');
$details['IsActive'] = $this->post('status');
$details['UpdateBy'] = $this->post('updateBy');
$details['UpdateOn'] = $now->format("Y-m-d H:i:s");
$updateDetails = $this->center_model->updateCenter($details,$CenterID);// Check if the users data store contains users (in case the database result returns NULL)
if ($updateDetails)
{
$updateDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($updateDetails, 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
}
}
}