371 lines
13 KiB
JavaScript
Executable File
371 lines
13 KiB
JavaScript
Executable File
'use strict';
|
|
/**
|
|
* daybook details capturing
|
|
*
|
|
*/
|
|
app.controller('daybooksuperadminapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window) {
|
|
|
|
// get local client details
|
|
var localDetail = JSON.parse(localStorage.getItem('localObj'));
|
|
var localDetails = ipCookie('cookiechk');
|
|
$scope.disableAddButton = false;
|
|
$scope.disableEditButton = false;
|
|
|
|
$scope.searchData = {
|
|
"date": "",
|
|
"dateTo": ""
|
|
}
|
|
|
|
$scope.viewStudentDetailsPage = false;
|
|
// load when html page load
|
|
$scope.init = function () {
|
|
if (localDetail != null) {
|
|
if (localDetails.localType === 'R004') {
|
|
$scope.getBranchList();
|
|
} else {
|
|
ipCookie.remove('cookiechk');
|
|
$window.localStorage.clear();
|
|
$state.go('login.signin');
|
|
}
|
|
} else {
|
|
}
|
|
}
|
|
|
|
|
|
$scope.getBranchList = function () {
|
|
$scope.loader = true;
|
|
var empListreq = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getBranchListDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: localDetails
|
|
}
|
|
};
|
|
$http(empListreq).then(function (response) {
|
|
if (response.data.branDetailstatus) {
|
|
$scope.loader = false;
|
|
$scope.branchList_data = response.data.branch_details;
|
|
} else {
|
|
}
|
|
});
|
|
}
|
|
|
|
$scope.changeBranch = function () {
|
|
$scope.viewStudentDetailsPage = false;
|
|
localDetails.localBranchID = $scope.localBranchDetails;
|
|
localDetail.localBranchID = $scope.localBranchDetails;
|
|
getDetails()
|
|
}
|
|
|
|
function getDetails() {
|
|
const LOCALTYPE = localDetail.localType;
|
|
if(LOCALTYPE === 'R004') {
|
|
$scope.currentDate = new Date();
|
|
var d = new Date();
|
|
$scope.oneMonthBefore = d.setMonth(d.getMonth()-1);
|
|
// alert($scope.oneMonthBefore);
|
|
var formate = "dd-MM-yyyy";
|
|
$scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), formate);
|
|
$scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate);
|
|
$scope.getDayBookList();
|
|
$scope.getIncomeExpenseType_Status();
|
|
$scope.viewStudentDetailsPage = true;
|
|
|
|
}else {
|
|
ipCookie.remove('cookiechk');
|
|
$window.localStorage.clear();
|
|
$state.go('login.signin');
|
|
}
|
|
}
|
|
$scope.dayBookApprovalAccess = '';
|
|
|
|
// Finance module access control
|
|
function getFinanceModuleAccess() {
|
|
var getFinacnceModuleAcccessCtrl = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'empDayBookModuleAccessChk/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
localReqDetails: localDetails
|
|
}
|
|
};
|
|
$http(getFinacnceModuleAcccessCtrl).then(function (response) {
|
|
if (response.data.dayBkAccessChkStatus) {
|
|
$scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value;
|
|
$scope.showTheRefValue = undefined;
|
|
$scope.localTypeViewAdmin = true;
|
|
$scope.currentDate = new Date();
|
|
var formate = "dd-MM-yyyy";
|
|
$scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate);
|
|
$scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate);
|
|
$scope.getIncomeExpenseType_Status();
|
|
$scope.getDayBookList();
|
|
return true;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
// change from date, update and call search functionality
|
|
$scope.changeDate = function () {
|
|
if($scope.searchData.date !== undefined) {
|
|
var formate = "dd-MM-yyyy";
|
|
$scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate);
|
|
$scope.getDayBookList();
|
|
} else {
|
|
$scope.searchData.date = '';
|
|
$scope.getDayBookList();
|
|
}
|
|
}
|
|
|
|
// change to date, update and call search functionality
|
|
$scope.changeToDate = function () {
|
|
if($scope.searchData.dateTo !== undefined) {
|
|
var formate = "dd-MM-yyyy";
|
|
$scope.searchData.dateTo = $filter('date')(new Date($scope.searchData.dateTo), formate);
|
|
$scope.getDayBookList();
|
|
} else {
|
|
$scope.searchData.dateTo = '';
|
|
$scope.getDayBookList();
|
|
}
|
|
}
|
|
|
|
// sorting function for table params
|
|
$scope.sort = function (keyname) {
|
|
// alert();
|
|
$scope.sortKey = keyname; //set the sortKey to the param passed
|
|
$scope.reverse = !$scope.reverse; //if true make it false and vice versa
|
|
}
|
|
|
|
// income expense type status list
|
|
$scope.getIncomeExpenseType_Status = function () {
|
|
var getIncomeExpenseType = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getIncomeExpenseTypeState/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
localReqDetails: localDetails
|
|
}
|
|
};
|
|
$http(getIncomeExpenseType).then(function (response) {
|
|
if (response.data.typeNameStatus) {
|
|
$scope.incomeExpenseName = response.data.typeList;
|
|
$scope.incomeExpenseType = response.data.typeNameList;
|
|
} else {
|
|
}
|
|
});
|
|
}
|
|
|
|
$scope.loadingsearch = false;
|
|
$scope.noRecordFound = true;
|
|
$scope.noRecordFoundSearch = false;
|
|
$scope.dataLengthIncome = 0;
|
|
$scope.dataLengthExpense = 0;
|
|
// day book entry list
|
|
$scope.getDayBookList = function () {
|
|
$scope.loadingsearch = true;
|
|
$scope.noRecordFoundSearch = false;
|
|
var getDatBookListDetails = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'getDayBookApprovalDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: $scope.searchData,
|
|
localReqDetails: localDetails,
|
|
}
|
|
};
|
|
$http(getDatBookListDetails).then(function (response) {
|
|
if (response.data.dayBookListStatus) {
|
|
$scope.loadingsearch = false;
|
|
// $scope.data = response.data.dayBookListDetails;
|
|
// $scope.datas = response.data.dayBookListDetails;
|
|
|
|
// const filterAddSelect = $scope.datas.filter(val => {
|
|
// val['Selected'] = false;
|
|
// return val;
|
|
// });
|
|
// $scope.searchResultDetails = filterAddSelect;
|
|
$scope.searchResultDetails = response.data.dayBookListDetails;
|
|
$scope.searchResultDetailsCopy = response.data.dayBookListDetails;
|
|
} else {
|
|
$scope.loadingsearch = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
// Select one row in a table once
|
|
$scope.setOneSelect = function (value) {
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
value.Selected = true;
|
|
$scope.OpenWindowStatus = true;
|
|
$scope.openUpdateWind();
|
|
}
|
|
|
|
$scope.unSelect = function () {
|
|
// alert(value.Selected);
|
|
angular.forEach($scope.searchResultDetails, function (item) {
|
|
item.Selected = false;
|
|
});
|
|
$scope.openUpdateWind();
|
|
}
|
|
|
|
$scope.myStatusModel = {
|
|
'staus': '',
|
|
'description': '',
|
|
'ID':''
|
|
}
|
|
|
|
|
|
$scope.editId = '';
|
|
$scope.updateStatus = function(p) {
|
|
$scope.editId = p.ORDER_ID;
|
|
$scope.myStatusModel.ID = p.ID;
|
|
}
|
|
|
|
$scope.updateStatusClose = function() {
|
|
$scope.editId = '';
|
|
$scope.myStatusModel = {
|
|
'staus': '',
|
|
'description': '',
|
|
'ID':''
|
|
}
|
|
}
|
|
|
|
|
|
// End: select all or individual functionality
|
|
|
|
$scope.OpenWindowStatus = false;
|
|
// open popup window when checkbox get selected / close popup window uncheck the selected items
|
|
$scope.openUpdateWind = function () {
|
|
var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
if (item.Selected === true) { return true; }
|
|
});
|
|
if (ItemsSelected.length) {
|
|
$scope.myStatusModel = {
|
|
'staus': '',
|
|
'description': '',
|
|
}
|
|
$scope.OpenWindowStatus = true;
|
|
} else {
|
|
$scope.OpenWindowStatus = false;
|
|
}
|
|
}
|
|
|
|
// update the status details
|
|
$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();
|
|
} else {
|
|
var selectedItems = [];
|
|
// var ItemsSelected = $scope.searchResultDetails.filter(function (item) {
|
|
// if (item.Selected === true && item.Status === 'Pending' ) {
|
|
// let itemGetID = new getUpdateDetails(item.ID);
|
|
// selectedItems.push(itemGetID);
|
|
// return true;
|
|
// }
|
|
// });
|
|
let itemGetID = new getUpdateDetails();
|
|
selectedItems.push(itemGetID);
|
|
function getUpdateDetails() {
|
|
this.dabookListId = $scope.myStatusModel.ID;
|
|
this.ListCodeStatus = $scope.myStatusModel.staus;
|
|
this.comments = $scope.myStatusModel.description;
|
|
}
|
|
if(selectedItems.length > 0) {
|
|
$scope.disableStatusUpdateButton = true;
|
|
var updateStudyMaterial = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'updateDayBookStatusAdmin/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
data: selectedItems,
|
|
requestDetails: localDetails
|
|
}
|
|
};
|
|
$http(updateStudyMaterial).then(function (response) {
|
|
if (response.data.addStatus) {
|
|
swal(" ", "Updated successfully,", "success");
|
|
// for success state
|
|
$scope.getDayBookList();
|
|
$scope.updateStatusClose();
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.disableStatusUpdateButton = false;
|
|
} else {
|
|
swal(" ", response.data.message, "error");
|
|
$scope.disableStatusUpdateButton = false;
|
|
}
|
|
});
|
|
} else {
|
|
swal(" ", "Item not Selected", "warning");
|
|
}
|
|
|
|
}
|
|
},
|
|
reset: function (form) {
|
|
form.$setPristine(true);
|
|
$scope.myStatusModel = {
|
|
'staus': '',
|
|
'description': '',
|
|
'ID':''
|
|
}
|
|
}
|
|
}
|
|
|
|
$scope.showTheResType = function (type) {
|
|
// alert(type);
|
|
if (type == undefined) {
|
|
$scope.searchResultDetails = $scope.searchResultDetailsCopy;
|
|
} else {
|
|
$scope.searchResultDetails = $scope.searchResultDetailsCopy.filter(val => {
|
|
return val.Name == type ? 1 : 0;
|
|
})
|
|
}
|
|
|
|
// const filterAddSelect = $scope.searchResultDetails.filter(val => {
|
|
|
|
// });
|
|
}
|
|
|
|
$scope.statusList = [{
|
|
"status_id": 'TS001',
|
|
"name": "Pending",
|
|
}, {
|
|
"status_id": 'TS002',
|
|
"name": "Approved",
|
|
}, {
|
|
"status_id": 'TS003',
|
|
"name": "Rejected",
|
|
}];
|
|
|
|
}]);
|
|
|
|
|