controller.js
3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
angular.module('focaOrdenCarga')
.controller('focaOrdenCargaController', [
'$scope',
'$uibModal',
'$location',
'$filter',
'$timeout',
'focaOrdenCargaService',
'focaBotoneraLateralService',
'focaModalService',
'notaPedidoBusinessService',
'$rootScope',
'focaSeguimientoService',
'APP',
'focaLoginService',
'$localStorage',
function (
$scope, $uibModal, $location, $filter, $timeout, focaOrdenCargaService,
focaBotoneraLateralService, focaModalService, notaPedidoBusinessService,
$rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) {
config();
function config() {
// PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA
$scope.tmpCantidad = Number;
$scope.tmpPrecio = Number;
$scope.isNumber = angular.isNumber;
$scope.datepickerAbierto = false;
$scope.show = false;
$scope.cargando = true;
$scope.cabeceras = [];
$scope.botonera = focaOrdenCargaService.getBotonera();
$scope.puntoVenta = $filter('rellenarDigitos')(0, 4);
$scope.comprobante = $filter('rellenarDigitos')(0, 8);
$scope.dateOptions = {
maxDate: new Date(),
minDate: new Date(2010, 0, 1)
};
//SETEO BOTONERA LATERAL
$timeout(function () {
focaBotoneraLateralService.showSalir(false);
focaBotoneraLateralService.showPausar(true);
focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido);
focaBotoneraLateralService.addCustomButton('Salir', salir);
});
init();
}
function init() {
$scope.ordenCarga = {
id: 0,
cliente: {},
proveedor: {},
domicilio: { dom: '' },
vendedor: {},
fechaCarga: new Date(),
cotizacion: {},
articulosNotaPedido: [],
notaPedidoPlazo: [],
notaPedidoPuntoDescarga: []
};
}
$scope.$watch('ordenCarga', function (newValue) {
focaBotoneraLateralService.setPausarData({
label: 'ordenCarga',
val: newValue
});
}, true);
$scope.$watch('ordenCarga', function (newValue) {
focaBotoneraLateralService.setPausarData({
label: 'ordenCarga',
val: newValue
});
focaBotoneraLateralService.setRutasPausadas({
label: 'rutas',
val: 'orden-carga'
});
}, true);
$scope.crearOrdenCarga = function () {
focaBotoneraLateralService.startGuardar();
$scope.saveLoading = true;
}
$scope.salir = function () {
$location.path('/');
};
function salir() {
var confirmacion = false;
if (!angular.equals($scope.ordenCarga, $scope.inicial)) {
confirmacion = true;
}
if (confirmacion) {
focaModalService.confirm(
'¿Está seguro de que desea salir? Se perderán todos los datos cargados.'
).then(function (data) {
if (data) {
$location.path('/');
}
});
} else {
$location.path('/');
}
}
}]);