606 lines
18 KiB
JavaScript
606 lines
18 KiB
JavaScript
'use strict';
|
|
/*** controller***/
|
|
app.controller('income_reportCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTableParams", "API_POINTS", "$localStorage", "$http", "$state","$modal","$log",
|
|
function ($scope,$rootScope,toaster, $filter, ngTableParams, apiPoint, $localStorage, $http, $state,$modal,$log){
|
|
|
|
//function ($scope, apiPoint, $http, SweetAlert, $state,$modal, md5, ipCookie, $window, dateListDescService) {
|
|
|
|
// DataTables configurable options
|
|
|
|
|
|
$scope.filters = {
|
|
|
|
"from_date": "",
|
|
"to_date": "",
|
|
|
|
};
|
|
|
|
//console.log('out')
|
|
|
|
|
|
// $scope.initHead = function() {
|
|
//console.log('rfd');
|
|
var logcheck = JSON.parse(localStorage.getItem('localObj'));
|
|
|
|
const LOCALTYPE = logcheck.localType;
|
|
if (logcheck != null && (LOCALTYPE == 'R003' || LOCALTYPE == 'R004' || LOCALTYPE == 'R002' || LOCALTYPE == 'R005')) {
|
|
console.log("if");
|
|
}else {
|
|
if(logcheck != null && LOCALTYPE !='R001') {
|
|
console.log("else if");
|
|
$state.go('app.dashboard');
|
|
} else {
|
|
|
|
console.log("else else");
|
|
//ipCookie.remove('cookiechk');
|
|
window.localStorage.clear();
|
|
$state.go('login.signin');
|
|
}
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
$scope.init = function(){
|
|
|
|
console.log('gf');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// $scope.filters = function () {
|
|
// var filterlist = {
|
|
// method: 'POST',
|
|
// url: apiPoint.url + 'report_filters/',
|
|
// headers: {
|
|
// 'Content-Type': 'application/json'
|
|
// },
|
|
// data: {
|
|
// branch : JSON.parse(localStorage.getItem('localObj')).localBranchID
|
|
|
|
// }
|
|
|
|
// };
|
|
// $http(filterlist).then(function (response) {
|
|
// if (response.data) {
|
|
// $scope.batch=[];
|
|
// $scope.batchlist = response.data.batch;
|
|
// $scope.university = response.data.university;
|
|
// //Desc order Batchlist
|
|
// 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])
|
|
// })
|
|
// });
|
|
// // call service for make a list in desc order based on date
|
|
// $scope.batch=dateListDescService.getOrderByList($scope.batch);
|
|
// //console.log($scope.branch);
|
|
// } else {
|
|
// }
|
|
// });
|
|
// }
|
|
//$scope.opinctotal='';
|
|
$scope.onSubmit = function () {
|
|
|
|
|
|
//alert($scope.batch.name);
|
|
$scope.expense_data = '';
|
|
$scope.message = '';
|
|
$scope.incomedetail = '';
|
|
$scope.Subtypes = '';
|
|
$scope.Total_expense = '';
|
|
$scope.Total_income = '';
|
|
$scope.load = '';
|
|
$scope.isLoaderShow = '';
|
|
$scope.fromda = '';
|
|
$scope.toda ='';
|
|
$scope.opinctotal='';
|
|
$scope.nonopinctotal='';
|
|
$scope.opexptotal='';
|
|
$scope.nonopexptotal='';
|
|
|
|
|
|
var response_data = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'IncomeExpenseDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
branch: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
from : $scope.filters.from_date,
|
|
to : $scope.filters.to_date
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
$http(response_data).then(function (response) {
|
|
//console.log(response.data);
|
|
if (response.data.status == '200')
|
|
{
|
|
|
|
$scope.expense_data = response.data.expense_data;
|
|
|
|
if($scope.expense_data.length>0)
|
|
{
|
|
$scope.isLoaderShow =false;
|
|
$scope.load = 'Loading....';
|
|
}
|
|
else
|
|
{
|
|
$scope.isLoaderShow = true;
|
|
$scope.load = "No Records Found";
|
|
}
|
|
|
|
//console.log($scope.expense_data);
|
|
if(($scope.expense_data.length)==2)
|
|
{
|
|
|
|
if($scope.expense_data[0].Total == 'undefined' || $scope.expense_data[0].Total == null)
|
|
{
|
|
$scope.Total_expense=0;
|
|
}
|
|
else
|
|
{
|
|
$scope.Total_expense = $scope.expense_data[0].Total;
|
|
}
|
|
|
|
if($scope.expense_data[1].Total == 'undefined' || $scope.expense_data[1].Total == null)
|
|
{
|
|
$scope.Total_income=0;
|
|
}
|
|
else
|
|
{
|
|
$scope.Total_income = $scope.expense_data[1].Total;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
if($scope.expense_data[0].TID == 'I002')
|
|
{
|
|
$scope.Total_income = $scope.expense_data[0].Total;
|
|
$scope.Total_expense = 0;
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
$scope.Total_expense = $scope.expense_data[0].Total;
|
|
$scope.Total_income = 0;
|
|
}
|
|
|
|
}
|
|
|
|
$scope.Net_Total = $scope.Total_income -$scope.Total_expense;
|
|
|
|
|
|
}
|
|
else {
|
|
$scope.message = response.data.message;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var income_data = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'ViewFullIncomeDetails/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
data: {
|
|
branch: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
from : $scope.filters.from_date,
|
|
to : $scope.filters.to_date
|
|
}
|
|
|
|
};
|
|
|
|
|
|
$http(income_data).then(function (response) {
|
|
//console.log(response.data);
|
|
if (response.data.status == '200')
|
|
{
|
|
$scope.incomedetail = response.data;
|
|
$scope.fullincomedetail = response.data.fullexpense_detail;
|
|
console.log($scope.fullincomedetail);
|
|
$scope.opinctotal =0;
|
|
$scope.nonopinctotal =0;
|
|
$scope.opexptotal = 0;
|
|
$scope.nonopexptotal =0;
|
|
angular.forEach(($scope.fullincomedetail),function(fullincomedetail,key)
|
|
{
|
|
//console.log('in')
|
|
|
|
if((fullincomedetail.Name == 'I002')&&(fullincomedetail.OrgType=='I002'))
|
|
{
|
|
$scope.opinctotal = parseFloat(fullincomedetail.Total)+parseFloat($scope.opinctotal);
|
|
|
|
|
|
}
|
|
|
|
if((fullincomedetail.Name == 'I002')&&((fullincomedetail.OrgType=='I003')||(fullincomedetail.OrgType=='I004')
|
|
||(fullincomedetail.OrgType=='I005')||(fullincomedetail.OrgType=='I006')))
|
|
{
|
|
$scope.nonopinctotal = parseFloat(fullincomedetail.Total)+parseFloat($scope.nonopinctotal);
|
|
|
|
|
|
}
|
|
|
|
|
|
if((fullincomedetail.Name == 'I001')&&(fullincomedetail.OrgType=='I001'))
|
|
{
|
|
$scope.opexptotal = parseFloat(fullincomedetail.Total)+parseFloat($scope.opexptotal);
|
|
|
|
}
|
|
|
|
if((fullincomedetail.Name == 'I001')&&((fullincomedetail.OrgType=='I003')||(fullincomedetail.OrgType=='I004')
|
|
||(fullincomedetail.OrgType=='I005')||(fullincomedetail.OrgType=='I006')))
|
|
{
|
|
$scope.nonopexptotal = parseFloat(fullincomedetail.Total)+parseFloat($scope.nonopexptotal);
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
$scope.message = response.data.message;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var getsubdivision = {
|
|
method: 'POST',
|
|
url: apiPoint.url + 'GetSubTypes/',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
|
data: {
|
|
branch: JSON.parse(localStorage.getItem('localObj')).localBranchID,
|
|
from : $scope.filters.from_date,
|
|
to : $scope.filters.to_date
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
$http(getsubdivision).then(function (response) {
|
|
// console.log(response.data);
|
|
if (response.data.status == '200')
|
|
{
|
|
$scope.Subtypes = response.data.details;
|
|
|
|
// console.log($scope.Subtypes);
|
|
|
|
}
|
|
else
|
|
{
|
|
$scope.message = response.data.message;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mystyle = {
|
|
sheetid: 'EXPENSE REPORT',
|
|
headers: true,
|
|
caption: {
|
|
title:'EXPENSE REPORT',
|
|
width: '300px',
|
|
style:'font-size:50px;'
|
|
},
|
|
// style:'background:#00FF00',
|
|
column: {
|
|
style:'font-size:10px'
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.exportData = function ()
|
|
{
|
|
//alert()
|
|
|
|
angular.forEach(($scope.fullincomedetail),function(fullincomedetail,key)
|
|
{
|
|
//console.log($scope.fullincomedetail[key].TypeName);
|
|
if($scope.fullincomedetail[key].Name == 'I001')
|
|
{
|
|
$scope.fullincomedetail[key]['Type'] = 'Expense';
|
|
|
|
}
|
|
|
|
else if($scope.fullincomedetail[key].Name == 'I002')
|
|
{
|
|
$scope.fullincomedetail[key]['Type'] = 'Income';
|
|
}
|
|
|
|
|
|
//console.log($scope.fullincomedetail);
|
|
|
|
// alasql('SELECT Type,ListName,TypeName,Date,Amount INTO XLS("Income_Expense_report.xls",?) FROM ?',[mystyle,$scope.fullincomedetail]);
|
|
|
|
|
|
});
|
|
|
|
//console.log($scope.fullincomedetail);
|
|
alasql('SELECT Type,ListName,TypeName,Date,Amount INTO XLS("Income Expense report.xls",?) FROM ?',[mystyle,$scope.fullincomedetail]);
|
|
|
|
};
|
|
|
|
|
|
$scope.OpenWindowStatus = false;
|
|
$scope.editId = -1;
|
|
$scope.setEditId = function (P)
|
|
{
|
|
//alert(P);
|
|
$scope.editId = P;
|
|
|
|
}
|
|
|
|
$scope.close = function ()
|
|
{
|
|
|
|
$scope.editId = -1;
|
|
|
|
}
|
|
|
|
|
|
// $scope.to=0;
|
|
// $scope.totaladd = function()
|
|
// {
|
|
// $scope.fullincomedetail
|
|
|
|
// to
|
|
|
|
// }
|
|
|
|
$scope.fdate ='';
|
|
$scope.tdate ='';
|
|
//$scope.Subtypes = '';
|
|
|
|
|
|
$scope.changeSem = function()
|
|
{
|
|
|
|
$scope.open($scope.fullincomedetail,$scope.expense_data,$scope.Subtypes);
|
|
}
|
|
|
|
|
|
var fm_date= '';
|
|
var Total_inc = 0;
|
|
var Total_exp = 0;
|
|
$scope.open = function(incomeexpensedetails,incomeexpenselist,Subtypes)
|
|
{
|
|
|
|
//Total_inc === incomeexpenselist[1].Total
|
|
if(incomeexpenselist[0] == 'undefined' || incomeexpenselist[0] == null)
|
|
{
|
|
Total_exp=0;
|
|
}
|
|
else
|
|
{
|
|
Total_exp = incomeexpenselist[0].Total;
|
|
}
|
|
|
|
if(incomeexpenselist[1] == 'undefined' || incomeexpenselist[1] == null)
|
|
{
|
|
Total_inc=0;
|
|
}
|
|
else
|
|
{
|
|
Total_inc = incomeexpenselist[1].Total;
|
|
}
|
|
//console.log(incomeexpenselist[1]);
|
|
|
|
//
|
|
var formate = "dd-MM-yyyy";
|
|
|
|
$scope.fdate = $filter('date')(new Date($scope.filters.from_date), formate);
|
|
$scope.tdate = $filter('date')(new Date($scope.filters.to_date), formate);
|
|
|
|
// fm_date = $scope.fdate;
|
|
// console.log(fm_date);
|
|
|
|
incomeexpensedetails['fdate'] = $scope.fdate;
|
|
incomeexpensedetails['tdate'] = $scope.tdate;
|
|
// console.log(incomeexpensedetails);
|
|
// console.log(Subtypes);
|
|
|
|
// $scope.opinctotal =0;
|
|
// $scope.nonopinctotal =0;
|
|
// $scope.opexptotal = 0;
|
|
// $scope.nonopexptotal =0;
|
|
|
|
$rootScope.income_expendelist = incomeexpenselist;
|
|
$rootScope.income_expensedetails = incomeexpensedetails;
|
|
$rootScope.listdetails = Subtypes;
|
|
$rootScope.fdate = $scope.fdate;
|
|
$rootScope.tdate = $scope.tdate
|
|
$rootScope.net_totalamount = $scope.Net_Total;
|
|
$rootScope.opeinctot = $scope.opinctotal;
|
|
$rootScope.nonopeinctot = $scope.nonopinctotal;
|
|
$rootScope.opeexptot = $scope.opexptotal;
|
|
$rootScope.nonopexptot = $scope.nonopexptotal;
|
|
//$rootScope.sum = incomeexpenselist[1].Total - incomeexpenselist[0].Total;
|
|
|
|
$rootScope.sum = Total_inc -Total_exp;
|
|
//console.log($rootScope.sum);
|
|
//console.log($rootScope.listdetails);
|
|
|
|
var modalInstance = $modal.open({
|
|
templateUrl: 'assets/views/income_expense_report_pdf.html',
|
|
controller: 'income_reportCtrl',
|
|
// size: size,
|
|
resolve: {
|
|
pdfitems: function () {
|
|
//return $scope.FeesName;
|
|
return incomeexpensedetails;
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
modalInstance.result.then(function (selectedItem) {
|
|
$scope.selected = selectedItem;
|
|
}, function () {
|
|
$log.info('Modal dismissed at: ' + new Date());
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.generatePDF = function()
|
|
{
|
|
|
|
|
|
// kendo.drawing.drawDOM($("#income_expensepdf")).then(function(group) {
|
|
// kendo.drawing.pdf.saveAs(group, "income_expensepdf"+".pdf");
|
|
|
|
|
|
kendo.drawing.drawDOM($("#income_expensepdf"),
|
|
{ paperSize: "A4",
|
|
margin:"1cm"} ).then(function(group) {
|
|
kendo.drawing.pdf.saveAs(group, "profit-loss statement"+".pdf");
|
|
});
|
|
|
|
|
|
}
|
|
|
|
// alert('in');
|
|
// //console.log($scope.income_expensedetails.fdate);
|
|
// // return false;
|
|
|
|
// var doc = new jsPDF('A4');
|
|
// var canvas = document.createElement("canvas");
|
|
// canvas.width = 100;
|
|
// canvas.height = 100;
|
|
// var ctx = canvas.getContext("2d");
|
|
// doc.line(10,240,200,240);
|
|
// doc.setFontSize(20);
|
|
// doc.text(70,32,"Apollo Distance Education");
|
|
// doc.setFontSize(15);
|
|
// doc.text(85,40,"Profit and Loss Report");
|
|
// doc.setFontSize(12);
|
|
// doc.text(83,48,"From "+$scope.income_expensedetails.fdate+" to "+$scope.income_expensedetails.tdate );
|
|
// doc.setFontSize(10);
|
|
// // doc.text(11,55,"Income");
|
|
|
|
// var TypeName= '';
|
|
// var row=15;
|
|
// var column=60;
|
|
// var columnam='';
|
|
// var rowam=60;
|
|
|
|
// doc.rect(10, 10, 190, 280);
|
|
// var col = 45;
|
|
|
|
// // var elem = document.getElementById('myCanvas');
|
|
// // var two = new Two({
|
|
// // type: Two.Types.canvas,
|
|
// // fullscreen: true
|
|
// // }).appendTo(elem);
|
|
// // two.update();
|
|
|
|
// var line = two.makeLine(450, 140, 900, 140);
|
|
// line.linewidth = 5;
|
|
// line.stroke = "blue";
|
|
// // doc.rect(col,57,5,5);
|
|
// //console.log(JSON.parse($scope.income_expensedetails).length);return false;
|
|
// angular.forEach(($scope.income_expensedetails),function(income_expensedetails,key)
|
|
// {
|
|
// //console.log(income_expensedetails.TypeName);
|
|
// TypeName = income_expensedetails.TypeName;
|
|
// //console.log(income_expensedetails.Amount);
|
|
// row= row+10;
|
|
// // column= column+10;
|
|
// rowam=rowam+10;
|
|
// columnam = columnam+10;
|
|
// if(income_expensedetails.Name == 'I002')
|
|
// {
|
|
|
|
// doc.setFontSize(11);
|
|
// doc.text(11,55,"Income");
|
|
// doc.setFontSize(8);
|
|
// column= column+15;
|
|
// console.log(income_expensedetails.TypeName)
|
|
|
|
// doc.text(row,column,income_expensedetails.TypeName);
|
|
// doc.text(rowam,column,income_expensedetails.Amount);
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
|
|
// angular.forEach(($scope.income_expensedetails),function(income_expensedetails,key)
|
|
// {
|
|
// //console.log(income_expensedetails.TypeName);
|
|
// TypeName = income_expensedetails.TypeName;
|
|
// //console.log(income_expensedetails.Amount);
|
|
// row= row+10;
|
|
// // column= column+10;
|
|
// rowam=rowam+10;
|
|
// columnam = columnam+10;
|
|
// if(income_expensedetails.Name == 'I001')
|
|
// {
|
|
// doc.setFontSize(10);
|
|
// doc.text(11,105,"Expense");
|
|
// doc.setFontSize(8);
|
|
// column= column+15;
|
|
// console.log(income_expensedetails.TypeName)
|
|
|
|
// doc.text(row,column,income_expensedetails.TypeName);
|
|
// doc.text(rowam,column,income_expensedetails.Amount);
|
|
// }
|
|
|
|
// });
|
|
|
|
|
|
// doc.save('sample.pdf');
|
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|