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

299 lines
12 KiB
PHP
Executable File

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
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 University_Controller extends REST_Controller {
/*
* get university details
* params:
* created by kdk
* */
function __construct()
{
// Construct the parent class
parent::__construct();
$this->methods['getUniversity_post']['limit'] = 100;
$this->methods['chkUnivIdExistDetail_post']['limit'] = 100;
$this->methods['getDefaultActivityDetails_post']['limit'] = 100;
$this->methods['updateDefaultActivityDetails_post']['limit'] = 100;
// load the university model
$this->load->model('University_model', 'university_model');
}
// get university details
public function getUniversity_post() {
$reqData = $this->post('data');
$loginUserId = $reqData['localUserID'];
$loginUserBranchId = $reqData['localBranchID'];
$loginUserType = $reqData['localType'];
$getUniversityListDetails = $this->university_model->get_university_list();// Check if the employee exist
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
}
}
//update university details
public function updateUniversityDetail_post() {
$reqData = $this->post('data');
$req['UpdatedBy'] = $this->post('updatedBy');
$date = date('Y-m-d H:i:s');
$req['UpdatedOn'] = $date;
$req['UniversityName']= $reqData['UniversityName'];
$req['UniversityShortName']= $reqData['UniversityShortName'];
$req['MobileNumber']= $reqData['MobileNumber'];
$req['EmailID']= $reqData['EmailID'];
$req['Address']= $reqData['Address'];
$req['IsActive']= $reqData['IsActive'];
$updateFor = $reqData['UniversityID'];
$updateUniversityDetail = $this->university_model->update_university_details($updateFor, $req);// Check if the employee exist
if ($updateUniversityDetail)
{
$updateUniversityDetail['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($updateUniversityDetail, 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
}
}
// check university details exist
public function chkUnivIdExistDetail_post() {
$data = $this->post('data');
$check = $this->post('check');
$checkUnivExist = $this->university_model->check_Univ_Exist($data, $check);// Check if the employee exist
if ($checkUnivExist)
{
$checkUnivExist['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($checkUnivExist, 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
}
}
// insert university details
public function insertUniversity_post() {
$reqData = $this->post('data');
$req['CreatedBy'] = $this->post('createdBy');
$date = date('Y-m-d H:i:s');
$req['CreatedOn'] = $date;
$req['UniversityName']= $reqData['UniversityName'];
$req['UniversityShortName']= $reqData['UniversityShortName'];
$req['MobileNumber']= $reqData['MobileNumber'];
$req['EmailID']= $reqData['EmailID'];
$req['Address']= $reqData['Address'];
$req['IsActive']= $reqData['switchsetting'];
$req['UniversityID']= $reqData['UniversityID'];
$insertUniv = $this->university_model->insert_Univ($req);// Check if the employee exist
if ($insertUniv)
{
$insertUniv['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($insertUniv, 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
}
}
/*
* add activity details
* created Surendiran
* */
public function addActivityDetails_post() {
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['ActivityID'] = $this->post('activityID');
$details['ActivityName'] = $this->post('activityName');
$details['Description'] = $this->post('description');
$details['CreatedBy'] = $this->post('createdBy');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
$details['IsActive'] = $this->post('status');
$jsonData=$this->post('activityStatus');
$activityDetails = $this->university_model->addActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
if ($activityDetails) {
$activityDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($activityDetails, 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 activity details
* created by Surendiran
* */
public function getActivityDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getActivity = $this->university_model->getActivity($requestedBy);
if ($getActivity)
{
$getActivity['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getActivity, 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 activity details
* created by Surendiran
* */
public function updateActivityDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['ActivityID'] = $this->post('activityID');
$details['ActivityName'] = $this->post('activityName');
$details['Description'] = $this->post('description');
$details['IsActive'] = $this->post('status');
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
$jsonData=$this->post('activityStatus');
$activityDetails = $this->university_model->updateActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
if ($activityDetails)
{
$activityDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($activityDetails, 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 default activity details
* created by kms
* */
public function getDefaultActivityDetails_post()
{
$requestedBy = $this->post('requestedBy');
$getDefaultActivity = $this->university_model->getDefaultActivity($requestedBy);
if ($getDefaultActivity)
{
$getDefaultActivity['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getDefaultActivity, 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 default activity status
* created by kms
* */
public function updateDefaultActivityDetails_post()
{
$now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['StudentActivityCode'] = $this->post('activityID');
$details['StatusCode'] = $this->post('activityName');
//$details['IsActive'] = $this->post('status');
$details['UpdatedBy'] = $this->post('updatedBy');
$details['UpdatedOn'] = $now->format('Y-m-d H:i:s');
$jsonData=$this->post('activityStatus');
$activityDetails = $this->university_model->updateDefaultActivity($details,$jsonData);// Check if the users data store contains users (in case the database result returns NULL)
if ($activityDetails)
{
$activityDetails['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($activityDetails, 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
}
}
}