diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index c8fec8f1..63ead59e 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -273,9 +273,10 @@ $route['getStudentListForRegistrer'] = 'Reregister_Controller/getStudentListForR $route['getSubject'] = 'Reregister_Controller/getSubject'; $route['getUniversityCourseDetailsforms'] = 'Reregister_Controller/getUniversityCourseDetailsforms'; -///PROMOTE BATCH AND RE REG +///PROMOTE BATCH AND $route['getUniversityBatchDetails'] = 'Reregister_Controller/getUniversityBatchDetails'; $route['getStudentListForPromoteBatch'] = 'Reregister_Controller/getStudentListForPromoteBatch'; +$route['promoteBatchInfomation'] = 'Reregister_Controller/promoteBatchInfomation'; //Reports $route['report_status'] = 'Report/status'; diff --git a/Apollo/api/application/controllers/Reregister_Controller.php b/Apollo/api/application/controllers/Reregister_Controller.php index 55933fed..f0642cfe 100644 --- a/Apollo/api/application/controllers/Reregister_Controller.php +++ b/Apollo/api/application/controllers/Reregister_Controller.php @@ -76,6 +76,37 @@ class Reregister_Controller extends REST_Controller { ], REST_Controller::HTTP_NOT_FOUND); } } + + + //Promote one Batch to anthor Batch + public function promoteBatchInfomation_post() + { + $UniversityID = $this->post('UniversityID'); + $BatchDetails = $this->post('BatchDetails'); + $StudentDetails = $this->post('StudentDetails'); + $FirstDueDate = $this->post('FirstDueDate'); + $SecondDueDate = $this->post('SecondDueDate'); + $CreadtedBy = $this->post('requestedBy'); + $BranchId = $this->post('branchId'); + + + $FirstDueDate = date_format(date_create($FirstDueDate),'d-m-Y'); + $SecondDueDate = date_format(date_create($SecondDueDate),'d-m-Y'); + // print_r($StudentDetails); + //die(); + $result = $this->Reregister_model->savePromotedBatchDeatils($UniversityID,$BatchDetails,$StudentDetails,$FirstDueDate,$SecondDueDate,$CreadtedBy,$BranchId); + + if($result) + { + $data['status'] = REST_Controller::HTTP_OK; + $this->response($data, REST_Controller::HTTP_OK); + } + else + { + $this->response(['message' => 'Something Went Wrong!','status' => REST_Controller::HTTP_NOT_FOUND], REST_Controller::HTTP_NOT_FOUND); + } + + } /* *Created by Visual Studio. * User: sriram diff --git a/Apollo/api/application/models/Reregister_model.php b/Apollo/api/application/models/Reregister_model.php index 8de4a665..b7cd617c 100644 --- a/Apollo/api/application/models/Reregister_model.php +++ b/Apollo/api/application/models/Reregister_model.php @@ -65,13 +65,23 @@ class Reregister_model extends CI_Model public function getStudentListForPromoteBatchmodal($UID,$batchCode,$branchId,$batchDate) { - $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,T_Session_Master.SessionID,T_Session_Master.SessionName,T_Session_Master.SessionDate'); + + + $sql = "SELECT * FROM apollod4_ApolloDECDev.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,T_Session_Master.SessionID,T_Session_Master.SessionName,T_Session_Master.SessionDate,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'); - $this->db->join('T_Session_Master','T_SessionDetails.SessionID = T_Session_Master.SessionID'); + $this->db->join('T_SessionDetails','T_Students_Fees_Status.SessionName=T_SessionDetails.SessionID and T_SessionDetails.isActive=1'); + $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); @@ -79,43 +89,177 @@ class Reregister_model extends CI_Model $this->db->group_by('T_StudentDetails.StudentID'); $res = $this->db->get(); $data['studentListOne'] = $res->result(); - + //print_r($data['studentListOne']); $data['finalStudentList'] = array(); foreach($data['studentListOne'] as $student) { - $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['CourseID'] = $student->CourseID; - $tempArray['CourseCode'] = $student->CourseCode; - $tempArray['CourseName'] = $student->CourseName; - $tempArray['SessionID'] = $student->SessionID; - $tempArray['SessionName'] = $student->SessionName; - $tempArray['SessionDate'] = $student->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(); - $tempArray['nextSessionName'] = $tempResult[0]->SessionName; - $tempArray['nextSessionID'] = $tempResult[0]->SessionID; - $data['finalStudentList'][] = $tempArray; + //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(); + + $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'] = $student->SessionName; + $tempArray['SessionDate'] = $student->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(); + $tempArray['nextSessionName'] = $tempResult[0]->SessionName; + $tempArray['nextSessionID'] = $tempResult[0]->SessionID; + $data['finalStudentList'][] = $tempArray; + } } - $sql = "SELECT * FROM apollod4_ApolloDECDev.T_BatchMaster where 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(); - //echo $this->db->last_query(); + 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 diff --git a/Apollo/assets/js/controllers/BatchmomentCtrl.js b/Apollo/assets/js/controllers/BatchmomentCtrl.js index 5c1d7a2a..7a3b13c9 100644 --- a/Apollo/assets/js/controllers/BatchmomentCtrl.js +++ b/Apollo/assets/js/controllers/BatchmomentCtrl.js @@ -147,7 +147,7 @@ $scope.isShowNxtBatch = false; $scope.selectedStudentsID.splice(pos,1); } - console.log($scope.selectedStudentsID); + //console.log($scope.selectedStudentsID); } @@ -174,17 +174,131 @@ $scope.isShowNxtBatch = false; { $scope.selectedStudentsID = []; } - console.log($scope.selectedStudentsID); + //console.log($scope.selectedStudentsID); } - + / $scope.promoteStudents = function() { if($scope.selectedStudentsID.length == 0 ) { swal('Select Proper Details..!','University, Batch, and atleast one student','warning'); return false; - } + } + + if($scope.nextBatchDetails == "") + { + swal('No Batch Available','It seems to be, There is no next immediate batch. create new Batch in Batch Master ','warning'); + return false; + + } + + var sessionCount = 0; + angular.forEach($scope.studentInfo,function(value,key){ + + if(value.SessionName == "" || value.nextSessionName == "") + { + sessionCount = sessionCount + 1; + } + + }); + + if(sessionCount != 0) + { + // swal('No Sessions Available','It seems to be, There is no current OR next immediate session for some studnets. Ensure Session details before Promote students ','warning'); + // return false; + swal({ + title: "No Sessions Available!", + text: "It seems to be, There are no current OR next immediate session not available for some studnets. Ensure Session details before Promote next batch", + icon: "warning", + buttons: true, + dangerMode: true, + }) + .then((willPromote) => { + if (!willPromote) + { + return false; + } + }); + } + + //calculate Due Dates + + var nxtBatchDate1 = $scope.nextBatchDetails[0].BatchDate; + var nxtBatchDate2 = nxtBatchDate1.split('-'); + //console.log(nxtBatchDate); + var nxtBatchDate = nxtBatchDate2[2]+'-'+nxtBatchDate2[1]+'-'+nxtBatchDate2[0]; + //console.log(nxtBatchDate); + nxtBatchDate = new Date(nxtBatchDate); + var currentDate = new Date(); + //console.log(currentDate); + //console.log(nxtBatchDate); + var seconddue = new Date(); + + if(nxtBatchDate < currentDate) + { + seconddue = new Date(); + } + else + { + //console.log('CAL'); + var timeDiff = Math.abs(currentDate.getTime() - nxtBatchDate.getTime()); + var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); + //console.log(diffDays); + if(diffDays > 30) + { + + seconddue = new Date((nxtBatchDate2[2]+'-'+nxtBatchDate2[1]+'-'+nxtBatchDate2[0])); + seconddue.setDate(nxtBatchDate.getDate() - 30); + + //console.log(seconddue); + } + else if(diffDays < 30 && diffDays >= 15) + { + seconddue = new Date((nxtBatchDate2[2]+'-'+nxtBatchDate2[1]+'-'+nxtBatchDate2[0])); + seconddue.setDate(nxtBatchDate.getDate() - 15); + //console.log(seconddue); + } + + } + + /*End of calculate Due Dates*/ + + /*Store All info*/ + var promoteBatch = { + method: 'POST', + url: apiPoint.url + 'promoteBatchInfomation/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + + UniversityID : $scope.myModel.universityName.universityID, + BatchDetails : $scope.nextBatchDetails[0], + StudentDetails : $scope.selectedStudentsID, + FirstDueDate : currentDate, + SecondDueDate : seconddue, + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID, + branchId:JSON.parse(localStorage.getItem('localObj')).localBranchID + } + }; + + $http(promoteBatch).then(function (response) { + if (response.data.status == 200) { + swal('Saved Sucessfully','','success') + $state.go($state.current, {}, {reload: true}); + } else { + swal('Someting Went Wrong','Try Later','error') + $state.go($state.current, {}, {reload: true});} + },function(error){ + swal('Someting Went Wrong','Try Later','error') + $state.go($state.current, {}, {reload: true}); + }); + + + + + } diff --git a/Apollo/assets/views/hallticket/semcoursemap.html b/Apollo/assets/views/hallticket/semcoursemap.html index 5a865799..569963b2 100755 --- a/Apollo/assets/views/hallticket/semcoursemap.html +++ b/Apollo/assets/views/hallticket/semcoursemap.html @@ -337,7 +337,7 @@ {{x.CourseName}} -
{{selectedCourseNameC.list | json}}
+