From a19d1b10e665d0f6ed27ce41ad4edb5ebcaf9cea Mon Sep 17 00:00:00 2001 From: gayathri1990 Date: Wed, 5 Sep 2018 13:13:41 +0530 Subject: [PATCH] batchshedule file upload --- Apollo/api/application/config/constants.php | 2 +- Apollo/api/application/config/routes.php | 4 +- .../controllers/Batch_Controller.php | 4 +- .../controllers/HallTickets_Controller.php | 54 ++++++++++--- .../application/models/Hallticket_model.php | 75 ++++++++++++++++- Apollo/assets/js/controllers/batchCtrl.js | 56 ++++++++++++- Apollo/assets/js/controllers/schCtrl.js | 80 +++++++++++++++++-- .../assets/views/hallticket/batchshedule.html | 35 +++++--- 8 files changed, 274 insertions(+), 36 deletions(-) diff --git a/Apollo/api/application/config/constants.php b/Apollo/api/application/config/constants.php index a7d21665..0d3d8d62 100755 --- a/Apollo/api/application/config/constants.php +++ b/Apollo/api/application/config/constants.php @@ -137,7 +137,7 @@ defined('STUDENTS') OR define('STUDENTS','T_StudentDetails'); defined('ANNOUNCEMENT') OR define('ANNOUNCEMENT','T_AnnouncementDetails'); defined('ACTIVITY') OR define('ACTIVITY','T_ActivityMaster'); defined('ACTIVITY_STATUS') OR define('ACTIVITY_STATUS','T_Activity_Status'); -defined('ANSWER_BOOKLET') OR define('ANSWER_BOOKLET','T_AnswerBookletStatus'); +defined('ANSWER_BOOKLET') OR define('ANSWER_BOOKLET','T_AnswerBookletStatus'); defined('APPLICATION_STATUS') OR define('APPLICATION_STATUS','T_ApplicationStatus'); defined('CERTIFICATION_STATUS') OR define('CERTIFICATION_STATUS','T_CertificationStatus'); defined('STUDENTS_FEES_STATUS') OR define('STUDENTS_FEES_STATUS','T_Students_Fees_Status'); diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index 2aa9297b..ecfecf93 100755 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -142,7 +142,7 @@ $route['deleteDocPendingDetails'] = 'Student_Controller/deleteDocPendingDetails' $route['getEmployeeDetailsBranch'] = 'Student_Controller/getEmployeeDetailsBranch'; //batch -$route['addBatchDetails'] = 'Batch_Controller/addBatchDetails'; +$route['addBatchDetails'] = 'Batch_Controller/addBatchDetails'; $route['updateBatchDetails'] = 'Batch_Controller/updateBatchDetails'; $route['getBatchDetails'] = 'Batch_Controller/getBatchDetails'; $route['updateBatchDefault'] = 'Batch_Controller/updateBatchDefault'; @@ -200,6 +200,7 @@ $route['feepaidDetails'] = 'Report/feepaidDetails'; $route['getSubjectDetaillist'] = 'HallTickets_Controller/getSubjectDetaillist'; + /* Add New Contact Group */ $route['addNewGroup'] = 'Broadcast_Controller/addNewGroup'; $route['getGroups'] = 'Broadcast_Controller/getGroups'; @@ -311,6 +312,7 @@ $route['updateSheduleDetails'] = 'HallTickets_Controller/updateSheduleDetails'; $route['getSheduleDetails'] = 'HallTickets_Controller/getSheduleDetails'; $route['getUniversityCourseId'] = 'HallTickets_Controller/getUniversityCourseId'; $route['saveBatchSchedule'] = 'HallTickets_Controller/SaveAllBatchSchedule'; +$route['batchUploadDataDetails'] = 'HallTickets_Controller/BatchUploadDataDetails'; // Re Registration Form $route['getStudentListForRegistrer'] = 'Reregister_Controller/getStudentListForReregister'; $route['getSubject'] = 'Reregister_Controller/getSubject'; diff --git a/Apollo/api/application/controllers/Batch_Controller.php b/Apollo/api/application/controllers/Batch_Controller.php index 7a53f21c..9a77c55b 100755 --- a/Apollo/api/application/controllers/Batch_Controller.php +++ b/Apollo/api/application/controllers/Batch_Controller.php @@ -36,13 +36,15 @@ class Batch_Controller extends REST_Controller { $now = new DateTime(); $now->setTimezone(new DateTimezone('Asia/Kolkata')); $details['BatchCode'] = $this->post('batchcode'); + $details['BatchName'] = $this->post('batcheName'); $details['BatchDate'] = $this->post('batcheDate'); $details['UniversityID'] = $this->post('universityName'); - $details['CreatedBy'] = $this->post('createdBy'); + $details['CreatedBy'] = $this->post('createdBy'); $details['IsActive'] = $this->post('status'); $details['BranchCode'] = $this->post('branchCode'); $details['CreatedOn'] = $now->format('Y-m-d H:i:s'); + print_r( $details +'samplearray'); $batchDetails = $this->batch_model->addBatch($details);// Check if the users data store contains users (in case the database result returns NULL) if ($batchDetails) diff --git a/Apollo/api/application/controllers/HallTickets_Controller.php b/Apollo/api/application/controllers/HallTickets_Controller.php index 3c00659f..7a6e1888 100755 --- a/Apollo/api/application/controllers/HallTickets_Controller.php +++ b/Apollo/api/application/controllers/HallTickets_Controller.php @@ -24,7 +24,7 @@ class HallTickets_Controller extends REST_Controller { $this->methods['getCourseSubjectDetails_post']['limit'] = 500; // 500 requests per hour per user/key $this->methods['getUniversityCourseDetails_post']['limit'] = 500; // 500 requests per hour per user/key $this->methods['updateSheduleDetails_post']['limit'] = 500; // 500 requests per hour per user/key - + $this->methods['BatchUploadDataDetails_post']['limit'] = 500; // load the model $this->load->model('Hallticket_model', 'Hallticket_model'); @@ -305,22 +305,58 @@ class HallTickets_Controller extends REST_Controller { } } + public function BatchUploadDataDetails_post() + { + // echo 'hai'; + $university= $this->post('universityDetails'); + $courseArray = $this->post('courseDetails'); + $filedetails = $this->post('details'); + $requestedBy = $this->post('requestedBy'); + $branchId = $this->post('branchId'); + $Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata')); + $CreatedOn = $Cdate->format('Y-m-d H:i:s'); + foreach($courseArray as $CourseDatialArray) + { + $course=$CourseDatialArray; + $schedulemaster = array('UniversityID'=>$university,'CourseID'=>$course,'BranchCode'=>$branchId,'CreatedBy'=>$requestedBy,'CreatedOn'=>$CreatedOn); + $schedulemasteradd = $this->Hallticket_model->AddBatchScheduleMasterFile($schedulemaster,$filedetails); + } + $SchId = ''; + if(count($schedulemasteradd)>0) + { + $SchId = $schedulemasteradd[0]['SchId']; + } + + + + if((count($schedulemasteradd)>0)) + { + $data['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($data, REST_Controller::HTTP_OK); + } + + else + { + $this->response([ + 'message' => 'No records found!', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); + + } + + } public function SaveAllBatchSchedule_post() { - - - $detailArray = $this->post('scheduleDetails'); - - $university =$this->post('getuniversityid'); - $courseid= $this->post('getcourseid'); + $detailArray = $this->post('scheduleDetails'); + $university =$this->post('getuniversityid'); + //$courseid= $this->post('getcourseid'); $requestedBy = $this->post('requestedBy'); $branchId = $this->post('branchId'); - $Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata')); $CreatedOn = $Cdate->format('Y-m-d H:i:s'); - //echo $courseid; $CourseDatialArray = $this->post('courseDetails'); foreach($CourseDatialArray as $coursedetails) { diff --git a/Apollo/api/application/models/Hallticket_model.php b/Apollo/api/application/models/Hallticket_model.php index aa2a5a78..b4927b14 100755 --- a/Apollo/api/application/models/Hallticket_model.php +++ b/Apollo/api/application/models/Hallticket_model.php @@ -108,18 +108,21 @@ class Hallticket_model extends CI_Model $this->db->select('SM.SubjectName,SM.SubjectID'); $this->db->from('T_SubjectMaster SM'); + $this->db->join('T_Batch_Schedule_Child','T_Batch_Schedule_Child.SubjectID=SM.SubjectID'); $this->db->where('SM.BranchCode',$branchcode); + $this->db->where('T_Batch_Schedule_Child.SchId',$mapid); $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('SCM.BranchCode',$branchcode); + // $this->db->where('T_Batch_Schedule_Child.SchId',$mapid); $this->db->where('T_Batch_Schedule_Child.SubjectID',$row->SubjectID); $existsheduledetails = $this->db->get(); @@ -1245,11 +1248,75 @@ class Hallticket_model extends CI_Model //echo "MODEL";print_r($result);die(); return $result; - } + } + public function AddBatchScheduleMasterFile($schedulemaster,$filedetails) + { + + $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($filedetails as $det) + { + + $sudate = $det['schduleDate']; + $SubDate = date("Y-m-d", strtotime($sudate)); + // $SubDate=$sudate->format('Y-m-d H:i:s'); + $stime = $det['FromTime']; + $etime = $det['ToTime']; + $isactive=1; + $subcode = $det['SubjectID']; + $Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata')); + $CreatedOn = $Cdate->format('Y-m-d H:i:s'); + $this->db->select('SubjectCode,SubjectID,SubjectName'); + $this->db->from('T_SubjectMaster'); + $this->db->where('T_SubjectMaster.BranchCode', $schedulemaster['BranchCode']); + $this->db->where('T_SubjectMaster.SubjectCode', $det['SubjectID']); + $subDetails = $this->db->get()->result(); + $SubjectID=$subDetails[0]->SubjectID; + $schedulchild = array('SchId'=>$schid,'SubjectID'=>$SubjectID,'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(); + + + + + } + + } + + //echo $schid; + // $schid=$query[0]['SchId']; + + // echo $schid; + + + } + return true; + + // return $query->result_array(); + + + } public function AddBatchScheduleMaster($schedulemaster,$detailArray) { - + $this->db->trans_start(); $this->db->insert('T_Batch_Schedule_Master', $schedulemaster); $insert_id = $this->db->affected_rows(); diff --git a/Apollo/assets/js/controllers/batchCtrl.js b/Apollo/assets/js/controllers/batchCtrl.js index 9e10e2d5..79e151b1 100755 --- a/Apollo/assets/js/controllers/batchCtrl.js +++ b/Apollo/assets/js/controllers/batchCtrl.js @@ -24,7 +24,7 @@ app.controller('batchCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTabl }; $scope.setEditId = function (pid,p) { - $scope.editModel.editBatchName = p.BatchName; + $scope.editModel.editBatchName = p.BatchName; $scope.editModel.editDate = p.BatchDate; $scope.localUniversityDetails=""; $scope.localUniversityDetails = JSON.parse(localStorage.getItem('localUniversityDetails')); @@ -61,11 +61,63 @@ app.controller('batchCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTabl $scope.sortKey = keyname; //set the sortKey to the param passed $scope.reverse = !$scope.reverse; //if true make it false and vice versa } + /* + * Submit,upload file and extract details + * @params myModel + * created by Bala + * */ + $scope.extractFileDetails=""; + $scope.readUploadXlsxDetails = function (workbook) { + /* DO SOMETHING WITH workbook HERE */ + for (var sheetName in workbook.Sheets) { + var jsonData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); + if(jsonData.length!=0){ + $scope.extractFileDetails=jsonData; + } + + } + $scope.error = function (e) { + /* DO SOMETHING WHEN ERROR IS THROWN */ + //console.log(e); + } + + } + + + $scope.UploadFileData = function (details,uploadForDetails) { + var updateUniversityEnrolment = { + method: 'POST', + url: apiPoint.url + 'fileUploadDataDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + localDetails: localDetail, + details: details, + batchcode: myModel.batchCode, + batcheName: myModel.batchName, + universityName: myModel.universityName, + universityID: angular.fromJson(uploadForDetails.university).UniversityID, + // universityName: angular.fromJson(uploadForDetails.university).UniversityName, + + } + }; + + $http(updateUniversityEnrolment).then(function (response) { + if (response.data.status == true) { + swal("", "Updated Successfully", "success"); + $state.go($state.current, {}, {reload: true}); + } else { + swal("", "Failed", "error"); + } + }); + } + // end /* * Submit,update and reset batch details * @params myModel - * created by subaram + * created by Bala * */ $scope.batchForm = { diff --git a/Apollo/assets/js/controllers/schCtrl.js b/Apollo/assets/js/controllers/schCtrl.js index 440c91f9..4488829f 100755 --- a/Apollo/assets/js/controllers/schCtrl.js +++ b/Apollo/assets/js/controllers/schCtrl.js @@ -86,7 +86,6 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP }; // $scope.details = []; $scope.cancel = function () { - $scope.init(); $scope.editId = -1; @@ -136,7 +135,7 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP * get course semester,subjects details * created by TamilBala * */ - + var course=''; $scope.getSemSubDetails = function(UID,COURSES){ course=COURSES; @@ -172,7 +171,7 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP swal("Select Course"); return false; } - + $scope.editId=1; $scope.semDropDownShowLoading = false; $scope.semDropDownShow = false; $scope.semDropDownShowLoading = true; @@ -226,11 +225,16 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP } ); - + } } - + $scope.remove = function () { + $scope.init(); + $scope.semDropDownShow = false; + + + }; /* * Remove Subjects from Master Subjects Arry * after selecting subjects for each semester @@ -326,7 +330,63 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP } + /* upload file for batch schedule + * created by bala + * */ + $scope.extractFileDetails=""; + $scope.readUploadBatchDetails = function (workbook) { + /* DO SOMETHING WITH workbook HERE */ + for (var sheetName in workbook.Sheets) { + var jsonData = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]); + if(jsonData.length!=0){ + $scope.extractFileDetails=jsonData; + } + } + $scope.error = function (e) { + /* DO SOMETHING WHEN ERROR IS THROWN */ + //console.log(e); + } + + } +/*upload file and extract data Created By bala */ + +$scope.UploadFileData = function (FileDetails,myModel,courseDetails) { + $scope.courseDetailsArray=courseDetails.list; + $scope.universityDetails=myModel.universityName.universityID; + // //console.log($scope.universityDetails); + // $scope.scheduledDetails=[]; + // $scope.scheduledDetails.push({ + // "universityID":myModel.universityName.universityID, + // }); + var updateUniversityEnrolment = { + method: 'POST', + url: apiPoint.url + 'batchUploadDataDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + details: FileDetails, + universityDetails : $scope.universityDetails, + courseDetails : $scope.courseDetailsArray, + requestedBy: JSON.parse(localStorage.getItem('localObj')).localUserID, + branchId:JSON.parse(localStorage.getItem('localObj')).localBranchID + + } + + }; + + $http(updateUniversityEnrolment).then(function (response) { + console.log(response); + if (response.data.status == 200) { + swal("", "Saved Successfully", "success"); + $state.go($state.current, {}, {reload: true}); + } else { + swal("", "Failed", "error"); + } + }); + } + // end $scope.saveAll= function(myModel,courseDetails,subjectsDetails) { @@ -369,7 +429,11 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP // var finalEndTime = new Date(newEndTime).toLocaleString('en-GB').slice(12 ,20); // finalEndTime = tempDate+'T'+finalEndTime+':000Z'; // console.log(finalEndTime); - $scope.scheduledDetails.push({ + + + + + $scope.scheduledDetails.push({ "universityID":myModel.universityName.universityID, //"courseID":courseDetails.list[0], "subjectID":value.Subject.SubjectID, @@ -382,7 +446,7 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP } }); //return false; - + var saveAllInfo = { method: 'POST', url: apiPoint.url + 'saveBatchSchedule/', @@ -418,7 +482,7 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP }); } - + $scope.updateShedule = function (unsheduledetails) { $scope.UpdatescheduledDetails=[]; diff --git a/Apollo/assets/views/hallticket/batchshedule.html b/Apollo/assets/views/hallticket/batchshedule.html index ded78335..95385d8f 100755 --- a/Apollo/assets/views/hallticket/batchshedule.html +++ b/Apollo/assets/views/hallticket/batchshedule.html @@ -24,7 +24,7 @@
- +

{{ mainTitle }}

Allocate Batch schedule @@ -129,7 +129,7 @@
-
+
@@ -148,16 +148,29 @@ repeat="x.CourseID as x in selectedUniversityCourseName | filter:$select.search"> {{x.CourseName}} - +
-
+ +

- + -
- +
+
+
+
+ (OR) +
+
+
+ +
+ + +
+
@@ -260,9 +273,11 @@
-
- - +
+ + +