v2.5
Update RestoreShift frontend
This commit is contained in:
124
web/controllers/reports.js
Normal file
124
web/controllers/reports.js
Normal file
@@ -0,0 +1,124 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('ReportsCtrl', ReportsCtrl);
|
||||
|
||||
ReportsCtrl.$inject = ['$scope', 'smartRequest'];
|
||||
function ReportsCtrl($scope, smartRequest) {
|
||||
var date = new Date();
|
||||
|
||||
var formatted = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear();
|
||||
|
||||
date.setDate(date.getDate() - 1);
|
||||
|
||||
var formatted_yesterday = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear();
|
||||
|
||||
$scope.report_delete = [];
|
||||
$scope.report_realisation = [];
|
||||
$scope.start_date = formatted_yesterday;
|
||||
$scope.end_date = formatted;
|
||||
$scope.report_id = 'realisation';
|
||||
$scope.history = [];
|
||||
$scope.statistic = {};
|
||||
$scope.staffs = [];
|
||||
$scope.printers = [];
|
||||
|
||||
$scope.update = function() {
|
||||
smartRequest.get('report/history', function(data) {
|
||||
$scope.history = data.reports;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportDelete = function() {
|
||||
smartRequest.get('report/deleted?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
$scope.report_delete = data.deleted;
|
||||
$scope.report_delete.total_sum = data.total_sum;
|
||||
$scope.report_delete.total_count = data.total_count;
|
||||
$('#report-delete').modal();
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportRealisation = function() {
|
||||
smartRequest.get('report/realisation?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
$scope.report_realisation = data.printers;
|
||||
$scope.return_printers = data.ret_prints;
|
||||
$scope.report_realisation.total_count = data.total_count;
|
||||
$scope.report_realisation.total_sum = data.total_sum;
|
||||
$('#report-realisation').modal();
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportStatistic = function() {
|
||||
smartRequest.get('report/statistics?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
$scope.statistic = data.statistic;
|
||||
$('#report-statistic').modal();
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportStaff = function() {
|
||||
smartRequest.get('report/staff?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
$scope.staffs = data.staffs;
|
||||
$('#report-staff').modal();
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportPay = function() {
|
||||
smartRequest.get('report/payment?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
$scope.printers = data.printers;
|
||||
$('#report-payment').modal();
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportOut = function () {
|
||||
smartRequest.get('v1/outorders?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function (data) {
|
||||
$scope.orders = data.orders;
|
||||
$scope.total = data.total;
|
||||
$('#report-out').modal();
|
||||
}, function (data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createReport = function() {
|
||||
switch ($scope.report_id) {
|
||||
case 'deleted': $scope.reportDelete(); break;
|
||||
case 'realisation': $scope.reportRealisation(); break;
|
||||
case 'statistics': $scope.reportStatistic(); break;
|
||||
case 'staff': $scope.reportStaff(); break;
|
||||
case 'pay': $scope.reportPay(); break;
|
||||
case 'out': $scope.reportOut(); break;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.archiveReport = function(type, start_date, end_date) {
|
||||
$scope.report_id = type;
|
||||
$scope.start_date = start_date;
|
||||
$scope.end_date = end_date;
|
||||
$scope.createReport();
|
||||
};
|
||||
|
||||
$scope.popup = function(data) {
|
||||
var mywindow = window.open();
|
||||
mywindow.document.write(data);
|
||||
mywindow.print();
|
||||
mywindow.close();
|
||||
};
|
||||
|
||||
$scope.printElem = function(elem) {
|
||||
$scope.popup($('<div/>').append($(elem).clone()).html());
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user