batchshedule file upload

This commit is contained in:
gayathri1990 2018-09-05 13:13:41 +05:30
parent 87304b2030
commit a19d1b10e6
8 changed files with 274 additions and 36 deletions

View File

@ -200,6 +200,7 @@ $route['feepaidDetails'] = 'Report/feepaidDetails';
$route['getSubjectDetaillist'] = 'HallTickets_Controller/getSubjectDetaillist'; $route['getSubjectDetaillist'] = 'HallTickets_Controller/getSubjectDetaillist';
/* Add New Contact Group */ /* Add New Contact Group */
$route['addNewGroup'] = 'Broadcast_Controller/addNewGroup'; $route['addNewGroup'] = 'Broadcast_Controller/addNewGroup';
$route['getGroups'] = 'Broadcast_Controller/getGroups'; $route['getGroups'] = 'Broadcast_Controller/getGroups';
@ -311,6 +312,7 @@ $route['updateSheduleDetails'] = 'HallTickets_Controller/updateSheduleDetails';
$route['getSheduleDetails'] = 'HallTickets_Controller/getSheduleDetails'; $route['getSheduleDetails'] = 'HallTickets_Controller/getSheduleDetails';
$route['getUniversityCourseId'] = 'HallTickets_Controller/getUniversityCourseId'; $route['getUniversityCourseId'] = 'HallTickets_Controller/getUniversityCourseId';
$route['saveBatchSchedule'] = 'HallTickets_Controller/SaveAllBatchSchedule'; $route['saveBatchSchedule'] = 'HallTickets_Controller/SaveAllBatchSchedule';
$route['batchUploadDataDetails'] = 'HallTickets_Controller/BatchUploadDataDetails';
// Re Registration Form // Re Registration Form
$route['getStudentListForRegistrer'] = 'Reregister_Controller/getStudentListForReregister'; $route['getStudentListForRegistrer'] = 'Reregister_Controller/getStudentListForReregister';
$route['getSubject'] = 'Reregister_Controller/getSubject'; $route['getSubject'] = 'Reregister_Controller/getSubject';

View File

@ -36,6 +36,7 @@ class Batch_Controller extends REST_Controller {
$now = new DateTime(); $now = new DateTime();
$now->setTimezone(new DateTimezone('Asia/Kolkata')); $now->setTimezone(new DateTimezone('Asia/Kolkata'));
$details['BatchCode'] = $this->post('batchcode'); $details['BatchCode'] = $this->post('batchcode');
$details['BatchName'] = $this->post('batcheName'); $details['BatchName'] = $this->post('batcheName');
$details['BatchDate'] = $this->post('batcheDate'); $details['BatchDate'] = $this->post('batcheDate');
$details['UniversityID'] = $this->post('universityName'); $details['UniversityID'] = $this->post('universityName');
@ -43,6 +44,7 @@ class Batch_Controller extends REST_Controller {
$details['IsActive'] = $this->post('status'); $details['IsActive'] = $this->post('status');
$details['BranchCode'] = $this->post('branchCode'); $details['BranchCode'] = $this->post('branchCode');
$details['CreatedOn'] = $now->format('Y-m-d H:i:s'); $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) $batchDetails = $this->batch_model->addBatch($details);// Check if the users data store contains users (in case the database result returns NULL)
if ($batchDetails) if ($batchDetails)

View File

@ -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['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['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['updateSheduleDetails_post']['limit'] = 500; // 500 requests per hour per user/key
$this->methods['BatchUploadDataDetails_post']['limit'] = 500;
// load the model // load the model
$this->load->model('Hallticket_model', 'Hallticket_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() public function SaveAllBatchSchedule_post()
{ {
$detailArray = $this->post('scheduleDetails');
$university =$this->post('getuniversityid');
$detailArray = $this->post('scheduleDetails'); //$courseid= $this->post('getcourseid');
$university =$this->post('getuniversityid');
$courseid= $this->post('getcourseid');
$requestedBy = $this->post('requestedBy'); $requestedBy = $this->post('requestedBy');
$branchId = $this->post('branchId'); $branchId = $this->post('branchId');
$Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata')); $Cdate = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
$CreatedOn = $Cdate->format('Y-m-d H:i:s'); $CreatedOn = $Cdate->format('Y-m-d H:i:s');
//echo $courseid;
$CourseDatialArray = $this->post('courseDetails'); $CourseDatialArray = $this->post('courseDetails');
foreach($CourseDatialArray as $coursedetails) foreach($CourseDatialArray as $coursedetails)
{ {

View File

@ -108,7 +108,9 @@ class Hallticket_model extends CI_Model
$this->db->select('SM.SubjectName,SM.SubjectID'); $this->db->select('SM.SubjectName,SM.SubjectID');
$this->db->from('T_SubjectMaster SM'); $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('SM.BranchCode',$branchcode);
$this->db->where('T_Batch_Schedule_Child.SchId',$mapid);
$result = $this->db->get(); $result = $this->db->get();
if($result->result()){ if($result->result()){
$resultShedule['status']=true; $resultShedule['status']=true;
@ -119,7 +121,8 @@ class Hallticket_model extends CI_Model
$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->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->from('T_Batch_Schedule_Master SCM');
$this->db->join('T_Batch_Schedule_Child','T_Batch_Schedule_Child.SchId = SCM.SchId'); $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); $this->db->where('T_Batch_Schedule_Child.SubjectID',$row->SubjectID);
$existsheduledetails = $this->db->get(); $existsheduledetails = $this->db->get();
@ -1245,6 +1248,70 @@ class Hallticket_model extends CI_Model
//echo "MODEL";print_r($result);die(); //echo "MODEL";print_r($result);die();
return $result; 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) public function AddBatchScheduleMaster($schedulemaster,$detailArray)

View File

@ -61,11 +61,63 @@ app.controller('batchCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTabl
$scope.sortKey = keyname; //set the sortKey to the param passed $scope.sortKey = keyname; //set the sortKey to the param passed
$scope.reverse = !$scope.reverse; //if true make it false and vice versa $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 * Submit,update and reset batch details
* @params myModel * @params myModel
* created by subaram * created by Bala
* */ * */
$scope.batchForm = { $scope.batchForm = {

View File

@ -86,7 +86,6 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP
}; };
// $scope.details = []; // $scope.details = [];
$scope.cancel = function () { $scope.cancel = function () {
$scope.init(); $scope.init();
$scope.editId = -1; $scope.editId = -1;
@ -172,7 +171,7 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP
swal("Select Course"); swal("Select Course");
return false; return false;
} }
$scope.editId=1;
$scope.semDropDownShowLoading = false; $scope.semDropDownShowLoading = false;
$scope.semDropDownShow = false; $scope.semDropDownShow = false;
$scope.semDropDownShowLoading = true; $scope.semDropDownShowLoading = true;
@ -230,7 +229,12 @@ app.controller('schCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableP
} }
} }
$scope.remove = function () {
$scope.init();
$scope.semDropDownShow = false;
};
/* /*
* Remove Subjects from Master Subjects Arry * Remove Subjects from Master Subjects Arry
* after selecting subjects for each semester * 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) $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); // var finalEndTime = new Date(newEndTime).toLocaleString('en-GB').slice(12 ,20);
// finalEndTime = tempDate+'T'+finalEndTime+':000Z'; // finalEndTime = tempDate+'T'+finalEndTime+':000Z';
// console.log(finalEndTime); // console.log(finalEndTime);
$scope.scheduledDetails.push({
$scope.scheduledDetails.push({
"universityID":myModel.universityName.universityID, "universityID":myModel.universityName.universityID,
//"courseID":courseDetails.list[0], //"courseID":courseDetails.list[0],
"subjectID":value.Subject.SubjectID, "subjectID":value.Subject.SubjectID,

View File

@ -129,7 +129,7 @@
<!-- <pre>{{myModel.universityName | json}}</pre> --> <!-- <pre>{{myModel.universityName | json}}</pre> -->
</div> </div>
<div class="col-md-5 form-group"> <div class="col-md-3 form-group">
<label> <label>
Course Course
</label> </label>
@ -152,12 +152,25 @@
<!-- <pre>{{selectedCourseNameC.list | json}}</pre> --> <!-- <pre>{{selectedCourseNameC.list | json}}</pre> -->
</div> </div>
<div class="col-md-3 form-group">
<div class="col-md-2 form-group">
<br> <br>
<button type="button" ladda="ldloading1.zoom_in" tabindex="3" class="btn btn-wide btn-success" data-style="zoom-in" ng-click="getSemSubDetails(myModel.universityName.universityID,selectedCourseNameC);">GET SUBJECTS</button> <button type="button" ladda="ldloading1.zoom_in" tabindex="3" class="btn btn-wide btn-success" data-style="zoom-in" ng-click="getSemSubDetails(myModel.universityName.universityID,selectedCourseNameC);">MANUAL SCHDULE</button>
</div> </div>
<div class="col-md-1 form group">
<br>
<br>
<lable style="color:green ;font-size:14px"> (OR) </lable>
</div>
<div class="col-md-3 form-group">
<fieldset>
<js-xls onread="readUploadBatchDetails" onerror="error"></js-xls>
<br>
<button type="button" class="btn btn-success btn-o" style="float: right" ng-click="UploadFileData(extractFileDetails,myModel,selectedCourseNameC)"> Submit</button>
</fieldset>
</div>
</div> </div>
<div class="row" ng-if="semDropDownShowLoading"> <div class="row" ng-if="semDropDownShowLoading">
@ -261,8 +274,10 @@
<div class="col-md-12 form-group" ng-if="semDropDownShow"> <div class="col-md-12 form-group" ng-if="semDropDownShow">
<div class="pull-right"> <div class="pull-right">
<br> <br>
<button type="button" ladda="ldloading1.zoom_in" tabindex="" class="btn btn-wide btn-success" data-style="zoom-in" ng-disabled="saveButtonDisabled" ng-click="saveAll(myModel,selectedCourseNameC,subjects);">{{saveButtonTxt}}</button>
<input type="button" class="btn btn-warning btn-wide" tabindex="3" value="Cancel"
ng-click="remove();">
<button type="button" ladda="ldloading1.zoom_in" tabindex="" class="btn btn-wide btn-primary" data-style="zoom-in" ng-disabled="saveButtonDisabled" ng-click="saveAll(myModel,selectedCourseNameC,subjects);">{{saveButtonTxt}}</button>
</div> </div>
</div> </div>