From a8262fd2c82963518f569a872599feed212c4763 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 23 Mar 2018 15:21:39 +0530 Subject: [PATCH] default batch done in controller --- .../controllers/Batch_Controller.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Apollo/api/application/controllers/Batch_Controller.php b/Apollo/api/application/controllers/Batch_Controller.php index 3791d225..348b13d5 100755 --- a/Apollo/api/application/controllers/Batch_Controller.php +++ b/Apollo/api/application/controllers/Batch_Controller.php @@ -19,6 +19,8 @@ class Batch_Controller extends REST_Controller { $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 + $this->methods['updateBatchDefault_post']['limit'] = 500;// 500 requests per hour per user/key + // load the model $this->load->model('Batch_model', 'batch_model'); @@ -120,6 +122,39 @@ class Batch_Controller extends REST_Controller { } + /* + * update the default batch details + * created by kms + * */ + public function updateBatchDefault_post() + { + $now = new DateTime(); + $now->setTimezone(new DateTimezone('Asia/Kolkata')); + $details['BatchCode'] = $this->post('batchCode'); + $details['UniversityID'] = $this->post('universityID'); + $details['IsDefault'] = $this->post('IsDefault'); + $details['UpdatedBy'] = $this->post('updatedBy'); + $details['UpdatedOn'] = $now->format("Y-m-d H:i:s"); + + $updateDetails = $this->batch_model->updateDefaultBatch($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 + } + + + } }