Merge branch 'master' of https://bitbucket.org/venbainformationtechnology/apollodec
This commit is contained in:
commit
c39f2567c9
@ -32,12 +32,12 @@ class SessionMater_Controller extends REST_Controller {
|
||||
$now = new DateTime();
|
||||
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
||||
$details['SessionName'] = $this->post('sessionName');
|
||||
$details['UniversityID'] = $this->post('universityName');
|
||||
$details['CreatedBy'] = $this->post('createdBy');
|
||||
$details['IsActive'] = $this->post('status');
|
||||
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
|
||||
$university['UniversityID'] = $this->post('universityName');
|
||||
|
||||
$sessionDetails = $this->sessionM_model->addSession($details);// Check if the users data store contains users (in case the database result returns NULL)
|
||||
$sessionDetails = $this->sessionM_model->addSession($details,$university);// Check if the users data store contains users (in case the database result returns NULL)
|
||||
if ($sessionDetails)
|
||||
{
|
||||
$sessionDetails['status'] = REST_Controller::HTTP_OK;
|
||||
|
||||
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: karthi
|
||||
* Date: 2/7/18
|
||||
* Time: 10:37 AM
|
||||
*/
|
||||
class SessionSchedule_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['addSessionScheduleDetails_post']['limit'] = 100; // 50 requests per hour per user/key
|
||||
$this->methods['getSessionScheduleDetails_post']['limit'] = 500; // 50 requests per hour per user/key
|
||||
$this->methods['updateSessionMaterDetails_post']['limit'] = 500;// 500 requests per hour per user/key
|
||||
// load the model
|
||||
$this->load->model('SeesionSchedule_model', 'sessionSC_model');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* This method used to add session Schedule details
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function addSessionScheduleDetails_post()
|
||||
{
|
||||
$now = new DateTime();
|
||||
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
||||
$details['SessionID'] = $this->post('sessionID');
|
||||
$details['SCDate'] = $this->post('date');
|
||||
$details['CreatedBy'] = $this->post('createdBy');
|
||||
$details['IsActive'] = $this->post('status');
|
||||
$details['CreatedOn'] = $now->format('Y-m-d H:i:s');
|
||||
$Timings['Timings'] = $this->post('timings');
|
||||
$sessionDetails = $this->sessionSC_model->addSessionScheduel($details,$Timings);// Check if the users data store contains users (in case the database result returns NULL)
|
||||
if ($sessionDetails)
|
||||
{
|
||||
$sessionDetails['status'] = REST_Controller::HTTP_OK;
|
||||
// Set the response and exit
|
||||
$this->response($sessionDetails, 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 session Schedule details
|
||||
* created by kms
|
||||
* */
|
||||
public function getSessionScheduleDetails_post()
|
||||
{
|
||||
$requestedBy = $this->post('requestedBy');
|
||||
$getSession = $this->sessionSC_model->getSessionSchedule($requestedBy);
|
||||
if ($getSession)
|
||||
{
|
||||
$getSession['status'] = REST_Controller::HTTP_OK;
|
||||
// Set the response and exit
|
||||
$this->response($getSession, 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 session Schedule details
|
||||
* created by kms
|
||||
* */
|
||||
public function updateSessionScheduleDetails_post()
|
||||
{
|
||||
$now = new DateTime();
|
||||
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
||||
$details['SCID'] = $this->post('scheduleID');
|
||||
$details['SessionID'] = $this->post('sessionID');
|
||||
$details['SCDate'] = $this->post('date');
|
||||
$details['IsActive'] = $this->post('status');
|
||||
$details['UpdatedBy'] = $this->post('updatedBy');
|
||||
$details['UpdatedOn'] = $now->format("Y-m-d H:i:s");
|
||||
$Timings['Timings'] = $this->post('timings');
|
||||
$updateDetails = $this->sessionSC_model->updateSessionSchedule($details,$Timings);// 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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -15,7 +15,7 @@ class SeesionMaster_model extends CI_Model {
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function addSession($arrayDetails=null)
|
||||
public function addSession($arrayDetails=null,$university=null)
|
||||
{
|
||||
|
||||
$this->db->select('SessionName');
|
||||
@ -34,7 +34,7 @@ class SeesionMaster_model extends CI_Model {
|
||||
|
||||
if ($this->db->affected_rows() == '1') {
|
||||
$insertDetails['SessionID']=$this->db->insert_id();
|
||||
foreach ($arrayDetails['UniversityID'] as $row1){
|
||||
foreach ($university['UniversityID'] as $row1){
|
||||
$insertDetails['UniversityID']=$row1['UniversityID'];
|
||||
$insertDetails['CreatedBy']=$arrayDetails['CreatedBy'];
|
||||
$insertDetails['IsActive']=$arrayDetails['IsActive'];
|
||||
|
||||
174
Apollo/api/application/models/SeesionSchedule_model.php
Normal file
174
Apollo/api/application/models/SeesionSchedule_model.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: karthi
|
||||
* Date: 2/7/18
|
||||
* Time: 10:44 AM
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class SeesionSchedule_model extends CI_Model {
|
||||
|
||||
|
||||
/*
|
||||
* Add session master details
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function addSessionScheduel($arrayDetails=null,$Timings=null)
|
||||
{
|
||||
$this->db->select('SCDate');
|
||||
$this->db->where('SCDate', $arrayDetails['SCDate']);
|
||||
$this->db->where('SessionID', $arrayDetails['SessionID']);
|
||||
if($this->db->get(SESSIONSCHEDULE)->first_row()){
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] ="This same session/date is already exist.";
|
||||
}
|
||||
else{
|
||||
$insertMaster['SCDate']=$arrayDetails['SCDate'];
|
||||
$insertMaster['SessionID']=$arrayDetails['SessionID'];
|
||||
$insertMaster['CreatedBy']=$arrayDetails['CreatedBy'];
|
||||
$insertMaster['IsActive']=$arrayDetails['IsActive'];
|
||||
$insertMaster['CreatedOn']=$arrayDetails['CreatedOn'];
|
||||
|
||||
$this->db->insert(SESSIONSCHEDULE, $insertMaster);
|
||||
|
||||
if ($this->db->affected_rows() == '1') {
|
||||
$insertDetails['SessionID']=$this->db->insert_id();
|
||||
foreach ($Timings['Timings'] as $row1){
|
||||
$insertDetails['StartTime']=$row1['startTime'];
|
||||
$insertDetails['EndTime']=$row1['endTime'];
|
||||
$insertDetails['CreatedBy']=$arrayDetails['CreatedBy'];
|
||||
$insertDetails['IsActive']=$arrayDetails['IsActive'];
|
||||
$insertDetails['CreatedOn']=$arrayDetails['CreatedOn'];
|
||||
$this->db->insert(SESSIONSCHEDULEDETAILS, $insertDetails);
|
||||
|
||||
}
|
||||
|
||||
$result['sessionStatus'] = true;
|
||||
$result['message'] = "Schedules added successfully";
|
||||
} else {
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] = "Something went wrong.please try again";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get session master details
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function getSessionSchedule()
|
||||
{
|
||||
$this->db->select('SS.SCID,SM.SessionName,SM.SessionID,SS.IsActive,SS.SCDate,GROUP_CONCAT(SD.StartTime) as StartTime,GROUP_CONCAT(SD.EndTime) as EndTime,GROUP_CONCAT(SD.SSD) as ScheduleID');
|
||||
$this->db->from(SESSIONSCHEDULEDETAILS.' as SD');
|
||||
$this->db->join(SESSIONSCHEDULE.' as SS', 'SS.SCID = SD.SessionID');
|
||||
$this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SS.SessionID');
|
||||
$this->db->where('SM.IsActive','1');
|
||||
$this->db->group_by('SS.SCID','DESC');
|
||||
$sessionDetails = $this->db->get();
|
||||
if($sessionDetails->result()){
|
||||
|
||||
$result['sessionStatus'] = true;
|
||||
$result['details'] = $sessionDetails->result();
|
||||
}
|
||||
else {
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] = "No records found!";
|
||||
}
|
||||
|
||||
$result['sessionMaster'] = $this->getSessionMasterDetails();
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* update session schedule details
|
||||
* created by kms
|
||||
* */
|
||||
public function updateSessionSchedule($arrayDetails=null,$Timings=null)
|
||||
{
|
||||
|
||||
$this->db->select('SessionID');
|
||||
$this->db->where('SessionID', $arrayDetails['SessionID']);
|
||||
$this->db->where('SCDate', $arrayDetails['SCDate']);
|
||||
$this->db->where('SCID !=', $arrayDetails['SCID']);
|
||||
if($this->db->get(SESSIONSCHEDULE)->first_row()){
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] ="This same session/date is already exist.";
|
||||
}
|
||||
else{
|
||||
$this->db->where('SCID', $arrayDetails['SCID']);
|
||||
$upateStatus=$this->db->update(SESSIONSCHEDULE, $arrayDetails);
|
||||
|
||||
if($upateStatus){
|
||||
|
||||
if($Timings['Timings']){
|
||||
|
||||
foreach ($Timings['Timings'] as $urow){
|
||||
if($urow['scheduleID']==''){
|
||||
$insertDetails['SessionID']=$arrayDetails['SCID'];
|
||||
$insertDetails['StartTime']=$urow['startTime'];
|
||||
$insertDetails['EndTime']=$urow['endTime'];
|
||||
$insertDetails['IsActive']=$arrayDetails['IsActive'];
|
||||
$insertDetails['CreatedBy']=$arrayDetails['UpdatedBy'];
|
||||
$insertDetails['CreatedOn']=$arrayDetails['UpdatedOn'];
|
||||
$this->db->insert(SESSIONSCHEDULEDETAILS, $insertDetails);
|
||||
|
||||
}
|
||||
else{
|
||||
$updateDetails['SessionID']=$arrayDetails['SCID'];
|
||||
$updateDetails['StartTime']=$urow['startTime'];
|
||||
$updateDetails['EndTime']=$urow['endTime'];
|
||||
$updateDetails['IsActive']=$arrayDetails['IsActive'];
|
||||
$updateDetails['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
||||
$updateDetails['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
||||
$this->db->where('SSD',$urow['scheduleID']);
|
||||
$this->db->where('SessionID',$arrayDetails['SCID']);
|
||||
$this->db->update(SESSIONSCHEDULEDETAILS, $updateDetails);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
$result['sessionStatus'] = true;
|
||||
$result['message'] = "Sessions schedule updated successfully";
|
||||
|
||||
} else {
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] = "Something went wrong.please try again";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
/*
|
||||
* Get session master details
|
||||
* created by kms
|
||||
* */
|
||||
public function getSessionMasterDetails()//doubt
|
||||
{
|
||||
$this->db->select('SessionID,SessionName');
|
||||
$this->db->order_by('SessionID','DESC');
|
||||
$this->db->where('IsActive','1');
|
||||
$sessionDetails = $this->db->get(SESSIONMASTER);
|
||||
return $sessionDetails->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user