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); $university_array['batchDetails']= $this->getBatchDetails($row->UniversityID,$branchId); $result_array[]=$university_array; } $result_university['univerSityDetails']= $result_array; //$result_university['centerDetails'] = $this->getCenterDetails($branchId); } else { $result_university['universityStatus'] = false; $result_university['message'] = "No records found!"; $result_university['universityID'] = ""; $result_university['universityName'] = ""; $result_university['courseDetails']= ""; } return $result_university; } public function getBatchDetails($UniversityID,$branchId) { $this->db->select("BatchID,BatchCode,BatchName,str_to_date( BatchDate,'%d-%m-%Y') as BD"); $this->db->from('T_BatchMaster'); $this->db->where('UniversityID',$UniversityID); $this->db->where('IsActive',1); $this->db->where('BranchCode',$branchId); $this->db->order_by("BD","DESC"); $res = $this->db->get(); return $res->result(); } public function getStudentListForPromoteBatchmodal($UID,$batchCode,$branchId,$batchDate) { $tempUniversityID = $UID['universityID']; $sql = "SELECT * FROM T_BatchMaster where isActive = 1 and UniversityID = ? and BranchCode = ? and str_to_date(BatchDate,'%d-%m-%Y') > str_to_date(?,'%d-%m-%Y') order by str_to_date(BatchDate,'%d-%m-%Y') asc limit 1"; $res2 = $this->db->query($sql,array($UID['universityID'],$branchId,date_format(date_create($batchDate),'d-m-Y'))); $data['nextBatch'] = $res2->result(); //print_r($data['nextBatch']); //echo $data['nextBatch'][0]->BatchCode; $this->db->select("T_StudentDetails.StudentID,T_StudentDetails.MobileNumber,T_StudentDetails.Firstname,T_StudentDetails.Lastname,T_StudentDetails.EmailID,max(T_Course_Fees_Details.Sem_Year) as current_sem,T_CourseMaster.CourseID,T_CourseMaster.CourseCode,T_CourseMaster.CourseName,max(T_Session_Master.SessionID) as SessionID,T_Students_Fees_Status.FeesType"); $this->db->from("T_Students_Fees_Status"); $this->db->join("T_StudentDetails","T_Students_Fees_Status.StudentID = T_StudentDetails.StudentID and T_StudentDetails.IsActive = 1"); $this->db->join("T_Course_Fees_Details","T_Students_Fees_Status.CourseID = T_Course_Fees_Details.CourseID and T_Students_Fees_Status.FeesType = T_Course_Fees_Details.ID and T_Course_Fees_Details.ProgramType = 'Y001' and T_Course_Fees_Details.FeesType = 'F002' and T_StudentDetails.IsActive = 1" ); $this->db->join("T_CourseMaster","T_Students_Fees_Status.CourseID=T_CourseMaster.CourseID"); $this->db->join("T_SessionDetails","T_Students_Fees_Status.SessionName=T_SessionDetails.SessionID and T_SessionDetails.isActive=1 and T_SessionDetails.BranchID = '$branchId' and T_SessionDetails.UniversityID = '$tempUniversityID'"); $this->db->join("T_Session_Master","T_SessionDetails.SessionID = T_Session_Master.SessionID and T_Session_Master.isActive=1"); $this->db->where("T_Students_Fees_Status.BatchCode",$batchCode); $this->db->where("T_Students_Fees_Status.BranchCode",$branchId); // $this->db->where('T_Session_Master.BranchCode',$branchId); // $this->db->where('T_SessionDetails.BranchID',$branchId); $this->db->group_by("T_StudentDetails.StudentID"); $res = $this->db->get(); $data['studentListOne'] = $res->result(); //print_r($data['studentListOne']); $data['finalStudentList'] = array(); //print_r($this->db->last_query());die(); foreach($data['studentListOne'] as $student) { //Get Session Details by Session ID $this->db->trans_start(); $this->db->select('SessionName,SessionDate'); $this->db->from('T_Session_Master'); $this->db->where('T_Session_Master.SessionID',$student->SessionID); $this->db->where('T_Session_Master.isActive',1); $this->db->where('T_Session_Master.BranchCode',$branchId); $sesstionDetails = $this->db->get(); $this->db->trans_complete(); $sesstionDetails = $sesstionDetails ->result_array(); //print_r($sesstionDetails);die(); //FIND OUT NEXT SEM NUMBER OR YEAR NUMBER $string = $student->current_sem; $string = str_replace(' ','',$string); $string = strtoupper($string); $next_sem = ""; $sempos = strpos($string,"SEM"); if($sempos !== FALSE) { $num = substr($string,-1); $num++; $next_sem = 'SEM'.$num; } else { $yearpos = strpos($string,"YEAR"); $num = substr($string,-1); $num++; $next_sem = 'YEAR'.$num; } //FIND OUT FEESTYPE ID $sem = $next_sem; $sem = '%'.(substr_replace($sem, '%', -1, 0)).'%'; $sql = "SELECT ID,FeesAmount FROM T_Course_Fees_Details where CourseID = ? and ProgramType = 'Y001' and FeesType = 'F002' and Sem_Year like ?"; $res = $this->db->query($sql,array($student->CourseID,$sem)); $res = $res->result_array(); if(!empty($res)) { $feesID = $res[0]['ID']; $feesAmount = $res[0]['FeesAmount']; //FIND OUT STUDENT FEES DETAILS EXIST OR NOT $this->db->trans_start(); $this->db->select('count(*) as feescount'); $this->db->from('T_Students_Fees_Status'); $this->db->where('T_Students_Fees_Status.BatchCode',$data['nextBatch'][0]->BatchCode); $this->db->where('T_Students_Fees_Status.BranchCode',$branchId); $this->db->where('T_Students_Fees_Status.StudentID',$student->StudentID); $this->db->where('T_Students_Fees_Status.CourseID',$student->CourseID); $this->db->where('T_Students_Fees_Status.FeesType',$feesID); $res = $this->db->get(); $res = $res->result_array(); // print_r($this->db->last_query()); // print_r($res); if($res[0]['feescount'] == 0) { $tempArray['StudentID'] = $student->StudentID; $tempArray['MobileNumber'] = $student->MobileNumber; $tempArray['Firstname'] = $student->Firstname; $tempArray['Lastname'] = $student->Lastname; $tempArray['EmailID'] = $student->EmailID; $tempArray['current_sem'] = $student->current_sem; $tempArray['next_sem'] = $next_sem; $tempArray['FeesType'] = $feesID; $tempArray['FeesAmount'] = $feesAmount; $tempArray['CourseID'] = $student->CourseID; $tempArray['CourseCode'] = $student->CourseCode; $tempArray['CourseName'] = $student->CourseName; $tempArray['SessionID'] = $student->SessionID; $tempArray['SessionName'] = $sesstionDetails[0]['SessionName']; $tempArray['SessionDate'] = $sesstionDetails[0]['SessionDate']; $sqlquery ="SELECT SessionID,SessionName FROM T_Session_Master where BranchCode = ? and str_to_date(SessionDate,'%d-%m-%Y') > str_to_date(?,'%d-%m-%Y') order by str_to_date(SessionDate,'%d-%m-%Y') asc limit 1"; $tempResult = $this->db->query($sqlquery,array($branchId,$tempArray['SessionDate'])); $tempResult = $tempResult->result(); //echo $this->db->last_query(); if($tempResult[0]){ $tempArray['nextSessionName'] = $tempResult[0]->SessionName; $tempArray['nextSessionID'] = $tempResult[0]->SessionID; } else{ $tempArray['nextSessionName'] = ""; $tempArray['nextSessionID'] = ""; } $data['finalStudentList'][] = $tempArray; } } } return $data; } public function savePromotedBatchDeatils($UniversityID,$BatchDetails,$StudentDetails,$FirstDueDate,$SecondDueDate,$CreadtedBy,$BranchId) { $now = new DateTime(); $now->setTimezone(new DateTimezone('Asia/Kolkata')); $feesCount = 0; $studentCount = count($StudentDetails); foreach($StudentDetails as $student) { $feesDeatils['BatchCode'] = $BatchDetails['BatchCode']; $feesDeatils['StudentID'] = $student['StudentID']; $feesDeatils['CourseID'] = $student['CourseID']; $feesDeatils['FeesType'] = $student['FeesType']; $feesDeatils['CourseFees'] = $student['FeesAmount']; $feesDeatils['STFOrWR'] = 0; $feesDeatils['Waiver'] = 0; $feesDeatils['Others'] = 0; $feesDeatils['ToSessionName'] = ''; $feesDeatils['RollNo'] = ''; $feesDeatils['SessionName'] = $student['nextSessionID']; $feesDeatils['Comments'] = 'Automatically promoted'; $feesDeatils['CreatedBy'] = $CreadtedBy; $feesDeatils['CreatedOn'] = $now->format('Y-m-d H:i:s'); $feesDeatils['BranchCode'] = $BranchId; $firstDue = $feesDeatils['CourseFees'] * (70/100); $secondDue = $feesDeatils['CourseFees'] * (30/100); $this->db->trans_start(); $this->db->insert('T_Students_Fees_Status',$feesDeatils); $setFeesID = $this->db->insert_id(); $this->db->trans_complete(); for($i = 1;$i<=2;$i++) { $installmentDetails['FeesID'] = $setFeesID; if($i == 1) { $installmentDetails['Name'] = 'First'; $installmentDetails['Amount'] = $firstDue; $installmentDetails['DueDate'] = $FirstDueDate; } elseif($i == 2) { $installmentDetails['Name'] = 'Second'; $installmentDetails['Amount'] = $secondDue; $installmentDetails['DueDate'] = $SecondDueDate; } $installmentDetails['CreatedBy'] = $CreadtedBy; $installmentDetails['CreatedOn'] = $now->format('Y-m-d H:i:s'); $this->db->trans_start(); $this->db->insert('T_Fees_Installments',$installmentDetails); $this->db->trans_complete(); } if($setFeesID) { $feesCount = $feesCount + 1; } } if($feesCount == $studentCount) { return TRUE; } else { return FALSE; } } /** * Created by Viual Studio. * User: sriram * Date: 6/19/18 * Reregister Function Query */ public function getUniversityDetails($branchId) { $this->db->select('UniversityID,UniversityName,ProfilePicPath,Address,EmailID,MobileNumber'); $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['ProfilePicPath'] = $row->ProfilePicPath; $university_array['EmailID'] = $row->EmailID; $university_array['Address'] = $row->Address; $university_array['MobileNumber'] = $row->MobileNumber; $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID,$branchId); $university_array['batchDetails']= $this->getformBatchDetails($row->UniversityID,$branchId); $result_array[]=$university_array; } $result_university['univerSityDetails']= $result_array; //$result_university['centerDetails'] = $this->getCenterDetails($branchId); } else { $result_university['universityStatus'] = false; $result_university['message'] = "No records found!"; $result_university['universityID'] = ""; $result_university['universityName'] = ""; $result_university['courseDetails']= ""; } return $result_university; } public function getCourseDetails($universityID=null,$branchId) { $this->db->select('CourseID,CONCAT(CourseName, "(",CourseCode,")") AS CourseName,concat(Specilization1," ",Specilization2) as Specilization'); $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(); } public function getformBatchDetails($UniversityID,$branchId) { $this->db->select("BatchID,BatchCode,BatchName,str_to_date( BatchDate,'%d-%m-%Y') as BD"); $this->db->from('T_BatchMaster'); $this->db->where('UniversityID',$UniversityID); $this->db->where('IsActive',1); $this->db->where('BranchCode',$branchId); $this->db->order_by("BD","DESC"); $res = $this->db->get(); return $res->result(); } public function getStudentListForReregistermodel($UID,$courseID,$batch,$requestedBy,$branchId) { $this->db->distinct(); $this->db->select('T_StudentDetails.StudentID,T_StudentDetails.MobileNumber,T_StudentDetails.Firstname,T_StudentDetails.Lastname,T_StudentDetails.EmailID,T_StudentDetails.Fathername,T_StudentDetails.MotherName,T_StudentDetails.PermanentAddress,if(T_Student_CourseDetails.EnrollmentID = "","",T_Student_CourseDetails.EnrollmentID) as EnrollmentID'); $this->db->from('T_Students_Fees_Status'); $this->db->join('T_StudentDetails','T_Students_Fees_Status.StudentID=T_StudentDetails.StudentID and T_StudentDetails.IsActive = 1'); $this->db->join('T_Student_CourseDetails','T_Students_Fees_Status.StudentID = T_Student_CourseDetails.StudentID'); $this->db->where('T_Students_Fees_Status.BatchCode',$batch); $this->db->where('T_Students_Fees_Status.BranchCode',$branchId); $this->db->where('T_Students_Fees_Status.CourseID',$courseID); //$this->db->group_by('_StudentDetails.StudentID'); // $this->db->order_by('T_Students_Fees_Status.FeesID','DESC'); // $this->db->limit(1); $res = $this->db->get(); $data = $res->result(); $result_array = array(); //print_r($data);die; if(count($data) > 0) { $result = array(); $prestu = ""; foreach($data as $r) { if($prestu != $r->StudentID && $r->EnrollmentID !="") { $studentdetails['StudentID'] = $r->StudentID; $studentdetails['MobileNumber'] = $r->MobileNumber; $studentdetails['Firstname'] = $r->Firstname; $studentdetails['Lastname'] = $r->Lastname; $studentdetails['EmailID'] = $r->EmailID; $studentdetails['Fathername'] = $r->Fathername; $studentdetails['MotherName'] = $r->MotherName; $PermanentAddress = ($r->PermanentAddress); $studentdetails['PermanentAddress'] = $PermanentAddress; $studentdetails['EnrollmentID'] = $r->EnrollmentID; $studentdetails['FeeDetails'] = $this->getFeeSemesterDetails($r->StudentID,$batch,$branchId,$courseID); // if(!empty($studetdetails['FeeDetails'])){ $result[] = $studentdetails; //} $prestu = $r->StudentID; } //print_r($result_array); } } //print_r($result);die; //echo json_encode(urldecode($result));die; //die; return $result; } function getFeeSemesterDetails($stuid,$bcode,$branchId,$courseID) { $this->db->distinct(); $this->db->select("T_Course_Fees_Details.FeesType,T_Course_Fees_Details.ID as FeesID,if(substr(substr(T_Course_Fees_Details.sem_Year,-4),1,3) = 'sem',substr(sem_Year,-1),if(substr(substr(T_Course_Fees_Details.sem_Year,-5),1,4) = 'year',substr(T_Course_Fees_Details.sem_Year,-1),false)) as SemID,if(substr(substr(T_Course_Fees_Details.sem_Year,-4),1,3) = 'sem','SEM',if(substr(substr(T_Course_Fees_Details.sem_Year,-5),1,4) = 'year','YEAR',false)) as SubType,T_Course_Fees_Details.Sem_Year,if(T_Course_Fees_Details.ProgramType = 'Y001','SEM',if(ProgramType = 'P001','REG',if(ProgramType = 'P002','LAT','FALSE'))) as Type"); $this->db->from('T_Students_Fees_Status'); //$this->db->join('T_StudentDetails','T_Students_Fees_Status.StudentID=T_StudentDetails.StudentID'); $this->db->join('T_Course_Fees_Details','T_Students_Fees_Status.FeesType=T_Course_Fees_Details.ID'); $this->db->where('T_Students_Fees_Status.BatchCode',$bcode); $this->db->where('T_Students_Fees_Status.BranchCode',$branchId); $this->db->where('T_Students_Fees_Status.CourseID',$courseID); $this->db->where('T_Students_Fees_Status.StudentID',$stuid); $this->db->where("T_Course_Fees_Details.FeesType !='F001'"); $this->db->order_by('T_Students_Fees_Status.FeesID','DESC'); $this->db->limit(1); $res = $this->db->get(); //print_r($res->result()); return $res->result(); } function getSubject($sem,$branch,$course){ $this->db->select('sub.*'); $this->db->join('T_SemSubMap_Child SC','SC.MapID = SM.MapID','left'); $this->db->join('T_SubjectMaster sub','sub.SubjectID = SC.SubjectID'); $this->db->where('SM.SemesterID',$sem); $this->db->where('SM.BranchCode',$branch); $this->db->where('SM.CourseID',$course); $this->db->where('SC.isActive',1); $query = $this->db->get('T_SemSubMap_Master SM'); //print_r($query->result());die; return $query->result(); } }