Commit 0bc4382d1a54bd52cf17874948da0e548ec8d045

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'develop'

Master(efernandez)

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