Commit e2b3485e5414185a87d8a4de92580bb4d79ae515
1 parent
3abde74d8a
Exists in
master
and in
2 other branches
Crear Hoja de ruta RA
Showing
6 changed files
with
1159 additions
and
208 deletions
Show diff stats
src/js/businessService.js
1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
2 | .factory('hojaRutaBusinessService', [ | 2 | .factory('hojaRutaBusinessService', [ |
3 | 'crearHojaRutaService', | 3 | 'focaCrearHojaRutaService', |
4 | function(crearHojaRutaService) { | 4 | function(crearHojaRutaService) { |
5 | return { | 5 | return { |
6 | addArticulos: function(articulosHojaRuta, idHojaRuta, cotizacion) { | 6 | addArticulos: function(articulosHojaRuta, idRemito, cotizacion) { |
7 | for(var i = 0; i < articulosHojaRuta.length; i++) { | 7 | for(var i = 0; i < articulosHojaRuta.length; i++) { |
8 | delete articulosHojaRuta[i].editCantidad; | 8 | delete articulosHojaRuta[i].editCantidad; |
9 | delete articulosHojaRuta[i].editPrecio; | 9 | delete articulosHojaRuta[i].editPrecio; |
10 | articulosHojaRuta[i].idHojaRuta = idHojaRuta; | 10 | delete articulosHojaRuta[i].sectorCodigo; |
11 | articulosHojaRuta[i].idRemito = idRemito; | ||
11 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; | 12 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; |
12 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); | 13 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); |
13 | } | 14 | } |
14 | }, | 15 | }, |
15 | addEstado: function(idHojaRuta, idVendedor) { | 16 | addEstado: function(idHojaRuta, idVendedor) { |
16 | var date = new Date(); | 17 | var date = new Date(); |
17 | var estado = { | 18 | var estado = { |
18 | idHojaRuta: idHojaRuta, | 19 | idHojaRuta: idHojaRuta, |
19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 20 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
20 | .toISOString().slice(0, 19).replace('T', ' '), | 21 | .toISOString().slice(0, 19).replace('T', ' '), |
21 | estado: 0, | 22 | estado: 0, |
22 | idVendedor: idVendedor | 23 | idVendedor: idVendedor |
23 | }; | 24 | }; |
24 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); | 25 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); |
25 | } | 26 | }, |
26 | }; | 27 | }; |
27 | }]); | 28 | }]); |
28 | 29 |
src/js/controller.js
1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
2 | [ | 2 | [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$timeout', | 7 | '$timeout', |
8 | 'focaCrearHojaRutaService', | 8 | 'focaCrearHojaRutaService', |
9 | 'focaModalService', | 9 | 'focaModalService', |
10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
11 | 'focaLoginService', | 11 | 'focaLoginService', |
12 | '$localStorage', | 12 | '$localStorage', |
13 | function($scope, $uibModal, $location, $filter, $timeout, | 13 | 'hojaRutaBusinessService', |
14 | '$cookies', | ||
15 | function ($scope, $uibModal, $location, $filter, $timeout, | ||
14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, | 16 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
15 | focaLoginSrv, $localStorage) | 17 | focaLoginSrv, $localStorage, hojaRutaBusinessService, $cookies) { |
16 | { | ||
17 | config(); | 18 | config(); |
18 | 19 | ||
19 | function config() { | 20 | function config() { |
20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); | 21 | |
22 | $scope.botoneraPrincipal = focaCrearHojaRutaService.getBotones(); | ||
23 | $scope.botonera = []; | ||
24 | |||
21 | $scope.datepickerAbierto = false; | 25 | $scope.datepickerAbierto = false; |
22 | $scope.show = false; | 26 | $scope.show = false; |
27 | $scope.precargado = false; | ||
28 | $scope.cargaRemito = false; | ||
29 | $scope.remitoAbierto = false; | ||
30 | $scope.cisternaCargas = []; | ||
23 | $scope.cargando = true; | 31 | $scope.cargando = true; |
32 | $scope.articulos = []; | ||
33 | $scope.remito = { | ||
34 | id: '', | ||
35 | numeroRemito: '' | ||
36 | }; | ||
24 | $scope.now = new Date(); | 37 | $scope.now = new Date(); |
25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 38 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 39 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
27 | 40 | ||
28 | //SETEO BOTONERA LATERAL | 41 | //SETEO BOTONERA LATERAL |
29 | $timeout(function() { | 42 | $timeout(function () { |
30 | focaBotoneraLateralService.showSalir(false); | 43 | focaBotoneraLateralService.showSalir(false); |
31 | focaBotoneraLateralService.showPausar(true); | 44 | focaBotoneraLateralService.showPausar(true); |
32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 45 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
33 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 46 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | }); | 47 | }); |
35 | 48 | ||
36 | focaCrearHojaRutaService.getParametros().then(function(res) { | 49 | focaCrearHojaRutaService.getParametros().then(function (res) { |
37 | 50 | ||
38 | var parametros = JSON.parse(res.data[0].jsonText); | 51 | var parametros = JSON.parse(res.data[0].jsonText); |
39 | 52 | ||
40 | if ($localStorage.hojaRuta) { | 53 | if ($localStorage.hojaRuta) { |
41 | $timeout(function() {getLSHojaRuta();}); | 54 | $timeout(function () { getLSHojaRuta(); }); |
42 | } else { | 55 | } else { |
43 | 56 | for (var property in parametros) { | |
44 | for(var property in parametros) { | ||
45 | $scope.hojaRuta[property] = parametros[property]; | 57 | $scope.hojaRuta[property] = parametros[property]; |
46 | $scope.inicial[property] = parametros[property]; | 58 | $scope.inicial[property] = parametros[property]; |
47 | } | 59 | } |
48 | 60 | //Setear Hoja de Ruta | |
49 | setearHojaRuta($scope.hojaRuta); | 61 | //setearHojaRuta($scope.hojaRuta); |
50 | } | 62 | } |
51 | }); | 63 | }); |
52 | init(); | 64 | init(); |
53 | } | 65 | } |
54 | |||
55 | function init() { | 66 | function init() { |
56 | $scope.$broadcast('cleanCabecera'); | 67 | $scope.$broadcast('cleanCabecera'); |
57 | 68 | ||
58 | $scope.hojaRuta = { | 69 | $scope.hojaRuta = { |
59 | fecha: new Date(), | 70 | fecha: new Date(), |
60 | litros: 0, | 71 | litros: 0, |
61 | chofer: {}, | 72 | chofer: {}, |
62 | vehiculo: { | 73 | vehiculo: { |
63 | capacidad: 0 | 74 | capacidad: 0 |
64 | }, | 75 | }, |
65 | transportista: {}, | 76 | transportista: {}, |
66 | remitosTabla: [] | 77 | remitosTabla: [] |
67 | }; | 78 | }; |
68 | $scope.idLista = undefined; | 79 | $scope.idLista = undefined; |
69 | 80 | ||
70 | focaCrearHojaRutaService.getNumeroHojaRuta().then( | 81 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
71 | function(res) { | 82 | function (res) { |
72 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); | 83 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
73 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); | 84 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
74 | }, | 85 | }, |
75 | function(err) { | 86 | function (err) { |
76 | focaModalService.alert('La terminal no esta configurada correctamente'); | 87 | focaModalService.alert('La terminal no esta configurada correctamente'); |
77 | console.info(err); | 88 | console.info(err); |
78 | } | 89 | } |
79 | ); | 90 | ); |
80 | setearFecha(new Date()); | 91 | setearFecha(new Date()); |
81 | $scope.inicial = angular.copy($scope.hojaRuta); | 92 | $scope.inicial = angular.copy($scope.hojaRuta); |
82 | } | 93 | } |
83 | 94 | ||
84 | $scope.$watch('hojaRuta', function(newValue) { | 95 | // $scope.$watch('hojaRuta', function(newValue) { |
85 | 96 | ||
86 | // Seteo checked en remitos | 97 | // // Seteo checked en remitos |
87 | if ($scope.hojaRuta.remitosTabla.length) { | 98 | // if ($scope.hojaRuta.remitosTabla.length) { |
99 | // $filter('filter')($scope.botonera, { | ||
100 | // label: 'Remitos', | ||
101 | // })[0].checked = true; | ||
102 | // } else { | ||
103 | // $filter('filter')($scope.botonera, { | ||
104 | // label: 'Remitos', | ||
105 | // })[0].checked = false; | ||
106 | // } | ||
107 | |||
108 | // focaBotoneraLateralService.setPausarData({ | ||
109 | // label: 'hojaRuta', | ||
110 | // val: newValue | ||
111 | // }); | ||
112 | // }, true); | ||
113 | |||
114 | $scope.seleccionarRemitoAbierto = function () { | ||
115 | $scope.remitoAbierto = true; | ||
116 | $scope.cargaRemito = false; | ||
117 | $scope.botoneraPrincipal.forEach(function (boton) { | ||
118 | boton.checked = false; | ||
119 | }); | ||
120 | $filter('filter')($scope.botoneraPrincipal, { | ||
121 | label: 'Remito Abierto', | ||
122 | })[0].checked = false; | ||
123 | |||
124 | $scope.botonera = focaCrearHojaRutaService.getRemitoAbierto(); | ||
125 | }; | ||
88 | 126 | ||
89 | $filter('filter')($scope.botonera, { | 127 | $scope.seleccionarCargarRemitos = function () { |
90 | label: 'Remitos', | 128 | $scope.cargaRemito = true; |
91 | })[0].checked = true; | 129 | |
130 | var isBotoneraDirty = $scope.botonera.find(function (boton) { | ||
131 | return boton.checked; | ||
132 | }); | ||
133 | |||
134 | if (isBotoneraDirty) { | ||
135 | focaModalService.confirm('Se perderan los cambios') | ||
136 | .then(function () { | ||
137 | limpiarBotonera($scope.botonera); | ||
138 | $scope.preCargados = false; | ||
139 | $filter('filter')($scope.botoneraPrincipal, { | ||
140 | label: 'Cargar Remitos', | ||
141 | })[0].checked = true; | ||
142 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
143 | }); | ||
92 | } else { | 144 | } else { |
93 | $filter('filter')($scope.botonera, { | 145 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
94 | label: 'Remitos', | ||
95 | })[0].checked = false; | ||
96 | } | 146 | } |
147 | $scope.precargado = false; | ||
148 | }; | ||
149 | |||
150 | $scope.seleccionarPrecargados = function () { | ||
151 | $scope.precargado = true; | ||
152 | $filter('filter')($scope.botoneraPrincipal, { | ||
153 | label: '', | ||
154 | })[0].checked = true; | ||
155 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); | ||
156 | }; | ||
97 | 157 | ||
98 | focaBotoneraLateralService.setPausarData({ | 158 | $scope.quitarArticulo = function (articulo) { |
99 | label: 'hojaRuta', | 159 | $scope.articulosSeleccionados.forEach( function () { |
100 | val: newValue | ||
101 | }); | 160 | }); |
102 | }, true); | 161 | articulo = -1; |
162 | }; | ||
103 | 163 | ||
104 | $scope.crearHojaRuta = function() { | 164 | function validarHojaRuta() { |
105 | if (!$scope.hojaRuta.remitosTabla.length) { | 165 | if ($scope.precargado) { |
106 | focaModalService.alert('Ingrese Remitos'); | 166 | if (!$scope.hojaRuta.chofer.id) { |
107 | return; | 167 | focaModalService.alert('Ingrese Chofer'); |
108 | } | 168 | return false; |
109 | if (!$scope.hojaRuta.chofer.id) { | 169 | } |
110 | focaModalService.alert('Ingrese Chofer'); | 170 | if (!$scope.hojaRuta.vehiculo.id) { |
111 | return; | 171 | focaModalService.alert('Ingrese Vehiculo'); |
172 | return false; | ||
173 | } | ||
174 | if (!$scope.hojaRuta.transportista.COD) { | ||
175 | focaModalService.alert('Ingrese Transportista'); | ||
176 | return false; | ||
177 | } | ||
178 | if (!$scope.hojaRuta.datosExtra) { | ||
179 | focaModalService.alert('Ingrese Datos extra'); | ||
180 | return false; | ||
181 | } | ||
182 | } else if ($scope.cargaRemito) { | ||
183 | if (!$scope.hojaRuta.remitosTabla.length) { | ||
184 | focaModalService.alert('Ingrese Remitos'); | ||
185 | return false; | ||
186 | } else if (!$scope.hojaRuta.chofer.id) { | ||
187 | focaModalService.alert('Ingrese Chofer'); | ||
188 | return false; | ||
189 | } | ||
190 | if (!$scope.hojaRuta.vehiculo.id) { | ||
191 | focaModalService.alert('Ingrese Vehiculo'); | ||
192 | return false; | ||
193 | } | ||
194 | if (!$scope.hojaRuta.transportista.COD) { | ||
195 | focaModalService.alert('Ingrese Transportista'); | ||
196 | return false; | ||
197 | } | ||
198 | if (!$scope.hojaRuta.datosExtra) { | ||
199 | focaModalService.alert('Ingrese Datos extra'); | ||
200 | return false; | ||
201 | } | ||
202 | } else if ($scope.remitoAbierto) { | ||
203 | if (!$scope.hojaRuta.transportista.COD) { | ||
204 | focaModalService.alert('Ingrese Transportista'); | ||
205 | return false; | ||
206 | } else if (!$scope.hojaRuta.vehiculo.id) { | ||
207 | focaModalService.alert('Ingrese Vehiculo'); | ||
208 | return false; | ||
209 | } else if (!$scope.hojaRuta.chofer.id) { | ||
210 | focaModalService.alert('Ingrese Chofer'); | ||
211 | return false; | ||
212 | } else if (!$scope.hojaRuta.proveedor.COD) { | ||
213 | focaModalService.alert('Ingrese Proveedor'); | ||
214 | return false; | ||
215 | } else if (!$scope.hojaRuta.cliente.COD) { | ||
216 | focaModalService.alert('Ingrese un Cliente'); | ||
217 | return; | ||
218 | } | ||
112 | } | 219 | } |
113 | if (!$scope.hojaRuta.vehiculo.id) { | 220 | return true; |
114 | focaModalService.alert('Ingrese Vehiculo'); | 221 | |
222 | } | ||
223 | |||
224 | function getImporte(propiedad) { | ||
225 | var importe = 0; | ||
226 | |||
227 | $scope.articulos.forEach(function (articulo) { | ||
228 | |||
229 | if (articulo[propiedad]) { | ||
230 | importe += articulo[propiedad] * articulo.cantidad; | ||
231 | } | ||
115 | return; | 232 | return; |
233 | |||
234 | }); | ||
235 | |||
236 | return importe; | ||
237 | } | ||
238 | |||
239 | function guardarRemitoAbierto() { | ||
240 | //guardar nuevo objeto (?) | ||
241 | var date = new Date(); | ||
242 | if ($scope.hojaRuta !== null) { | ||
243 | focaBotoneraLateralService.startGuardar(); | ||
244 | var save = { | ||
245 | remito: { | ||
246 | id: 0, | ||
247 | fechaRemito: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | ||
248 | idCliente: $scope.hojaRuta.cliente.COD, | ||
249 | nombreCliente: $scope.hojaRuta.cliente.NOM, | ||
250 | cuitCliente: $scope.hojaRuta.cliente.CUIT, | ||
251 | idVendedor: $cookies.get('vendedorCobrador'), | ||
252 | idProveedor: $scope.hojaRuta.proveedor.COD, | ||
253 | idDomicilio: $scope.hojaRuta.idDomicilio || $scope.hojaRuta.domicilio.id, | ||
254 | idCotizacion: $scope.hojaRuta.cotizacion.ID, | ||
255 | domicilioStamp: $scope.hojaRuta.domicilioStamp, | ||
256 | observaciones: $scope.hojaRuta.observaciones, | ||
257 | idListaPrecio: $scope.hojaRuta.cliente.MOD.trim(), | ||
258 | total: getImporte('total') || 0, | ||
259 | descuento: 0,//TODO, | ||
260 | importeNeto: getImporte('netoUnitario') || 0, //TODO: arreglar, | ||
261 | importeExento: getImporte('exentoUnitario'), | ||
262 | importeIva: getImporte('ivaUnitario') || 0, //TODO: arreglar | ||
263 | importeIvaServicios: 0,//TODO | ||
264 | importeImpuestoInterno: getImporte('impuestoInternoUnitario'), | ||
265 | importeImpuestoInterno1: getImporte('impuestoInterno1Unitario'), | ||
266 | importeImpuestoInterno2: getImporte('impuestoInterno2Unitario'), | ||
267 | percepcion: 0,//TODO | ||
268 | percepcionIva: 0,//TODO | ||
269 | redondeo: 0,//TODO | ||
270 | anulado: false, | ||
271 | planilla: $filter('date')($scope.now, 'ddMMyyyy'), | ||
272 | lugar: parseInt($scope.puntoVenta), | ||
273 | cuentaMadre: 0,//TODO | ||
274 | cuentaContable: 0,//TODO | ||
275 | asiento: 0,//TODO | ||
276 | e_hd: '',//TODO | ||
277 | c_hd: '', | ||
278 | numeroLiquidoProducto: 0,//TODO | ||
279 | estado: 0, | ||
280 | destinoVenta: 0,//TODO | ||
281 | operacionTipo: 0, //TODO | ||
282 | }, | ||
283 | notaPedido: { | ||
284 | id: 0 | ||
285 | } | ||
286 | }; | ||
287 | focaCrearHojaRutaService.crearRemito(save).then( | ||
288 | function (data) { | ||
289 | focaBotoneraLateralService.endGuardar(true); | ||
290 | $scope.saveLoading = false; | ||
291 | |||
292 | $scope.remito.id = data.data.id; | ||
293 | |||
294 | focaCrearHojaRutaService.guardarCisternas({ | ||
295 | cisternaCargas: $scope.cisternaCargas, | ||
296 | cisternaMovimientos: $scope.cisternaMovimientos, | ||
297 | fechaReparto: $scope.hojaRuta.fechaReparto, | ||
298 | idVehiculo: $scope.hojaRuta.vehiculo.id | ||
299 | }, data.data.id); | ||
300 | $scope.remito.numeroRemito = data.data.numero; | ||
301 | |||
302 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { | ||
303 | // remitoBusinessService.addPuntosDescarga(data.data.id, | ||
304 | // $scope.remito.remitoPuntoDescarga); | ||
305 | // } | ||
306 | |||
307 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, | ||
308 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); | ||
309 | |||
310 | guardarHojaRuta(data.data.id); | ||
311 | |||
312 | }, function (error) { | ||
313 | focaModalService.alert(error.data || 'Hubo un error al crear el remito'); | ||
314 | focaBotoneraLateralService.endGuardar(); | ||
315 | $scope.saveLoading = false; | ||
316 | console.info(error); | ||
317 | } | ||
318 | ); | ||
319 | |||
320 | function guardarHojaRuta(idRemito) { | ||
321 | |||
322 | |||
323 | var save2 = { | ||
324 | hojaRuta: { | ||
325 | id: 0, | ||
326 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | ||
327 | .replace('T', ' '), | ||
328 | idTransportista: $scope.hojaRuta.transportista.COD, | ||
329 | idChofer: $scope.hojaRuta.chofer.id, | ||
330 | idVehiculo: $scope.hojaRuta.vehiculo.id, | ||
331 | proveedor: $scope.hojaRuta.proveedor.id, | ||
332 | fechaReparto: | ||
333 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | ||
334 | estado: 0, | ||
335 | abierta: 1 | ||
336 | }, | ||
337 | remitos: [{id: idRemito}] | ||
338 | } | ||
339 | save2.hojaRuta = angular.extend({}, save2.hojaRuta, $scope.hojaRuta.datosExtra); | ||
340 | focaCrearHojaRutaService.crearHojaRuta(save2).then( | ||
341 | function (data) { | ||
342 | focaModalService.alert( | ||
343 | 'Hoja ruta creada Nยบ: ' + | ||
344 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | ||
345 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | ||
346 | ); | ||
347 | |||
348 | config(); | ||
349 | }, | ||
350 | function (error) { | ||
351 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | ||
352 | console.info(error); | ||
353 | } | ||
354 | ); | ||
355 | } | ||
116 | } | 356 | } |
117 | if (!$scope.hojaRuta.transportista.COD) { | 357 | } |
118 | focaModalService.alert('Ingrese Transportista'); | 358 | |
359 | $scope.seleccionarCliente = function () { | ||
360 | var modalInstance = $uibModal.open( | ||
361 | { | ||
362 | ariaLabelledBy: 'Busqueda de Cliente', | ||
363 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
364 | controller: 'focaBusquedaClienteModalController', | ||
365 | resolve: { | ||
366 | vendedor: function () { return null; }, | ||
367 | cobrador: function () { return null; } | ||
368 | }, | ||
369 | size: 'lg' | ||
370 | } | ||
371 | ); | ||
372 | modalInstance.result.then( | ||
373 | function (cliente) { | ||
374 | $scope.abrirModalDomicilios(cliente); | ||
375 | $scope.cliente = cliente; | ||
376 | }, function () { | ||
377 | } | ||
378 | ); | ||
379 | }; | ||
380 | |||
381 | $scope.abrirModalDomicilios = function (cliente) { | ||
382 | var modalInstanceDomicilio = $uibModal.open( | ||
383 | { | ||
384 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
385 | templateUrl: 'modal-domicilio.html', | ||
386 | controller: 'focaModalDomicilioController', | ||
387 | size: 'lg', | ||
388 | resolve: { | ||
389 | idCliente: function () { return cliente.cod; }, | ||
390 | esNuevo: function () { return cliente.esNuevo; } | ||
391 | } | ||
392 | } | ||
393 | ); | ||
394 | modalInstanceDomicilio.result.then( | ||
395 | function (domicilio) { | ||
396 | $scope.hojaRuta.domicilio = domicilio; | ||
397 | $scope.hojaRuta.cliente = { | ||
398 | COD: cliente.cod, | ||
399 | CUIT: cliente.cuit, | ||
400 | NOM: cliente.nom, | ||
401 | MAIL: cliente.mail, | ||
402 | MOD: cliente.mod, | ||
403 | IVA: cliente.iva, | ||
404 | VEN: cliente.ven | ||
405 | }; | ||
406 | focaCrearHojaRutaService.getVendedorById($scope.hojaRuta.cliente.VEN) | ||
407 | .then(function (res) { | ||
408 | if (res.data !== '') { | ||
409 | $scope.hojaRuta.vendedor = res.data; | ||
410 | $scope.$broadcast('addCabecera', { | ||
411 | label: 'Vendedor:', | ||
412 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor | ||
413 | .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | ||
414 | }); | ||
415 | } | ||
416 | var domicilioStamp = | ||
417 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | ||
418 | domicilio.Localidad + ', ' + domicilio.Provincia; | ||
419 | $scope.hojaRuta.domicilioStamp = domicilioStamp; | ||
420 | $scope.$broadcast('addCabecera', { | ||
421 | label: 'Cliente:', | ||
422 | valor: $filter('rellenarDigitos')(cliente.cod, 3) + | ||
423 | ' - ' + cliente.nom | ||
424 | }); | ||
425 | $scope.$broadcast('addCabecera', { | ||
426 | label: 'Domicilio:', | ||
427 | valor: domicilioStamp | ||
428 | }); | ||
429 | |||
430 | if (domicilio.verPuntos) { | ||
431 | delete $scope.hojaRuta.domicilio.verPuntos; | ||
432 | $scope.seleccionarPuntosDeDescarga(); | ||
433 | } else { | ||
434 | focaCrearHojaRutaService | ||
435 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | ||
436 | .then(function (res) { | ||
437 | if (res.data.length) { | ||
438 | $scope.seleccionarPuntosDeDescarga(); | ||
439 | } | ||
440 | }); | ||
441 | } | ||
442 | |||
443 | $filter('filter')($scope.botonera, { | ||
444 | label: 'Cliente', | ||
445 | })[0].checked = true; | ||
446 | }) | ||
447 | .catch(function (e) { console.log(e); }); | ||
448 | }, function () { | ||
449 | $scope.seleccionarCliente(true); | ||
450 | return; | ||
451 | } | ||
452 | ); | ||
453 | }; | ||
454 | |||
455 | $scope.seleccionarPuntosDeDescarga = function () { | ||
456 | if (!$scope.hojaRuta.cliente.COD || !$scope.hojaRuta.domicilio.id) { | ||
457 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | ||
119 | return; | 458 | return; |
459 | } else { | ||
460 | var modalInstance = $uibModal.open( | ||
461 | { | ||
462 | ariaLabelledBy: 'Bรบsqueda de Puntos de descarga', | ||
463 | templateUrl: 'modal-punto-descarga.html', | ||
464 | controller: 'focaModalPuntoDescargaController', | ||
465 | size: 'lg', | ||
466 | resolve: { | ||
467 | filters: { | ||
468 | idDomicilio: $scope.remito.domicilio.id, | ||
469 | idCliente: $scope.remito.cliente.COD, | ||
470 | articulos: $scope.remito.articulosRemito, | ||
471 | puntosDescarga: $scope.remito.remitoPuntoDescarga, | ||
472 | domicilio: $scope.remito.domicilio | ||
473 | } | ||
474 | } | ||
475 | } | ||
476 | ); | ||
477 | modalInstance.result.then( | ||
478 | function(puntosDescarga) { | ||
479 | |||
480 | puntosDescarga.forEach(function(punto) { | ||
481 | $scope.hojaRuta.remitoPuntoDescarga.push( | ||
482 | { | ||
483 | puntoDescarga: punto | ||
484 | } | ||
485 | ); | ||
486 | }); | ||
487 | |||
488 | $scope.$broadcast('addCabecera', { | ||
489 | label: 'Puntos de descarga:', | ||
490 | valor: getCabeceraPuntoDescarga(puntosDescarga) | ||
491 | }); | ||
492 | }, function () { | ||
493 | $scope.abrirModalDomicilios($scope.cliente); | ||
494 | } | ||
495 | ); | ||
120 | } | 496 | } |
121 | if (!$scope.hojaRuta.tarifario) { | 497 | }; |
122 | focaModalService.alert('Ingrese Tarifario'); | 498 | |
499 | function getCabeceraPuntoDescarga(puntosDescarga) { | ||
500 | var puntosStamp = ''; | ||
501 | puntosDescarga.forEach(function (punto, idx, arr) { | ||
502 | puntosStamp += punto.descripcion; | ||
503 | if ((idx + 1) !== arr.length) puntosStamp += ', '; | ||
504 | }); | ||
505 | return puntosStamp; | ||
506 | } | ||
507 | |||
508 | $scope.crearHojaRuta = function () { | ||
509 | |||
510 | var continuar = validarHojaRuta(); | ||
511 | if (!continuar) { | ||
123 | return; | 512 | return; |
124 | } | 513 | } else if ($scope.remitoAbierto) { |
125 | if (!$scope.hojaRuta.datosExtra) { | 514 | guardarRemitoAbierto(); |
126 | focaModalService.alert('Ingrese Datos extra'); | ||
127 | return; | 515 | return; |
128 | } | 516 | } |
129 | var date = new Date(); | 517 | var date = new Date(); |
130 | var save = { | 518 | var save = { |
131 | hojaRuta: { | 519 | hojaRuta: { |
132 | id: 0, | 520 | id: 0, |
133 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 521 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
134 | .replace('T', ' '), | 522 | .replace('T', ' '), |
135 | idTransportista: $scope.hojaRuta.transportista.COD, | 523 | idTransportista: $scope.hojaRuta.transportista.COD, |
136 | idChofer: $scope.hojaRuta.chofer.id, | 524 | idChofer: $scope.hojaRuta.chofer.id, |
137 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 525 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
138 | tarifaFlete: $scope.hojaRuta.tarifario, | 526 | tarifaFlete: $scope.hojaRuta.tarifario, |
139 | fechaReparto: | 527 | fechaReparto: |
140 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | 528 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
141 | estado: 0 | 529 | estado: 0 |
142 | }, | 530 | }, |
143 | remitos: $scope.hojaRuta.remitosTabla | 531 | remitos: $scope.hojaRuta.remitosTabla |
144 | }; | 532 | }; |
533 | |||
145 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); | 534 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
146 | focaCrearHojaRutaService.crearHojaRuta(save).then( | 535 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
147 | function(data) { | 536 | function (data) { |
148 | focaModalService.alert( | 537 | focaModalService.alert( |
149 | 'Hoja ruta creada Nยบ: ' + | 538 | 'Hoja ruta creada Nยบ: ' + |
150 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 539 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
151 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | 540 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
152 | ); | 541 | ); |
153 | 542 | ||
154 | config(); | 543 | config(); |
155 | }, | 544 | }, |
156 | function(error) { | 545 | function (error) { |
157 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | 546 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
158 | console.info(error); | 547 | console.info(error); |
159 | } | 548 | } |
160 | ); | 549 | ); |
161 | }; | 550 | }; |
162 | 551 | ||
163 | $scope.seleccionarTransportista = function() { | 552 | $scope.seleccionarProveedor = function () { |
553 | var parametrosModal = { | ||
554 | titulo: 'Bรบsqueda de Proveedor', | ||
555 | query: '/proveedor', | ||
556 | columnas: [ | ||
557 | { | ||
558 | nombre: 'Cรณdigo', | ||
559 | propiedad: 'COD', | ||
560 | filtro: { | ||
561 | nombre: 'rellenarDigitos', | ||
562 | parametro: 5 | ||
563 | } | ||
564 | }, | ||
565 | { | ||
566 | nombre: 'Nombre', | ||
567 | propiedad: 'NOM' | ||
568 | }, | ||
569 | { | ||
570 | nombre: 'CUIT', | ||
571 | propiedad: 'CUIT' | ||
572 | } | ||
573 | ], | ||
574 | tipo: 'POST', | ||
575 | json: { razonCuitCod: '' } | ||
576 | }; | ||
577 | focaModalService.modal(parametrosModal).then( | ||
578 | function (proveedor) { | ||
579 | $filter('filter')($scope.botonera, { | ||
580 | label: 'Proveedor', | ||
581 | })[0].checked = true; | ||
582 | |||
583 | $scope.$broadcast('addCabecera', { | ||
584 | label: 'Proveedor:', | ||
585 | valor: proveedor.COD + ' - ' + proveedor.NOM | ||
586 | }); | ||
587 | $scope.hojaRuta.proveedor = proveedor; | ||
588 | }, function () { } | ||
589 | ); | ||
590 | }; | ||
591 | |||
592 | $scope.seleccionarTransportista = function () { | ||
164 | if (eligioPreConfirmado()) return; | 593 | if (eligioPreConfirmado()) return; |
165 | var parametrosModal = { | 594 | var parametrosModal = { |
166 | titulo: 'Bรบsqueda de transportista', | 595 | titulo: 'Bรบsqueda de transportista', |
167 | query: '/transportista', | 596 | query: '/transportista', |
168 | columnas: [ | 597 | columnas: [ |
169 | { | 598 | { |
170 | nombre: 'Cรณdigo', | 599 | nombre: 'Cรณdigo', |
171 | propiedad: 'COD' | 600 | propiedad: 'COD' |
172 | }, | 601 | }, |
173 | { | 602 | { |
174 | nombre: 'Nombre', | 603 | nombre: 'Nombre', |
175 | propiedad: 'NOM' | 604 | propiedad: 'NOM' |
176 | }, | 605 | }, |
177 | { | 606 | { |
178 | nombre: 'CUIT', | 607 | nombre: 'CUIT', |
179 | propiedad: 'CUIT' | 608 | propiedad: 'CUIT' |
180 | } | 609 | } |
181 | ] | 610 | ] |
182 | }; | 611 | }; |
183 | focaModalService.modal(parametrosModal).then( | 612 | focaModalService.modal(parametrosModal).then( |
184 | function(proveedor) { | 613 | function (proveedor) { |
185 | $scope.hojaRuta.transportista = proveedor; | 614 | $scope.hojaRuta.transportista = proveedor; |
186 | $scope.$broadcast('addCabecera', { | 615 | $scope.$broadcast('addCabecera', { |
187 | label: 'Transportista:', | 616 | label: 'Transportista:', |
188 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 617 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
189 | proveedor.NOM | 618 | proveedor.NOM |
190 | }); | 619 | }); |
191 | 620 | ||
192 | $filter('filter')($scope.botonera, { | 621 | $filter('filter')($scope.botonera, { |
193 | label: 'Transportista', | 622 | label: 'Transportista', |
194 | })[0].checked = true; | 623 | })[0].checked = true; |
195 | }, function() { | 624 | }, function () { |
196 | 625 | ||
197 | } | 626 | } |
198 | ); | 627 | ); |
199 | }; | 628 | }; |
200 | 629 | ||
201 | $scope.seleccionarChofer = function() { | 630 | $scope.seleccionarChofer = function () { |
202 | var parametrosModal = { | 631 | var parametrosModal = { |
203 | titulo: 'Bรบsqueda de Chofer', | 632 | titulo: 'Bรบsqueda de Chofer', |
204 | query: '/chofer', | 633 | query: '/chofer', |
205 | columnas: [ | 634 | columnas: [ |
206 | { | 635 | { |
207 | propiedad: 'id', | 636 | propiedad: 'id', |
208 | nombre: 'Cรณdigo', | 637 | nombre: 'Cรณdigo', |
209 | filtro: { | 638 | filtro: { |
210 | nombre: 'rellenarDigitos', | 639 | nombre: 'rellenarDigitos', |
211 | parametro: 3 | 640 | parametro: 3 |
212 | } | 641 | } |
213 | }, | 642 | }, |
214 | { | 643 | { |
215 | propiedad: 'nombre', | 644 | propiedad: 'nombre', |
216 | nombre: 'Nombre' | 645 | nombre: 'Nombre' |
217 | }, | 646 | }, |
218 | { | 647 | { |
219 | propiedad: 'dni', | 648 | propiedad: 'dni', |
220 | nombre: 'DNI' | 649 | nombre: 'DNI' |
221 | }, | 650 | }, |
222 | { | 651 | { |
223 | propiedad: 'telefono', | 652 | propiedad: 'telefono', |
224 | nombre: 'Telรฉfono' | 653 | nombre: 'Telรฉfono' |
225 | } | 654 | } |
226 | ] | 655 | ] |
227 | }; | 656 | }; |
228 | focaModalService.modal(parametrosModal).then( | 657 | focaModalService.modal(parametrosModal).then( |
229 | function(chofer) { | 658 | function (chofer) { |
230 | $scope.hojaRuta.chofer = chofer; | 659 | $scope.hojaRuta.chofer = chofer; |
231 | $scope.$broadcast('addCabecera', { | 660 | $scope.$broadcast('addCabecera', { |
232 | label: 'Chofer:', | 661 | label: 'Chofer:', |
233 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre | 662 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre |
234 | }); | 663 | }); |
235 | 664 | ||
236 | $filter('filter')($scope.botonera, { | 665 | $filter('filter')($scope.botonera, { |
237 | label: 'Chofer', | 666 | label: 'Chofer', |
238 | })[0].checked = true; | 667 | })[0].checked = true; |
239 | }, function() { | 668 | $scope.mostrarDetalle($scope.hojaRuta); |
669 | |||
670 | }, function () { | ||
240 | // funcion ejecutada cuando se cancela el modal | 671 | // funcion ejecutada cuando se cancela el modal |
241 | } | 672 | } |
242 | ); | 673 | ); |
243 | }; | 674 | }; |
244 | 675 | ||
245 | $scope.seleccionarVehiculo = function() { | 676 | $scope.seleccionarVehiculo = function () { |
246 | if (!eligioFecha() || eligioPreConfirmado()) return; | 677 | if (!eligioFecha() || eligioPreConfirmado()) return; |
247 | modalVehiculos(); | 678 | modalVehiculos(); |
248 | }; | 679 | }; |
249 | 680 | ||
250 | $scope.seleccionarTarifario = function() { | 681 | $scope.seleccionarTarifario = function () { |
251 | focaModalService | 682 | focaModalService |
252 | .prompt({ | 683 | .prompt({ |
253 | titulo: 'Tarifa flete', | 684 | titulo: 'Tarifa flete', |
254 | value: $scope.hojaRuta.tarifario | 685 | value: $scope.hojaRuta.tarifario |
255 | }) | 686 | }) |
256 | .then(function(costo) { | 687 | .then(function (costo) { |
257 | if (isNaN(costo)) { | 688 | if (isNaN(costo)) { |
258 | focaModalService | 689 | focaModalService |
259 | .alert('Ingrese un valor vรกlido') | 690 | .alert('Ingrese un valor vรกlido') |
260 | .then(function() { | 691 | .then(function () { |
261 | $scope.seleccionarTarifario(); | 692 | $scope.seleccionarTarifario(); |
262 | }); | 693 | }); |
263 | 694 | ||
264 | return; | 695 | return; |
265 | } | 696 | } |
266 | 697 | ||
267 | $scope.hojaRuta.tarifario = costo; | 698 | $scope.hojaRuta.tarifario = costo; |
268 | $scope.$broadcast('addCabecera', { | 699 | $scope.$broadcast('addCabecera', { |
269 | label: 'Tarifario:', | 700 | label: 'Tarifario:', |
270 | valor: costo | 701 | valor: costo |
271 | }); | 702 | }); |
272 | 703 | ||
273 | $filter('filter')($scope.botonera, { | 704 | $filter('filter')($scope.botonera, { |
274 | label: 'Tarifario', | 705 | label: 'Tarifario', |
275 | })[0].checked = true; | 706 | })[0].checked = true; |
276 | }); | 707 | }); |
277 | }; | 708 | }; |
278 | 709 | ||
279 | $scope.seleccionarRemitos = function() { | 710 | $scope.seleccionarRemitos = function () { |
280 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | 711 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
281 | var modalInstance = $uibModal.open( | 712 | var modalInstance = $uibModal.open( |
282 | { | 713 | { |
283 | ariaLabelledBy: 'Busqueda de Remito', | 714 | ariaLabelledBy: 'Busqueda de Remito', |
284 | templateUrl: 'foca-modal-remito.html', | 715 | templateUrl: 'foca-modal-remito.html', |
285 | controller: 'focaModalRemitoController', | 716 | controller: 'focaModalRemitoController', |
286 | size: 'lg', | 717 | size: 'lg', |
287 | resolve: {usadoPor: function() {return 'hojaRuta';}} | 718 | resolve: { usadoPor: function () { return 'hojaRuta'; } } |
288 | } | 719 | } |
289 | ); | 720 | ); |
290 | modalInstance.result.then( | 721 | modalInstance.result.then( |
291 | function(remito) { | 722 | function (remito) { |
292 | // TODO: borrar cuando no se use definitivamente | 723 | // TODO: borrar cuando no se use definitivamente |
293 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { | 724 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
294 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { | 725 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
295 | // focaModalService.alert('Remito ya incluido'); | 726 | // focaModalService.alert('Remito ya incluido'); |
296 | // return; | 727 | // return; |
297 | // } | 728 | // } |
298 | // } | 729 | // } |
299 | 730 | ||
300 | // var litros = 0; | 731 | // var litros = 0; |
301 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 732 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
302 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 733 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
303 | // } | 734 | // } |
304 | 735 | ||
305 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 736 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
306 | // focaModalService.alert( | 737 | // focaModalService.alert( |
307 | // 'Debe ingresar toda la informaciรณn para el transporte' | 738 | // 'Debe ingresar toda la informaciรณn para el transporte' |
308 | // ); | 739 | // ); |
309 | // return; | 740 | // return; |
310 | // } | 741 | // } |
311 | 742 | ||
312 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 743 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
313 | // { | 744 | // { |
314 | // var litrostotales = litros; | 745 | // var litrostotales = litros; |
315 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 746 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
316 | // focaModalService.alert( | 747 | // focaModalService.alert( |
317 | // 'La carga excede la capacidad disponible del vehiculo. ' + | 748 | // 'La carga excede la capacidad disponible del vehiculo. ' + |
318 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 749 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
319 | // ); | 750 | // ); |
320 | // } | 751 | // } |
321 | 752 | ||
322 | // remito.litros = litros; | 753 | // remito.litros = litros; |
323 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 754 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
324 | $scope.cargarCisterna(remito.id).then(function() { | 755 | $scope.cargarCisterna(remito.id).then(function () { |
325 | $scope.hojaRuta.remitosTabla.push(remito); | 756 | $scope.hojaRuta.remitosTabla.push(remito); |
326 | }, function(error) { | 757 | $filter('filter')($scope.botonera, { |
758 | label: 'Remitos', | ||
759 | })[0].checked = true; | ||
327 | 760 | ||
761 | }, function (error) { | ||
328 | if (error && error !== 'backdrop click') { | 762 | if (error && error !== 'backdrop click') { |
329 | |||
330 | focaModalService | 763 | focaModalService |
331 | .alert(error || 'Ha ocurrido un error') | 764 | .alert(error || 'Ha ocurrido un error') |
332 | .then(function() { | 765 | .then(function () { |
333 | $scope.seleccionarRemitos(); | 766 | $scope.seleccionarRemitos(); |
334 | }); | 767 | }); |
335 | 768 | ||
336 | } else { | 769 | } else { |
337 | |||
338 | $scope.seleccionarRemitos(); | 770 | $scope.seleccionarRemitos(); |
339 | |||
340 | } | 771 | } |
341 | }); | 772 | }); |
342 | }, function() { | 773 | }, function () { |
343 | // funcion ejecutada cuando se cancela el modal | 774 | // funcion ejecutada cuando se cancela el modal |
344 | } | 775 | } |
345 | ); | 776 | ); |
346 | }; | 777 | }; |
347 | 778 | ||
348 | $scope.seleccionarVehiculosPrecargados = function() { | 779 | $scope.seleccionarVehiculosPrecargados = function () { |
349 | if (!eligioFecha()) return; | 780 | if (!eligioFecha()) return; |
350 | modalVehiculos(true); | 781 | modalVehiculos(true); |
351 | }; | 782 | }; |
352 | 783 | ||
353 | $scope.cargarCisterna = function(idRemito) { | 784 | $scope.cargarCisterna = function (idRemito) { |
354 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | 785 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; |
355 | var modalInstance = $uibModal.open( | 786 | var modalInstance = $uibModal.open( |
356 | { | 787 | { |
357 | ariaLabelledBy: 'Busqueda de Vehiculo', | 788 | ariaLabelledBy: 'Busqueda de Vehiculo', |
358 | templateUrl: 'foca-detalle-vehiculo.html', | 789 | templateUrl: 'foca-detalle-vehiculo.html', |
359 | controller: 'focaDetalleVehiculo', | 790 | controller: 'focaDetalleVehiculo', |
360 | size: 'lg', | 791 | size: 'lg', |
361 | resolve: { | 792 | resolve: { |
362 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | 793 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, |
363 | idRemito: function() {return idRemito;}, | 794 | idRemito: function () { return idRemito; }, |
364 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | 795 | fechaReparto: function () { return $scope.hojaRuta.fechaReparto; } |
365 | } | 796 | } |
366 | } | 797 | } |
367 | ); | 798 | ); |
368 | return modalInstance.result; | 799 | return modalInstance.result; |
369 | }; | 800 | }; |
370 | 801 | ||
371 | $scope.seleccionarFechaEntrega = function() { | 802 | $scope.seleccionarFechaEntrega = function () { |
372 | var confirmacion = false; | 803 | var confirmacion = false; |
373 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; | 804 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; |
374 | var hasTarifario = $scope.hojaRuta.tarifario !== null; | 805 | var hasTarifario = $scope.hojaRuta.tarifario !== null; |
375 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; | 806 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; |
376 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; | 807 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; |
377 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; | 808 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; |
378 | 809 | ||
379 | if (hasVehiculoId || hasTarifario || hasTransportista || | 810 | if (hasVehiculoId || hasTarifario || hasTransportista || |
380 | hasChofer || hasDatosExtra) { | 811 | hasChofer || hasDatosExtra) { |
381 | confirmacion = true; | 812 | confirmacion = true; |
382 | if (confirmacion) { | 813 | if (confirmacion) { |
383 | focaModalService | 814 | focaModalService |
384 | .confirm('Si cambia la fecha se perderรกn los datos actuales') | 815 | .confirm('Si cambia la fecha se perderรกn los datos actuales') |
385 | .then(function(data) { | 816 | .then(function (data) { |
386 | if(data) { | 817 | if (data) { |
387 | $scope.hojaRuta.vehiculo.id = undefined; | 818 | $scope.hojaRuta.vehiculo.id = undefined; |
388 | $scope.hojaRuta.tarifario = null; | 819 | $scope.hojaRuta.tarifario = null; |
389 | $scope.hojaRuta.transportista = {}; | 820 | $scope.hojaRuta.transportista = {}; |
390 | $scope.hojaRuta.chofer = {}; | 821 | $scope.hojaRuta.chofer = {}; |
391 | $scope.hojaRuta.datosExtra = undefined; | 822 | $scope.hojaRuta.datosExtra = undefined; |
392 | elegirFecha(); | 823 | elegirFecha(); |
393 | } | 824 | } |
394 | }, function() { | 825 | }, function () { |
395 | return ; | 826 | return; |
396 | }); | 827 | }); |
397 | } | 828 | } |
398 | } else { | 829 | } else { |
399 | elegirFecha(); | 830 | elegirFecha(); |
400 | } | 831 | } |
401 | }; | 832 | }; |
402 | 833 | ||
403 | function setearFecha(fecha) { | 834 | function setearFecha(fecha) { |
404 | $timeout(function() { | 835 | $timeout(function () { |
405 | $scope.$broadcast('addCabecera', { | 836 | $scope.$broadcast('addCabecera', { |
406 | label: 'Fecha de entrega: ', | 837 | label: 'Fecha de entrega: ', |
407 | valor: fecha.toLocaleDateString() | 838 | valor: fecha.toLocaleDateString() |
408 | }); | 839 | }); |
409 | $scope.hojaRuta.fechaReparto = fecha; | 840 | $scope.hojaRuta.fechaReparto = fecha; |
410 | $scope.inicial.fechaReparto = fecha; | 841 | $scope.inicial.fechaReparto = fecha; |
411 | }); | 842 | }); |
412 | } | 843 | } |
413 | 844 | ||
414 | $scope.seleccionarDatosExtra = function() { | 845 | $scope.seleccionarDatosExtra = function () { |
415 | var datosHojaRuta = $scope.hojaRuta.datosExtra; | 846 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
416 | var modalInstance = $uibModal.open( | 847 | var modalInstance = $uibModal.open( |
417 | { | 848 | { |
418 | templateUrl: 'foca-modal-datos-hoja-ruta.html', | 849 | templateUrl: 'foca-modal-datos-hoja-ruta.html', |
419 | controller: 'focaModalDatosHojaRutaCtrl', | 850 | controller: 'focaModalDatosHojaRutaCtrl', |
420 | size: 'lg', | 851 | size: 'lg', |
421 | resolve: { | 852 | resolve: { |
422 | parametrosDatos: function() { | 853 | parametrosDatos: function () { |
423 | return { | 854 | return { |
424 | datosHojaRuta: datosHojaRuta | 855 | datosHojaRuta: datosHojaRuta |
425 | }; | 856 | }; |
426 | } | 857 | } |
427 | } | 858 | } |
428 | } | 859 | } |
429 | ); | 860 | ); |
430 | return modalInstance.result.then(function(datosExtra) { | 861 | return modalInstance.result.then(function (datosExtra) { |
431 | 862 | ||
432 | $filter('filter')($scope.botonera, { | 863 | $filter('filter')($scope.botonera, { |
433 | label: 'Datos extra', | 864 | label: 'Datos extra', |
434 | })[0].checked = true; | 865 | })[0].checked = true; |
435 | 866 | ||
436 | $scope.hojaRuta.datosExtra = datosExtra; | 867 | $scope.hojaRuta.datosExtra = datosExtra; |
437 | }, function() { | 868 | }, function () { |
438 | //se ejecuta cuando se cancela el modal | 869 | //se ejecuta cuando se cancela el modal |
439 | }); | 870 | }); |
440 | }; | 871 | }; |
441 | 872 | ||
442 | $scope.desasociarRemito = function(key, idRemito) { | 873 | $scope.desasociarRemito = function (key, idRemito) { |
443 | var idsRemito = [idRemito]; | 874 | var idsRemito = [idRemito]; |
444 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + | 875 | focaModalService.confirm('ยฟEstรก seguro que desea desasociar este remito del' + |
445 | ' vehรญculo?').then(function() { | 876 | ' vehรญculo?').then(function () { |
446 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, | 877 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
447 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) | 878 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
448 | .then(function() { | 879 | .then(function () { |
449 | $scope.hojaRuta.remitosTabla.splice(key, 1); | 880 | $scope.hojaRuta.remitosTabla.splice(key, 1); |
450 | focaModalService.alert('Remito desasociado con รฉxito'); | 881 | focaModalService.alert('Remito desasociado con รฉxito'); |
451 | }); | 882 | }); |
452 | }); | 883 | }); |
453 | }; | 884 | }; |
454 | 885 | ||
455 | $scope.verProductosRemito = function(idRemito) { | 886 | $scope.verProductosRemito = function (idRemito) { |
456 | var parametrosModal = { | 887 | var parametrosModal = { |
457 | titulo: 'Articulos remito', | 888 | titulo: 'Articulos remito', |
458 | query: '/articulos/remito/' + idRemito, | 889 | query: '/articulos/remito/' + idRemito, |
459 | soloMostrar: true, | 890 | soloMostrar: true, |
460 | columnas: [ | 891 | columnas: [ |
461 | { | 892 | { |
462 | nombre: 'Cรณdigo', | 893 | nombre: 'Cรณdigo', |
463 | propiedad: 'codigo' | 894 | propiedad: 'codigo' |
464 | }, | 895 | }, |
465 | { | 896 | { |
466 | nombre: 'Descripciรณn', | 897 | nombre: 'Descripciรณn', |
467 | propiedad: 'descripcion' | 898 | propiedad: 'descripcion' |
468 | }, | 899 | }, |
469 | { | 900 | { |
470 | nombre: 'Cantidad', | 901 | nombre: 'Cantidad', |
471 | propiedad: 'cantidad' | 902 | propiedad: 'cantidad' |
472 | } | 903 | } |
473 | ] | 904 | ] |
474 | }; | 905 | }; |
475 | focaModalService.modal(parametrosModal).then(); | 906 | focaModalService.modal(parametrosModal).then(); |
476 | }; | 907 | }; |
477 | 908 | ||
909 | $scope.mostrarDetalle = function (hojasRutas) { | ||
910 | var modalInstance =$uibModal.open( | ||
911 | { | ||
912 | ariaLabelledBy: '', | ||
913 | templateUrl: 'modal-detalle-carga.html', | ||
914 | controller: 'focaModalDetalleController', | ||
915 | resolve: { | ||
916 | hojasRutas: function () { return hojasRutas; } | ||
917 | }, | ||
918 | size: 'lg', | ||
919 | } | ||
920 | ); | ||
921 | return modalInstance.result.then(function (res) { | ||
922 | res.cisternas.forEach( function (cisterna) { | ||
923 | $scope.cisternaCargas.push(cisterna.cisternaCarga); | ||
924 | }); | ||
925 | $scope.cisternaMovimientos = res.movimientos; | ||
926 | $scope.articulosRecibidos = res.articulos; | ||
927 | $scope.articulos = res.articulos; | ||
928 | }, function () { | ||
929 | //se ejecuta cuando se cancela el modal | ||
930 | }); | ||
931 | }; | ||
932 | |||
478 | function elegirFecha() { | 933 | function elegirFecha() { |
479 | var fechaEntrega = { | 934 | var fechaEntrega = { |
480 | titulo: 'Fecha de entrega', | 935 | titulo: 'Fecha de entrega', |
481 | minDate: new Date() | 936 | minDate: new Date() |
482 | }; | 937 | }; |
483 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | 938 | focaModalService.modalFecha(fechaEntrega).then(function (fecha) { |
484 | 939 | ||
485 | $scope.hojaRuta.fechaReparto = fecha; | 940 | $scope.hojaRuta.fechaReparto = fecha; |
486 | 941 | ||
487 | $scope.$broadcast('addCabecera', { | 942 | $scope.$broadcast('addCabecera', { |
488 | label: 'Fecha de entrega: ', | 943 | label: 'Fecha de entrega: ', |
489 | valor: fecha.toLocaleDateString() | 944 | valor: fecha.toLocaleDateString() |
490 | }); | 945 | }); |
946 | //habilitar los otros botones | ||
947 | var temp = []; | ||
948 | if ($scope.botonera.length > 1) { | ||
949 | limpiarBotonera($scope.botonera); | ||
950 | } else if ($scope.precargado) { | ||
951 | temp = focaCrearHojaRutaService.getBotoneraPrecargado(); | ||
952 | modalVehiculos(true); | ||
953 | } else if ($scope.cargaRemito && $scope.precargado === false) { | ||
954 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | ||
955 | } else { | ||
956 | temp = focaCrearHojaRutaService.getBotoneraCargarRemito(); | ||
957 | modalVehiculos(true); | ||
958 | } | ||
959 | temp.forEach(function (e) { | ||
960 | $scope.botonera.push(e); | ||
961 | }); | ||
491 | 962 | ||
492 | $filter('filter')($scope.botonera, { | 963 | $filter('filter')($scope.botonera, { |
493 | label: 'Fecha Entrega', | 964 | label: 'Fecha Entrega', |
494 | })[0].checked = true; | 965 | })[0].checked = true; |
495 | }); | 966 | }); |
496 | } | 967 | } |
497 | 968 | ||
498 | function eligioPreConfirmado() { | 969 | function eligioPreConfirmado() { |
499 | if ($scope.eligioPreConfirmado) { | 970 | if ($scope.eligioPreConfirmado) { |
500 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); | 971 | focaModalService.alert('No puede elegir si eligiรณ un vehiculo pre cargado'); |
501 | return true; | 972 | return true; |
502 | } | 973 | } |
503 | return false; | 974 | return false; |
504 | } | 975 | } |
505 | 976 | ||
506 | function eligioFecha() { | 977 | function eligioFecha() { |
507 | if (!$scope.hojaRuta.fechaReparto) { | 978 | if (!$scope.hojaRuta.fechaReparto) { |
508 | focaModalService.alert('Primero seleccione fecha de reparto'); | 979 | focaModalService.alert('Primero seleccione fecha de reparto'); |
509 | return false; | 980 | return false; |
510 | } | 981 | } |
511 | return true; | 982 | return true; |
512 | } | 983 | } |
513 | 984 | ||
514 | function eligioVehiculo() { | 985 | function eligioVehiculo() { |
515 | if (!$scope.hojaRuta.vehiculo.id) { | 986 | if (!$scope.hojaRuta.vehiculo.id) { |
516 | focaModalService.alert('Primero seleccione vehiculo'); | 987 | focaModalService.alert('Primero seleccione vehiculo'); |
517 | return false; | 988 | return false; |
518 | } | 989 | } |
519 | return true; | 990 | return true; |
520 | } | 991 | } |
521 | 992 | ||
522 | function modalVehiculos(preCargados) { | 993 | function modalVehiculos(preCargados) { |
523 | var parametrosModal = {}; | 994 | var parametrosModal = {}; |
524 | if (preCargados) { | 995 | if (preCargados) { |
525 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + | 996 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
526 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); | 997 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
527 | parametrosModal.titulo = 'Bรบsqueda de vehiculos pre confirmados'; | 998 | parametrosModal.titulo = 'Bรบsqueda de vehiculos precargados'; |
528 | } else { | 999 | } else { |
529 | parametrosModal.query = '/vehiculo'; | 1000 | parametrosModal.query = '/vehiculo'; |
530 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; | 1001 | parametrosModal.titulo = 'Bรบsqueda de vehรญculos'; |
531 | } | 1002 | } |
532 | parametrosModal.columnas = [ | 1003 | parametrosModal.columnas = [ |
533 | { | 1004 | { |
534 | propiedad: 'codigo', | 1005 | propiedad: 'codigo', |
535 | nombre: 'Cรณdigo' | 1006 | nombre: 'Cรณdigo' |
536 | }, | 1007 | }, |
537 | { | 1008 | { |
538 | propiedad: 'tractor', | 1009 | propiedad: 'tractor', |
539 | nombre: 'tractor' | 1010 | nombre: 'tractor' |
540 | }, | 1011 | }, |
541 | { | 1012 | { |
542 | propiedad: 'semi', | 1013 | propiedad: 'semi', |
543 | nombre: 'Semi' | 1014 | nombre: 'Semi' |
544 | } | 1015 | } |
545 | ]; | 1016 | ]; |
546 | focaModalService.modal(parametrosModal).then(function(vehiculo) { | 1017 | focaModalService.modal(parametrosModal).then(function (vehiculo) { |
547 | if (!preCargados && vehiculoEnUso(vehiculo)) return; | 1018 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
548 | $scope.hojaRuta.vehiculo = vehiculo; | 1019 | $scope.hojaRuta.vehiculo = vehiculo; |
549 | $scope.hojaRuta.transportista = vehiculo.transportista; | 1020 | $scope.hojaRuta.transportista = vehiculo.transportista; |
1021 | // mostrarDetalle(vehiculo); | ||
550 | if (preCargados) { | 1022 | if (preCargados) { |
551 | $scope.eligioPreConfirmado = true; | 1023 | $scope.eligioPreConfirmado = true; |
552 | $scope.hojaRuta.vehiculo = vehiculo; | 1024 | $scope.hojaRuta.vehiculo = vehiculo; |
553 | $scope.$broadcast('addCabecera', { | 1025 | $scope.$broadcast('addCabecera', { |
554 | label: 'Transportista:', | 1026 | label: 'Transportista:', |
555 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + | 1027 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + |
556 | ' - ' + vehiculo.transportista.NOM | 1028 | ' - ' + vehiculo.transportista.NOM |
557 | }); | 1029 | }); |
558 | focaCrearHojaRutaService | 1030 | focaCrearHojaRutaService |
559 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) | 1031 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
560 | .then(function(res) { | 1032 | .then(function (res) { |
561 | |||
562 | $filter('filter')($scope.botonera, { | 1033 | $filter('filter')($scope.botonera, { |
563 | label: 'Vehiculos precargados', | 1034 | label: 'Transportista', |
1035 | })[0].checked = true; | ||
1036 | |||
1037 | $filter('filter')($scope.botonera, { | ||
1038 | label: 'Vehiculo', | ||
564 | })[0].checked = true; | 1039 | })[0].checked = true; |
565 | 1040 | ||
566 | $scope.hojaRuta.remitosTabla = res.data; | 1041 | $scope.hojaRuta.remitosTabla = res.data; |
567 | }); | 1042 | }); |
568 | } else { | 1043 | } else { |
569 | focaCrearHojaRutaService | 1044 | focaCrearHojaRutaService |
570 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) | 1045 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
571 | .then(function(res) { | 1046 | .then(function (res) { |
572 | 1047 | ||
573 | $filter('filter')($scope.botonera, { | 1048 | $filter('filter')($scope.botonera, { |
574 | label: 'Vehiculo', | 1049 | label: 'Vehiculo', |
575 | })[0].checked = true; | 1050 | })[0].checked = true; |
576 | 1051 | ||
577 | $scope.hojaRuta.remitosTabla = res.data; | 1052 | $scope.hojaRuta.remitosTabla = res.data; |
578 | }); | 1053 | }); |
579 | } | 1054 | } |
580 | $scope.$broadcast('addCabecera', { | 1055 | $scope.$broadcast('addCabecera', { |
581 | label: 'Tractor:', | 1056 | label: 'Tractor:', |
582 | valor: vehiculo.tractor | 1057 | valor: vehiculo.tractor |
583 | }); | 1058 | }); |
584 | $scope.$broadcast('addCabecera', { | 1059 | $scope.$broadcast('addCabecera', { |
585 | label: 'Semi:', | 1060 | label: 'Semi:', |
586 | valor: vehiculo.semi | 1061 | valor: vehiculo.semi |
587 | }); | 1062 | }); |
588 | $scope.$broadcast('addCabecera', { | 1063 | $scope.$broadcast('addCabecera', { |
589 | label: 'Capacidad:', | 1064 | label: 'Capacidad:', |
590 | valor: vehiculo.capacidad | 1065 | valor: vehiculo.capacidad |
591 | }); | 1066 | }); |
592 | 1067 | ||
593 | }); | 1068 | }); |
594 | } | 1069 | } |
595 | 1070 | ||
596 | function vehiculoEnUso(vehiculo) { | 1071 | function vehiculoEnUso(vehiculo) { |
597 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; | 1072 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; |
598 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 1073 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
599 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 1074 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
600 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 1075 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
601 | if (cisternaCarga.fechaReparto.substring(0, 10) === | 1076 | if (cisternaCarga.fechaReparto.substring(0, 10) === |
602 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && | 1077 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
603 | cisternaCarga.idUsuarioProceso && | 1078 | cisternaCarga.idUsuarioProceso && |
604 | cisternaCarga.idUsuarioProceso !== idUsuario) | 1079 | cisternaCarga.idUsuarioProceso !== idUsuario) { |
605 | { | ||
606 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + | 1080 | focaModalService.alert('El vehรญculo estรก siendo usado por otro' + |
607 | ' usuario'); | 1081 | ' usuario'); |
608 | return true; | 1082 | return true; |
609 | } | 1083 | } |
610 | } | 1084 | } |
611 | } | 1085 | } |
612 | return false; | 1086 | return false; |
613 | } | 1087 | } |
614 | 1088 | ||
615 | function salir() { | 1089 | function salir() { |
616 | var confirmacion = false; | 1090 | var confirmacion = false; |
617 | 1091 | ||
618 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 1092 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
619 | confirmacion = true; | 1093 | confirmacion = true; |
620 | } | 1094 | } |
621 | 1095 | ||
622 | if (confirmacion) { | 1096 | if (confirmacion) { |
623 | focaModalService.confirm( | 1097 | focaModalService.confirm( |
624 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' | 1098 | 'ยฟEstรก seguro de que desea salir? Se perderรกn todos los datos cargados.' |
625 | ).then(function(data) { | 1099 | ).then(function (data) { |
626 | if (data) { | 1100 | if (data) { |
627 | $location.path('/'); | 1101 | $location.path('/'); |
628 | } | 1102 | } |
629 | }); | 1103 | }); |
630 | } else { | 1104 | } else { |
631 | $location.path('/'); | 1105 | $location.path('/'); |
632 | } | 1106 | } |
633 | } | 1107 | } |
634 | 1108 | ||
1109 | function limpiarBotonera(botonera) { | ||
1110 | botonera.forEach(function (boton) { | ||
1111 | boton.checked = false; | ||
1112 | }); | ||
1113 | } | ||
635 | function setearHojaRuta(hojaRuta) { | 1114 | function setearHojaRuta(hojaRuta) { |
636 | $scope.$broadcast('cleanCabecera'); | 1115 | $scope.$broadcast('cleanCabecera'); |
637 | 1116 | ||
638 | var cabeceras = []; | 1117 | var cabeceras = []; |
639 | if (hojaRuta.fechaReparto) { | 1118 | if (hojaRuta.fechaReparto) { |
640 | cabeceras.push({ | 1119 | cabeceras.push({ |
641 | label: 'Fecha de entrega:', | 1120 | label: 'Fecha de entrega:', |
642 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | 1121 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
643 | }); | 1122 | }); |
644 | 1123 | ||
645 | $filter('filter')( $scope.botonera, { | 1124 | $filter('filter')($scope.botonera, { |
646 | label: 'Fecha Entrega' | 1125 | label: 'Fecha Entrega' |
647 | })[0].checked = true; | 1126 | })[0].checked = true; |
648 | } | 1127 | } |
649 | if (hojaRuta.transportista.COD) { | 1128 | if (hojaRuta.transportista.COD) { |
650 | cabeceras.push({ | 1129 | cabeceras.push({ |
651 | label: 'Transportista:', | 1130 | label: 'Transportista:', |
652 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + | 1131 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
653 | hojaRuta.transportista.NOM | 1132 | hojaRuta.transportista.NOM |
654 | }); | 1133 | }); |
655 | 1134 | ||
656 | $filter('filter')( $scope.botonera, { | 1135 | $filter('filter')($scope.botonera, { |
657 | label: 'Transportista' | 1136 | label: 'Transportista' |
658 | })[0].checked = true; | 1137 | })[0].checked = true; |
659 | } | 1138 | } |
660 | if (hojaRuta.chofer.id) { | 1139 | if (hojaRuta.chofer.id) { |
661 | cabeceras.push({ | 1140 | cabeceras.push({ |
662 | label: 'Chofer:', | 1141 | label: 'Chofer:', |
663 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + | 1142 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
664 | ' - ' + hojaRuta.chofer.nombre | 1143 | ' - ' + hojaRuta.chofer.nombre |
665 | }); | 1144 | }); |
666 | 1145 | ||
667 | $filter('filter')( $scope.botonera, { | 1146 | $filter('filter')($scope.botonera, { |
668 | label: 'Chofer' | 1147 | label: 'Chofer' |
669 | })[0].checked = true; | 1148 | })[0].checked = true; |
670 | } | 1149 | } |
671 | if (hojaRuta.vehiculo.id) { | 1150 | if (hojaRuta.vehiculo.id) { |
672 | cabeceras.push({ | 1151 | cabeceras.push({ |
673 | label: 'Tractor:', | 1152 | label: 'Tractor:', |
674 | valor: hojaRuta.vehiculo.tractor | 1153 | valor: hojaRuta.vehiculo.tractor |
675 | }); | 1154 | }); |
676 | cabeceras.push({ | 1155 | cabeceras.push({ |
677 | label: 'Semi:', | 1156 | label: 'Semi:', |
678 | valor: hojaRuta.vehiculo.semi | 1157 | valor: hojaRuta.vehiculo.semi |
679 | }); | 1158 | }); |
680 | cabeceras.push({ | 1159 | cabeceras.push({ |
681 | label: 'Capacidad:', | 1160 | label: 'Capacidad:', |
682 | valor: hojaRuta.vehiculo.capacidad | 1161 | valor: hojaRuta.vehiculo.capacidad |
683 | }); | 1162 | }); |
684 | 1163 | ||
685 | $filter('filter')( $scope.botonera, { | 1164 | $filter('filter')($scope.botonera, { |
686 | label: 'Vehiculo' | 1165 | label: 'Vehiculo' |
687 | })[0].checked = true; | 1166 | })[0].checked = true; |
688 | } | 1167 | } |
689 | if (hojaRuta.tarifario) { | 1168 | if (hojaRuta.tarifario) { |
690 | cabeceras.push({ | 1169 | cabeceras.push({ |
691 | label: 'Tarifario:', | 1170 | label: 'Tarifario:', |
692 | valor: hojaRuta.tarifario | 1171 | valor: hojaRuta.tarifario |
693 | }); | 1172 | }); |
694 | 1173 | ||
695 | $filter('filter')( $scope.botonera, { | 1174 | $filter('filter')($scope.botonera, { |
696 | label: 'Tarifario' | 1175 | label: 'Tarifario' |
697 | })[0].checked = true; | 1176 | })[0].checked = true; |
698 | } | 1177 | } |
699 | 1178 | ||
700 | addArrayCabecera(cabeceras); | 1179 | addArrayCabecera(cabeceras); |
701 | $scope.hojaRuta = hojaRuta; | 1180 | $scope.hojaRuta = hojaRuta; |
702 | } | 1181 | } |
703 | 1182 | ||
704 | function getLSHojaRuta() { | 1183 | function getLSHojaRuta() { |
705 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); | 1184 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); |
706 | if (hojaRuta) { | 1185 | if (hojaRuta) { |
707 | setearHojaRuta(hojaRuta); | 1186 | setearHojaRuta(hojaRuta); |
708 | delete $localStorage.hojaRuta; | 1187 | delete $localStorage.hojaRuta; |
709 | } | 1188 | } |
src/js/controllerDetalles.js
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .controller('focaModalDetalleController', [ | ||
3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | ||
4 | 'focaCrearHojaRutaService', 'hojasRutas', '$uibModal', '$filter', | ||
5 | function ($scope, $timeout, $uibModalInstance, focaModalService, | ||
6 | focaCrearHojaRutaService, hojasRutas, $uibModal, $filter) { | ||
7 | |||
8 | $scope.mostrar = false; | ||
9 | $scope.articulos = []; | ||
10 | $scope.cisternaMovimientos = []; | ||
11 | |||
12 | init(); | ||
13 | function init() { | ||
14 | $scope.hojasRutas = hojasRutas; | ||
15 | |||
16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | ||
17 | function (cisterna) { | ||
18 | return !cisterna.desactivado; | ||
19 | } | ||
20 | ); | ||
21 | focaCrearHojaRutaService.getArticulos() | ||
22 | .then(function (articulos) { | ||
23 | $scope.articulos = articulos.data; | ||
24 | }); | ||
25 | } | ||
26 | |||
27 | $scope.validarCisternaDisponible = function (cisterna) { | ||
28 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { | ||
29 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + | ||
30 | 'superior a la ' + 'capacidad del vehiculo '); | ||
31 | cisterna.disponible = cisterna.capacidad; | ||
32 | return; | ||
33 | } | ||
34 | }; | ||
35 | |||
36 | $scope.seleccionarProductos = function (cisterna) { | ||
37 | focaModalService.modal({ | ||
38 | titulo: 'Productos', | ||
39 | data: $scope.articulos, | ||
40 | size: 'md', | ||
41 | columnas: [ | ||
42 | { | ||
43 | propiedad: 'CodRub', | ||
44 | nombre: 'Codigo' | ||
45 | }, | ||
46 | { | ||
47 | propiedad: 'descripcion', | ||
48 | nombre: 'Nombre' | ||
49 | }, | ||
50 | ], | ||
51 | }).then(function (res) { | ||
52 | console.log('Res: ', res); | ||
53 | |||
54 | var newArt = | ||
55 | { | ||
56 | id: 0, | ||
57 | idRemito: 0, | ||
58 | codigo: res.codigo, | ||
59 | sector: res.sector, | ||
60 | sectorCodigo: res.sector + '-' + res.codigo, | ||
61 | descripcion: res.descripcion, | ||
62 | item: 1, | ||
63 | nombre: res.descripcion, | ||
64 | precio: parseFloat(res.precio.toFixed(4)), | ||
65 | costoUnitario: res.costo, | ||
66 | editCantidad: false, | ||
67 | editPrecio: false, | ||
68 | rubro: res.CodRub, | ||
69 | ivaUnitario: res.IMPIVA, | ||
70 | impuestoInternoUnitario: res.ImpInt, | ||
71 | impuestoInterno1Unitario: res.ImpInt2, | ||
72 | impuestoInterno2Unitario: res.ImpInt3, | ||
73 | precioLista: res.precio, | ||
74 | combustible: 1, | ||
75 | facturado: 0, | ||
76 | idArticulo: res.id, | ||
77 | tasaIva: res.tasaIVA | ||
78 | }; | ||
79 | |||
80 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | ||
81 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | ||
82 | |||
83 | cisterna.articuloSeleccionado = newArt; | ||
84 | cisterna.nombreArticulo = res.descripcion; | ||
85 | }).catch(function (e) { | ||
86 | console.log(e); | ||
87 | }); | ||
88 | }; | ||
89 | |||
90 | $scope.guardar = function () { | ||
91 | |||
92 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas.filter(function (cisterna) { | ||
93 | return parseInt(cisterna.disponible) > 0; | ||
94 | }); | ||
95 | |||
96 | var articulos = []; | ||
97 | |||
98 | cisternasFilter.forEach(function (cisterna) { | ||
99 | |||
100 | var fechaReparto = $scope.hojasRutas.fechaReparto; | ||
101 | |||
102 | var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { | ||
103 | return carga.fechaReparto === fechaReparto; | ||
104 | }); | ||
105 | |||
106 | if (filtroCisternaCarga.length) { | ||
107 | cisterna.cisternaCarga = filtroCisternaCarga[0]; | ||
108 | } else { | ||
109 | cisterna.cisternaCarga = { | ||
110 | confirmado: null, | ||
111 | fechaReparto: fechaReparto, | ||
112 | idCisterna: cisterna.id, | ||
113 | }; | ||
114 | } | ||
115 | |||
116 | if (!cisterna.articuloSeleccionado) { | ||
117 | focaModalService.alert('Seleccione Articulo'); | ||
118 | |||
119 | return; | ||
120 | } | ||
121 | |||
122 | //cargar | ||
123 | if (cisterna.cisternaCarga.cantidad) { | ||
124 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | ||
125 | } else { | ||
126 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | ||
127 | cisterna.cisternaCarga.idProducto = | ||
128 | cisterna.articuloSeleccionado.idArticulo; | ||
129 | } | ||
130 | |||
131 | //Guardar | ||
132 | var now = new Date(); | ||
133 | var cisternaMovimiento = { | ||
134 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
135 | cantidad: cisterna.disponible, | ||
136 | metodo: 'carga', | ||
137 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
138 | }; | ||
139 | |||
140 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
141 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | ||
142 | articulos.push(cisterna.articuloSeleccionado); | ||
143 | $scope.cisternaMovimientos.push(cisternaMovimiento); | ||
144 | }); | ||
145 | |||
146 | $uibModalInstance.close({ | ||
147 | cisternas: cisternasFilter, | ||
148 | movimientos: $scope.cisternaMovimientos, | ||
149 | articulos: articulos | ||
150 | }); | ||
151 | }; | ||
152 | |||
153 | $scope.cancel = function () { | ||
154 | $uibModalInstance.close(null); | ||
155 | }; | ||
156 | } | ||
157 | ]); | ||
158 |
src/js/service.js
1 | angular.module('focaCrearHojaRuta') | 1 | angular.module('focaCrearHojaRuta') |
2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', | 2 | .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', '$cookies', |
3 | function($http, API_ENDPOINT) { | 3 | function($http, API_ENDPOINT, $cookies) { |
4 | var route = API_ENDPOINT.URL; | 4 | var route = API_ENDPOINT.URL; |
5 | return { | 5 | return { |
6 | idUsuario: $cookies.get('vendedorCobrador'), | ||
6 | crearHojaRuta: function(hojaRuta) { | 7 | crearHojaRuta: function(hojaRuta) { |
7 | return $http.post(route + '/hoja-ruta', hojaRuta); | 8 | return $http.post(route + '/hoja-ruta', hojaRuta); |
8 | }, | 9 | }, |
10 | crearRemito: function(remito) { | ||
11 | console.log('Crear remito-----: ', remito); | ||
12 | // TODO: Cambiar para usar el servicio /remito | ||
13 | return $http.post(route + '/remito', remito); | ||
14 | }, | ||
9 | obtenerHojaRuta: function() { | 15 | obtenerHojaRuta: function() { |
10 | return $http.get(route +'/hoja-ruta'); | 16 | return $http.get(route +'/hoja-ruta'); |
11 | }, | 17 | }, |
12 | setHojaRuta: function(hojaRuta) { | 18 | setHojaRuta: function(hojaRuta) { |
13 | this.hojaRuta = hojaRuta; | 19 | this.hojaRuta = hojaRuta; |
14 | }, | 20 | }, |
15 | clearHojaRuta: function() { | 21 | clearHojaRuta: function() { |
16 | this.hojaRuta = undefined; | 22 | this.hojaRuta = undefined; |
17 | }, | 23 | }, |
18 | getHojaRuta: function() { | 24 | getHojaRuta: function() { |
19 | return this.hojaRuta; | 25 | return this.hojaRuta; |
20 | }, | 26 | }, |
21 | getArticulosByIdHojaRuta: function(id) { | 27 | getArticulosByIdHojaRuta: function(id) { |
22 | return $http.get(route+'/articulos/hoja-ruta/'+id); | 28 | return $http.get(route+'/articulos/hoja-ruta/'+id); |
23 | }, | 29 | }, |
24 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | 30 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { |
25 | return $http.post(route + '/articulos/hoja-ruta', | 31 | return $http.post(route + '/articulos/remito', |
26 | {articuloHojaRuta: articuloHojaRuta}); | 32 | {articuloRemito: articuloHojaRuta}); |
27 | }, | 33 | }, |
28 | getDomiciliosByIdHojaRuta: function(id) { | 34 | getDomiciliosByIdHojaRuta: function(id) { |
29 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); | 35 | return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); |
30 | }, | 36 | }, |
31 | getDomiciliosByIdCliente: function(id) { | 37 | getDomiciliosByIdCliente: function(id) { |
32 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | 38 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) |
33 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | 39 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); |
34 | }, | 40 | }, |
35 | getPrecioCondicion: function() { | 41 | getPrecioCondicion: function() { |
36 | return $http.get(route + '/precio-condicion'); | 42 | return $http.get(route + '/precio-condicion'); |
37 | }, | 43 | }, |
38 | getPrecioCondicionById: function(id) { | 44 | getPrecioCondicionById: function(id) { |
39 | return $http.get(route + '/precio-condicion/' + id); | 45 | return $http.get(route + '/precio-condicion/' + id); |
40 | }, | 46 | }, |
41 | getPlazoPagoByPrecioCondicion: function(id) { | 47 | getPlazoPagoByPrecioCondicion: function(id) { |
42 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); | 48 | return $http.get(route + '/plazo-pago/precio-condicion/' + id); |
43 | }, | 49 | }, |
44 | crearFlete: function(flete) { | 50 | crearFlete: function(flete) { |
45 | return $http.post(route + '/flete', {flete : flete}); | 51 | return $http.post(route + '/flete', {flete : flete}); |
46 | }, | 52 | }, |
47 | crearPlazosParaHojaRuta: function(plazos) { | 53 | crearPlazosParaHojaRuta: function(plazos) { |
48 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); | 54 | return $http.post(route + '/plazo-pago/hoja-ruta', plazos); |
49 | }, | 55 | }, |
50 | getCotizacionByIdMoneda: function(id) { | 56 | getCotizacionByIdMoneda: function(id) { |
51 | return $http.get(route + '/moneda/' + id); | 57 | return $http.get(route + '/moneda/' + id); |
52 | }, | 58 | }, |
53 | crearEstadoParaHojaRuta: function(estado) { | 59 | crearEstadoParaHojaRuta: function(estado) { |
54 | return $http.post(route + '/estado', {estado: estado}); | 60 | return $http.post(route + '/estado', {estado: estado}); |
55 | }, | 61 | }, |
56 | getNumeroHojaRuta: function() { | 62 | getNumeroHojaRuta: function() { |
57 | return $http.get(route + '/hoja-ruta/numero-siguiente'); | 63 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
58 | }, | 64 | }, |
59 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { | 65 | getRemitosByIdVehiculo: function(idVehiculo, fechaReparto, sinConfirmar) { |
60 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; | 66 | var noCofirmados = sinConfirmar ? '/sinConfirmar' : ''; |
61 | return $http.get(route + '/vehiculo/obtener/remitos/' + | 67 | return $http.get(route + '/vehiculo/obtener/remitos/' + |
62 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); | 68 | idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10) + noCofirmados); |
63 | }, | 69 | }, |
64 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { | 70 | desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) { |
65 | return $http.post(route + '/vehiculo/desasociar-remitos', | 71 | return $http.post(route + '/vehiculo/desasociar-remitos', |
66 | { | 72 | { |
67 | idsRemitos: idsRemitos, | 73 | idsRemitos: idsRemitos, |
68 | idVehiculo: idVehiculo, | 74 | idVehiculo: idVehiculo, |
69 | vehiculoSinRemitos: sinRemitos | 75 | vehiculoSinRemitos: sinRemitos |
70 | }); | 76 | }); |
71 | }, | 77 | }, |
72 | getParametros: function() { | 78 | getParametros: function() { |
73 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); | 79 | return $http.get(API_ENDPOINT.URL + '/parametros/hojaRuta'); |
74 | }, | 80 | }, |
75 | getBotonera: function() { | 81 | getBotonera: function() { |
76 | return [ | 82 | return [ |
77 | { | 83 | { |
78 | label: 'Fecha Entrega', | 84 | label: 'Fecha Entrega', |
79 | image: 'FechaEntrega.png' | 85 | image: 'FechaEntrega.png' |
80 | }, | 86 | }, |
81 | { | 87 | { |
82 | label: 'Transportista', | 88 | label: 'Transportista', |
83 | image: 'transportista.png' | 89 | image: 'transportista.png' |
84 | }, | 90 | }, |
85 | { | 91 | { |
86 | label: 'Chofer', | 92 | label: 'Chofer', |
87 | image: 'chofer.png' | 93 | image: 'chofer.png' |
88 | }, | 94 | }, |
89 | { | 95 | { |
90 | label: 'Vehiculo', | 96 | label: 'Vehiculo', |
91 | image: 'vehiculos.png' | 97 | image: 'vehiculos.png' |
92 | }, | 98 | }, |
93 | { | 99 | { |
94 | label: 'Tarifario', | 100 | label: 'Tarifario', |
95 | image: 'tarifario.png' | 101 | image: 'tarifario.png' |
96 | }, | 102 | }, |
97 | { | 103 | { |
98 | label: 'Remitos', | 104 | label: 'Remitos', |
99 | image: 'remito.png' | 105 | image: 'remito.png' |
100 | }, | 106 | }, |
101 | { | 107 | { |
102 | label: 'Vehiculos precargados', | 108 | label: 'Vehiculos precargados', |
103 | image: 'vehiculos.png' | 109 | image: 'vehiculos.png' |
104 | }, | 110 | }, |
105 | { | 111 | { |
106 | label: 'Datos extra', | 112 | label: 'Datos extra', |
107 | image: 'tarifario.png' | 113 | image: 'tarifario.png' |
108 | } | 114 | } |
109 | ]; | 115 | ]; |
116 | }, | ||
117 | getBotones: function () { | ||
118 | return [ | ||
119 | { | ||
120 | label: 'Precargados', | ||
121 | image: 'vehiculos.png' | ||
122 | }, | ||
123 | { | ||
124 | label: 'Cargar Remitos', | ||
125 | image: 'remito.png' | ||
126 | }, | ||
127 | { | ||
128 | label: 'Remito Abierto', | ||
129 | image: 'remitoabierto.png' | ||
130 | } | ||
131 | ]; | ||
132 | }, | ||
133 | getRemitoAbierto: function () { | ||
134 | return [ | ||
135 | { | ||
136 | label: 'Fecha Entrega', | ||
137 | image: 'FechaEntrega.png' | ||
138 | }, | ||
139 | { | ||
140 | label: 'Transportista', | ||
141 | image: 'transportista.png' | ||
142 | }, | ||
143 | { | ||
144 | label: 'Vehiculo', | ||
145 | image: 'vehiculos.png' | ||
146 | }, | ||
147 | { | ||
148 | label: 'Chofer', | ||
149 | image: 'chofer.png' | ||
150 | }, | ||
151 | { | ||
152 | label: 'Proveedor', | ||
153 | image: 'proveedor.png' | ||
154 | }, | ||
155 | { | ||
156 | label: 'Tarifario', | ||
157 | image: 'tarifario.png' | ||
158 | }, | ||
159 | { | ||
160 | label: 'Cliente', | ||
161 | image: 'cliente.png' | ||
162 | } | ||
163 | ]; | ||
164 | }, | ||
165 | getArticulos : function () { | ||
166 | return $http.get(API_ENDPOINT.URL + '/articulos'); | ||
167 | }, | ||
168 | getVendedorById : function (idVendedor) { | ||
169 | return $http.get(API_ENDPOINT.URL + '/vendedor-cobrador/' + idVendedor); | ||
170 | }, | ||
171 | getPuntosDescargaByClienDom: function(idDomicilio, idCliente) { | ||
172 | return $http.get(API_ENDPOINT.URL + '/punto-descarga/' + | ||
173 | idDomicilio + '/' + idCliente); | ||
174 | }, | ||
175 | getBotonFecha : function () { | ||
176 | return [ | ||
177 | { | ||
178 | label: 'Fecha Entrega', | ||
179 | image: 'FechaEntrega.png' | ||
180 | }, | ||
181 | ]; | ||
182 | }, | ||
183 | getBotoneraPrecargado: function () { | ||
184 | return [ | ||
185 | |||
186 | { | ||
187 | label: 'Transportista', | ||
188 | image: 'transportista.png' | ||
189 | }, | ||
190 | { | ||
191 | label: 'Chofer', | ||
192 | image: 'chofer.png' | ||
193 | }, | ||
194 | { | ||
195 | label: 'Vehiculo', | ||
196 | image: 'vehiculos.png' | ||
197 | }, | ||
198 | { | ||
199 | label: 'Tarifario', | ||
200 | image: 'tarifario.png' | ||
201 | }, | ||
202 | { | ||
203 | label: 'Datos extra', | ||
204 | image: 'tarifario.png' | ||
205 | } | ||
206 | ]; | ||
207 | }, | ||
208 | getBotoneraCargarRemito: function () { | ||
209 | return [ | ||
210 | { | ||
211 | label: 'Transportista', | ||
212 | image: 'transportista.png' | ||
213 | }, | ||
214 | { | ||
215 | label: 'Chofer', | ||
216 | image: 'chofer.png' | ||
217 | }, | ||
218 | { | ||
219 | label: 'Vehiculo', | ||
220 | image: 'flete.png' | ||
221 | }, | ||
222 | { | ||
223 | label: 'Remitos', | ||
224 | image: 'remito.png' | ||
225 | }, | ||
226 | { | ||
227 | label: 'Tarifario', | ||
228 | image: 'tarifario.png' | ||
229 | }, | ||
230 | { | ||
231 | label: 'Datos extra', | ||
232 | image: 'tarifario.png' | ||
233 | } | ||
234 | ]; | ||
235 | }, | ||
236 | guardarCisternas: function(cisterna, idRemito) { | ||
237 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | ||
238 | this.idUsuario + '/' + idRemito, cisterna); | ||
239 | }, | ||
240 | crearArticulosParaRemito: function(articuloRemito) { | ||
241 | return $http.post(route + '/articulos/remito', | ||
242 | {articuloRemito: articuloRemito}); | ||
110 | } | 243 | } |
111 | }; | 244 | }; |
112 | }]); | 245 | }]); |
113 | 246 |
src/views/hoja-ruta.html
1 | <div class="crear-hoja-ruta foca-crear row"> | 1 | <div class="crear-hoja-ruta foca-crear row"> |
2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador |
3 | titulo="'Hoja de ruta'" | 3 | titulo="'Hoja de ruta'" |
4 | numero="puntoVenta + '-' + comprobante" | 4 | numero="puntoVenta + '-' + comprobante" |
5 | fecha="now" | 5 | fecha="now" |
6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
7 | ></foca-cabecera-facturador> | 7 | ></foca-cabecera-facturador> |
8 | <div class="col-lg-12"> | 8 | <div class="col-lg-12"> |
9 | <div class="row mt-4"> | 9 | <div class="row mt-4"> |
10 | <div class="col-12 col-md-10 border border-light rounded"> | 10 | <div class="col-12 col-md-10 border border-light rounded"> |
11 | <div class="row px-5 py-2 botonera-secundaria"> | 11 | <div class="row px-5 py-2 botonera-secundaria"> |
12 | <div class="col-12"> | 12 | <div class="col"> |
13 | <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> | 13 | <foca-botonera-facturador botones="botoneraPrincipal" max="botoneraPrincipal.length" class="row"></foca-botonera-facturador> |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | <!-- PC --> | 16 | </div> |
17 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | 17 | </div> |
18 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> | 18 | <div class="row mt-2"> |
19 | <thead> | 19 | <div class="col-12 col-md-10 border border-light rounded"> |
20 | <tr class="d-flex"> | 20 | <div class="row px-5 py-2 botonera-secundaria"> |
21 | <th class="col-auto">#</th> | 21 | <div class="col"> |
22 | <th class="col-2">Remito</th> | 22 | <foca-botonera-facturador botones="botonera" max="botonera.length" class="row"></foca-botonera-facturador> |
23 | <th class="col">Cliente</th> | 23 | </div> |
24 | <th class="col">Direcciรณn</th> | 24 | </div> |
25 | <th class="col-auto"></th> | 25 | <div class="row"> |
26 | <th class="col-auto"> | 26 | <div class="col"> |
27 | <button | 27 | <!-- PC --> |
28 | class="btn btn-outline-light selectable" | 28 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> |
29 | ng-click="show = !show; masMenos()" | 29 | <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> |
30 | > | 30 | <thead> |
31 | <i | 31 | <tr class="d-flex"> |
32 | class="fa fa-chevron-down" | 32 | <th class="">#</th> |
33 | ng-show="show" | 33 | <th class="col">Cรณdigo</th> |
34 | aria-hidden="true" | 34 | <th class="col-4">Descripciรณn</th> |
35 | > | 35 | <th class="col text-right">Cantidad</th> |
36 | </i> | 36 | <th class="col text-right">Precio Unitario</th> |
37 | <i | 37 | <th class="col text-right">SubTotal</th> |
38 | class="fa fa-chevron-up" | 38 | <th class="text-right"> |
39 | ng-hide="show" | 39 | <button |
40 | aria-hidden="true"> | 40 | class="btn btn-outline-light selectable" |
41 | </i> | 41 | ng-click="show = !show; masMenos()" |
42 | </button> | 42 | > |
43 | </th> | 43 | <i |
44 | </tr> | 44 | class="fa fa-chevron-down" |
45 | </thead> | 45 | ng-show="show" |
46 | <tbody class="tabla-articulo-body"> | 46 | aria-hidden="true" |
47 | <tr | 47 | > |
48 | ng-repeat="(key, remito) in hojaRuta.remitosTabla" | 48 | </i> |
49 | class="d-flex" | 49 | <i |
50 | ng-show="show || key == hojaRuta.remitosTabla.length - 1" | 50 | class="fa fa-chevron-up" |
51 | > | 51 | ng-hide="show" |
52 | <td ng-bind="key + 1" class="col-auto"></td> | 52 | aria-hidden="true"> |
53 | <td | 53 | </i> |
54 | class="col-2" | 54 | </button> |
55 | >{{remito.sucursal | rellenarDigitos: 4}}-{{remito.numeroRemito | rellenarDigitos: 8}}</td> | 55 | </th> |
56 | <th class="col" ng-bind="remito.nombreCliente"></th> | 56 | </tr> |
57 | <th class="col" ng-bind="remito.domicilioStamp"></th> | 57 | </thead> |
58 | <td class="text-center col-auto"> | 58 | <tbody class="tabla-articulo-body"> |
59 | <button | 59 | <tr |
60 | class="btn btn-outline-light" | 60 | ng-repeat="(key, articulo) in articulos" |
61 | ng-click="verProductosRemito(remito.id)" | 61 | ng-show="show || key == (articulos.length - 1)" |
62 | title="Ver productos" | 62 | class="d-flex" |
63 | > | ||
64 | <i class="fa fa-eye"></i> | ||
65 | </button> | ||
66 | </td> | ||
67 | <td class="text-center col-auto"> | ||
68 | <button | ||
69 | class="btn btn-outline-light" | ||
70 | ng-click="desasociarRemito(key, remito.id)" | ||
71 | title="Eliminar" | ||
72 | > | 63 | > |
73 | <i class="fa fa-trash"></i> | 64 | <td ng-bind="key + 1"></td> |
74 | </button> | 65 | <td |
75 | </td> | 66 | class="col" |
76 | </tr> | 67 | ng-bind="articulo.sector + '-' + articulo.codigo" |
77 | </tbody> | 68 | ></td> |
78 | <tfoot> | 69 | <td |
79 | <tr class="d-flex"> | 70 | class="col-4" |
80 | <td class="col-auto px-1"> | 71 | ng-bind="articulo.descripcion" |
81 | <strong>Remitos:</strong> | 72 | ></td> |
82 | <a ng-bind="hojaRuta.remitosTabla.length"></a> | 73 | <td class="col text-right"> |
83 | </td> | 74 | <input |
84 | <td class="col"></td> | 75 | ng-show="articulo.editCantidad" |
85 | <td class="col-auto px-1"> | 76 | ng-model="tmpCantidad" |
86 | <strong>Cantidad:</strong> | 77 | class="form-control" |
87 | <a ng-bind="hojaRuta.litros"></a> | 78 | foca-tipo-input |
88 | </td> | 79 | min="1" |
89 | </tr> | 80 | foca-focus="articulo.editCantidad" |
90 | </tfoot> | 81 | ng-keypress="editarArticulo($event.keyCode, articulo, tmpCantidad, tmpPrecio);" |
91 | </table> | 82 | esc-key="cancelarEditar(articulo)" |
83 | ng-focus="selectFocus($event); | ||
84 | tmpCantidad = articulo.cantidad; | ||
85 | tmpPrecio = 0" | ||
86 | teclado-virtual | ||
87 | > | ||
88 | <i | ||
89 | class="selectable" | ||
90 | ng-click="cambioEdit(articulo, 'cantidad')" | ||
91 | ng-hide="articulo.editCantidad" | ||
92 | ng-bind="articulo.cantidad"> | ||
93 | </i> | ||
94 | </td> | ||
95 | <td class="col text-right"> | ||
96 | <i | ||
97 | class="selectable" | ||
98 | ng-bind="0 | number: 4"> | ||
99 | </i> | ||
100 | </td> | ||
101 | <td | ||
102 | class="col text-right" | ||
103 | ng-bind="0 | number: 2"> | ||
104 | </td> | ||
105 | <td class="text-center"> | ||
106 | <button | ||
107 | class="btn btn-outline-light" | ||
108 | ng-click="quitarArticulo(articulo)" | ||
109 | > | ||
110 | <i class="fa fa-trash"></i> | ||
111 | </button> | ||
112 | </td> | ||
113 | </tr> | ||
114 | </tbody> | ||
115 | <tfoot> | ||
116 | <tr ng-show="!cargando" class="d-flex"> | ||
117 | <td | ||
118 | class="align-middle" | ||
119 | ng-bind="articulosFiltro.length + 1" | ||
120 | ></td> | ||
121 | <td class="col"> | ||
122 | <input | ||
123 | class="form-control" | ||
124 | ng-model="articuloACargar.sectorCodigo" | ||
125 | readonly | ||
126 | > | ||
127 | </td> | ||
128 | <td class="col-4 tabla-articulo-descripcion"> | ||
129 | <input | ||
130 | class="form-control" | ||
131 | ng-model="articuloACargar.descripcion" | ||
132 | readonly | ||
133 | > | ||
134 | </td> | ||
135 | <td class="col text-right"> | ||
136 | <input | ||
137 | class="form-control" | ||
138 | foca-tipo-input | ||
139 | min="1" | ||
140 | ng-model="articuloACargar.cantidad" | ||
141 | foca-focus="!cargando" | ||
142 | esc-key="resetFilter()" | ||
143 | ng-keypress="agregarATabla($event.keyCode)" | ||
144 | teclado-virtual | ||
145 | > | ||
146 | </td> | ||
147 | <td class="col text-right"> | ||
148 | <input | ||
149 | class="form-control" | ||
150 | ng-model="articuloACargar.precio" | ||
151 | ng-show="idLista != -1" | ||
152 | ng-keypress="agregarATabla($event.keyCode)" | ||
153 | > | ||
154 | <input | ||
155 | class="form-control" | ||
156 | foca-tipo-input | ||
157 | step="0.0001" | ||
158 | ng-model="articuloACargar.precio" | ||
159 | esc-key="resetFilter()" | ||
160 | ng-keypress="agregarATabla($event.keyCode)" | ||
161 | ng-show="idLista == -1" | ||
162 | teclado-virtual | ||
163 | > | ||
164 | </td> | ||
165 | <td class="col text-right"> | ||
166 | <input | ||
167 | class="form-control" | ||
168 | ng-value="getSubTotal() | number: 2" | ||
169 | readonly | ||
170 | > | ||
171 | </td> | ||
172 | </tr> | ||
173 | |||
174 | <tr class="d-flex"> | ||
175 | <td colspan="4" class="no-border-top"> | ||
176 | <strong>Items:</strong> | ||
177 | <a ng-bind="articulos.length"></a> | ||
178 | </td> | ||
179 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
180 | <h3>Total:</h3> | ||
181 | </td> | ||
182 | <td class="table-celda-total text-right no-border-top" colspan="1"> | ||
183 | <h3>{{getTotal() | currency: hojaRuta.cotizacion.moneda.SIMBOLO}}</h3> | ||
184 | </td> | ||
185 | <td class="text-right no-border-top"> | ||
186 | <button | ||
187 | type="button" | ||
188 | class="btn btn-sm" | ||
189 | > | ||
190 | Totales | ||
191 | </button> | ||
192 | </td> | ||
193 | </tr> | ||
194 | </tfoot> |
src/views/modal-detalle-carga.html
File was created | 1 | <div class="modal-header py-1"> | |
2 | <div class="row w-100"> | ||
3 | <div class="col-lg-6"> | ||
4 | <h5 class="modal-title my-1">Detalle de Carga</h5> | ||
5 | </div> | ||
6 | </div> | ||
7 | </div> | ||
8 | <div class="row"> | ||
9 | <div class="col ml-3 mt-2"> | ||
10 | <span class=" text-left"> | ||
11 | Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> | ||
12 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | ||
13 | </span> | ||
14 | |||
15 | </div> | ||
16 | </div> | ||
17 | <div class="row"> | ||
18 | <div class="col ml-3"> | ||
19 | <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> | ||
20 | </div> | ||
21 | </div> | ||
22 | <div class="modal-body" id="modal-body"> | ||
23 | <table class="table table-hover table-sm table-striped"> | ||
24 | <thead> | ||
25 | <tr> | ||
26 | <th>Cisterna</th> | ||
27 | <th>Capacidad</th> | ||
28 | <th>Disponibles</th> | ||
29 | <th>Articulo Cargado</th> | ||
30 | </tr> | ||
31 | </thead> | ||
32 | <tbody> | ||
33 | <tr | ||
34 | ng-repeat="cisterna in hojasRutas.vehiculo.cisternas" | ||
35 | > | ||
36 | <td ng-bind="cisterna.id"></td> | ||
37 | <td ng-bind="cisterna.capacidad"></td> | ||
38 | <td class="w-50"> | ||
39 | <input | ||
40 | ng-model="cisterna.disponible" | ||
41 | ng-keyup="validarCisternaDisponible(cisterna)" | ||
42 | class="form-control" | ||
43 | solo-positivos | ||
44 | foca-tipo-input | ||
45 | /> | ||
46 | </td> | ||
47 | <td class="w-25"> | ||
48 | <div class="input-group "> | ||
49 | <input | ||
50 | ng-model="cisterna.nombreArticulo" | ||
51 | class="form-control" | ||
52 | ng-click="seleccionarProductos(cisterna)" | ||
53 | readonly | ||
54 | /> | ||
55 | <div class="input-group-append"> | ||
56 | <button | ||
57 | ladda="searchLoading" | ||
58 | class="btn btn-outline-secondary form-control" | ||
59 | type="button" | ||
60 | ng-click="seleccionarProductos(cisterna)" | ||
61 | > | ||
62 | <i class="fa fa-search" aria-hidden="true"></i> | ||
63 | </button> | ||
64 | </div> | ||
65 | </div> | ||
66 | </td> | ||
67 | </tr> | ||
68 | </tbody> | ||
69 | </table> | ||
70 | </div> | ||
71 | <div class="modal-footer py-1"> | ||
72 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
73 | <button class="btn btn-sm btn-secondary" type="button" ng-click="guardar()">Guardar</button> | ||
74 | </div> | ||
75 | </div> |