apollodec/Apollo/api/application/controllers/Course_Controller.php
2018-11-05 11:28:53 +05:30

203 lines
8.3 KiB
PHP
Executable File

<?php
/**
* Created by PhpStorm.
* User: karthi
* Date: 11/23/17
* Time: 4:11 PM
*/
class Course_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['addCourseDetails_get']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['addCourseDetails_post']['limit'] = 100; // 100 requests per hour per user/key
$this->methods['addCourseDetails_delete']['limit'] = 500; // 50 requests per hour per user/key
$this->methods['getCourseDetails_post']['limit'] = 1500; // 50 requests per hour per user/key
$this->methods['updateCourseDetails_post']['limit'] = 500;
// load the model
$this->load->model('Course_model', 'course_model');
}
/*
* This method used to add Course details
* created by kms
* */
public function addCourseDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['CourseCode'] = $this->post('courseCode');
$details['CourseName'] = $this->post('courseName');
$details['UniversityID'] = $this->post('universityName');
$details['Specilization1'] = $this->post('specilization1');
$details['Specilization2'] = $this->post('specilization2');
$details['BranchCode'] = $this->post('branchCode');
$coursedetails = $this->post('numberofsem');
//$details['FeesType'] = $this->post('feesType');
$details['PC'] = $this->post('provFess');
$details['DC'] = $this->post('degreeAmount');
$details['TC'] = $this->post('transferAmount');
$details['MC'] = $this->post('migrationAmount');
$details['OtherFees'] = $this->post('otherAmount');
$details['CreatedBy'] = $this->post('createdBy');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
$details['IsActive'] = $this->post('status');
$jsonRegularFeesData=$this->post('regularFeesAmounts');
// print_r($jsonRegularFeesData);die();
$jsonLateralFeesData=$this->post('lateralFeesAmounts');
$jsonSemFeesData=$this->post('semFeesAmounts');
// push regular,lateral fees into same array
if($jsonRegularFeesData['FeesAmount'] != 0 AND $jsonRegularFeesData['FeesAmount'] != '' AND $jsonRegularFeesData['FeesAmount'] != 'undefined'){
array_push($jsonSemFeesData,$jsonRegularFeesData);
}
if($jsonLateralFeesData['FeesAmount'] != 0 AND $jsonLateralFeesData['FeesAmount'] != '' AND $jsonLateralFeesData['FeesAmount'] != 'undefined'){
array_push($jsonSemFeesData,$jsonLateralFeesData);
}
// get subject details
//$subjectDetails=$this->post('subjects');
$courseDetails = $this->course_model->addCourse($details,$jsonSemFeesData,$coursedetails);// $subjectDetails Check if the users data store contains users (in case the database result returns NULL)
if ($courseDetails)
{
$courseDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($courseDetails, 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 course details
* created by kms
* */
public function getCourseDetails_post()
{
$requestedBy = $this->post('requestedBy');
$branchCode = $this->post('branchCode');
$getCourse = $this->course_model->getCourse($requestedBy,$branchCode);
if ($getCourse)
{
$getCourse['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getCourse, 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
}
}
public function getCourseUnivFeesDetails_post() {
$requestedBy = $this->post('requestedBy');
$branchCode = $this->post('branchCode');
$getCourseUnivFee = $this->course_model->getCourseUnivFeesTypes($requestedBy,$branchCode);
if ($getCourseUnivFee)
{
$getCourseUnivFee['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getCourseUnivFee, 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 course details
* created by kms
* */
public function updateCourseDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['CourseID'] = $this->post('courseID');
$details['CourseCode'] = $this->post('courseCode');
$details['CourseName'] = $this->post('courseName');
$details['UniversityID'] = $this->post('universityID');
$details['Specilization1'] = $this->post('specilization1');
$details['Specilization2'] = $this->post('specilization2');
$details['IsActive'] = $this->post('status');
$details['PC'] = $this->post('provFess');
$details['DC'] = $this->post('degreeAmount');
$details['TC'] = $this->post('transferAmount');
$details['MC'] = $this->post('migrationAmount');
$details['OtherFees'] = $this->post('otherAmount');
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
$details['BranchCode'] = $this->post('branchCode');
$existCourseID = $this->post('existCourseID');
$jsonRegularFeesData=$this->post('regularFeesAmounts');
$jsonLateralFeesData=$this->post('lateralFeesAmounts');
$jsonSemFeesData=$this->post('semFeesAmounts');
$coursedetails = $this->post('sem_number');
// push regular,lateral fees into same array
if($jsonRegularFeesData != '' AND $jsonRegularFeesData != null AND $jsonRegularFeesData != 'undefined'){
array_push($jsonSemFeesData,$jsonRegularFeesData);
}
if($jsonLateralFeesData != '' AND $jsonLateralFeesData != null AND $jsonLateralFeesData != 'undefined'){
array_push($jsonSemFeesData,$jsonLateralFeesData);
}
// update course subject details
/* $subjectDetails['UniversityID'] = $this->post('universityID');
$subjectDetails['CourseID'] = $this->post('courseID');
$subjectDetails['Subjects'] = $this->post('subjects');
$subjectDetails['UpdatedBy'] = $this->post('updatedBy');
$subjectDetails['UpdatedOn'] = $now->format('Y-m-d H:i:s');*/
$updateDetails = $this->course_model->updateCourse($details,$jsonSemFeesData,$coursedetails);// $subjectDetails 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
}
}
}