Expense report fixes
This commit is contained in:
parent
c02f6401ad
commit
78173a5d71
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
/*** controller***/
|
||||
app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window',"dateListDescService",
|
||||
app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', '$window', "dateListDescService",
|
||||
function ($scope, apiPoint, $http, SweetAlert, $state, md5, ipCookie, $window, dateListDescService) {
|
||||
|
||||
// DataTables configurable options
|
||||
@ -18,9 +18,9 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
var localDetail = JSON.parse(localStorage.getItem('localObj'));
|
||||
const LOCALTYPE = localDetail.localType;
|
||||
//console.log(LOCALTYPE)
|
||||
if (localDetail != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' )) {
|
||||
}else {
|
||||
if((localDetail != null) && (LOCALTYPE !='R001')) {
|
||||
if (localDetail != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004')) {
|
||||
} else {
|
||||
if ((localDetail != null) && (LOCALTYPE != 'R001')) {
|
||||
$state.go('app.dashboard');
|
||||
} else {
|
||||
//ipCookie.remove('cookiechk');
|
||||
@ -37,35 +37,39 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
branch : JSON.parse(localStorage.getItem('localObj')).localBranchID
|
||||
branch: JSON.parse(localStorage.getItem('localObj')).localBranchID
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
$http(filterlist).then(function (response) {
|
||||
if (response.data) {
|
||||
$scope.batch=[];
|
||||
$scope.batch = [];
|
||||
$scope.batchlist = response.data.batch;
|
||||
$scope.university = response.data.university;
|
||||
//Desc order Batchlist
|
||||
angular.forEach($scope.batchlist,function (values,key) {
|
||||
angular.forEach($scope.batchlist, function (values, key) {
|
||||
var parts = values.BatchDate.split("-");
|
||||
$scope.batch.push({
|
||||
"batchcode":values.batchcode,
|
||||
"batch":values.batch + '('+ values.batchcode + ')',
|
||||
"BatchDate":values.BatchDate,
|
||||
"givenDateObject":new Date(parts[2], parts[1] - 1, parts[0])
|
||||
"batchcode": values.batchcode,
|
||||
"batch": values.batch + '(' + values.batchcode + ')',
|
||||
"BatchDate": values.BatchDate,
|
||||
"givenDateObject": new Date(parts[2], parts[1] - 1, parts[0])
|
||||
})
|
||||
});
|
||||
// call service for make a list in desc order based on date
|
||||
$scope.batch=dateListDescService.getOrderByList($scope.batch);
|
||||
$scope.batch = dateListDescService.getOrderByList($scope.batch);
|
||||
//console.log($scope.branch);
|
||||
} else {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.expense_data = '';
|
||||
$scope.expense = '';
|
||||
$scope.totArray = '';
|
||||
$scope.show = false;
|
||||
$scope.Total = 0;
|
||||
|
||||
$scope.onSubmit = function (form) {
|
||||
var firstError = null;
|
||||
if (form.$invalid) {
|
||||
@ -83,9 +87,9 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
}
|
||||
}
|
||||
angular.element('.ng-invalid[toDate=' + firstError + ']').focus();
|
||||
}else {
|
||||
} else {
|
||||
//alert($scope.batch.name);
|
||||
$scope.expense_data = '';
|
||||
|
||||
$scope.message = '';
|
||||
var response_data = {
|
||||
method: 'POST',
|
||||
@ -95,8 +99,8 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
},
|
||||
data: {
|
||||
branch: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
||||
from : $scope.filters.from_date,
|
||||
to : $scope.filters.to_date
|
||||
from: $scope.filters.from_date,
|
||||
to: $scope.filters.to_date
|
||||
}
|
||||
|
||||
};
|
||||
@ -104,8 +108,8 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
$http(response_data).then(function (response) {
|
||||
if (response.data.expenseList == true) {
|
||||
$scope.expense_data = response.data.expense_data;
|
||||
for(var i=0;i<$scope.expense_data.length;i++)
|
||||
$scope.expense_data[i].SL_NO = i+1;
|
||||
for (var i = 0; i < $scope.expense_data.length; i++)
|
||||
$scope.expense_data[i].SL_NO = i + 1;
|
||||
|
||||
|
||||
} else {
|
||||
@ -113,33 +117,56 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
}
|
||||
|
||||
});
|
||||
$scope.getTotal = function(){
|
||||
|
||||
|
||||
$scope.getTotal = function () {
|
||||
var total = 0;
|
||||
for(var i = 0; i < $scope.expense_data.length; i++){
|
||||
for (var i = 0; i < $scope.expense_data.length; i++) {
|
||||
var item = $scope.expense_data[i];
|
||||
total += parseFloat(item.total);
|
||||
|
||||
|
||||
}
|
||||
return total; }
|
||||
$scope.Total = total;
|
||||
$scope.totArray = {
|
||||
|
||||
Expense_name:"Grand Total",
|
||||
total: $scope.Total
|
||||
}
|
||||
|
||||
// console.log($scope.Total);
|
||||
$scope.expense = $scope.expense_data.concat($scope.totArray);
|
||||
// console.log($scope.expense_data);
|
||||
// console.log($scope.totArray);
|
||||
// console.log($scope.expense);
|
||||
return total;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
var mystyle = {
|
||||
sheetid: 'EXPENSE REPORT',
|
||||
headers: true,
|
||||
caption: {
|
||||
title:'EXPENSE REPORT',
|
||||
title: 'EXPENSE REPORT',
|
||||
width: '300px',
|
||||
style:'font-size:50px;'
|
||||
style: 'font-size:50px;'
|
||||
},
|
||||
// style:'background:#00FF00',
|
||||
column: {
|
||||
style:'font-size:10px'
|
||||
style: 'font-size:10px'
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
$scope.exportData = function () {
|
||||
alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Expense_name as ExpenseName,CAST(January as NUMBER) as January,CAST(February as NUMBER) as February,CAST(March as NUMBER) as March,CAST(April as NUMBER) as April,CAST(May as NUMBER) as May,CAST(June as NUMBER) as June,CAST(July as NUMBER) as July,CAST(August as NUMBER) as August,CAST(September as NUMBER) as September,CAST(October as NUMBER) as October,CAST(November as NUMBER) as November,CAST(December as NUMBER) as December,CAST(total as NUMBER) as Amount INTO XLS("Expense_report.xls",?) FROM ?',[mystyle,$scope.expense]);
|
||||
};
|
||||
//pdf
|
||||
var rows1 = 0;
|
||||
$scope.generatePFD = function (datas) {
|
||||
$scope.loadStaring = true;
|
||||
|
||||
@ -147,27 +174,27 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
var intDataSNo = 1;
|
||||
var intDate = 0;
|
||||
|
||||
for(var i = 0 ; i <= datas.length-1; ++i){
|
||||
for (var i = 0; i <= datas.length - 1; ++i) {
|
||||
var element = datas[i];
|
||||
//var element = datas[i-1];
|
||||
console.log('staff or trainee');
|
||||
console.log(datas);
|
||||
var value = {};
|
||||
|
||||
value['SL_NO'] = element.ORDER_ID;
|
||||
value['Expense_name'] = element.VoucherNumber;
|
||||
value['January'] = element.PaidTo;
|
||||
value['February'] = University;
|
||||
value['March'] = element.Ty;
|
||||
value['April'] = element.ReceiptNo || '-';
|
||||
value['May'] = element.ReceiptNoComments || '-';
|
||||
value['June'] = element.ModeOfPayment || '-';
|
||||
value['July'] = element.Status || '-';
|
||||
value['August'] = element.Status;
|
||||
value['September'] = element.Balance || '-';
|
||||
value['October'] = element.Balance || '-';
|
||||
value['November'] = element.Balance || '-';
|
||||
value['December'] = element.Balance || '-';
|
||||
value['total'] = element.Balance || '-';
|
||||
value['SL_NO'] = element.SL_NO || '';
|
||||
value['Expense_name'] = element.Expense_name || '-';
|
||||
value['January'] = element.January || '';
|
||||
value['February'] =element. February || '';
|
||||
value['March'] = element.March || '';
|
||||
value['April'] = element.April || '';
|
||||
value['May'] = element.May || '';
|
||||
value['June'] = element.June || '';
|
||||
value['July'] = element.July || '';
|
||||
value['August'] = element.August || '';
|
||||
value['September'] = element.September || '';
|
||||
value['October'] = element.October || '';
|
||||
value['November'] = element.November || '';
|
||||
value['December'] = element.December || '';
|
||||
value['total'] = element.total || 0;
|
||||
o[intDate] = value;
|
||||
intDate++;
|
||||
intDataSNo++;
|
||||
@ -217,9 +244,11 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
body.push(row);
|
||||
}
|
||||
}
|
||||
console.log(rows1);
|
||||
for (var key in rows1) {
|
||||
if (rows1.hasOwnProperty(key)) {
|
||||
var data = rows1[key];
|
||||
|
||||
var row = new Array();
|
||||
row.push(data.SL_NO.toString());
|
||||
row.push(data.Expense_name.toString());
|
||||
@ -249,7 +278,7 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
margin: 0,
|
||||
columns: [
|
||||
{
|
||||
text: ['Expense Report' ],
|
||||
text: ['Expense Report'],
|
||||
alignment: 'left', bold: true, margin: [20, 30, 0, 0], fontSize: 18
|
||||
}
|
||||
]
|
||||
@ -260,7 +289,7 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
return {
|
||||
columns: [
|
||||
{
|
||||
text: ['Note'],
|
||||
text: [''],
|
||||
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 }
|
||||
@ -322,13 +351,13 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
};
|
||||
|
||||
|
||||
pdfMake.createPdf(docDefinition).download('Expense Report).pdf', function(res) {
|
||||
if(res === 'success'){
|
||||
$scope.$apply(function(){
|
||||
pdfMake.createPdf(docDefinition).download('Expense Report).pdf', function (res) {
|
||||
if (res === 'success') {
|
||||
$scope.$apply(function () {
|
||||
$scope.loadStaring = false;
|
||||
});
|
||||
}else{
|
||||
$scope.$apply(function(){
|
||||
} else {
|
||||
$scope.$apply(function () {
|
||||
$scope.loadStaring = false;
|
||||
});
|
||||
}
|
||||
@ -336,9 +365,7 @@ app.controller('report_expenseCtrl', ["$scope", "API_POINTS", "$http", "SweetAle
|
||||
}
|
||||
//end of pdf
|
||||
|
||||
$scope.exportData = function () {
|
||||
alasql('SELECT CAST(SL_NO AS NUMBER) as SLNO,Expense_name as ExpenseName,CAST(January as NUMBER) as January,CAST(February as NUMBER) as February,CAST(March as NUMBER) as March,CAST(April as NUMBER) as April,CAST(May as NUMBER) as May,CAST(June as NUMBER) as June,CAST(July as NUMBER) as July,CAST(August as NUMBER) as August,CAST(September as NUMBER) as September,CAST(October as NUMBER) as October,CAST(November as NUMBER) as November,CAST(December as NUMBER) as December,CAST(total as NUMBER) as Amount INTO XLS("Expense_report.xls",?) FROM ?',[mystyle,$scope.expense_data]);
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
|
||||
|
||||
@ -81,11 +81,11 @@
|
||||
<div class="col-md-4">
|
||||
<input class="form-control" type="text" ng-model="search" id="searchIn" autofocus tabindex="2" placeholder="Search" />
|
||||
</div>
|
||||
<!--<button pdf-save-button="getpdf" pdf-name="Expense_Report.pdf" class="btn btn-success btn-o">PDF</button>-->
|
||||
<!-- <button pdf-save-button="getpdf" pdf-name="Expense_Report.pdf" class="btn btn-success btn-o">PDF</button> -->
|
||||
<button class="btn btn-success btn-o" ng-click="exportData()">Export to Excel</button>
|
||||
<!--<button ng-disabled="loadStaring" ng-click="generatePFD(datas)" class="btn btn-sm btn-default">
|
||||
<button ng-disabled="loadStaring" ng-click="generatePFD(expense)" class="btn btn-success btn-o">
|
||||
Export As PDF
|
||||
</button>-->
|
||||
</button>
|
||||
</div>
|
||||
<div pdf-save-content="getpdf" class="table-responsive" style="margin-top: 20px;">
|
||||
<h4 style="text-align:center;">Apollo Distance Education College - {{expense_data[0].branch}}</h4>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user