Initial Commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
Number.prototype.toFixedDown = function (digits) {
|
||||
var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)");
|
||||
var m = this.toString().match(re);
|
||||
return m ? parseFloat(m[1]) : this.valueOf();
|
||||
};
|
||||
|
||||
Number.prototype.truncate = function (digits) {
|
||||
var num = this.valueOf().toFixedDown(digits);
|
||||
num = num.toString();
|
||||
var intero = String(num.split('.')[0]);
|
||||
var fraction = String(num.split('.')[1]);
|
||||
var padding = '';
|
||||
if (isNaN(intero)) return '';
|
||||
|
||||
if (fraction == 'undefined') {
|
||||
fraction = '';
|
||||
padding = new Array(Math.max(digits - fraction.length, 0) + 1).join('0');
|
||||
if (digits > 0) {
|
||||
num += '.' + padding;
|
||||
}
|
||||
} else {
|
||||
padding = new Array(Math.max(digits - fraction.length, 0) + 1).join('0');
|
||||
num += padding;
|
||||
}
|
||||
return num;
|
||||
};
|
||||
|
||||
//funzione per l'arrotondamento delle cifre decimali in eccesso dal 5
|
||||
Number.prototype.toFixedExcess = function(precision){
|
||||
precision = (parseInt(precision) == 0) ? 0:(parseInt(precision) || 2);
|
||||
var num = this.valueOf();
|
||||
var pow = Math.pow(10,precision);
|
||||
return (Math.round( num * pow ) / pow).toFixed(precision);
|
||||
};
|
||||
|
||||
//Funzione per arrotondare correttamente i numeri in modo da correggere l'errore delle somme e differenze
|
||||
function myParseFloat(number){
|
||||
//console.log("MyParseFloat-Old: "+number);
|
||||
var newnumber = new Number(number+'').toFixed(12);
|
||||
//console.log("MyParseFloat-New: "+newnumber);
|
||||
return parseFloat(newnumber);
|
||||
}
|
||||
|
||||
//Funzione che implementa il pad left di una stringa
|
||||
Number.prototype.padLeft = function (n,str) {
|
||||
return (this < 0 ? '-' : '') +
|
||||
Array(n-String(Math.abs(this)).length+1)
|
||||
.join(str||'0') +
|
||||
(Math.abs(this));
|
||||
};
|
||||
|
||||
const checkIfAddressIsInArea = (location, area) => {
|
||||
if (google.maps.geometry.poly.containsLocation(location, area)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const checkIfAddressIsInAreaLatLon = (lat, lon) => {
|
||||
const location = new google.maps.LatLng(lat, lon);
|
||||
if (google.maps.geometry.poly.containsLocation(location, area)){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Vendored
+1000
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
function DashboardController($scope, Ordini, moment, toaster, AuthService, DateRangePickerService, $timeout, $window) {
|
||||
|
||||
$scope.dateRangeOptions = {
|
||||
...defaultDateRangePickerOptions,
|
||||
ranges: DateRangePickerService.getTrimestreCustomRangeOptions(),
|
||||
autoApply: true
|
||||
};
|
||||
|
||||
const stampaRapportoAdminUri = `${BASE_URL_SITE}/admin/index/stampareportattivita`;
|
||||
|
||||
$scope.loading = true;
|
||||
$scope.DataConsegna = {startDate: moment().subtract(29, 'days'), endDate: moment()};
|
||||
|
||||
$scope.Periodo = '';
|
||||
|
||||
$scope.series = ['Ordini ' + $scope.Periodo, ''];
|
||||
$scope.colors = ['#44ABF1', '#DDDDDD'];
|
||||
|
||||
$scope.labels = [];
|
||||
$scope.data = [];
|
||||
|
||||
$scope.TotOrdiniPeriodo = 0;
|
||||
|
||||
$scope.graphOptions = {
|
||||
legend: {display: false},
|
||||
scales: {
|
||||
yAxes: [
|
||||
{
|
||||
id: 'y-axis-1',
|
||||
type: 'linear',
|
||||
display: true,
|
||||
position: 'left'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$watch('DataConsegna', (oldVal, newVal) => {
|
||||
$scope.Periodo = 'Dal ' + newVal.startDate.format('DD/MM/YYYY') + ' al ' + newVal.endDate.format('DD/MM/YYYY');
|
||||
$scope.refreshGraph();
|
||||
});
|
||||
|
||||
$scope.refreshGraph = () => {
|
||||
$scope.loading = true;
|
||||
const per = $scope.DataConsegna.startDate.format('YYYY-MM-DD') + '|' + $scope.DataConsegna.endDate.format('YYYY-MM-DD');
|
||||
Ordini.getGraphData(per).then((res) => {
|
||||
$scope.labels = res.DatiGrafico.labels;
|
||||
$scope.data = [res.DatiGrafico.data, []];
|
||||
$scope.TotOrdiniPeriodo = res.TotOrdini;
|
||||
}).catch((err) => {
|
||||
toaster.error("Attenzione", "Errore durante il recupero dei dati del grafico");
|
||||
}).finally(() => {
|
||||
$timeout(() => {
|
||||
$scope.loading = false
|
||||
}, 300);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.stampaRapporto = () => {
|
||||
|
||||
if (!$scope.DataConsegna) {
|
||||
alert("Devi selezionare un periodo per la stampa rapporto");
|
||||
return;
|
||||
}
|
||||
|
||||
let periodo = $scope.DataConsegna.startDate.format('YYYY-MM-DD') + '|' + $scope.DataConsegna.endDate.format('YYYY-MM-DD');
|
||||
|
||||
/*if(!confirm(`Aprire la stampa report per il periodo scelto (${periodo}) ?`)){
|
||||
return;
|
||||
}*/
|
||||
|
||||
let url = `${stampaRapportoAdminUri}/p/${periodo}`;
|
||||
$window.open(url, '_blank');
|
||||
};
|
||||
|
||||
//$scope.refreshGraph();
|
||||
|
||||
}
|
||||
|
||||
app.controller('DashboardController', DashboardController);
|
||||
Vendored
+271
@@ -0,0 +1,271 @@
|
||||
angular.module('app')
|
||||
|
||||
.factory('SottoAree', function ($resource) {
|
||||
const resource = $resource(basePath + 'sottoaree/:id', {id: '@id'}, {
|
||||
update: {method: 'PUT'},
|
||||
insert: {method: 'POST'},
|
||||
getList: {
|
||||
method: 'GET',
|
||||
url: basePath + 'sottoaree',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
getByCodice: {
|
||||
method: 'GET',
|
||||
url: basePath + 'sottoaree/m/get-by-codice'
|
||||
}
|
||||
});
|
||||
return {
|
||||
get: function (success, error) {
|
||||
return resource.query(success, error);
|
||||
},
|
||||
find: function (id) {
|
||||
return resource.get({id: id}).$promise;
|
||||
},
|
||||
insert: function (data) {
|
||||
return resource.insert(data).$promise;
|
||||
},
|
||||
update: function (data) {
|
||||
return resource.update(data).$promise;
|
||||
},
|
||||
delete: function (id) {
|
||||
return resource.delete({id: id}).$promise;
|
||||
},
|
||||
getList: function (data) {
|
||||
return resource.getList(data).$promise;
|
||||
},
|
||||
getByCodice: function (codice) {
|
||||
return resource.getByCodice({Codice: codice}).$promise;
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.factory('Users', function ($resource) {
|
||||
const resource = $resource(basePath + 'users/:id', {id: '@id'}, {
|
||||
update: {method: 'PUT'},
|
||||
insert: {method: 'POST'},
|
||||
getUserData: {
|
||||
method: 'GET',
|
||||
url: basePath + 'users/m/get-user-info',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
getList: {
|
||||
method: 'GET',
|
||||
url: basePath + 'users',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
proponiCodiceUtente: {
|
||||
method: 'GET',
|
||||
url: basePath + 'users/m/get-codice'
|
||||
},
|
||||
caricaRidersMt: {
|
||||
method: 'GET',
|
||||
url: basePath + 'users/m/get-riders-mt',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
});
|
||||
return {
|
||||
get: function (success, error) {
|
||||
return resource.query(success, error);
|
||||
},
|
||||
find: function (id) {
|
||||
return resource.get({id: id}).$promise;
|
||||
},
|
||||
getByToken: function (token) {
|
||||
return resource.getList({token: token}).$promise;
|
||||
},
|
||||
getUserData: function () {
|
||||
return resource.getUserData().$promise;
|
||||
},
|
||||
insert: function (data) {
|
||||
return resource.insert(data).$promise;
|
||||
},
|
||||
update: function (data) {
|
||||
return resource.update(data).$promise;
|
||||
},
|
||||
delete: function (id) {
|
||||
return resource.delete({id: id}).$promise;
|
||||
},
|
||||
getList: function (data) {
|
||||
return resource.getList(data).$promise;
|
||||
},
|
||||
proponiCodiceUtente: function (role) {
|
||||
return resource.proponiCodiceUtente({role: role}).$promise;
|
||||
},
|
||||
caricaRidersMt: function () {
|
||||
return resource.caricaRidersMt().$promise;
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.factory('FasceOrarie', function ($resource) {
|
||||
const resource = $resource(basePath + 'fasceorarie/:id', {id: '@id'}, {
|
||||
update: {method: 'PUT'},
|
||||
insert: {method: 'POST'},
|
||||
getList: {
|
||||
method: 'GET',
|
||||
url: basePath + 'fasceorarie',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
get: function (success, error) {
|
||||
return resource.query(success, error);
|
||||
},
|
||||
find: function (id) {
|
||||
return resource.get({id: id}).$promise;
|
||||
},
|
||||
insert: function (data) {
|
||||
return resource.insert(data).$promise;
|
||||
},
|
||||
update: function (data) {
|
||||
return resource.update(data).$promise;
|
||||
},
|
||||
delete: function (id) {
|
||||
return resource.delete({id: id}).$promise;
|
||||
},
|
||||
getList: function (data) {
|
||||
return resource.getList(data).$promise;
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.factory('TipologieAttivita', function ($resource) {
|
||||
const resource = $resource(basePath + 'tipologieattivita/:id', {id: '@id'}, {
|
||||
update: {method: 'PUT'},
|
||||
insert: {method: 'POST'},
|
||||
getList: {
|
||||
method: 'GET',
|
||||
url: basePath + 'tipologieattivita',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
get: function (success, error) {
|
||||
return resource.query(success, error);
|
||||
},
|
||||
find: function (id) {
|
||||
return resource.get({id: id}).$promise;
|
||||
},
|
||||
insert: function (data) {
|
||||
return resource.insert(data).$promise;
|
||||
},
|
||||
update: function (data) {
|
||||
return resource.update(data).$promise;
|
||||
},
|
||||
delete: function (id) {
|
||||
return resource.delete({id: id}).$promise;
|
||||
},
|
||||
getList: function (data) {
|
||||
return resource.getList(data).$promise;
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.factory('Ordini', function ($resource) {
|
||||
const resource = $resource(basePath + 'ordini/:id', {id: '@id'}, {
|
||||
update: {method: 'PUT'},
|
||||
insert: {method: 'POST'},
|
||||
getList: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordini',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
getOrdiniDaGestire: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordiniadmin',
|
||||
transformResponse: function (result,headers) {
|
||||
let res = {};
|
||||
res.data = angular.fromJson(result);
|
||||
res.headers = headers();
|
||||
return res;
|
||||
}
|
||||
},
|
||||
checkStatoOrdiniSync: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordiniadmin/m/check-ordini-sync',
|
||||
},
|
||||
setStatoOrdiniSync: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordiniadmin/m/set-ordini-sync',
|
||||
},
|
||||
resetMtDashboard: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordiniadmin/m/reset-mt-dashboard',
|
||||
},
|
||||
getGraphData: {
|
||||
method: 'GET',
|
||||
url: basePath + 'ordiniadmin/m/get-graph-data',
|
||||
}
|
||||
});
|
||||
return {
|
||||
get: function (success, error) {
|
||||
return resource.query(success, error);
|
||||
},
|
||||
find: function (id) {
|
||||
return resource.get({id: id}).$promise;
|
||||
},
|
||||
insert: function (data) {
|
||||
return resource.insert(data).$promise;
|
||||
},
|
||||
update: function (data) {
|
||||
return resource.update(data).$promise;
|
||||
},
|
||||
delete: function (id) {
|
||||
return resource.delete({id: id}).$promise;
|
||||
},
|
||||
getList: function (data) {
|
||||
return resource.getList(data).$promise;
|
||||
},
|
||||
getOrdiniDaGestire: function (data) {
|
||||
return resource.getOrdiniDaGestire(data).$promise;
|
||||
},
|
||||
checkStatoOrdiniSync: function () {
|
||||
return resource.checkStatoOrdiniSync().$promise;
|
||||
},
|
||||
setStatoOrdiniSync: function (stato) {
|
||||
return resource.setStatoOrdiniSync({s: stato}).$promise;
|
||||
},
|
||||
resetMtDashboard: function () {
|
||||
return resource.resetMtDashboard().$promise;
|
||||
},
|
||||
getGraphData: function (periodo) {
|
||||
return resource.getGraphData({p: periodo}).$promise;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user