From 6322501fc29a3b63c3d9114b648f24dc37e1549d Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Wed, 7 Feb 2018 19:02:08 +0530 Subject: [PATCH] course details changes done --- .../models/SeesionMaster_model.php | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 Apollo/api/application/models/SeesionMaster_model.php diff --git a/Apollo/api/application/models/SeesionMaster_model.php b/Apollo/api/application/models/SeesionMaster_model.php new file mode 100644 index 00000000..384eca95 --- /dev/null +++ b/Apollo/api/application/models/SeesionMaster_model.php @@ -0,0 +1,188 @@ +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(); + } + + + +} \ No newline at end of file