apollodec/Apollo/api/application/controllers/University_Controller.php
2018-08-17 11:46:27 +05:30

354 lines
13 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('Universityfile_model', 'universityfile_model');
}
// get university details
public function getUniversity_post() {
$reqData = $this->post('data');
$loginUserId = $reqData['localUserID'];
$loginUserBranchId = $reqData['localBranchID'];
$loginUserType = $reqData['localType'];
$getUniversityListDetails = $this->universityfile_model->get_university_list($loginUserBranchId);// 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() {
//s print_r($_FILES);
$imagename='';
$size='';
$imageSource='';
if(!empty($_FILES))
{
$imagename = $_FILES['idProof']['name'];
$size = $_FILES['idProof']['size'];
$imageSource = $_FILES['idProof']['tmp_name'];
}
// echo $imagename;
// echo $size;
// echo $imageSource;
// die();
$reqData = $this->post('data');
$data = json_decode($reqData, true);
$req['UpdatedBy'] = $this->post('updatedBy');
$date = date('Y-m-d H:i:s');
$req['UpdatedOn'] = $date;
$req['UniversityName']= $data['UniversityName'];
$req['UniversityShortName']= $data['UniversityShortName'];
$req['MobileNumber']= $data['MobileNumber'];
$req['EmailID']= $data['EmailID'];
$req['Address']= $data['Address'];
$req['IsActive']= $data['IsActive'];
$req['BranchCode'] = $this->post('branchCode');
$req['ID']= $data['ID'];
$updateFor = $data['UniversityID'];
$updateUniversityDetail = $this->university_model->update_university_details($updateFor, $req,$imagename,$imageSource,$size);// 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');
$branchCode = $this->post('branchCode');
$checkUnivExist = $this->university_model->check_Univ_Exist($data, $check,$branchCode);// 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() {
// echo "sdg";
$imagename='';
$size='';
$imageSource='';
if(!empty($_FILES))
{
$imagename = $_FILES['idProof']['name'];
$size = $_FILES['idProof']['size'];
$imageSource = $_FILES['idProof']['tmp_name'];
}
// echo $imagename;
// echo $size;
// echo $imageSource;
$reqData = $this->post('data');
$temp = json_decode($reqData, true);
//print_r($reqData);
//die();
$req['CreatedBy'] = $this->post('createdBy');
$date = date('Y-m-d H:i:s');
$req['CreatedOn'] = $date;
$req['UniversityName']= $temp['UniversityName'];
$req['UniversityShortName']= $temp['UniversityShortName'];
$req['MobileNumber']= $temp['MobileNumber'];
$req['EmailID']= $temp['EmailID'];
$req['Address']= $temp['Address'];
$req['IsActive']= $temp['switchsetting'];
$req['UniversityID']= $temp['UniversityID'];
$req['BranchCode']= $this->post('branchCode');
$insertUniv = $this->university_model->insert_Univ($req,$imagename,$imageSource,$size);// 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');
$details['BranchCode'] = $this->post('branchCode');
$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');
$requestedBranch = $this->post('branchCode');
$getActivity = $this->university_model->getActivity($requestedBy,$requestedBranch);
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');
$details['BranchCode'] = $this->post('branchCode');
$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');
$requestedBranch = $this->post('requestedBranch');
$getDefaultActivity = $this->university_model->getDefaultActivity($requestedBy, $requestedBranch);
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['BranchCode'] = $this->post('reqBranch');
$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
}
}
}