diff --git a/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js b/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js index 720328fa..5ef2149d 100644 --- a/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js +++ b/Apollo/assets/js/controllers/daybookadminapprovalCtrl.js @@ -23,11 +23,13 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " // getFinanceModuleAccess(); // // if(getFinanceModuleAccess()){ $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); + var d = new Date(); + $scope.oneMonthBefore = d.setMonth(d.getMonth()-1); var formate = "dd-MM-yyyy"; - $scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate); + $scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), formate); $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); $scope.getIncomeExpenseType_Status(); $scope.getDayBookList(); @@ -35,16 +37,7 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " } else { ipCookie.remove('cookiechk'); $window.localStorage.clear(); - $state.go('login.signin'); - // $scope.localTypeViewSuperAdmin = true; - // $scope.showTheRefValue = 'I001'; - // $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(); + $state.go('login.signin'); } } @@ -65,7 +58,7 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " $http(getFinacnceModuleAcccessCtrl).then(function (response) { if (response.data.dayBkAccessChkStatus) { $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); var formate = "dd-MM-yyyy"; @@ -81,8 +74,6 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " } - - // change from date, update and call search functionality $scope.changeDate = function () { if($scope.searchData.date !== undefined) { @@ -107,14 +98,14 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " } } - // sorting function for table params + // 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 + // income expense type status list $scope.getIncomeExpenseType_Status = function () { var getIncomeExpenseType = { method: 'POST', @@ -135,12 +126,12 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " }); } - $scope.loadingsearch = false; + $scope.loadingsearch = false; $scope.noRecordFound = true; $scope.noRecordFoundSearch = false; - $scope.dataLengthIncome = 0; - $scope.dataLengthExpense = 0; - // day book entry list + $scope.dataLengthIncome = 0; + $scope.dataLengthExpense = 0; + // day book entry list $scope.getDayBookList = function () { $scope.loadingsearch = true; $scope.noRecordFoundSearch = false; @@ -157,68 +148,23 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " }; $http(getDatBookListDetails).then(function (response) { if (response.data.dayBookListStatus) { - $scope.loadingsearch = false; + $scope.loadingsearch = false; // $scope.data = response.data.dayBookListDetails; - let datas = response.data.dayBookListDetails; - if (datas.length <= 0) { - $scope.noRecordFoundSearch = true; - } else { - $scope.noRecordFoundSearch = false; - } - let searchResultDetailsBef = datas.filter(val => { - return val.Name == 'I001' ? 1 : 0; - }); - $scope.IncomeData = datas.filter(val => { - return val.Name == 'I002' ? 1 : 0; - }); - $scope.dataLengthIncome = $scope.IncomeData.length; - const filterAddSelect = searchResultDetailsBef.filter(val => { + $scope.datas = response.data.dayBookListDetails; + + const filterAddSelect = $scope.datas.filter(val => { val['Selected'] = false; return val; }); $scope.searchResultDetails = filterAddSelect; - $scope.dataLengthExpense = $scope.searchResultDetails.length; - // alert(JSON.stringify($scope.searchResultDetails)); - $scope.searchResultLength = Object.keys($scope.searchResultDetails).length; - // if ($scope.data.length !== 0) { - // $scope.OpenWindowStatus = false; - // $scope.noRecordFound = false; - // } else { - // $scope.OpenWindowStatus = false; - // $scope.noRecordFound = true; - // } - // alert(JSON.stringify($scope.data)); - // $scope.incomeExpenseType = response.data.typeNameList; + $scope.searchResultDetailsCopy = filterAddSelect; } else { - $scope.loadingsearch = false; + $scope.loadingsearch = false; } }); } - // 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) { - // angular.forEach($scope.searchResultDetails, function (item) { - // item.Selected = value; - // }); - // } - - // $scope.allSelected = function (value) { - // if (value !== undefined) { - // return setAllSelected(value); - // } else { - // return getAllSelected(); - // } - // } - - // Select one row in a table once + // Select one row in a table once $scope.setOneSelect = function (value) { angular.forEach($scope.searchResultDetails, function (item) { item.Selected = false; @@ -227,7 +173,15 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " $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': '', @@ -241,9 +195,7 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " var ItemsSelected = $scope.searchResultDetails.filter(function (item) { if (item.Selected === true) { return true; } }); - // $scope.getStatusList(); - // alert(ItemsSelected.length); - if (ItemsSelected.length) { + if (ItemsSelected.length) { $scope.myStatusModel = { 'staus': '', 'description': '', @@ -271,8 +223,7 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " } } 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 { + } else { var selectedItems = []; var ItemsSelected = $scope.searchResultDetails.filter(function (item) { if (item.Selected === true && item.Status === 'Pending' ) { @@ -303,6 +254,11 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " swal(" ", "Updated successfully,", "success"); // for success state $scope.getDayBookList(); + $scope.unSelect(); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } $scope.allSelected('undefined'); $scope.OpenWindowStatus = false; } else { @@ -324,7 +280,20 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " } } - + $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', @@ -337,263 +306,6 @@ app.controller('daybookadminapprovalCtrl', ["$scope", "$rootScope", "toaster", " "name": "Rejected", }]; - $scope.data = [{ - "id": 1, - "date": "20-12-2017", - "incomeExpense": "Income", - "type": "typeIncome1", - "amount": "1000", - "status": "Pending", - "description": "income type income type income type" - }, { - "id": 2, - "date": "20-12-2017", - "incomeExpense": "Expense", - "type": "typeIncome2", - "amount": "2000", - "status": "Pending", - "description": "income type income type income type" - }, { - "id": 3, - "date": "20-12-2017", - "incomeExpense": "Expense", - "type": "typeIncome3", - "amount": "3000", - "status": "Pending", - "description": "income type income type income type" - }]; - - $scope.incomeExpenseType = [{ - "type_id": 1, - "type": "Income", - "name": "fees" - }, { - "type_id": 2, - "type": "Expense", - "name": "food" - }, { - "type_id": 3, - "type": "Expense", - "name": "phone" - }, { - "type_id": 4, - "type": "Expense", - "name": "tea-coffee" - }, { - "type_id": 5, - "type": "Expense", - "name": "Paper" - }]; - - $scope.getIncomeExpense = function () { - $scope.incomeExpenseName = [{ - "type_id": 1, - "type": "TYPE001", - "name": "Income" - }, { - "type_id": 2, - "type": "TYPE002", - "name": "Expense" - }]; - - } - - $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { - return val.type === 'Income' ? 1 : 0; - }); - $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { - return val.type === 'Expense' ? 1 : 0; - }); - - $scope.getType = function (type) { - // alert(type); - $scope.myModelAdd.type = ''; - $scope.getTypes = type === 'Income' ? $scope.getIncomeTypes : $scope.getExpenseTypes; - }; - - $scope.editId = -1; - $scope.setEditId = function (P) { - // alert(id); - $scope.editId = P; - } - - $scope.editClose = function () { - $scope.editId = -1; - $scope.myModel = { - "id": "", - "date": "", - "incomeExpense": "", - "type": "", - "amount": "", - "status": "", - "description": "" - } - } - - $scope.myModel = { - "id": "", - "date": "", - "incomeExpense": "", - "type": "", - "amount": "", - "status": "", - "description": "" - } - - $scope.copyModel = function (p) { - $scope.myModel = { - "id": p.id, - "date": p.date, - "incomeExpense": p.incomeExpense, - "type": p.type, - "amount": p.amount, - "status": p.status, - "description": p.description - } - } - - // delete the entry row from the daybook list - $scope.deleEditEntry = function (id) { - swal({ - title: "Are you sure?", - text: "Your will not be able to recover this record!", - type: "warning", - showCancelButton: true, - confirmButtonClass: "btn-danger", - confirmButtonText: "Yes, delete it!", - closeOnConfirm: false - }, - function () { - $scope.indexDelete2(); - // if( $scope.indexDelete2() === true) { - // $scope.data; - // swal("Deleted!", "Your imaginary file has been deleted.", "success"); - // } - }); - $scope.indexDelete2 = function () { - let ans = $scope.data.some(function (val, i) { - if (val.id === id) { - $scope.data.splice(i, 1); - swal("Deleted!", "Your record has been deleted.", "success"); - return true; - } - }); return ans; - } - - } - - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "" - } - - // add a new entry to the day book list - $scope.daybookAdd = { - submit: function (form, myModelAdd) { - 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 { - var formate = "dd-MM-yyyy"; - $scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); - $scope.myModelAdd.status = 'Pending'; - $scope.data.push(myModelAdd); - } - } - } - - // update daybook entry data from the list - $scope.daybookeditUpdate = { - submit: function (form, myModel) { - 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 { - // 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; - // } - // // alert(JSON.stringify($scope.myStatusModel)); - // // alert(JSON.stringify(studentForUpdate)); - - // var updateStudyMaterial = { - // method: 'POST', - // url: apiPoint.url + 'updateStudentMaterialStatus/', - // headers: { - // 'Content-Type': 'application/json' - // }, - // data: { - // data: studentForUpdate, - // requestDetails : localDetails - // } - // }; - // $http(updateStudyMaterial).then(function (response) { - // if (response.data.addStatus) { - // swal("Success!", response.data.message, "success"); - // // for success state - // $scope.allSelected('undefined'); - // $scope.OpenWindowStatus = false; - // } else { - // swal("Failed!", response.data.message, "error"); - // } - // }); - } - }, - // reset: function (form) { - // form.$setPristine(true); - // $scope.myStatusModel = { - // 'semYear': '', - // 'staus': '', - // 'dateOn': '', - // 'comment': '' - // } - // } - } - }]); diff --git a/Apollo/assets/js/controllers/daybookapprovalCtrl.js b/Apollo/assets/js/controllers/daybookapprovalCtrl.js index 1f96ef10..55276d5f 100644 --- a/Apollo/assets/js/controllers/daybookapprovalCtrl.js +++ b/Apollo/assets/js/controllers/daybookapprovalCtrl.js @@ -23,7 +23,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt // getFinanceModuleAccess(); // // if(getFinanceModuleAccess()){ $scope.dayBookApprovalAccess = localDetail.is_DayBookApproval_Access; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); var d = new Date(); @@ -58,7 +58,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt $http(getFinacnceModuleAcccessCtrl).then(function (response) { if (response.data.dayBkAccessChkStatus) { $scope.dayBookApprovalAccess = response.data.dayBkAccessChk_Value; - $scope.showTheRefValue = 'I001'; + $scope.showTheRefValue = undefined; $scope.localTypeViewAdmin = true; $scope.currentDate = new Date(); var formate = "dd-MM-yyyy"; @@ -157,6 +157,7 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt return val; }); $scope.searchResultDetails = filterAddSelect; + $scope.searchResultDetailsCopy = filterAddSelect; } else { $scope.loadingsearch = false; } @@ -173,6 +174,14 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt $scope.openUpdateWind(); } + $scope.unSelect = function () { + // alert(value.Selected); + angular.forEach($scope.searchResultDetails, function (item) { + item.Selected = false; + }); + $scope.openUpdateWind(); + } + $scope.myStatusModel = { 'staus': '', 'description': '', @@ -245,6 +254,11 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt swal(" ", "Updated successfully,", "success"); // for success state $scope.getDayBookList(); + $scope.unSelect(); + $scope.myStatusModel = { + 'staus': '', + 'description': '', + } $scope.allSelected('undefined'); $scope.OpenWindowStatus = false; } else { @@ -266,7 +280,16 @@ app.controller('daybookapprovalCtrl', ["$scope", "$rootScope", "toaster", "$filt } } - $scope.showTheResType = function(type){ + $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 => { // }); diff --git a/Apollo/assets/views/daybook/dayBookApproval.html b/Apollo/assets/views/daybook/dayBookApproval.html index e37b0f18..9d20930f 100644 --- a/Apollo/assets/views/daybook/dayBookApproval.html +++ b/Apollo/assets/views/daybook/dayBookApproval.html @@ -75,7 +75,7 @@ Type is Required @@ -276,6 +276,7 @@