diff --git a/Apollo/assets/js/controllers/daybookCtrl1.js b/Apollo/assets/js/controllers/daybookCtrl1.js deleted file mode 100755 index 5ba72834..00000000 --- a/Apollo/assets/js/controllers/daybookCtrl1.js +++ /dev/null @@ -1,777 +0,0 @@ -'use strict'; -/** - * daybook details capturing - * - */ -app.controller('daybookCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window','SweetAlert', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window, SweetAlert) { - - // 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": "" - } - - // get the data while page loading functions goes here - $scope.init = function () { - $scope.todayDate = new Date(); - const LOCALTYPE = localDetail.localType; - if(LOCALTYPE === 'R002' || LOCALTYPE == 'R005') { - $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(); - - }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.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.getDayBookList(); - $scope.getIncomeExpenseType_Status(); - return true; - } else { - return true; - } - }); - - } - - // $scope.getApproveLoad = function() { - // alert(); - // } - - // 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) { - $scope.sortKey = keyname; //set the sortKey to the param passed - $scope.reverse = !$scope.reverse; //if true make it false and vice versa - } - - $scope.noRecordFound = true; - $scope.dataLength = 0; - // get day book type name list - $scope.getDayBookList = function () { - var getDatBookListDetails = { - method: 'POST', - url: apiPoint.url + 'getDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.searchData, - localReqDetails: localDetails, - } - }; - $http(getDatBookListDetails).then(function (response) { - if (response.data.dayBookListStatus) { - - $scope.data = response.data.dayBookListDetails; - $scope.datas = response.data.dayBookListDetails; - $scope.dataLength = $scope.data.length; - if ($scope.data.length !== 0) { - $scope.noRecordFound = false; - } else { - $scope.noRecordFound = true; - } - // alert(JSON.stringify($scope.data)); - // $scope.incomeExpenseType = response.data.typeNameList; - } else { - - } - }); - } - - //print PDF -------- START ============================================================================== - - var rows1 = ''; - - $scope.paymentOptions = [ - { - "paymentOn": "CASH" - }, - { - "paymentOn": "CHEQUE" - }, - { - "paymentOn": "REFERRAL" - }, - { - "paymentOn": "ONLINE TRANSACTION" - }, - { - "paymentOn": "WAIVER" - }, - { - "paymentOn": "Credit/Debit Card" - } - - ]; - - function getSortCutModeofPayment(type) { - var sortCutName = ''; - switch (type) { - case 'CASH': - sortCutName = 'CH'; - break; - case 'CHEQUE': - sortCutName = 'CHQ'; - break; - case 'REFERRAL': - sortCutName = 'REF'; - break; - case 'ONLINE TRANSACTION': - sortCutName = 'ONL'; - break; - case 'WAIVER': - sortCutName = 'WAI'; - break; - case 'Credit/Debit Card': - sortCutName = 'CARD'; - break; - default: - sortCutName = type; - } - return sortCutName; - } - - - $scope.generatePFD = function (datas) { - $scope.loadStaring = true; - // daybookDetails.generatePFD(datas,$scope.searchData.date, $scope.searchData.dateTo); - - var o = {}; - var intDataSNo = 1; - var intDate = 0; - // var arrForeach = datas.reverse(); - // for() - // var ememem = datas[7-1]; - // alert(ememem.VoucherNumber); - for(var i = datas.length ; i > 0; --i){ - var element = datas[i-1]; - var value = {}; - value['SNo'] = intDataSNo; - value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - var ListName = element.ListName; - value['PaidReceivedToFrom'] = element.PaidTo || '-'; - var Sem = element.FeePaymentDetails || '-'; - var Course = element.CourseName || '-'; - var University = element.UniversityName || '-'; - value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - value['Type'] = element.TypeName || '-'; - value['ReceiptNo'] = element.ReceiptNo || '-'; - value['Comments'] = element.ReceiptNoComments || '-'; - value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - value['Status'] = element.Status || '-'; - value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - value['Balance'] = element.Balance || '-'; - o[intDate] = value; - intDate++; - intDataSNo++; - } - // alert(JSON.stringify(o)); - // arrForeach.forEach(function (element) { - // var value = {}; - // value['SNo'] = intDataSNo; - // value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - // var ListName = element.ListName; - // value['PaidReceivedToFrom'] = element.PaidTo || '-'; - // var Sem = element.FeePaymentDetails || '-'; - // var Course = element.CourseName || '-'; - // var University = element.UniversityName || '-'; - // value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - // value['Type'] = element.TypeName || '-'; - // value['ReceiptNo'] = element.ReceiptNo || '-'; - // value['Comments'] = element.ReceiptNoComments || '-'; - // value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - // value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - // value['Balance'] = element.Balance || '-'; - // o[intDate] = value; - // intDate++; - // intDataSNo++; - // }); - rows1 = o; - var headers = { - fila_1: { - col_1: { text: 'SNo', style: 'tableHeader', alignment: 'center', bold: true }, - col_2: { text: 'Voucher Number Bill Number / DATE', style: 'tableHeader', alignment: 'center', bold: true }, - col_3: { text: 'Paid To Received From', style: 'tableHeader', alignment: 'center', bold: true }, - col_4: { text: 'University / Course/ Sem', style: 'tableHeader', alignment: 'center', bold: true }, - col_5: { text: 'Type', style: 'tableHeader', alignment: 'center', bold: true }, - col_6: { text: 'Receipt No', style: 'tableHeader', alignment: 'center', bold: true }, - col_7: { text: 'Comments', style: 'tableHeader', alignment: 'center', bold: true }, - col_8: { text: 'Mode of Payment', style: 'tableHeader', alignment: 'center', bold: true }, - col_9: { text: 'Status', style: 'tableHeader', alignment: 'center', bold: true }, - col_10: { text: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, - col_11: { text: 'Balance', style: 'tableHeader', alignment: 'center', bold: true }, - } - } - var body = []; - for (var key in headers) { - if (headers.hasOwnProperty(key)) { - var header = headers[key]; - var row = new Array(); - row.push(header.col_1); - row.push(header.col_2); - row.push(header.col_3); - row.push(header.col_4); - row.push(header.col_5); - row.push(header.col_6); - row.push(header.col_7); - row.push(header.col_8); - row.push(header.col_9); - row.push(header.col_10); - row.push(header.col_11); - body.push(row); - } - } - for (var key in rows1) { - if (rows1.hasOwnProperty(key)) { - var data = rows1[key]; - var row = new Array(); - row.push(data.SNo.toString()); - row.push(data.Date.toString()); - row.push(data.PaidReceivedToFrom.toString()); - row.push(data.UnivCourseSem.toString()); - row.push(data.Type.toString()); - row.push(data.ReceiptNo.toString()); - row.push(data.Comments.toString()); - row.push(data.ModeofPayment.toString()); - row.push(data.Status.toString()); - row.push(data.Amount.toString()); - row.push(data.Balance.toString()); - body.push(row); - } - } - - - var docDefinition = { - pageMargins: [20, 85, 20, 50], - pageOrientation: 'landscape', - header: function () { - return { - margin: 0, - columns: [ - { - text: ['DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' )'], - alignment: 'left', bold: true, margin: [20, 30, 0, 0], fontSize: 18 - } - ] - } - }, - footer: function (currentPage, pageCount) { - if (currentPage === pageCount) { - return { - columns: [ - { - text: ['Note :' + '\n\t\t\t\t\t\t CH-CASH, CHQ-CHEQUE, REF-REFERRAL, ONL-ONLINE TRANSACTION, WAI-WAIVER, CARD-Credit/Debit Card'], - alignment: 'left', margin: [10, 0, 0, 0], fontSize: 8 - }, - { text: ['\n Page ' + currentPage.toString() + ' of ' + pageCount], alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 } - ] - }; - } else { - return { - text: 'Page ' + currentPage.toString() + ' of ' + pageCount, alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 - }; - } - }, - content: [ - { - // layout: 'lightHorizontalLines', // optional - table: { - // headers are automatically repeated if the table spans over multiple pages - // you can declare how many rows should be treated as headers - // headerRows: 1, - // widths: [ '40', '40', '40', '40', '40'], - headerRows: 1, - keepWithHeaderRows: 0, - body: body - }, - layout: { - hLineWidth: function (i, node) { - return 0.5; - }, - vLineWidth: function (i, node) { - // return (i === 0 || i === node.table.widths.length) ? 0 : 40; - return 0.5; - }, - hLineColor: function (i, node) { - return '#2D4D81'; - }, - vLineColor: function (i, node) { - return '#2D4D81'; - }, - } - } - ], - styles: { - header: { - fontSize: 12, - bold: true - }, - subheader: { - fontSize: 12, - bold: true - }, - quote: { - italics: true - }, - small: { - fontSize: 6 - }, - sta: { - fontSize: 8, - bold: false, - alignment: 'justify' - } - } - }; - - // alert(JSON.stringify(rows1)); - // pdfMake.createPdf(docDefinition).download('file.pdf', () => { - // console.log("success"); - // }); - // alert(JSON.stringify(rows1)); - // var returndata = pdfMake.createPdf(docDefinition).download('DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' ).pdf', function(){ - // return true; - // }); - // if(returndata){ - // $scope.loadStaring = false; - // } - - pdfMake.createPdf(docDefinition).download('DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' ).pdf', function(res) { - if(res === 'success'){ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - }else{ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - } - }); - } - - - - // print PDF-------- END ============================================================================== - - - - // 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 { - } - }); - } - - // parse the income and expense type from the list - $scope.getType = function (type) { - $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { - return val.TypeID === 'I002' ? 1 : 0; - }); - $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { - return val.TypeID === 'I001' ? 1 : 0; - }); - $scope.myModelAdd.type = ''; - $scope.getTypes = type === 'I002' ? $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": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch":"", - "name":"" - } - } - - $scope.myModel = { - "id": "", - "date": "", - "incomeExpense": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch": "", - "name":"" - } - - $scope.copyModel = function (p) { - - var inc = $scope.incomeExpenseType.filter((inc)=>inc.ID == p.Type); - $scope.incexp = inc[0]; - - $scope.myModel = { - "id": p.ID, - "date": p.Date, - "incomeExpense": p.Name, - "type":$scope.incexp.ID, - "amount": p.Amount, - "status": p.Status, - "description": p.Description, - "paidTo": p.PaidTo, - "description_paid": p.PaidDescription, - "voucherNumber": p.VoucherNumber, - "branch":p.BranchCode, - "name": p.Name - } - // alert(JSON.stringify($scope.myModel)); - } - - $scope.deleted1 = function (id) { - - var id=id; - var reason=prompt("Reason For Deletion!",""); - - if(reason !=null) - { - $scope.deleteFeePayableEntry(reason, id); - } - - else - { - //alert('check') - } - - ///$scope.deleteFeePayableEntry(reason,id); - } - //delete the income entry From the fees payable - $scope.deleteFeePayableEntry = function (reason, id) { - // alert(id); - SweetAlert.swal({ - title: "Warning!", - text: "Do you want to Delete this Entry ?", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#007aff", - confirmButtonText: "Yes!" - }, function (res) { - if (res === true) { - // alert(id); - // alert(stuId); - if(reason == '') - { - - alert('Please Enter Reason for Deletion'); - return false; - } - else{ - - - - var deleteFeePayableDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookFeePayableDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason:reason, - data: id, - requestDetails: localDetails - } - }; - $http(deleteFeePayableDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - } - } - }); - } - - $scope.deleted = function (id) { - - var id=id; - var a=prompt("Enter Reason!",""); - $scope.deleEditEntry(a,id); - - - - } - - // delete the income/expense list row - $scope.deleEditEntry = function (a, 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(a, id); - }); - $scope.indexDelete2 = function (a, id) { - var deleteDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason: a, - data: id, - requestDetails: localDetails - } - }; - $http(deleteDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - } - } - - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - - // add a new daybook entry - $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 { - $scope.disableAddButton = true; - var sdate= $('#date').val(); - var formate = "dd-MM-yyyy"; - $scope.myModelAdd.date= sdate; - //$scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); - $scope.myModelAdd.status = $scope.myModelAdd.name == 'I001' ? 'Pending' : 'Approved'; - // $scope.data.push(myModelAdd); - - var addDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'addDayBook/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: myModelAdd, - localReqDetails: localDetails - } - }; - $http(addDayBookDetails).then(function (response) { - if (response.data.addDayBookStatus) { - swal(" ", "Income/Expense added successfully.", "success"); - $state.go($state.current, {}, { reload: true }); - $scope.disableAddButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableAddButton = false; - } - }); - } - }, - reset: function (form) { - form.$setPristine(true); - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - } - } - - // update a daybook entry details - $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 { - // alert(JSON.stringify($scope.myModel));exit(); - $scope.disableEditButton = true; - var updateDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'updateDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.myModel, - requestDetails: localDetails - } - }; - $http(updateDayBookDetails).then(function (response) { - if (response.data.updateDetailsStatus) { - swal(" ","Updated successfully.", "success"); - // for success state - $scope.editId = -1; - $scope.getDayBookList(); - $scope.disableEditButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableEditButton = false; - } - }); - } - } - } - function styleXl(){ - var mystyle = { - sheetid: 'DAYBOOK DETAILS', - headers: true, - caption: { - title:'DAYBOOK DETAILS'+ '('+ $scope.searchData.date + ' - ' + $scope.searchData.dateTo +')', - width: '300px', - style:'font-size:50px;color:blue;' - }, - // style:'background:#00FF00', - column: { - style:'font-size:25px; color:blue;' - } - }; - return mystyle; - } - - $scope.exportData = function () { - - alasql('SELECT Date as Date, ListName as IncomeExpense, VoucherNumber as VoucherNumberBillNumber, PaidTo as PaidToReceivedFrom,FeePaymentDetails as Sem, CourseName as Course,UniversityName as University,TypeName as Type, ReceiptNo as Receipt_No, ReceiptNoComments as Comments, ModeOfPayment as Mode_of_Payment,Amount as Amount,Balance as Balance, Reason, Activity INTO XLS("daybook_details.xls",?) FROM ?',[styleXl(),$scope.data]); - }; - - - -}]); - - diff --git a/Apollo/assets/js/controllers/daybookadminCtrl1.js b/Apollo/assets/js/controllers/daybookadminCtrl1.js deleted file mode 100755 index e970fad7..00000000 --- a/Apollo/assets/js/controllers/daybookadminCtrl1.js +++ /dev/null @@ -1,763 +0,0 @@ -'use strict'; -/** - * daybook details capturing - * - */ -app.controller('daybookadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window','SweetAlert', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window, SweetAlert) { - - // 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": "" - } - - // get the data while page loading functions goes here - $scope.init = function () { - $scope.todayDate = new Date(); - const LOCALTYPE = localDetail.localType; - if(LOCALTYPE === 'R003') { - $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(); - - }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.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.getDayBookList(); - $scope.getIncomeExpenseType_Status(); - return true; - } else { - return true; - } - }); - } - - // $scope.getApproveLoad = function() { - // alert(); - // } - - // 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) { - $scope.sortKey = keyname; //set the sortKey to the param passed - $scope.reverse = !$scope.reverse; //if true make it false and vice versa - } - - $scope.noRecordFound = true; - $scope.dataLength = 0; - // get day book type name list - $scope.getDayBookList = function () { - var getDatBookListDetails = { - method: 'POST', - url: apiPoint.url + 'getDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.searchData, - localReqDetails: localDetails, - } - }; - $http(getDatBookListDetails).then(function (response) { - if (response.data.dayBookListStatus) { - - $scope.data = response.data.dayBookListDetails; - $scope.datas = response.data.dayBookListDetails; - $scope.dataLength = $scope.data.length; - if ($scope.data.length !== 0) { - $scope.noRecordFound = false; - } else { - $scope.noRecordFound = true; - } - // alert(JSON.stringify($scope.data)); - // $scope.incomeExpenseType = response.data.typeNameList; - } else { - - } - }); - } - - - //print PDF -------- START ============================================================================== - - var rows1 = ''; - - $scope.paymentOptions = [ - { - "paymentOn": "CASH" - }, - { - "paymentOn": "CHEQUE" - }, - { - "paymentOn": "REFERRAL" - }, - { - "paymentOn": "ONLINE TRANSACTION" - }, - { - "paymentOn": "WAIVER" - }, - { - "paymentOn": "Credit/Debit Card" - } - - ]; - - function getSortCutModeofPayment(type) { - var sortCutName = ''; - switch (type) { - case 'CASH': - sortCutName = 'CH'; - break; - case 'CHEQUE': - sortCutName = 'CHQ'; - break; - case 'REFERRAL': - sortCutName = 'REF'; - break; - case 'ONLINE TRANSACTION': - sortCutName = 'ONL'; - break; - case 'WAIVER': - sortCutName = 'WAI'; - break; - case 'Credit/Debit Card': - sortCutName = 'CARD'; - break; - default: - sortCutName = type; - } - return sortCutName; - } - - - $scope.generatePFD = function (datas) { - $scope.loadStaring = true; - - // daybookDetails.generatePFD(datas,$scope.searchData.date, $scope.searchData.dateTo); - - var o = {}; - var intDataSNo = 1; - var intDate = 0; - // var arrForeach = datas.reverse(); - // for() - // var ememem = datas[7-1]; - // alert(ememem.VoucherNumber); - for(var i = datas.length ; i > 0; --i){ - var element = datas[i-1]; - var value = {}; - value['SNo'] = intDataSNo; - value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - var ListName = element.ListName; - value['PaidReceivedToFrom'] = element.PaidTo || '-'; - var Sem = element.FeePaymentDetails || '-'; - var Course = element.CourseName || '-'; - var University = element.UniversityName || '-'; - value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - value['Type'] = element.TypeName || '-'; - value['ReceiptNo'] = element.ReceiptNo || '-'; - value['Comments'] = element.ReceiptNoComments || '-'; - value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - value['Status'] = element.Status || '-'; - value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - value['Balance'] = element.Balance || '-'; - o[intDate] = value; - intDate++; - intDataSNo++; - } - // alert(JSON.stringify(o)); - // arrForeach.forEach(function (element) { - // var value = {}; - // value['SNo'] = intDataSNo; - // value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - // var ListName = element.ListName; - // value['PaidReceivedToFrom'] = element.PaidTo || '-'; - // var Sem = element.FeePaymentDetails || '-'; - // var Course = element.CourseName || '-'; - // var University = element.UniversityName || '-'; - // value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - // value['Type'] = element.TypeName || '-'; - // value['ReceiptNo'] = element.ReceiptNo || '-'; - // value['Comments'] = element.ReceiptNoComments || '-'; - // value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - // value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - // value['Balance'] = element.Balance || '-'; - // o[intDate] = value; - // intDate++; - // intDataSNo++; - // }); - rows1 = o; - var headers = { - fila_1: { - col_1: { text: 'SNo', style: 'tableHeader', alignment: 'center', bold: true }, - col_2: { text: 'Voucher Number Bill Number / DATE', style: 'tableHeader', alignment: 'center', bold: true }, - col_3: { text: 'Paid To Received From', style: 'tableHeader', alignment: 'center', bold: true }, - col_4: { text: 'University / Course/ Sem', style: 'tableHeader', alignment: 'center', bold: true }, - col_5: { text: 'Type', style: 'tableHeader', alignment: 'center', bold: true }, - col_6: { text: 'Receipt No', style: 'tableHeader', alignment: 'center', bold: true }, - col_7: { text: 'Comments', style: 'tableHeader', alignment: 'center', bold: true }, - col_8: { text: 'Mode of Payment', style: 'tableHeader', alignment: 'center', bold: true }, - col_9: { text: 'Status', style: 'tableHeader', alignment: 'center', bold: true }, - col_10: { text: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, - col_11: { text: 'Balance', style: 'tableHeader', alignment: 'center', bold: true }, - } - } - var body = []; - for (var key in headers) { - if (headers.hasOwnProperty(key)) { - var header = headers[key]; - var row = new Array(); - row.push(header.col_1); - row.push(header.col_2); - row.push(header.col_3); - row.push(header.col_4); - row.push(header.col_5); - row.push(header.col_6); - row.push(header.col_7); - row.push(header.col_8); - row.push(header.col_9); - row.push(header.col_10); - row.push(header.col_11); - body.push(row); - } - } - for (var key in rows1) { - if (rows1.hasOwnProperty(key)) { - var data = rows1[key]; - var row = new Array(); - row.push(data.SNo.toString()); - row.push(data.Date.toString()); - row.push(data.PaidReceivedToFrom.toString()); - row.push(data.UnivCourseSem.toString()); - row.push(data.Type.toString()); - row.push(data.ReceiptNo.toString()); - row.push(data.Comments.toString()); - row.push(data.ModeofPayment.toString()); - row.push(data.Status.toString()); - row.push(data.Amount.toString()); - row.push(data.Balance.toString()); - body.push(row); - } - } - - - var docDefinition = { - pageMargins: [20, 85, 20, 50], - pageOrientation: 'landscape', - header: function () { - return { - margin: 0, - columns: [ - { - text: ['DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' )'], - alignment: 'left', bold: true, margin: [20, 30, 0, 0], fontSize: 18 - } - ] - } - }, - footer: function (currentPage, pageCount) { - if (currentPage === pageCount) { - return { - columns: [ - { - text: ['Note :' + '\n\t\t\t\t\t\t CH-CASH, CHQ-CHEQUE, REF-REFERRAL, ONL-ONLINE TRANSACTION, WAI-WAIVER, CARD-Credit/Debit Card'], - alignment: 'left', margin: [10, 0, 0, 0], fontSize: 8 - }, - { text: ['\n Page ' + currentPage.toString() + ' of ' + pageCount], alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 } - ] - }; - } else { - return { - text: 'Page ' + currentPage.toString() + ' of ' + pageCount, alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 - }; - } - }, - content: [ - { - // layout: 'lightHorizontalLines', // optional - table: { - // headers are automatically repeated if the table spans over multiple pages - // you can declare how many rows should be treated as headers - // headerRows: 1, - // widths: [ '40', '40', '40', '40', '40'], - headerRows: 1, - keepWithHeaderRows: 0, - body: body - }, - layout: { - hLineWidth: function (i, node) { - return 0.5; - }, - vLineWidth: function (i, node) { - // return (i === 0 || i === node.table.widths.length) ? 0 : 40; - return 0.5; - }, - hLineColor: function (i, node) { - return '#2D4D81'; - }, - vLineColor: function (i, node) { - return '#2D4D81'; - }, - } - } - ], - styles: { - header: { - fontSize: 12, - bold: true - }, - subheader: { - fontSize: 12, - bold: true - }, - quote: { - italics: true - }, - small: { - fontSize: 6 - }, - sta: { - fontSize: 8, - bold: false, - alignment: 'justify' - } - } - }; - - // alert(JSON.stringify(rows1)); - // pdfMake.createPdf(docDefinition).download('file.pdf', () => { - // console.log("success"); - // }); - // alert(JSON.stringify(rows1)); - pdfMake.createPdf(docDefinition).download('DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' ).pdf', function(res) { - if(res === 'success'){ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - }else{ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - } - }); - } - - - - // print PDF-------- END ============================================================================== - - - // 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; - } - }); - } - - // parse the income and expense type from the list - $scope.getType = function (type) { - $scope.getIncomeTypes = $scope.incomeExpenseType.filter(function (val) { - return val.TypeID === 'I002' ? 1 : 0; - }); - $scope.getExpenseTypes = $scope.incomeExpenseType.filter(function (val) { - return val.TypeID === 'I001' ? 1 : 0; - }); - $scope.myModelAdd.type = ''; - $scope.getTypes = type === 'I002' ? $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": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch":"", - "name":"" - } - } - - $scope.myModel = { - "id": "", - "date": "", - "incomeExpense": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch": "", - "name":"" - } - - $scope.copyModel = function (p) { - var inc = $scope.incomeExpenseType.filter((inc)=>inc.ID == p.Type); - $scope.incexp = inc[0]; - - $scope.myModel = { - "id": p.ID, - "date": p.Date, - "incomeExpense": p.Name, - "type":$scope.incexp.ID, - "amount": p.Amount, - "status": p.Status, - "description": p.Description, - "paidTo": p.PaidTo, - "description_paid": p.PaidDescription, - "voucherNumber": p.VoucherNumber, - "branch":p.BranchCode, - "name": p.Name - } - // alert(JSON.stringify($scope.myModel)); - } - $scope.deleted1 = function (id) { - - var id=id; - var reason=prompt("Reason For Deletion!",""); - - if(reason !=null) - { - $scope.deleteFeePayableEntry(reason, id); - } - - else - { - //alert('check') - } - // $scope.deleteFeePayableEntry(reason,id); - } - - //delete the income entry From the fees payable - $scope.deleteFeePayableEntry = function (reason,id) { - SweetAlert.swal({ - title: "Warning!", - text: "Do you want to Delete this Entry ?", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#007aff", - confirmButtonText: "Yes!" - }, function (res) { - if (res === true) { - // alert(id); - // alert(stuId); - if(reason == '') - { - - alert('Please Enter Reason for Deletion'); - return false; - } - else{ - - - var deleteFeePayableDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookFeePayableDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason:reason, - data: id, - requestDetails: localDetails - } - }; - $http(deleteFeePayableDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - - } - } - }); - } - - $scope.deleted = function (id) { - - var id=id; - var a=prompt("Enter Reason!",""); - $scope.deleEditEntry(a,id); - - - - } - // delete the income/expense list row - $scope.deleEditEntry = function (a, 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(a, id); - }); - $scope.indexDelete2 = function (a, id) { - var deleteDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason: a, - data: id, - requestDetails: localDetails - } - }; - $http(deleteDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - } - } - - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - - // add a new daybook entry - $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 sdate= $('#date').val(); - $scope.disableAddButton = true; - var formate = "dd-MM-yyyy"; - $scope.myModelAdd.date= sdate; - //$scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); - $scope.myModelAdd.status = $scope.myModelAdd.name == 'I001' ? 'Pending' : 'Approved'; - // $scope.data.push(myModelAdd); - - var addDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'addDayBook/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: myModelAdd, - localReqDetails: localDetails - } - }; - $http(addDayBookDetails).then(function (response) { - if (response.data.addDayBookStatus) { - swal(" ", "Income/Expense added successfully.", "success"); - $state.go($state.current, {}, { reload: true }); - $scope.disableAddButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableAddButton = false; - } - }); - } - }, - reset: function (form) { - form.$setPristine(true); - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - } - } - - // update a daybook entry details - $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 { - // alert(JSON.stringify($scope.myModel));exit(); - $scope.disableEditButton = true; - var updateDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'updateDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.myModel, - requestDetails: localDetails - } - }; - $http(updateDayBookDetails).then(function (response) { - if (response.data.updateDetailsStatus) { - swal(" ","Updated successfully.", "success"); - // for success state - $scope.editId = -1; - $scope.getDayBookList(); - $scope.disableEditButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableEditButton = false; - } - }); - } - } - } - function styleXl(){ - var mystyle = { - sheetid: 'DAYBOOK DETAILS', - headers: true, - caption: { - title:'DAYBOOK DETAILS'+ '('+ $scope.searchData.date + ' - ' + $scope.searchData.dateTo +')', - width: '300px', - style:'font-size:50px;color:blue;' - }, - // style:'background:#00FF00', - column: { - style:'font-size:11px; color:blue;' - } - }; - return mystyle; - } - $scope.exportData = function () { - - alasql('SELECT Date as Date, ListName as IncomeExpense, VoucherNumber as VoucherNumberBillNumber, PaidTo as PaidToReceivedFrom,FeePaymentDetails as Sem, CourseName as Course,UniversityName as University,TypeName as Type, ReceiptNo as Receipt_No, ReceiptNoComments as Comments, ModeOfPayment as Mode_of_Payment,Amount as Amount,Balance as Balance, Reason, Activity INTO XLS("daybook_details.xls",?) FROM ?',[styleXl(),$scope.data]); - }; - -}]); - - diff --git a/Apollo/assets/js/controllers/daybooksuperadminCtrl1.js b/Apollo/assets/js/controllers/daybooksuperadminCtrl1.js deleted file mode 100755 index 6aac0f48..00000000 --- a/Apollo/assets/js/controllers/daybooksuperadminCtrl1.js +++ /dev/null @@ -1,939 +0,0 @@ -'use strict'; -/** - * daybook details capturing - * - */ -app.controller('daybooksuperadminCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state", 'ipCookie', '$window', 'SweetAlert', '$timeout', function ($scope, $rootScope, toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state, ipCookie, $window, SweetAlert, $timeout) { - - // get local client details - var localDetail = JSON.parse(localStorage.getItem('localObj')); - var localDetails = ipCookie('cookiechk'); - $scope.disableAddButton = false; - $scope.disableEditButton = false; - - - - - //In controller - $scope.exportAction = function () { - // alert(); - switch ('excel') { - case 'pdf': $scope.$broadcast('export-pdf', {}); - break; - case 'excel': $scope.$broadcast('export-excel', {}); - break; - case 'doc': $scope.$broadcast('export-doc', {}); - break; - default: console.log('no event caught'); - } - } - - - $scope.searchData = { - "date": "", - "dateTo": "" - } - - $scope.viewStudentDetailsPage = false; - // load when html page load - $scope.init = function () { - if (localDetail != null) { - if (localDetails.localType === 'R004') { - // $scope.getBranchList(); - getDetails(); - } 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() { - $scope.todayDate = new Date(); - 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'); - } - } - - // get the data while page loading functions goes here - // $scope.init = function () { - // const LOCALTYPE = localDetail.localType; - // if(LOCALTYPE === 'R003') { - // $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(); - - // }else {alert(); - // 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.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.getDayBookList(); - $scope.getIncomeExpenseType_Status(); - return true; - } else { - return true; - } - }); - - } - - // $scope.getApproveLoad = function() { - // alert(); - // } - - // 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) { - $scope.sortKey = keyname; //set the sortKey to the param passed - $scope.reverse = !$scope.reverse; //if true make it false and vice versa - } - - - - - - - $scope.noRecordFound = true; - $scope.dataLength = 0; - - // get day book type name list - $scope.getDayBookList = function () { - var getDatBookListDetails = { - method: 'POST', - url: apiPoint.url + 'getDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.searchData, - localReqDetails: localDetails, - } - }; - $http(getDatBookListDetails).then(function (response) { - if (response.data.dayBookListStatus) { - - $scope.data = response.data.dayBookListDetails; - $scope.datas = response.data.dayBookListDetails; - // alert(JSON.stringify($scope.data)); - - - $scope.dataLength = $scope.data.length; - if ($scope.data.length !== 0) { - $scope.noRecordFound = false; - } else { - $scope.noRecordFound = true; - } - // alert(JSON.stringify($scope.data)); - // $scope.incomeExpenseType = response.data.typeNameList; - } else { - - } - }); - } - - - - //print PDF -------- START ============================================================================== - - var rows1 = ''; - - $scope.paymentOptions = [ - { - "paymentOn": "CASH" - }, - { - "paymentOn": "CHEQUE" - }, - { - "paymentOn": "REFERRAL" - }, - { - "paymentOn": "ONLINE TRANSACTION" - }, - { - "paymentOn": "WAIVER" - }, - { - "paymentOn": "Credit/Debit Card" - } - - ]; - - function getSortCutModeofPayment(type) { - var sortCutName = ''; - switch (type) { - case 'CASH': - sortCutName = 'CH'; - break; - case 'CHEQUE': - sortCutName = 'CHQ'; - break; - case 'REFERRAL': - sortCutName = 'REF'; - break; - case 'ONLINE TRANSACTION': - sortCutName = 'ONL'; - break; - case 'WAIVER': - sortCutName = 'WAI'; - break; - case 'Credit/Debit Card': - sortCutName = 'CARD'; - break; - default: - sortCutName = type; - } - return sortCutName; - } - - - $scope.generatePFD = function (datas) { -$scope.loadStaring = true; - // daybookDetails.generatePFD(datas,$scope.searchData.date, $scope.searchData.dateTo); - - var o = {}; - var intDataSNo = 1; - var intDate = 0; - // var arrForeach = datas.reverse(); - // for() - // var ememem = datas[7-1]; - // alert(ememem.VoucherNumber); - for(var i = datas.length ; i > 0; --i){ - var element = datas[i-1]; - var value = {}; - value['SNo'] = intDataSNo; - value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - var ListName = element.ListName; - value['PaidReceivedToFrom'] = element.PaidTo || '-'; - var Sem = element.FeePaymentDetails || '-'; - var Course = element.CourseName || '-'; - var University = element.UniversityName || '-'; - value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - value['Type'] = element.TypeName || '-'; - value['ReceiptNo'] = element.ReceiptNo || '-'; - value['Comments'] = element.ReceiptNoComments || '-'; - value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - value['Status'] = element.Status || '-'; - value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - value['Balance'] = element.Balance || '-'; - o[intDate] = value; - intDate++; - intDataSNo++; - } - // alert(JSON.stringify(o)); - // arrForeach.forEach(function (element) { - // var value = {}; - // value['SNo'] = intDataSNo; - // value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; - // var ListName = element.ListName; - // value['PaidReceivedToFrom'] = element.PaidTo || '-'; - // var Sem = element.FeePaymentDetails || '-'; - // var Course = element.CourseName || '-'; - // var University = element.UniversityName || '-'; - // value['UnivCourseSem'] = University.concat('/ ' + Course, '/ ' + Sem); - // value['Type'] = element.TypeName || '-'; - // value['ReceiptNo'] = element.ReceiptNo || '-'; - // value['Comments'] = element.ReceiptNoComments || '-'; - // value['ModeofPayment'] = getSortCutModeofPayment(element.ModeOfPayment) || '-'; - // value['Amount'] = (ListName == 'Expense' ? '-' : '+') + ' ' + element.Amount || '-'; - // value['Balance'] = element.Balance || '-'; - // o[intDate] = value; - // intDate++; - // intDataSNo++; - // }); - rows1 = o; - var headers = { - fila_1: { - col_1: { text: 'SNo', style: 'tableHeader', alignment: 'center', bold: true }, - col_2: { text: 'Voucher Number Bill Number / DATE', style: 'tableHeader', alignment: 'center', bold: true }, - col_3: { text: 'Paid To Received From', style: 'tableHeader', alignment: 'center', bold: true }, - col_4: { text: 'University / Course/ Sem', style: 'tableHeader', alignment: 'center', bold: true }, - col_5: { text: 'Type', style: 'tableHeader', alignment: 'center', bold: true }, - col_6: { text: 'Receipt No', style: 'tableHeader', alignment: 'center', bold: true }, - col_7: { text: 'Comments', style: 'tableHeader', alignment: 'center', bold: true }, - col_8: { text: 'Mode of Payment', style: 'tableHeader', alignment: 'center', bold: true }, - col_9: { text: 'Status', style: 'tableHeader', alignment: 'center', bold: true }, - col_10: { text: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, - col_11: { text: 'Balance', style: 'tableHeader', alignment: 'center', bold: true }, - } - } - var body = []; - for (var key in headers) { - if (headers.hasOwnProperty(key)) { - var header = headers[key]; - var row = new Array(); - row.push(header.col_1); - row.push(header.col_2); - row.push(header.col_3); - row.push(header.col_4); - row.push(header.col_5); - row.push(header.col_6); - row.push(header.col_7); - row.push(header.col_8); - row.push(header.col_9); - row.push(header.col_10); - row.push(header.col_11); - body.push(row); - } - } - for (var key in rows1) { - if (rows1.hasOwnProperty(key)) { - var data = rows1[key]; - var row = new Array(); - row.push(data.SNo.toString()); - row.push(data.Date.toString()); - row.push(data.PaidReceivedToFrom.toString()); - row.push(data.UnivCourseSem.toString()); - row.push(data.Type.toString()); - row.push(data.ReceiptNo.toString()); - row.push(data.Comments.toString()); - row.push(data.ModeofPayment.toString()); - row.push(data.Status.toString()); - row.push(data.Amount.toString()); - row.push(data.Balance.toString()); - body.push(row); - } - } - - - var docDefinition = { - pageMargins: [10, 85, 20, 50], - pageOrientation: 'landscape', - header: function () { - return { - margin: 0, - columns: [ - { - text: ['DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' )'], - alignment: 'left', bold: true, margin: [20, 30, 0, 0], fontSize: 18 - } - ] - } - }, - footer: function (currentPage, pageCount) { - if (currentPage === pageCount) { - return { - columns: [ - { - text: ['Note :' + '\n\t\t\t\t\t\t CH-CASH, CHQ-CHEQUE, REF-REFERRAL, ONL-ONLINE TRANSACTION, WAI-WAIVER, CARD-Credit/Debit Card'], - alignment: 'left', margin: [10, 0, 0, 0], fontSize: 8 - }, - { text: ['\n Page ' + currentPage.toString() + ' of ' + pageCount], alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 } - ] - }; - } else { - return { - text: 'Page ' + currentPage.toString() + ' of ' + pageCount, alignment: 'right', margin: [0, 10, 10, 0], fontSize: 10 - }; - } - }, - content: [ - { - // layout: 'lightHorizontalLines', // optional - table: { - // headers are automatically repeated if the table spans over multiple pages - // you can declare how many rows should be treated as headers - // headerRows: 1, - // widths: [ '40', '40', '40', '40', '40'], - headerRows: 1, - keepWithHeaderRows: 0, - body: body - }, - layout: { - hLineWidth: function (i, node) { - return 0.5; - }, - vLineWidth: function (i, node) { - // return (i === 0 || i === node.table.widths.length) ? 0 : 40; - return 0.5; - }, - hLineColor: function (i, node) { - return '#2D4D81'; - }, - vLineColor: function (i, node) { - return '#2D4D81'; - }, - } - } - ], - styles: { - header: { - fontSize: 12, - bold: true - }, - subheader: { - fontSize: 12, - bold: true - }, - quote: { - italics: true - }, - small: { - fontSize: 6 - }, - sta: { - fontSize: 8, - bold: false, - alignment: 'justify' - } - } - }; - - // alert(JSON.stringify(rows1)); - // var returndata = pdfMake.createPdf(docDefinition).download('DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' ).pdf', function(){ - // return true; - // }); - // pdfMake.createPdf(docDefinition).getDataUrl(function(url) { alert('your pdf is done'); }); - pdfMake.createPdf(docDefinition).download('DAYBOOK DETAILS' + '( ' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ' ).pdf', function(res) { - if(res === 'success'){ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - }else{ - $scope.$apply(function(){ - $scope.loadStaring = false; - }); - } - }); - - // if(returndata === 1){ - // $scope.loadStaring = false; - // } - - // if(returndata){ - // $scope.loadStaring = false; - // } - // pdfMake.createPdf(docDefinition).print(); - - // $scope.loadStaring = false; - // pdfMake.createPdf(docDefinition).open(); - } - - - - // print PDF-------- END ============================================================================== - - // 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; - - } - }); - } - - // parse the income and expense type from the list - $scope.getType = function (type) { - $scope.getIncomeTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I002' ? 1 : 0; - }); - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I001' ? 1 : 0; - }); - - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I003' ? 1 : 0; - }); - - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I004' ? 1 : 0; - }); - - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I005' ? 1 : 0; - }); - - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { - return val.TypeID === 'I006' ? 1 : 0; - }); - - - - - $scope.myModelAdd.type = ''; - $scope.getTypes = type === 'I002' ? $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": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch": "", - "name": "" - } - } - - $scope.myModel = { - "id": "", - "date": "", - "incomeExpense": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "", - "branch": "", - "name": "" - } - - $scope.copyModel = function (p) { - var inc = $scope.incomeExpenseType.filter((inc) => inc.ID == p.Type); - $scope.incexp = inc[0]; - $scope.myModel = { - "id": p.ID, - "date": p.Date, - "incomeExpense": p.Name, - "type": $scope.incexp.ID, - "amount": p.Amount, - "status": p.Status, - "description": p.Description, - "paidTo": p.PaidTo, - "description_paid": p.PaidDescription, - "voucherNumber": p.VoucherNumber, - "branch": p.BranchCode, - "name": p.Name - - } - // alert(JSON.stringify($scope.myModel)); - } - - - $scope.deleted1 = function (id) { - var id = id; - var reason = prompt("Reason For Deletion!", ""); - - if(reason !=null) - { - $scope.deleteFeePayableEntry(reason, id); - } - - else - { - //alert('check') - } - //console.log($scope.deleteFeePayableEntry) - - - } - //delete the income entry From the fees payable - $scope.deleteFeePayableEntry = function (reason, id) { - // alert(id); - SweetAlert.swal({ - title: "Warning!", - text: "Do you want to Delete this Entry ?", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#007aff", - confirmButtonText: "Yes!", - cancelButtonText: "No", - closeOnConfirm: false, - closeOnCancel: false - }, function (res) { - - console.log(res); - //return false; - - if (res === true) { - - if(reason == '') - { - - alert('Please Enter Reason for Deletion'); - - // swal("Please Enter Reason!", "", "error"); - - return false; - } - else{ - - - - var deleteFeePayableDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookFeePayableDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason: reason, - data: id, - requestDetails: localDetails - } - }; - $http(deleteFeePayableDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - - } - } - // else - // { - // alert('close') - // } - }); - } - - - - $scope.deleted = function (id) { - - var id = id; - var a = prompt("Enter Reason!", ""); - $scope.deleEditEntry(a, id); - - - - } - // delete the income/expense list row - $scope.deleEditEntry = function (a, 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(a, id); - }); - $scope.indexDelete2 = function (a, id) { - var deleteDetails = { - method: 'POST', - url: apiPoint.url + 'deleteDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - reason: a, data: id, - requestDetails: localDetails - } - }; - $http(deleteDetails).then(function (response) { - if (response.data.deletedStatus) { - swal(" ", "Deleted Successfully.", "success"); - $scope.getDayBookList(); - } else { - swal(" ", response.data.message, "error"); - } - }); - } - } - - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - - // add a new daybook entry - $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 sdate = $('#date').val(); - $scope.disableAddButton = true; - var formate = "dd-MM-yyyy"; - $scope.myModelAdd.date = sdate; - //$scope.myModelAdd.date = $filter('date')(new Date($scope.myModelAdd.date), formate); - $scope.myModelAdd.status = $scope.myModelAdd.name == 'I001' ? 'Pending' : 'Approved'; - // $scope.data.push(myModelAdd); - - var addDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'addDayBook/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: myModelAdd, - localReqDetails: localDetails - } - }; - $http(addDayBookDetails).then(function (response) { - if (response.data.addDayBookStatus) { - swal(" ", "Income/Expense added successfully.", "success"); - $state.go($state.current, {}, { reload: true }); - $scope.viewStudentDetailsPage = false; - // $scope.myActivateDiv(); - $scope.disableAddButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableAddButton = false; - } - }); - } - }, - reset: function (form) { - form.$setPristine(true); - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } - } - } - - - // $scope.myActivateDiv = function () { - // $scope.viewStudentDetailsPage = false; - // $scope.myModelAdd = { - // "id": "", - // "date": "", - // "name": "", - // "type": "", - // "amount": "", - // "status": "", - // "description": "", - // "paidTo": "", - // "description_paid": "", - // "voucherNumber": "" - // } - - // $timeout(function () { - // getDetails(); - // }, 1000); - // } - - - // update a daybook entry details - $scope.daybookeditUpdate = { - submit: function (form, myModel) { - - //return false; - 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 { - // alert(JSON.stringify($scope.myModel));exit(); - $scope.disableEditButton = true; - var updateDayBookDetails = { - method: 'POST', - url: apiPoint.url + 'updateDayBookDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - data: $scope.myModel, - requestDetails: localDetails - } - }; - $http(updateDayBookDetails).then(function (response) { - if (response.data.updateDetailsStatus) { - swal(" ", "Updated successfully.", "success"); - // for success state - $scope.editId = -1; - $scope.getDayBookList(); - $scope.disableEditButton = false; - } else { - swal(" ", response.data.message, "error"); - $scope.disableEditButton = false; - } - }); - } - } - } - - - function styleXl() { - var mystyle = { - sheetid: 'DAYBOOK DETAILS', - headers: true, - caption: { - title: 'DAYBOOK DETAILS' + '(' + $scope.searchData.date + ' - ' + $scope.searchData.dateTo + ')', - width: '300px', - style: 'font-size:50px;color:blue;' - }, - // style:'background:#00FF00', - column: { - style: 'font-size:11px; color:blue;' - } - }; - return mystyle; - } - $scope.exportData = function () { - alasql('SELECT Date as Date, ListName as IncomeExpense, VoucherNumber as VoucherNumberBillNumber, PaidTo as PaidToReceivedFrom,FeePaymentDetails as Sem, CourseName as Course,UniversityName as University,TypeName as Type, ReceiptNo as Receipt_No, ReceiptNoComments as Comments, ModeOfPayment as Mode_of_Payment,Amount as Amount,Balance as Balance, Reason, Activity INTO XLS("daybook_details.xls",?) FROM ?', [styleXl(), $scope.data]); - }; - - -}]); - - - -