398 lines
14 KiB
JavaScript
Executable File
398 lines
14 KiB
JavaScript
Executable File
'use strict';
|
|
/*** controller for Wizard Form example***/
|
|
app.controller('certificationStatusCtrl', ["$scope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, toaster, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) {
|
|
|
|
/**
|
|
* Certification status update search / Mark card status update
|
|
* by : kdk
|
|
*/
|
|
|
|
$scope.sort = function (keyname) {
|
|
$scope.sortKey = keyname; //set the sortKey to the param passed
|
|
$scope.reverse = !$scope.reverse; //if true make it false and vice versa
|
|
}
|
|
|
|
$scope.editId = -1;
|
|
$scope.setEditId = function (P) {
|
|
// alert(P);
|
|
$scope.editId = P;
|
|
}
|
|
$scope.cancel = function () {
|
|
$scope.editId = -1;
|
|
}
|
|
|
|
|
|
// get local client details
|
|
var localDetail = JSON.parse(localStorage.getItem('localObj'));
|
|
var localDetails = ipCookie('cookiechk');
|
|
const localUpdateStatus = 'CERTIFICATION_STATUS';
|
|
|
|
$scope.init = function () {
|
|
$scope.getUniversityList();
|
|
// $scope.getCertificateList();
|
|
}
|
|
|
|
$scope.searchData = {
|
|
'University': '',
|
|
'Course': '',
|
|
'Batch': '',
|
|
'Mobile': '',
|
|
'Name': ''
|
|
}
|
|
|
|
$scope.myStatusModel = {
|
|
'semYear': '',
|
|
'staus': '',
|
|
'dateOn': '',
|
|
'comment': '',
|
|
'certificatetype': '',
|
|
'certificateNumber': ''
|
|
}
|
|
|
|
// get University List
|
|
$scope.universityData = '';
|
|
$scope.getUniversityList = function () {
|
|
var empListreq = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getUniveCourseBratch/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(empListreq).then(function (response) {
|
|
if (response.data.univList) {
|
|
$scope.universityData = response.data.university_details;
|
|
} else {
|
|
}
|
|
});
|
|
};
|
|
|
|
//get certificates List
|
|
$scope.getCertificateList = function () {
|
|
var getCerfreg = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getCertificateList/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(getCerfreg).then(function (response) {
|
|
if (response.data.certificateStatus) {
|
|
$scope.certificateData = response.data.certificate_details;
|
|
// alert(JSON.stringify($scope.certificateData));
|
|
} else {
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.getUniveId = function (univ) {
|
|
let name = JSON.parse(univ);
|
|
$scope.searchData.University = name.UniversityID;
|
|
$scope.searchData.Course = '';
|
|
$scope.searchData.Batch = '';
|
|
$scope.courseData = name.Course;
|
|
$scope.batchData = name.Batch;
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.getSearch();
|
|
};
|
|
|
|
$scope.getValueChange = function () {
|
|
$scope.getSearch();
|
|
}
|
|
|
|
$scope.searchResultDetails = '';
|
|
$scope.searchLoading = false;
|
|
$scope.searchResultLength = 0;
|
|
// get student list based on search data
|
|
$scope.getSearch = function () {
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.searchLoading = true;
|
|
var getSearchDetails = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getSearchAutoDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: $scope.searchData,
|
|
requestDetails: localDetails
|
|
}
|
|
};
|
|
$http(getSearchDetails).then(function (response) {
|
|
if (response.data.searchResult) {
|
|
$scope.searchResultStatus = response.data.searchResult;
|
|
$scope.searchLoading = false;
|
|
let searchResultDetailsBef = response.data.search_result_details;
|
|
const filterAddSelect = searchResultDetailsBef.filter(val => {
|
|
val['Selected'] = false;
|
|
return val;
|
|
});
|
|
$scope.searchResultDetails = filterAddSelect;
|
|
$scope.searchResultLength = Object.keys($scope.searchResultDetails).length;
|
|
} else {
|
|
$scope.searchLoading = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
// mobile number search functionlity
|
|
$scope.mySearchChangeFunc = function (val) {
|
|
if (val > 0) {
|
|
$scope.allSelectedHide = true;
|
|
$scope.allSelected('undefined');
|
|
$scope.OpenWindowStatus = false;
|
|
} else {
|
|
$scope.allSelected('undefined');
|
|
$scope.allSelectedHide = false;
|
|
}
|
|
}
|
|
// End: mobile number search functionlity
|
|
|
|
// select all or individual functionality
|
|
|
|
// var getAllSelected = function () {
|
|
// var selectedItems = $scope.searchResultDetails.filter(function (item) {
|
|
// return item.Selected;
|
|
// });
|
|
|
|
// return selectedItems.length === $scope.searchResultDetails.length;
|
|
// }
|
|
|
|
// var setAllSelected = function (value) {
|
|
// alert(value);
|
|
// angular.forEach($scope.searchResultDetails, function (item) {
|
|
// item.Selected = value;
|
|
// });
|
|
// }
|
|
|
|
// $scope.allSelected = function (value) {
|
|
// alert(value);
|
|
// if (value !== undefined) {
|
|
// return setAllSelected(value);
|
|
// } else {
|
|
// return getAllSelected();
|
|
// }
|
|
// }
|
|
|
|
//--------------------------------------------------->
|
|
|
|
// Select one row in a table once
|
|
$scope.setOneSelect = function (value) {
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = value;
|
|
});
|
|
value.Selected = true;
|
|
$scope.OpenWindowStatus = true;
|
|
$scope.openUpdateWind();
|
|
}
|
|
|
|
// End: select all or individual functionality
|
|
|
|
// unselect all the items
|
|
$scope.unSelect = function () {
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
$scope.openUpdateWind();
|
|
}
|
|
|
|
|
|
// open popup window onselct checkbox or close unselect all the items
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.openUpdateWind = function () {
|
|
var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
if (item.Selected === true) { return true; }
|
|
});
|
|
|
|
if (ItemsSelected.length !== 0) {
|
|
const courseLocal = ItemsSelected[0].CourseID;
|
|
const selectedStuId = ItemsSelected[0].StudentID;
|
|
$scope.getSemYearList(courseLocal, selectedStuId);
|
|
$scope.getStatusList();
|
|
$scope.OpenWindowStatus = true;
|
|
$scope.myStatusModel = {
|
|
'semYear': '',
|
|
'staus': '',
|
|
'dateOn': '',
|
|
'comment': '',
|
|
'certificatetype': '',
|
|
'certificateNumber': ''
|
|
}
|
|
} else {
|
|
$scope.OpenWindowStatus = false;
|
|
}
|
|
}
|
|
|
|
// get status list for this activity
|
|
$scope.getStatusList = function () {
|
|
var getStatusL = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getStatusListForUpdate/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
statusFor: 'studyMaterial',
|
|
data: localUpdateStatus
|
|
}
|
|
};
|
|
$http(getStatusL).then(function (response) {
|
|
if (response.data.statusList) {
|
|
$scope.statusDetailsList = response.data.statusList_details;
|
|
// $scope.searchLoading = false;
|
|
} else {
|
|
// $scope.searchLoading = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
// get Sem/Year based on the course select
|
|
$scope.getSemYearList = function (courseID, StuId) {
|
|
$scope.semYearList = '';
|
|
if (courseID !== '' && courseID !== undefined) {
|
|
var getSemYear = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getSemYearForCourse/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: courseID,
|
|
stuFor: StuId
|
|
}
|
|
};
|
|
$http(getSemYear).then(function (response) {
|
|
if (response.data.semYearResult) {
|
|
$scope.semYearList = response.data.semYear_result_details;
|
|
} else {
|
|
$scope.semYearList = '';
|
|
}
|
|
});
|
|
|
|
} else {
|
|
|
|
}
|
|
}
|
|
|
|
// Update the status For Certification
|
|
$scope.statusUpdate = {
|
|
submit: function (form, myStatusModel) {
|
|
var firstError = null;
|
|
if (form.$invalid) {
|
|
var field = null, firstError = null;
|
|
for (field in form) {
|
|
if (field[0] != '$') {
|
|
if (firstError === null && !form[field].$valid) {
|
|
firstError = form[field].$name;
|
|
}
|
|
if (form[field].$pristine) {
|
|
form[field].$dirty = true;
|
|
}
|
|
}
|
|
}
|
|
angular.element('.ng-invalid[name=' + firstError + ']').focus();
|
|
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
|
|
} else {
|
|
$scope.disableButton = true;
|
|
var studentForUpdate = [];
|
|
let formate = "dd-MM-yyyy";
|
|
$scope.myStatusModel.dateOn = $filter('date')(new Date($scope.myStatusModel.dateOn), formate);
|
|
var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
if (item.Selected === true) {
|
|
let getStudentID = new getStudentForUpdateDetails(item.StudentID);
|
|
studentForUpdate.push(getStudentID);
|
|
return true;
|
|
}
|
|
});
|
|
function getStudentForUpdateDetails(id) {
|
|
this.StudentID = id;
|
|
this.CourseID = $scope.myStatusModel.semYear;
|
|
this.BranchCode = localDetails.localBranchID;
|
|
this.ListCode = $scope.myStatusModel.staus;
|
|
this.SDate = $scope.myStatusModel.dateOn;
|
|
this.Coursedetail = id;
|
|
this.Comments = $scope.myStatusModel.comment;
|
|
this.CertificateType = $scope.myStatusModel.certificatetype;
|
|
this.CertificateNumber = $scope.myStatusModel.certificateNumber;
|
|
}
|
|
var updateCertificateStatus = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateCertificationStatus/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: studentForUpdate,
|
|
requestDetails: localDetails
|
|
}
|
|
};
|
|
$http(updateCertificateStatus).then(function (response) {
|
|
if (response.data.addStatus) {
|
|
swal("Success!", response.data.message, "success");
|
|
$scope.disableButton = false;
|
|
// for success state
|
|
// $scope.allSelected('undefined');
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
$scope.OpenWindowStatus = false;
|
|
} else {
|
|
swal("Failed!", response.data.message, "error");
|
|
$scope.disableButton = false;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
reset: function (form) {
|
|
form.$setPristine(true);
|
|
$scope.myStatusModel = {
|
|
'semYear': '',
|
|
'staus': '',
|
|
'dateOn': '',
|
|
'comment': '',
|
|
'certificatetype': '',
|
|
'certificateNumber': ''
|
|
}
|
|
}
|
|
}
|
|
|
|
// check unchek for table values
|
|
|
|
$scope.prevStatusListForStudentCourse = '';
|
|
// get previous status details for the student
|
|
$scope.getPrevStatus = function (p) {
|
|
$scope.prevStatusListForStudentCourseLoading = true;
|
|
$scope.prevStatusListForStudentCourseNoRecord = false;
|
|
$scope.prevStatusListForStudentCourse = '';
|
|
var getPrevStatus = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getPrevStatusDetailsForStu/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
statusFor: localUpdateStatus,
|
|
getDetailsFor: { "student": p.StudentID, "CourseID": p.CourseID },
|
|
data: localDetail
|
|
}
|
|
};
|
|
$http(getPrevStatus).then(function (response) {
|
|
if (response.data.preStatusDetails) {
|
|
$scope.prevStatusListForStudentCourseLoading = false;
|
|
$scope.prevStatusListForStudentCourse = response.data.preStatus_details_list;
|
|
$scope.prevNoRecordFound = false;
|
|
} else {
|
|
$scope.prevStatusListForStudentCourseLoading = false;
|
|
$scope.prevStatusListForStudentCourseNoRecord = true;
|
|
$scope.prevNoRecordFound = true;
|
|
}
|
|
});
|
|
}
|
|
}]);
|