124 lines
4.4 KiB
PHP
Executable File
124 lines
4.4 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by VisualCodeStudio.
|
|
* User: Subaram
|
|
* Date: 11/27/17
|
|
* Time: 12:55 PM
|
|
*/
|
|
class Batch_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['addBatchDetails_get']['limit'] = 500; // 500 requests per hour per user/key
|
|
$this->methods['addBatchDetails_post']['limit'] = 100; // 100 requests per hour per user/key
|
|
$this->methods['addBatchDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
|
|
$this->methods['getBatchDetails_post']['limit'] = 500; // 50 requests per hour per user/key
|
|
$this->methods['updateBatchDetails_post']['limit'] = 500;// 500 requests per hour per user/key
|
|
// load the model
|
|
$this->load->model('Batch_model', 'batch_model');
|
|
|
|
}
|
|
|
|
/*
|
|
* This method used to add batch details
|
|
* created by srk
|
|
* */
|
|
|
|
public function addBatchDetails_post()
|
|
{
|
|
$now = new DateTime();
|
|
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
$details['BatchCode'] = $this->post('batchcode');
|
|
$details['BatchName'] = $this->post('batcheName');
|
|
$details['UniversityID'] = $this->post('universityName');
|
|
$details['CreatedBy'] = $this->post('createdBy');
|
|
$details['IsActive'] = $this->post('status');
|
|
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
|
|
|
|
$batchDetails = $this->batch_model->addBatch($details);// Check if the users data store contains users (in case the database result returns NULL)
|
|
if ($batchDetails)
|
|
{
|
|
$batchDetails['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($batchDetails, 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 getBatchDetails_post()
|
|
{
|
|
$requestedBy = $this->post('requestedBy');
|
|
$getBatch = $this->batch_model->getBatch($requestedBy);
|
|
if ($getBatch)
|
|
{
|
|
$getBatch['status'] = REST_Controller::HTTP_OK;
|
|
// Set the response and exit
|
|
$this->response($getBatch, 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 batch details
|
|
* created by srk
|
|
* */
|
|
public function updateBatchDetails_post()
|
|
{
|
|
$now = new DateTime();
|
|
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
$details['BatchCode'] = $this->post('batchCode');
|
|
$details['BatchName'] = $this->post('batchName');
|
|
$details['IsActive'] = $this->post('status');
|
|
$details['UpdatedBy'] = $this->post('updatedBy');
|
|
$details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
|
|
|
|
// print_r( $details['UpdatedOn'])
|
|
//exit();
|
|
$updateDetails = $this->batch_model->updateBatch($details);// 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
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|