apollodec/Apollo/api/application/controllers/Subject_Controller.php
2018-02-06 15:40:53 +05:30

182 lines
6.4 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: subaram
*/
class Subject_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['addSubjectDetails_get']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['addSubjectDetails_post']['limit'] = 100; // 100 requests per hour per user/key
$this->methods['addSubjectDetails_delete']['limit'] = 50; // 50 requests per hour per user/key
$this->methods['getSubjectDetails_post']['limit'] = 500; // 50 requests per hour per user/key
$this->methods['updateSubjectDetails_post']['limit'] = 500;// 500 requests per hour per user/key
// load the model
$this->load->model('Subject_model', 'subject_model');
}
/*
* This method used to add Subject details
*
* */
public function addSubjectDetails_post()
{
$now = new DateTime();
$save['UniversityName'] = $this->post('university');
$save['Course'] = $this->post('course');
$save['Batch'] = $this->post('batch');
$save['Comments'] = $this->post('Comment');
$save['IsActive'] = 1;
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$save['CreatedBy'] = $this->post('createdBy');
$save['CreatedOn'] = $now->format('Y-m-d H:i:s');
//$details['IsActive'] = $this->post('status');
$jsonSemFeesData=$this->post('semFeesAmounts');
$subjectDetails = $this->subject_model->addSubject($save,$jsonSemFeesData);// Check if the users data store contains users (in case the database result returns NULL)
if ($subjectDetails)
{
$subjectDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($subjectDetails, 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 Subject details
*
* */
public function getSubjectDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getSubject = $this->subject_model->getSubject($requestedBy);
if ($getSubject)
{
$getSubject['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getSubject, 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 Subject details
*
* */
public function updateSubjectDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$updateID = $this->post('updateID');
$save['Comments'] = $this->post('Comments');
$save['IsActive'] = 1;
$save['UpdatedBy'] = $this->post('updatedBy');
$save['UpdatedOn'] = $now->format('Y-m-d H:i:s');
//$details['IsActive'] = $this->post('status');
$jsonSemFeesData=$this->post('semFeesAmounts');
$updateDetails = $this->subject_model->updateSubject($save,$jsonSemFeesData,$updateID);// 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
}
}
//get university dropdown
public function getUniversity_post() {
$reqData = $this->post('data');
$getUniversityListDetails = $this->subject_model->get_university_list();
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
}
}
//get course & Batch dropdown
public function getCorsBatch_post() {
$data = $this->post('data');
$getCourseBatchListDetails = $this->subject_model->get_courseBatch_list($data);// Check if the employee exist
if ($getCourseBatchListDetails)
{
$getCourseBatchListDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getCourseBatchListDetails, 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
}
}
}