558 lines
17 KiB
PHP
Executable File
558 lines
17 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by Notepad++.
|
|
* User: velz
|
|
* Date: 3/19/18
|
|
* Time: 7:48 PM
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Hallticket_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* get university details
|
|
* created by velz
|
|
* */
|
|
public function getUniversityDetails($branchId)
|
|
{
|
|
$this->db->select('UniversityID,UniversityName');
|
|
$this->db->where('IsActive','1');
|
|
$this->db->where('BranchCode',$branchId);
|
|
$this->db->order_by('UniversityID','ASC');
|
|
$unviversityDetails = $this->db->get(UNIVERSITY);
|
|
|
|
if($unviversityDetails->result()){
|
|
$result_university = array();
|
|
$result_university['universityStatus'] = true;
|
|
foreach ($unviversityDetails->result() as $row)
|
|
{
|
|
|
|
$university_array['universityID'] = $row->UniversityID;
|
|
$university_array['universityName'] = $row->UniversityName;
|
|
$university_array['courseDetails']= $this->getCourseDetails($row->UniversityID,$branchId);
|
|
$result_array[]=$university_array;
|
|
}
|
|
$result_university['univerSityDetails']= $result_array;
|
|
}
|
|
else {
|
|
$result_university['universityStatus'] = false;
|
|
$result_university['message'] = "No records found!";
|
|
$result_university['universityID'] = "";
|
|
$result_university['universityName'] = "";
|
|
$result_university['courseDetails']= "";
|
|
}
|
|
|
|
|
|
return $result_university;
|
|
|
|
}
|
|
/*
|
|
* get university details and course details
|
|
* for view shedule
|
|
* created by TamilBala
|
|
* */
|
|
public function getUniversityid($branchCode)
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('T_Batch_Schedule_Master.UniversityID,T_Batch_Schedule_Master.CourseID,T_Batch_Schedule_Master.SchId,T_UniversityMaster.UniversityName,T_CourseMaster.CourseName,T_CourseMaster.CourseCode,T_Batch_Schedule_Child.ScheduleDate,T_Batch_Schedule_Child.FromTime,T_Batch_Schedule_Child.ToTime,T_Batch_Schedule_Child.SchId,T_SubjectMaster.SubjectName,T_SubjectMaster.SubjectID,T_UniversityMaster.UniversityID,T_SubjectMaster.BranchCode');
|
|
$this->db->from('T_Batch_Schedule_Master');
|
|
$this->db->join('T_UniversityMaster','T_Batch_Schedule_Master.UniversityID=T_UniversityMaster.UniversityID');
|
|
$this->db->join('T_CourseMaster','T_Batch_Schedule_Master.CourseID=T_CourseMaster.CourseID');
|
|
$this->db->join('T_Batch_Schedule_Child','T_Batch_Schedule_Master.SchId=T_Batch_Schedule_Child.SchId');
|
|
$this->db->join('T_SubjectMaster','T_Batch_Schedule_Child.SubjectID=T_SubjectMaster.SubjectID');
|
|
$this->db->where('T_Batch_Schedule_Master.BranchCode',$branchCode);
|
|
$this->db->where('T_Batch_Schedule_Master.IsActive',1);
|
|
$this->db->group_by('T_CourseMaster.CourseName');
|
|
$result = $this->db->get();
|
|
//print_r($result->result());
|
|
return $result->result();
|
|
}
|
|
/*
|
|
* get shedule details details
|
|
* for edit/view shedule
|
|
* created by TamilBala
|
|
* */
|
|
public function getShedules($mapid)
|
|
{
|
|
$this->db->select('T_Batch_Schedule_Child.ScheduleDate,T_Batch_Schedule_Child.FromTime,T_Batch_Schedule_Child.ToTime,T_SubjectMaster.SubjectName,T_Batch_Schedule_Child.SchChildId,T_Batch_Schedule_Child.SubjectID');
|
|
$this->db->from('T_SubjectMaster');
|
|
$this->db->join('T_Batch_Schedule_Child','T_Batch_Schedule_Child.SubjectID=T_SubjectMaster.SubjectID','left');
|
|
$this->db->where('T_Batch_Schedule_Child.SchId',$mapid);
|
|
$result = $this->db->get();
|
|
//print_r($result->result());
|
|
//die();
|
|
return $result->result();
|
|
}
|
|
/*
|
|
* get shedule details details
|
|
* for edit/view shedule
|
|
* created by TamilBala
|
|
* */
|
|
public function get_unShedules($mapid,$subid,$branchcode)
|
|
{
|
|
|
|
$this->db->select('SM.SubjectName,SM.SubjectID');
|
|
$this->db->from('T_SubjectMaster SM');
|
|
$this->db->where('SM.BranchCode',$branchcode);
|
|
$result = $this->db->get();
|
|
if($result->result()){
|
|
$resultShedule['status']=true;
|
|
$mastScheduleID="";
|
|
foreach($result->result() as $row)
|
|
{
|
|
|
|
$this->db->select('T_Batch_Schedule_Child.SchId,T_Batch_Schedule_Child.SubjectID,T_Batch_Schedule_Child.ScheduleDate,T_Batch_Schedule_Child.FromTime,T_Batch_Schedule_Child.ToTime,T_Batch_Schedule_Child.SchChildId,T_Batch_Schedule_Child.SchId');
|
|
$this->db->from('T_Batch_Schedule_Master SCM');
|
|
$this->db->join('T_Batch_Schedule_Child','T_Batch_Schedule_Child.SchId = SCM.SchId');
|
|
$this->db->where('T_Batch_Schedule_Child.SchId',$mapid);
|
|
$this->db->where('T_Batch_Schedule_Child.SubjectID',$row->SubjectID);
|
|
$existsheduledetails = $this->db->get();
|
|
|
|
if($existData=$existsheduledetails->result())
|
|
{
|
|
|
|
$fetchData['ID']="1";
|
|
$fetchData['SubjectID']=$row->SubjectID;
|
|
$fetchData['SubjectName']=$row->SubjectName;
|
|
$fetchData['ScheduleDate']=$existData[0]->ScheduleDate;
|
|
$fetchData['FromTime']=$existData[0]->FromTime;
|
|
$fetchData['ToTime']=$existData[0]->ToTime;
|
|
$fetchData['SchChildId']=$existData[0]->SchChildId;
|
|
$fetchData['SchId']=$existData[0]->SchId;
|
|
$mastScheduleID=$existData[0]->SchId;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$fetchData['SubjectID']=$row->SubjectID;
|
|
$fetchData['SubjectName']=$row->SubjectName;
|
|
$fetchData['ID']="0";
|
|
$fetchData['ScheduleDate']="";
|
|
$fetchData['FromTime']="";
|
|
$fetchData['ToTime']="";
|
|
$fetchData['SchChildId']="";
|
|
$fetchData['SchId']= $mastScheduleID;
|
|
|
|
}
|
|
$fetchshedule[]=$fetchData;
|
|
}
|
|
$resultShedule['scheduleDetails']=$fetchshedule;
|
|
}
|
|
else{
|
|
$resultShedule['status']=false;
|
|
$resultShedule['scheduleDetails']="";
|
|
}
|
|
//print_r($resultShedule);
|
|
//die();
|
|
return $resultShedule;
|
|
}
|
|
/*
|
|
* get course details
|
|
* @params university id
|
|
* created by velz
|
|
* */
|
|
public function getCourseDetails($universityID=null,$branchId)
|
|
{
|
|
$this->db->select('CourseID,CONCAT(CourseName, "(",CourseCode,")") AS CourseName');
|
|
$this->db->where('UniversityID',$universityID);
|
|
$this->db->where('BranchCode',$branchId);
|
|
$this->db->where('IsActive','1');
|
|
$this->db->group_by('CourseName');
|
|
$this->db->order_by('CourseID','ASC');
|
|
$courseDetails = $this->db->get(COURSE);
|
|
return $courseDetails->result();
|
|
}
|
|
|
|
/*
|
|
* get subject details
|
|
* @params university id and CourseID
|
|
* created by velz
|
|
* */
|
|
public function getSubjectDetails($universityID,$courseIDS,$branchId)
|
|
{
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('SubjectID,SubjectCode,SubjectName');
|
|
$this->db->from('T_SubjectMaster');
|
|
//$this->db->join('T_SubjectMaster','T_CourseSubject_Details.SubjectID=T_SubjectMaster.SubjectID');
|
|
$this->db->where('T_SubjectMaster.IsActive','1');
|
|
// $this->db->where('T_CourseSubject_Details.UniversityID',$universityID);
|
|
$this->db->where_in('T_SubjectMaster.BranchCode',$branchId);
|
|
$result = $this->db->get();
|
|
//echo $this->db->last_query();
|
|
return $result->result();
|
|
}
|
|
|
|
|
|
/*
|
|
* get semester details
|
|
* @params university id and CourseID
|
|
* created by velz
|
|
* */
|
|
public function getSemesterDetails($universityID,$courseIDS)
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('CourseID,Sem_Year');
|
|
$this->db->from('T_Course_Fees_Details');
|
|
$this->db->where('IsActive','1');
|
|
$this->db->where_in('T_Course_Fees_Details.CourseID',$courseIDS);
|
|
$result = $this->db->get();
|
|
return $result->result();
|
|
}
|
|
|
|
|
|
/*
|
|
* save All Semester Subject Mapping Info
|
|
* @params university id,CourseID,requestedBy,branchId,semArray
|
|
* created by velz
|
|
* */
|
|
public function saveAllSemesterSubjectMappingmodel($UID,$courseIDS,$requestedBy,$branchId,$semArray)
|
|
{
|
|
$sem1 = 0;$sem2=0;$sem3=0;$sem4=0;$sem5=0;$sem6=0;$sem7=0;$sem8 = 0;
|
|
foreach($semArray as $key => $s)
|
|
{
|
|
if($key == 0)
|
|
{
|
|
$sem1 = $s;
|
|
}
|
|
if($key == 1)
|
|
{
|
|
$sem2 = $s;
|
|
}if($key == 2)
|
|
{
|
|
$sem3 = $s;
|
|
}if($key == 3)
|
|
{
|
|
$sem4 = $s;
|
|
}if($key == 4)
|
|
{
|
|
$sem5 = $s;
|
|
}if($key == 5)
|
|
{
|
|
$sem6 = $s;
|
|
}
|
|
if($key == 6)
|
|
{
|
|
$sem7 = $s;
|
|
}
|
|
if($key == 7)
|
|
{
|
|
$sem8 = $s;
|
|
}
|
|
}
|
|
//Check If Exist or Not for UniversityID and CourseID's
|
|
|
|
$this->db->select('count(*) as counts');
|
|
$this->db->from('T_SemSubMap_Master');
|
|
$this->db->where('BranchCode',$branchId);
|
|
$this->db->where('UniversityID',$UID);
|
|
$this->db->where_in('CourseID',$courseIDS);
|
|
$isExist = $this->db->get();
|
|
$isExist = $isExist->result();
|
|
$result_array = array('insert'=>'','exist'=>'');
|
|
if($isExist[0]->counts == 0 )
|
|
{
|
|
|
|
|
|
|
|
|
|
$ids = array();
|
|
|
|
foreach($courseIDS as $course)
|
|
{
|
|
for($i=1;$i<=8;$i++)
|
|
{
|
|
|
|
$dataArray = array('UniversityID'=>$UID,'CourseID'=>$course,'SemesterID'=>$i,'BranchCode'=>$branchId,'CreatedBy'=>$requestedBy);
|
|
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Master',$dataArray);
|
|
$last_id = $this->db->insert_id();
|
|
$this->db->trans_complete();
|
|
//echo $last_id;
|
|
//$current = '$sem'.$i;
|
|
//echo $current;die();
|
|
$ids[] = $last_id;
|
|
if($i == 1)
|
|
{
|
|
if(count($sem1) != 0){
|
|
foreach($sem1 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 2)
|
|
{
|
|
if(count($sem2) != 0){
|
|
foreach($sem2 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 3)
|
|
{
|
|
if(count($sem3) != 0){
|
|
foreach($sem3 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 4)
|
|
{
|
|
if(count($sem4) != 0){
|
|
foreach($sem4 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 5)
|
|
{
|
|
if(count($sem5) != 0){
|
|
foreach($sem5 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 6)
|
|
{
|
|
if(count($sem6) != 0){
|
|
foreach($sem6 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 7)
|
|
{
|
|
if(count($sem7) != 0){
|
|
foreach($sem7 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
if($i == 8)
|
|
{
|
|
if(count($sem8) != 0){
|
|
foreach($sem8 as $s)
|
|
{
|
|
$childArray = array('MapID'=>$last_id,'SubjectID'=>$s['SubjectID']);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_SemSubMap_Child',$childArray);
|
|
$this->db->trans_complete();
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if(count($ids) > 0)
|
|
{
|
|
$result_array['insert'] = true;
|
|
$result_array['exist'] = false;
|
|
return $result_array;
|
|
}
|
|
else
|
|
{
|
|
$result_array['insert'] = false;
|
|
$result_array['exist'] = false;
|
|
return $result_array;
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
$result_array['insert'] = false;
|
|
$result_array['exist'] = true;
|
|
return $result_array;
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* get All Semester Subject Mapping Info
|
|
* @params branchId
|
|
* created by velz
|
|
* */
|
|
public function getAllSemesterSubjectsmodel($branchId)
|
|
{
|
|
$this->db->select('T_SemSubMap_Master.*,T_UniversityMaster.UniversityName,T_CourseMaster.CourseID,T_CourseMaster.CourseCode,T_CourseMaster.CourseName,T_SubjectMaster.SubjectID,T_SubjectMaster.SubjectCode,T_SubjectMaster.SubjectName');
|
|
$this->db->from('T_SemSubMap_Master');
|
|
$this->db->join('T_UniversityMaster','T_SemSubMap_Master.UniversityID=T_UniversityMaster.UniversityID') ;
|
|
$this->db->join('T_CourseMaster','T_SemSubMap_Master.CourseID=T_CourseMaster.CourseID');
|
|
$this->db->join('T_SemSubMap_Child','T_SemSubMap_Master.MapID=T_SemSubMap_Child.MapID','left');
|
|
$this->db->join('T_SubjectMaster','T_SemSubMap_Child.SubjectID=T_SubjectMaster.SubjectID');
|
|
$res = $this->db->get();
|
|
return $res->result();
|
|
|
|
|
|
}
|
|
|
|
|
|
public function AddBatchScheduleMaster($schedulemaster,$detailArray)
|
|
{
|
|
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_Batch_Schedule_Master', $schedulemaster);
|
|
$insert_id = $this->db->affected_rows();
|
|
$this->db->trans_complete();
|
|
// print_r($this->db->last_query());
|
|
if($insert_id>0)
|
|
{
|
|
$subQuery = 'select max(SchId) as SchId from T_Batch_Schedule_Master';
|
|
|
|
$query = $this->db->query($subQuery);
|
|
|
|
|
|
$result = $query->result_array();
|
|
$schid= $result[0]['SchId'];
|
|
|
|
// if(($schid != '')||($schid !=0))
|
|
|
|
if(count($result)>0)
|
|
{
|
|
|
|
foreach($detailArray as $det)
|
|
{
|
|
|
|
$sudate = $det['scheduleDate'];
|
|
$SubDate = date("Y-m-d", strtotime($sudate));
|
|
// $SubDate=$sudate->format('Y-m-d H:i:s');
|
|
$stime = $det['scheduleStart'];
|
|
$etime = $det['scheduleEnd'];
|
|
$isactive=1;
|
|
$subId = $det['subjectID'];
|
|
$Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
|
|
$CreatedOn = $Cdate->format('Y-m-d H:i:s');
|
|
|
|
$schedulchild = array('SchId'=>$schid,'SubjectID'=>$subId,'SchChildId'=>'','ScheduleDate'=>$SubDate,'FromTime'=>$stime,'ToTime'=>$etime,'IsActive'=>$isactive);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_Batch_Schedule_Child',$schedulchild);
|
|
$this->db->trans_complete();
|
|
|
|
|
|
|
|
|
|
// print_r($schedulchild);
|
|
//die();
|
|
|
|
//$schedulchildadd = $this->Hallticket_model->AddScheduleChild($schedulchild);
|
|
}
|
|
|
|
}
|
|
|
|
//echo $schid;
|
|
// $schid=$query[0]['SchId'];
|
|
|
|
// echo $schid;
|
|
|
|
|
|
}
|
|
return true;
|
|
|
|
// return $query->result_array();
|
|
|
|
|
|
}
|
|
public function scheduleUpdate($schedulearray,$up)
|
|
{
|
|
|
|
$MasterID = "";
|
|
foreach($schedulearray as $shed)
|
|
{
|
|
$ChildID = $shed['schChildId'];
|
|
//echo $ChildID;
|
|
$sudate = $shed['scheduleDate'];
|
|
$SubDate = date("Y-m-d", strtotime($sudate));
|
|
$MasterID = $shed['SchId'];
|
|
//echo $SchId;
|
|
$SubjectID = $shed['SubjectID'];
|
|
$scheduleStart = $shed['scheduleStart'];
|
|
$scheduleEnd = $shed['scheduleEnd'];
|
|
$isactive=1;
|
|
if($ChildID != '')
|
|
{
|
|
|
|
$schedulchildUpdate = array('ScheduleDate'=>$SubDate,'FromTime'=>$scheduleStart,'ToTime'=>$scheduleEnd);
|
|
//print_r($schedulchild);
|
|
$this->db->trans_start();
|
|
$this->db->where('T_Batch_Schedule_Child.SchChildId',$ChildID);
|
|
$this->db->where('T_Batch_Schedule_Child.SubjectID',$SubjectID);
|
|
$this->db->update('T_Batch_Schedule_Child',$schedulchildUpdate);
|
|
$this->db->trans_complete();
|
|
|
|
}
|
|
else
|
|
{
|
|
$schedulchildInsert = array('SchId'=>$MasterID,'SubjectID'=>$SubjectID,'ScheduleDate'=>$SubDate,'FromTime'=>$scheduleStart,'ToTime'=>$scheduleEnd,'IsActive'=>$isactive);
|
|
$this->db->trans_start();
|
|
$this->db->insert('T_Batch_Schedule_Child',$schedulchildInsert);
|
|
$this->db->trans_complete();
|
|
|
|
}
|
|
}
|
|
|
|
$schedulMaster = array('UpdatedBy'=>$up);
|
|
|
|
$this->db->trans_start();
|
|
$this->db->update('T_Batch_Schedule_Master',$schedulMaster);
|
|
$this->db->where('T_Batch_Schedule_Master.SchId',$MasterID);
|
|
$this->db->trans_complete();
|
|
|
|
return $up;
|
|
|
|
}
|
|
|
|
|
|
// public function AddScheduleChild($schedulchild)
|
|
// {
|
|
// $this->db->trans_start();
|
|
// $this->db->insert('T_Batch_Schedule_Child',$schedulchild);
|
|
// $this->db->trans_complete();
|
|
// return true;
|
|
|
|
// }
|
|
|
|
} |