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

134 lines
4.5 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: karthi
* Date: 12/26/17
* Time: 4:06 PM
*/
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 DayBookMaster_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['addDaybookMasterDetails_post']['limit'] = 100; // 50 requests per hour per user/key
$this->methods['getDayBookMasterDetails_post']['limit'] = 500; // 50 requests per hour per user/key
$this->methods['updateDayBookMasterDetails_post']['limit'] = 500;
// load the model
$this->load->model('DaybookMaster_model', 'daybookmaster_model');
}
/*
* This method used to get day book master details
* created by kms
* */
public function addDaybookMasterDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['TypeID'] = $this->post('type');
$details['TypeName'] = $this->post('name');
$details['IsActive'] = $this->post('status');
$details['CreatedBy'] = $this->post('createdBy');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
$addDetails = $this->daybookmaster_model->addDetails($details);// Check if the users data store contains users (in case the database result returns NULL)
if ($addDetails)
{
$addDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($addDetails, 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
}
}
/*
* This method used to get day book master details
* created by kms
* */
public function getDayBookMasterDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getdetails = $this->daybookmaster_model->getDayBookDetails($requestedBy);
if ($getdetails)
{
$getdetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getdetails, 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 day book details
* created by kms
* */
public function updateDayBookMasterDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['ID'] = $this->post('ID');
$details['TypeName'] = $this->post('TypeName');
$details['TypeID'] = $this->post('TypeID');
$details['IsActive'] = $this->post('status');
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
$updateDetails = $this->daybookmaster_model->updateDayBook($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
}
}
}