diff --git a/Apollo/api/application/controllers/HallTickets_Controller.php b/Apollo/api/application/controllers/HallTickets_Controller.php index 31dd9c55..9732f367 100755 --- a/Apollo/api/application/controllers/HallTickets_Controller.php +++ b/Apollo/api/application/controllers/HallTickets_Controller.php @@ -401,7 +401,7 @@ class HallTickets_Controller extends REST_Controller { $centerName = $this->post('centerName'); $res['UniversityDetails'] = $this->Hallticket_model->getUniversityDetials($UID,$branchId); - $res['studentDetails'] = $this->Hallticket_model->getStudentDetails($UID,$courseID,$branchId,$studentIDs); + $res['studentDetails'] = $this->Hallticket_model->getStudentDetails($UID,$courseID,$branchId,$studentIDs,$centerName,$batch,$requestedBy); if(count($res['UniversityDetails']) != 0 || count($res['studentDetails']) != 0 ) diff --git a/Apollo/api/application/models/Hallticket_model.php b/Apollo/api/application/models/Hallticket_model.php index 5946a068..b552e1e3 100755 --- a/Apollo/api/application/models/Hallticket_model.php +++ b/Apollo/api/application/models/Hallticket_model.php @@ -757,7 +757,7 @@ class Hallticket_model extends CI_Model } //Student Details with All Corresponding Semesters and Subjects - public function getStudentDetails($UID,$courseID,$branchId,$studentIDs) + public function getStudentDetails($UID,$courseID,$branchId,$studentIDs,$centerName,$batch,$requestedBy) { foreach($studentIDs as $key1 => $id) @@ -918,12 +918,102 @@ class Hallticket_model extends CI_Model array_splice($studentIDs[$key1]['FeeDetails'],0,10,$id['FeeDetails']) ; } - //print_r($studentIDs);//die(); + //print_r($studentIDs);die(); + $this->saveHallTicketDataForExamAttendance($UID,$courseID,$branchId,$studentIDs,$centerName,$batch,$requestedBy); return $studentIDs; } - + public function saveHallTicketDataForExamAttendance($UID,$courseID,$branchId,$studentIDs,$centerName,$batch,$requestedBy) + { + $MASTERID = '00'; + + $this->db->select('HallTicket_ID'); + $this->db->from('T_Hallticket_Master'); + $this->db->where('UniversityID',$UID['universityID']); + $this->db->where('CourseID',$courseID); + $this->db->where('BatchCode',$batch); + $this->db->where('CenterID',$centerName['CenterID']); + $this->db->where('BranchCode',$branchId); + $isExist = $this->db->get(); + $isExist = $isExist->result_array(); + + //print_r($isExist);die(); + if(!empty($isExist[0]['HallTicket_ID'])) + { + $MASTERID = $isExist[0]['HallTicket_ID']; + + $this->db->trans_start(); + $this->db->where('HallTicket_ID',$MASTERID); + $this->db->update('T_Hallticket_Master',array('UpdatedBy'=>$requestedBy)); + $this->db->trans_complete(); + + $this->db->trans_start(); + $this->db->select('HallTicket_Student_ID'); + $this->db->from('T_Hallticket_Student_Details'); + $this->db->where('`HallTicket_ID',$MASTERID); + $existStudentID = $this->db->get(); + $existStudentID = $existStudentID->result_array(); + $this->db->trans_complete(); + $finalExistStudentID = array(); + foreach($existStudentID as $exist) + { + $finalExistStudentID[] = $exist['HallTicket_Student_ID']; + } + + $this->db->trans_start(); + $this->db->where_in('HallTicket_ID',$MASTERID); + $this->db->delete('T_Hallticket_Student_Details'); + $this->db->trans_complete(); + + $this->db->trans_start(); + $this->db->where_in('HallTicket_Student_ID',$finalExistStudentID); + $this->db->delete('T_Hallticket_Subject_Details'); + $this->db->trans_complete(); + } + else + { + $masterArray = array('UniversityID'=>$UID['universityID'],'CourseID'=>$courseID,'BatchCode'=>$batch,'BranchCode'=>$branchId,'CreatedBy'=>$requestedBy,'CenterID'=>$centerName['CenterID']); + $this->db->trans_start(); + $this->db->insert('T_Hallticket_Master',$masterArray); + $MASTERID = $this->db->insert_id(); + $this->db->trans_complete(); + } + //Save University,Course,Batch,BranchCode, and Center ID + + foreach($studentIDs as $student) + { + //print_r($student);echo ""; + if(!empty($student['FeeDetails'])) + { + foreach($student['FeeDetails'] as $key => $fees) + { + //print_r($fees); + $tempArray = array('Hallticket_ID'=>$MASTERID,'StudentID'=>$student['StudentID'],'EnrollmentID'=>$student['EnrollmentID'],'Sem_Year'=>('SEM'.($key + 1))); + + $this->db->trans_start(); + $this->db->insert('T_Hallticket_Student_Details',$tempArray); + $HallTicketStudentID = $this->db->insert_id(); + $this->db->trans_complete(); + + foreach($fees as $subject) + { + //echo $subject->SubjectCode;echo ""; + $tempSubjectArray = array('HallTicket_Student_ID'=>$HallTicketStudentID,'SubjectCode'=>$subject->SubjectCode,'ExamDate'=>$subject->ScheduleDate,'FromTime'=>$subject->FromTime,'EndTime'=>$subject->ToTime); + + $this->db->trans_start(); + $this->db->insert('T_Hallticket_Subject_Details',$tempSubjectArray); + $this->db->trans_complete(); + + } + + + } + } + } + + + } public function AddBatchScheduleMaster($schedulemaster,$detailArray) { diff --git a/Apollo/assets/js/controllers/generateHallTicketCtrl.js b/Apollo/assets/js/controllers/generateHallTicketCtrl.js index 1e94f655..c2f25be7 100755 --- a/Apollo/assets/js/controllers/generateHallTicketCtrl.js +++ b/Apollo/assets/js/controllers/generateHallTicketCtrl.js @@ -26,6 +26,8 @@ $scope.isTblShow = false; $scope.isLoader = false; $scope.isLoaderShow = false; $scope.isLoaderTxt = "Loading..."; +$scope.generateButtonTxt = "GENERATE"; +$scope.generateButtonStatus = false; // sorting function for table params $scope.sort = function(keyname){ @@ -234,7 +236,8 @@ $scope.isLoaderTxt = "Loading..."; var university = $scope.myModel.universityName; var course = $scope.myModel.courseName; var batch = $scope.myModel.batchName; - + $scope.generateButtonTxt = "Please Wait..."; + $scope.generateButtonStatus = true; var dataForHallTicket = { method: 'POST', url: apiPoint.url + 'getHallTicket/', @@ -263,6 +266,9 @@ $scope.isLoaderTxt = "Loading..."; $scope.pdfModel.semDataType =response.data.semDataType; $scope.open($scope.pdfModel); + $scope.generateButtonTxt = "GENERATE"; + $scope.generateButtonStatus = false; + } },function(error){ swal('No Records Found','',error); }); } diff --git a/Apollo/assets/views/hallticket/examAttendance.html b/Apollo/assets/views/hallticket/examAttendance.html index 79e8a705..64f52727 100644 --- a/Apollo/assets/views/hallticket/examAttendance.html +++ b/Apollo/assets/views/hallticket/examAttendance.html @@ -71,7 +71,7 @@