diff --git a/Apollo/assets/js/controllers/daybookCtrl.js b/Apollo/assets/js/controllers/daybookCtrl.js index d3892373..f311d628 100755 --- a/Apollo/assets/js/controllers/daybookCtrl.js +++ b/Apollo/assets/js/controllers/daybookCtrl.js @@ -121,6 +121,7 @@ $scope.dayBookApprovalAccess = ''; 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; @@ -135,6 +136,263 @@ $scope.dayBookApprovalAccess = ''; }); } + //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) { + + // 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['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: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, + col_10: { 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); + 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.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"); + // }); + pdfMake.createPdf(docDefinition).print(() => { + console.log("success"); + }); + } + + + + // print PDF-------- END ============================================================================== + + + // income expense type status list $scope.getIncomeExpenseType_Status = function () { var getIncomeExpenseType = { diff --git a/Apollo/assets/js/controllers/daybookadminCtrl.js b/Apollo/assets/js/controllers/daybookadminCtrl.js index 9e747f14..c8b41bf1 100755 --- a/Apollo/assets/js/controllers/daybookadminCtrl.js +++ b/Apollo/assets/js/controllers/daybookadminCtrl.js @@ -121,6 +121,7 @@ $scope.dayBookApprovalAccess = ''; 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; @@ -135,6 +136,263 @@ $scope.dayBookApprovalAccess = ''; }); } + + //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) { + + // 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['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: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, + col_10: { 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); + 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.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"); + // }); + pdfMake.createPdf(docDefinition).print(() => { + console.log("success"); + }); + } + + + + // print PDF-------- END ============================================================================== + + // income expense type status list $scope.getIncomeExpenseType_Status = function () { var getIncomeExpenseType = { diff --git a/Apollo/assets/js/controllers/daybooksuperadminCtrl.js b/Apollo/assets/js/controllers/daybooksuperadminCtrl.js index 46e3a8df..a8d174ee 100755 --- a/Apollo/assets/js/controllers/daybooksuperadminCtrl.js +++ b/Apollo/assets/js/controllers/daybooksuperadminCtrl.js @@ -3,30 +3,30 @@ * 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) { +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; + $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'); - } -} + + //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 = { @@ -34,7 +34,7 @@ $scope.exportAction = function(){ "dateTo": "" } - $scope.viewStudentDetailsPage = false; + $scope.viewStudentDetailsPage = false; // load when html page load $scope.init = function () { if (localDetail != null) { @@ -80,21 +80,21 @@ $scope.exportAction = function(){ // } function getDetails() { - $scope.todayDate = new Date(); + $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 { + 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'); @@ -114,7 +114,7 @@ $scope.exportAction = function(){ // $scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate); // $scope.getDayBookList(); // $scope.getIncomeExpenseType_Status(); - + // }else {alert(); // ipCookie.remove('cookiechk'); // $window.localStorage.clear(); @@ -122,10 +122,10 @@ $scope.exportAction = function(){ // } // } -$scope.dayBookApprovalAccess = ''; - // Finance module access control + $scope.dayBookApprovalAccess = ''; + // Finance module access control function getFinanceModuleAccess() { - var getFinacnceModuleAcccessCtrl = { + var getFinacnceModuleAcccessCtrl = { method: 'POST', url: apiPoint.url + 'empDayBookModuleAccessChk/', headers: { @@ -149,7 +149,7 @@ $scope.dayBookApprovalAccess = ''; return true; } }); - + } // $scope.getApproveLoad = function() { @@ -158,7 +158,7 @@ $scope.dayBookApprovalAccess = ''; // change from date, update and call search functionality $scope.changeDate = function () { - if($scope.searchData.date !== undefined) { + if ($scope.searchData.date !== undefined) { var formate = "dd-MM-yyyy"; $scope.searchData.date = $filter('date')(new Date($scope.searchData.date), formate); $scope.getDayBookList(); @@ -167,10 +167,10 @@ $scope.dayBookApprovalAccess = ''; $scope.getDayBookList(); } } - + // change to date, update and call search functionality $scope.changeToDate = function () { - if($scope.searchData.dateTo !== undefined) { + if ($scope.searchData.dateTo !== undefined) { var formate = "dd-MM-yyyy"; $scope.searchData.dateTo = $filter('date')(new Date($scope.searchData.dateTo), formate); $scope.getDayBookList(); @@ -186,10 +186,14 @@ $scope.dayBookApprovalAccess = ''; $scope.reverse = !$scope.reverse; //if true make it false and vice versa } + + + + + $scope.noRecordFound = true; $scope.dataLength = 0; - -var rows1 = ''; + // get day book type name list $scope.getDayBookList = function () { var getDatBookListDetails = { @@ -207,33 +211,9 @@ var rows1 = ''; if (response.data.dayBookListStatus) { $scope.data = response.data.dayBookListDetails; + $scope.datasss = response.data.dayBookListDetails; // alert(JSON.stringify($scope.data)); - var o = {}; - // o[key] = value; - var intDate = 0; - - var arrForeach = $scope.data; - arrForeach.forEach(function(element) { - var value = {}; - value['Date'] = element.Date || '-'; - value['IncomeExpence'] = element.ListName || '-'; - value['VoucherBillNumber'] = element.VoucherNumber || '-'; - value['PaidReceivedToFrom'] = element.PaidTo || '-'; - value['Sem'] = element.FeePaymentDetails || '-'; - // value['Course'] = element.CourseName || '-'; - // value['University'] = element.UniversityName || '-'; - // value['Type'] = element.TypeName || '-'; - // value['ReceiptNo'] = element.ReceiptNo || '-'; - // value['Comments'] = element.ReceiptNoComments || '-'; - // value['ModeofPayment'] = element.ModeOfPayment || '-'; - // value['Amount'] = element.Amount || '-'; - // value['Balance'] = element.Balance || '-'; - o[intDate] = value; - intDate++; - }); - - rows1 = o; $scope.dataLength = $scope.data.length; if ($scope.data.length !== 0) { @@ -251,150 +231,260 @@ var rows1 = ''; - //============================================================================== + //print PDF -------- START ============================================================================== - - $scope.generatePFD = function() { + var rows1 = ''; - // var docDefinition = { content: 'This is an sample PDF printed with pdfMake' }; - -var headers = { - // fila_0:{ - // col_1:{ text: 'Faltas', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, - // col_2:{ text: 'Fecha', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, - // col_3:{ text: 'Descripción', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, - // col_4:{ text: 'Cita con acudientes', style: 'tableHeader',colSpan: 2, alignment: 'center' } - // }, - fila_1:{ - col_1:{ text: 'DATE', style: 'tableHeader', alignment: 'center' }, - col_2:{ text: 'Income Expense', style: 'tableHeader', alignment: 'center' }, - col_3:{ text: 'Voucher Number Bill Number', style: 'tableHeader', alignment: 'center' }, - col_4:{ text: 'Paid To Received From', style: 'tableHeader', alignment: 'center' }, - col_5:{ text: 'Sem', style: 'tableHeader', alignment: 'center'}, - // col_6:{ text: 'Course', style: 'tableHeader', alignment: 'center'}, - // col_7:{ text: 'University', style: 'tableHeader', alignment: 'center'}, - // col_8:{ text: 'Type', style: 'tableHeader', alignment: 'center'}, - // col_9:{ text: 'Receipt No', style: 'tableHeader', alignment: 'center'}, - // col_10:{ text: 'Comments', style: 'tableHeader', alignment: 'center'}, - // col_11:{ text: 'Mode of Payment', style: 'tableHeader', alignment: 'center'}, - // col_12:{ text: 'Amount', style: 'tableHeader', alignment: 'center'}, - // col_13:{ text: 'Balance', style: 'tableHeader', alignment: 'center'}, - } -} -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 ); - // row.push( header.col_12 ); - // row.push( header.col_13 ); - body.push(row); - } -} -for (var key in rows1) -{ - if (rows1.hasOwnProperty(key)) - { - var data = rows1[key]; - var row = new Array(); - row.push( data.Date.toString() ); - row.push( data.IncomeExpence.toString() ); - row.push( data.VoucherBillNumber.toString() ); - row.push( data.PaidReceivedToFrom.toString() ); - row.push( data.Sem.toString() ); - // row.push( data.Course.toString() ); - // row.push( data.University.toString() ); - // row.push( data.Type.toString() ); - // row.push( data.ReceiptNo.toString() ); - // row.push( data.Comments.toString() ); - // row.push( data.ModeofPayment.toString() ); - // row.push( data.Amount.toString() ); - // row.push( data.Balance.toString() ); - body.push(row); - } -} - - -var docDefinition = { - pageMargins: [40,165,40,55], - pageOrientation: 'landscape', - header: function() { - return { - margin: 2, - columns: [ - { - }, - { text:['DAYBOOK DETAILS'], - alignment: 'left',bold:true,margin:[-405,80,0,0],fontSize: 24} - ] - } + $scope.paymentOptions = [ + { + "paymentOn": "CASH" }, - footer: function(currentPage, pageCount) { - return { text:'Pagina '+ currentPage.toString() + ' de ' + pageCount, alignment: 'center',margin:[0,30,0,0] }; + { + "paymentOn": "CHEQUE" }, - 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: [ '*', 'auto', 100, '*' ], + { + "paymentOn": "REFERRAL" + }, + { + "paymentOn": "ONLINE TRANSACTION" + }, + { + "paymentOn": "WAIVER" + }, + { + "paymentOn": "Credit/Debit Card" + } - // body: [ - // [ 'First', 'Second', 'Third', 'The last one' ], - // [ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ], - // [ { text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4' ] - // ] - widths: [ '40', 'auto', 'auto', 'auto', 'auto'], - headerRows: 2, - // keepWithHeaderRows: 1, - body: body - } + ]; + + 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; } - ], - styles: { - header: { - fontSize: 28, - bold: true - }, - subheader: { - fontSize: 15, - bold: true - }, - quote: { - italics: true - }, - small: { - fontSize: 8 - }, - sta: { - fontSize: 11, - bold: false, - alignment: 'justify' + + + $scope.generatePFD = function (datas) { + + // 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['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: 'Amount', style: 'tableHeader', alignment: 'center', bold: true }, + col_10: { 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); + 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.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(); - pdfMake.createPdf(docDefinition).print(); + // pdfMake.createPdf(docDefinition).download('file.pdf', () => { + // console.log("success"); + // }); + pdfMake.createPdf(docDefinition).print(() => { + console.log("success"); + }); } - - //============================================================================== + + // print PDF-------- END ============================================================================== // income expense type status list $scope.getIncomeExpenseType_Status = function () { @@ -430,15 +520,15 @@ var docDefinition = { return val.TypeID === 'I003' ? 1 : 0; }); - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { + $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { return val.TypeID === 'I004' ? 1 : 0; }); - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { + $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { return val.TypeID === 'I005' ? 1 : 0; }); - $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { + $scope.getExpenseTypes = $scope.incomeExpenseName.filter(function (val) { return val.TypeID === 'I006' ? 1 : 0; }); @@ -452,7 +542,7 @@ var docDefinition = { $scope.editId = -1; $scope.setEditId = function (P) { - //alert(id); + //alert(id); $scope.editId = P; } @@ -468,9 +558,9 @@ var docDefinition = { "description": "", "paidTo": "", "description_paid": "", - "voucherNumber": "", - "branch":"", - "name":"" + "voucherNumber": "", + "branch": "", + "name": "" } } @@ -486,38 +576,38 @@ var docDefinition = { "description_paid": "", "voucherNumber": "", "branch": "", - "name":"" + "name": "" } $scope.copyModel = function (p) { - var inc = $scope.incomeExpenseType.filter((inc)=>inc.ID == p.Type); + 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, + "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, + "branch": p.BranchCode, "name": p.Name } // alert(JSON.stringify($scope.myModel)); } - - - $scope.deleted1 = function (id) { - var id=id; - var reason=prompt("Reason For Deletion!",""); - $scope.deleteFeePayableEntry(reason,id); - } + + + $scope.deleted1 = function (id) { + var id = id; + var reason = prompt("Reason For Deletion!", ""); + $scope.deleteFeePayableEntry(reason, id); + } //delete the income entry From the fees payable - $scope.deleteFeePayableEntry = function (reason,id) { + $scope.deleteFeePayableEntry = function (reason, id) { // alert(id); SweetAlert.swal({ title: "Warning!", @@ -530,15 +620,15 @@ var docDefinition = { if (res === true) { // alert(id); // alert(stuId); - var deleteFeePayableDetails ={ + var deleteFeePayableDetails = { method: 'POST', url: apiPoint.url + 'deleteDayBookFeePayableDetails/', headers: { 'Content-Type': 'application/json' }, data: { - reason:reason, - data:id, + reason: reason, + data: id, requestDetails: localDetails } }; @@ -554,21 +644,21 @@ var docDefinition = { }); } - - $scope.deleted = function (id) { - - var id=id; - var a=prompt("Enter Reason!",""); - $scope.deleEditEntry(a,id); - - - + + $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) { + $scope.deleEditEntry = function (a, id) { swal({ - + title: "Are you sure?", text: "Your will not be able to recover this record!", type: "warning", @@ -578,9 +668,9 @@ var docDefinition = { closeOnConfirm: false }, function () { - $scope.indexDelete2(a,id); + $scope.indexDelete2(a, id); }); - $scope.indexDelete2 = function (a,id) { + $scope.indexDelete2 = function (a, id) { var deleteDetails = { method: 'POST', url: apiPoint.url + 'deleteDayBookDetails/', @@ -588,7 +678,7 @@ var docDefinition = { 'Content-Type': 'application/json' }, data: { - reason:a,data: id, + reason: a, data: id, requestDetails: localDetails } }; @@ -635,10 +725,10 @@ var docDefinition = { 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 sdate = $('#date').val(); + $scope.disableAddButton = true; var formate = "dd-MM-yyyy"; - $scope.myModelAdd.date= sdate; + $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); @@ -658,34 +748,34 @@ var docDefinition = { if (response.data.addDayBookStatus) { swal(" ", "Income/Expense added successfully.", "success"); $state.go($state.current, {}, { reload: true }); - $scope.viewStudentDetailsPage = false; + $scope.viewStudentDetailsPage = false; // $scope.myActivateDiv(); - $scope.disableAddButton = false; + $scope.disableAddButton = false; } else { swal(" ", response.data.message, "error"); - $scope.disableAddButton = false; + $scope.disableAddButton = false; } }); } }, reset: function (form) { - form.$setPristine(true); - $scope.myModelAdd = { - "id": "", - "date": "", - "name": "", - "type": "", - "amount": "", - "status": "", - "description": "", - "paidTo": "", - "description_paid": "", - "voucherNumber": "" - } + form.$setPristine(true); + $scope.myModelAdd = { + "id": "", + "date": "", + "name": "", + "type": "", + "amount": "", + "status": "", + "description": "", + "paidTo": "", + "description_paid": "", + "voucherNumber": "" + } } } - + // $scope.myActivateDiv = function () { // $scope.viewStudentDetailsPage = false; // $scope.myModelAdd = { @@ -700,7 +790,7 @@ var docDefinition = { // "description_paid": "", // "voucherNumber": "" // } - + // $timeout(function () { // getDetails(); // }, 1000); @@ -711,7 +801,7 @@ var docDefinition = { $scope.daybookeditUpdate = { submit: function (form, myModel) { - //return false; + //return false; var firstError = null; if (form.$invalid) { @@ -730,7 +820,7 @@ var docDefinition = { 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; + $scope.disableEditButton = true; var updateDayBookDetails = { method: 'POST', url: apiPoint.url + 'updateDayBookDetails/', @@ -744,40 +834,40 @@ var docDefinition = { }; $http(updateDayBookDetails).then(function (response) { if (response.data.updateDetailsStatus) { - swal(" ","Updated successfully.", "success"); + swal(" ", "Updated successfully.", "success"); // for success state $scope.editId = -1; $scope.getDayBookList(); - $scope.disableEditButton = false; + $scope.disableEditButton = false; } else { swal(" ", response.data.message, "error"); - $scope.disableEditButton = false; + $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]); + + 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/filters/daybookPrintService.js b/Apollo/assets/js/filters/daybookPrintService.js new file mode 100644 index 00000000..4000dd2a --- /dev/null +++ b/Apollo/assets/js/filters/daybookPrintService.js @@ -0,0 +1,230 @@ +'use strict'; + +app.service('daybookDetails', ['$scope', function ($scope) { + + 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, from, to) { + var o = {}; + var intDataSNo = 1; + var intDate = 0; + var arrForeach = datas.reverse(); + alert(JSON.stringify(arrForeach)); + arrForeach.forEach(function(element) { + var value = {}; + value['SNo'] = intDataSNo; + value['Date'] = element.VoucherNumber + '\n/' + element.Date || '-'; + // value['IncomeExpence'] = element.ListName || '-'; + var ListName = element.ListName; + // value['VoucherBillNumber'] = element.VoucherNumber || '-'; + 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['ModeofPayment'] = element.ModeOfPayment == ''? '-' : getSortCutModeofPayment(element.ModeOfPayment); + value['Amount'] = (ListName == 'Expense' ? '-' : '+') +' '+ element.Amount || '-'; + value['Balance'] = element.Balance || '-'; + o[intDate] = value; + intDate++; + intDataSNo++; + }); + + rows1 = o; + + + + +var headers = { + // fila_0:{ + // col_1:{ text: 'Faltas', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, + // col_2:{ text: 'Fecha', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, + // col_3:{ text: 'Descripción', style: 'tableHeader',rowSpan: 2, alignment: 'center',margin: [0, 8, 0, 0] }, + // col_4:{ text: 'Cita con acudientes', style: 'tableHeader',colSpan: 2, alignment: 'center' } + // }, + 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: 'Income Expense', style: 'tableHeader', alignment: 'center' }, + // col_3:{ text: 'Voucher Number Bill Number', style: 'tableHeader', alignment: 'center' }, + col_3:{ text: 'Paid To Received From', style: 'tableHeader', alignment: 'center', bold:true }, + // col_5:{ text: 'Sem', style: 'tableHeader', alignment: 'center'}, + // col_6:{ text: 'Course', style: 'tableHeader', alignment: 'center'}, + 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: 'Amount', style: 'tableHeader', alignment: 'center', bold:true}, + col_10:{ 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 ); + // row.push( header.col_12 ); + // row.push( header.col_13 ); + 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.IncomeExpence.toString() ); + // row.push( data.VoucherBillNumber.toString() ); + row.push( data.PaidReceivedToFrom.toString() ); + // row.push( data.Sem.toString() ); + // row.push( data.Course.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.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' + '( '+from+ ' - ' + to +' )'], + 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: [ '*', 'auto', 100, '*' ], + + // body: [ + // [ 'First', 'Second', 'Third', 'The last one' ], + // [ 'Value 1', 'Value 2', 'Value 3', 'Value 4' ], + // [ { text: 'Bold value', bold: true }, 'Val 2', 'Val 3', 'Val 4' ] + // ] + // 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(); + pdfMake.createPdf(docDefinition).print(); + } + + +}]); \ No newline at end of file diff --git a/Apollo/assets/views/daybook/daybook.html b/Apollo/assets/views/daybook/daybook.html index f8ce665b..d5b70884 100755 --- a/Apollo/assets/views/daybook/daybook.html +++ b/Apollo/assets/views/daybook/daybook.html @@ -102,6 +102,15 @@ } +