course details changes done
This commit is contained in:
parent
b06beaac38
commit
6322501fc2
188
Apollo/api/application/models/SeesionMaster_model.php
Normal file
188
Apollo/api/application/models/SeesionMaster_model.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: karthi
|
||||
* Date: 2/7/18
|
||||
* Time: 10:44 AM
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class SeesionMaster_model extends CI_Model {
|
||||
|
||||
|
||||
/*
|
||||
* Add session master details
|
||||
* created by kms
|
||||
* */
|
||||
|
||||
public function addSession($arrayDetails=null)
|
||||
{
|
||||
|
||||
$this->db->select('SessionName');
|
||||
$this->db->where('SessionName', $arrayDetails['SessionName']);
|
||||
if($this->db->get(SESSIONMASTER)->first_row()){
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] ="This sessions is already exist.";
|
||||
}
|
||||
else{
|
||||
$insertMaster['SessionName']=$arrayDetails['SessionName'];
|
||||
$insertMaster['CreatedBy']=$arrayDetails['CreatedBy'];
|
||||
$insertMaster['IsActive']=$arrayDetails['IsActive'];
|
||||
$insertMaster['CreatedOn']=$arrayDetails['CreatedOn'];
|
||||
|
||||
$this->db->insert(SESSIONMASTER, $insertMaster);
|
||||
|
||||
if ($this->db->affected_rows() == '1') {
|
||||
$insertDetails['SessionID']=$this->db->insert_id();
|
||||
foreach ($arrayDetails['UniversityID'] as $row1){
|
||||
$insertDetails['UniversityID']=$row1['UniversityID'];
|
||||
$insertDetails['CreatedBy']=$arrayDetails['CreatedBy'];
|
||||
$insertDetails['IsActive']=$arrayDetails['IsActive'];
|
||||
$insertDetails['CreatedOn']=$arrayDetails['CreatedOn'];
|
||||
$this->db->insert(SESSIONDETAILS, $insertDetails);
|
||||
|
||||
}
|
||||
|
||||
$result['sessionStatus'] = true;
|
||||
$result['message'] = "Sessions 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 getSession()
|
||||
{
|
||||
$this->db->select('SM.SessionID,SM.SessionName,GROUP_CONCAT(SD.UniversityID) as UniversityID,GROUP_CONCAT(SM.SessionID) as GrpID,SM.IsActive,GROUP_CONCAT(US.UniversityName) as UniversityName');
|
||||
$this->db->from(SESSIONMASTER.' as SM');
|
||||
$this->db->join(SESSIONDETAILS.' as SD', 'SM.SessionID = SD.SessionID');
|
||||
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = SD.UniversityID');
|
||||
$this->db->where('SD.IsActive','1');
|
||||
$this->db->order_by('SM.CreatedOn','DESC');
|
||||
$this->db->group_by('SM.SessionName','DESC');
|
||||
$sessionDetails = $this->db->get();
|
||||
if($sessionDetails->result()){
|
||||
|
||||
$result['sessionStatus'] = true;
|
||||
$result['details'] = $sessionDetails->result();
|
||||
}
|
||||
else {
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] = "No records found!";
|
||||
}
|
||||
// load batch model for get university details
|
||||
$this->load->model('Batch_model', 'batch');
|
||||
$result['universityDetails'] = $this->batch->getUniversityDetails();
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* update session master details
|
||||
* created by kms
|
||||
* */
|
||||
public function updateSession($arrayDetails=null,$universityDetails=null)
|
||||
{
|
||||
$this->db->select('SessionName');
|
||||
$this->db->where('SessionName', $arrayDetails['SessionName']);
|
||||
$this->db->where('SessionID !=', $arrayDetails['SessionID']);
|
||||
if($this->db->get(SESSIONMASTER)->first_row()){
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] ="This sessions is already exist.";
|
||||
}
|
||||
else{
|
||||
$this->db->where('SessionID', $arrayDetails['SessionID']);
|
||||
$upateStatus=$this->db->update(SESSIONMASTER, $arrayDetails);
|
||||
|
||||
if($upateStatus){
|
||||
$deactiveStatus['IsActive']=false;
|
||||
$deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
||||
$deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
||||
$this->db->where('SessionID ',$arrayDetails['SessionID']);
|
||||
$updateActivityStatusDeactive = $this->db->update(SESSIONDETAILS, $deactiveStatus);
|
||||
|
||||
if($updateActivityStatusDeactive){
|
||||
|
||||
if($universityDetails['University']){
|
||||
|
||||
foreach ($universityDetails['University'] as $urow){
|
||||
$this->db->select('ID');
|
||||
$this->db->where('SessionID',$arrayDetails['SessionID']);
|
||||
$this->db->where('UniversityID',$urow);
|
||||
if($this->db->get(SESSIONDETAILS)->first_row()){
|
||||
$existStatusUpdate['IsActive']=true;
|
||||
$existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
||||
$existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
||||
$this->db->where('SessionID',$arrayDetails['SessionID']);
|
||||
$this->db->where('UniversityID',$urow);
|
||||
$this->db->update(SESSIONDETAILS, $existStatusUpdate);
|
||||
}
|
||||
else{
|
||||
$update_array["UniversityID"]=$urow;
|
||||
$update_array["SessionID"]=$arrayDetails['SessionID'];
|
||||
$update_array["IsActive"]=true;
|
||||
$update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
|
||||
$update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
|
||||
$this->db->insert(SESSIONDETAILS, $update_array);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
$activateStatus['IsActive']=true;
|
||||
$this->db->where('SessionID ',$arrayDetails['SessionID']);
|
||||
$this->db->update(SESSIONMASTER, $activateStatus);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result['sessionStatus'] = true;
|
||||
$result['message'] = "Sessions updated successfully";
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$result['sessionStatus'] = false;
|
||||
$result['message'] = "Something went wrong.please try again";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
/*
|
||||
* Get university details
|
||||
* created by kms
|
||||
* */
|
||||
public function getUniversityDetails()//doubt
|
||||
{
|
||||
$this->db->select('UniversityID,UniversityName');
|
||||
$this->db->order_by('UniversityID','ASC');
|
||||
$this->db->where('IsActive','1');
|
||||
// $this->db->where_not_in('ID', $id);
|
||||
$universityDetails = $this->db->get(UNIVERSITY);
|
||||
return $universityDetails->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user