Commit 15820169c2a441e42df9ccbcfe90f443d0eb83ca

Authored by Pablo Marco del Pont
1 parent 6403392f1f
Exists in master

Cambio de mensaje de validación.

Showing 1 changed file with 1 additions and 2 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', 1 angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl',
2 [ 2 [
3 '$scope', '$uibModal', '$location', '$filter', 'crearHojaRutaService', 'focaModalService', 3 '$scope', '$uibModal', '$location', '$filter', 'crearHojaRutaService', 'focaModalService',
4 function($scope, $uibModal, $location, $filter, crearHojaRutaService, focaModalService) { 4 function($scope, $uibModal, $location, $filter, crearHojaRutaService, focaModalService) {
5 $scope.botonera = [ 5 $scope.botonera = [
6 {texto: 'Transportista', accion: function() {$scope.seleccionarProveedor();}}, 6 {texto: 'Transportista', accion: function() {$scope.seleccionarProveedor();}},
7 {texto: 'Chofer', accion: function() {$scope.seleccionarChofer();}}, 7 {texto: 'Chofer', accion: function() {$scope.seleccionarChofer();}},
8 {texto: 'Vehiculo', accion: function() {$scope.seleccionarVehiculo();}}, 8 {texto: 'Vehiculo', accion: function() {$scope.seleccionarVehiculo();}},
9 {texto: 'Tarifario', accion: function() {$scope.seleccionarTarifario();}}, 9 {texto: 'Tarifario', accion: function() {$scope.seleccionarTarifario();}},
10 {texto: 'Remitos', accion: function() {$scope.seleccionarRemito();}}, 10 {texto: 'Remitos', accion: function() {$scope.seleccionarRemito();}},
11 {texto: '', accion: function() {}}, 11 {texto: '', accion: function() {}},
12 {texto: '', accion: function() {}}, 12 {texto: '', accion: function() {}},
13 {texto: '', accion: function() {}} 13 {texto: '', accion: function() {}}
14 ]; 14 ];
15 $scope.datepickerAbierto = false; 15 $scope.datepickerAbierto = false;
16 16
17 $scope.show = false; 17 $scope.show = false;
18 $scope.cargando = true; 18 $scope.cargando = true;
19 $scope.dateOptions = { 19 $scope.dateOptions = {
20 maxDate: new Date(), 20 maxDate: new Date(),
21 minDate: new Date(2010, 0, 1) 21 minDate: new Date(2010, 0, 1)
22 }; 22 };
23 23
24 $scope.hojaRuta = { 24 $scope.hojaRuta = {
25 fecha: new Date(), 25 fecha: new Date(),
26 litros: 0, 26 litros: 0,
27 chofer: {}, 27 chofer: {},
28 vehiculo: { 28 vehiculo: {
29 capacidad: 0 29 capacidad: 0
30 }, 30 },
31 transportista: {}, 31 transportista: {},
32 tarifario: { 32 tarifario: {
33 costo: null 33 costo: null
34 } 34 }
35 }; 35 };
36 36
37 $scope.cabecera = []; 37 $scope.cabecera = [];
38 $scope.showCabecera = true; 38 $scope.showCabecera = true;
39 39
40 $scope.now = new Date(); 40 $scope.now = new Date();
41 $scope.puntoVenta = '0000'; 41 $scope.puntoVenta = '0000';
42 $scope.comprobante = '00000000'; 42 $scope.comprobante = '00000000';
43 $scope.remitosTabla = []; 43 $scope.remitosTabla = [];
44 $scope.idLista = undefined; 44 $scope.idLista = undefined;
45 //La pantalla solo se usa para cargar pedidos 45 //La pantalla solo se usa para cargar pedidos
46 //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); 46 //var hojaRutaTemp = crearHojaRutaService.getHojaRuta();
47 47
48 crearHojaRutaService.getNumeroHojaRuta().then( 48 crearHojaRutaService.getNumeroHojaRuta().then(
49 function(res) { 49 function(res) {
50 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); 50 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4);
51 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 51 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
52 }, 52 },
53 function(err) { 53 function(err) {
54 focaModalService.alert('La terminal no esta configurada correctamente'); 54 focaModalService.alert('La terminal no esta configurada correctamente');
55 console.info(err); 55 console.info(err);
56 } 56 }
57 ); 57 );
58 //La pantalla solo se usa para cargar pedidos 58 //La pantalla solo se usa para cargar pedidos
59 // if (hojaRutaTemp !== undefined) { 59 // if (hojaRutaTemp !== undefined) {
60 // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); 60 // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga);
61 // $scope.hojaRuta = hojaRutaTemp; 61 // $scope.hojaRuta = hojaRutaTemp;
62 // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); 62 // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString();
63 // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); 63 // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString();
64 // $scope.idLista = $scope.hojaRuta.precioCondicion; 64 // $scope.idLista = $scope.hojaRuta.precioCondicion;
65 // crearHojaRutaService 65 // crearHojaRutaService
66 // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( 66 // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then(
67 // function(res) { 67 // function(res) {
68 // $scope.remitosTabla = res.data; 68 // $scope.remitosTabla = res.data;
69 // } 69 // }
70 // ); 70 // );
71 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO 71 //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO
72 //(NO REQUERIDO EN ESTA VERSION) 72 //(NO REQUERIDO EN ESTA VERSION)
73 // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( 73 // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then(
74 // function(res) { 74 // function(res) {
75 // $scope.hojaRuta.domicilio = res.data; 75 // $scope.hojaRuta.domicilio = res.data;
76 // } 76 // }
77 // ); 77 // );
78 // } else { 78 // } else {
79 // $scope.hojaRuta.fechaCarga = new Date(); 79 // $scope.hojaRuta.fechaCarga = new Date();
80 // $scope.hojaRuta.bomba = '0'; 80 // $scope.hojaRuta.bomba = '0';
81 // $scope.hojaRuta.flete = '0'; 81 // $scope.hojaRuta.flete = '0';
82 // $scope.idLista = undefined; 82 // $scope.idLista = undefined;
83 // } 83 // }
84 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO 84 //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO
85 // $scope.addNewDom = function() { 85 // $scope.addNewDom = function() {
86 // $scope.hojaRuta.domicilio.push({ 'id': 0 }); 86 // $scope.hojaRuta.domicilio.push({ 'id': 0 });
87 // }; 87 // };
88 // $scope.removeNewChoice = function(choice) { 88 // $scope.removeNewChoice = function(choice) {
89 // if ($scope.hojaRuta.domicilio.length > 1) { 89 // if ($scope.hojaRuta.domicilio.length > 1) {
90 // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( 90 // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex(
91 // function(c) { 91 // function(c) {
92 // return c.$$hashKey === choice.$$hashKey; 92 // return c.$$hashKey === choice.$$hashKey;
93 // } 93 // }
94 // ), 1); 94 // ), 1);
95 // } 95 // }
96 // }; 96 // };
97 97
98 $scope.crearHojaRuta = function() { 98 $scope.crearHojaRuta = function() {
99 if($scope.hojaRuta.litros <= 0) { 99 if($scope.hojaRuta.litros <= 0) {
100 focaModalService.alert('Ingrese Remitos'); 100 focaModalService.alert('Ingrese Remitos');
101 return; 101 return;
102 } 102 }
103 103
104 if(!$scope.hojaRuta.chofer.id) { 104 if(!$scope.hojaRuta.chofer.id) {
105 focaModalService.alert('Ingrese Chofer'); 105 focaModalService.alert('Ingrese Chofer');
106 return; 106 return;
107 } 107 }
108 108
109 if(!$scope.hojaRuta.vehiculo.id) { 109 if(!$scope.hojaRuta.vehiculo.id) {
110 focaModalService.alert('Ingrese Vehiculo'); 110 focaModalService.alert('Ingrese Vehiculo');
111 return; 111 return;
112 } 112 }
113 113
114 if(!$scope.hojaRuta.transportista.codigo) { 114 if(!$scope.hojaRuta.transportista.codigo) {
115 focaModalService.alert('Ingrese Transportista'); 115 focaModalService.alert('Ingrese Transportista');
116 return; 116 return;
117 } 117 }
118 118
119 if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) { 119 if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) {
120 focaModalService.alert( 120 focaModalService.alert(
121 'La capacidad del Vehiculo es menor a lo ingresado en Remitos' 121 'La capacidad del Vehiculo es menor a lo ingresado en Remitos'
122 ); 122 );
123 return; 123 return;
124 } 124 }
125 125
126 if(!$scope.hojaRuta.tarifario.costo) { 126 if(!$scope.hojaRuta.tarifario.costo) {
127 focaModalService.alert('Ingrese Tarifario'); 127 focaModalService.alert('Ingrese Tarifario');
128 return; 128 return;
129 } 129 }
130 130
131 var date = new Date(); 131 var date = new Date();
132 var save = { 132 var save = {
133 hojaRuta: { 133 hojaRuta: {
134 id: 0, 134 id: 0,
135 fechaCreacion: 135 fechaCreacion:
136 new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) 136 new Date(date.getTime() - (date.getTimezoneOffset() * 60000))
137 .toISOString().slice(0, 19) .replace('T', ' '), 137 .toISOString().slice(0, 19) .replace('T', ' '),
138 idTransportista: $scope.hojaRuta.transportista.codigo, 138 idTransportista: $scope.hojaRuta.transportista.codigo,
139 idChofer: $scope.hojaRuta.chofer.id, 139 idChofer: $scope.hojaRuta.chofer.id,
140 idVehiculo: $scope.hojaRuta.vehiculo.id, 140 idVehiculo: $scope.hojaRuta.vehiculo.id,
141 tarifaFlete: $scope.hojaRuta.tarifario.costo 141 tarifaFlete: $scope.hojaRuta.tarifario.costo
142 }, 142 },
143 remitos: $scope.remitosTabla 143 remitos: $scope.remitosTabla
144 }; 144 };
145 145
146 crearHojaRutaService.crearHojaRuta(save).then( 146 crearHojaRutaService.crearHojaRuta(save).then(
147 function(data) { 147 function(data) {
148 focaModalService.alert( 148 focaModalService.alert(
149 'Hoja ruta creada Nº: ' + 149 'Hoja ruta creada Nº: ' +
150 $scope.rellenar(data.data.sucursal, 4) + 150 $scope.rellenar(data.data.sucursal, 4) +
151 '-' + 151 '-' +
152 $scope.rellenar(data.data.numeroHojaRuta, 8) 152 $scope.rellenar(data.data.numeroHojaRuta, 8)
153 ); 153 );
154 $scope.hojaRuta = { 154 $scope.hojaRuta = {
155 fecha: new Date(), 155 fecha: new Date(),
156 litros: 0, 156 litros: 0,
157 chofer: {}, 157 chofer: {},
158 vehiculo: { 158 vehiculo: {
159 capacidad: 0 159 capacidad: 0
160 }, 160 },
161 transportista: {}, 161 transportista: {},
162 tarifario: { 162 tarifario: {
163 costo: null 163 costo: null
164 } 164 }
165 }; 165 };
166 166
167 $scope.remitosTabla = []; 167 $scope.remitosTabla = [];
168 $scope.cabecera = []; 168 $scope.cabecera = [];
169 169
170 crearHojaRutaService.getNumeroHojaRuta().then(function(res) { 170 crearHojaRutaService.getNumeroHojaRuta().then(function(res) {
171 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 171 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
172 }); 172 });
173 }, 173 },
174 function(error) { 174 function(error) {
175 focaModalService.alert('Hubo un error al crear la nota de pedido'); 175 focaModalService.alert('Hubo un error al crear la nota de pedido');
176 console.info(error); 176 console.info(error);
177 } 177 }
178 ); 178 );
179 }; 179 };
180 180
181 $scope.seleccionarProveedor = function() { 181 $scope.seleccionarProveedor = function() {
182 var modalInstance = $uibModal.open( 182 var modalInstance = $uibModal.open(
183 { 183 {
184 ariaLabelledBy: 'Busqueda de Transportista', 184 ariaLabelledBy: 'Busqueda de Transportista',
185 templateUrl: 'modal-proveedor.html', 185 templateUrl: 'modal-proveedor.html',
186 controller: 'focaModalProveedorCtrl', 186 controller: 'focaModalProveedorCtrl',
187 size: 'lg', 187 size: 'lg',
188 resolve: { 188 resolve: {
189 transportista: function() { 189 transportista: function() {
190 return true; 190 return true;
191 } 191 }
192 } 192 }
193 } 193 }
194 ); 194 );
195 modalInstance.result.then( 195 modalInstance.result.then(
196 function(proveedor) { 196 function(proveedor) {
197 console.info($scope.hojaRuta); 197 console.info($scope.hojaRuta);
198 $scope.hojaRuta.transportista.codigo = proveedor.COD; 198 $scope.hojaRuta.transportista.codigo = proveedor.COD;
199 addCabecera('Transportista:', proveedor.NOM); 199 addCabecera('Transportista:', proveedor.NOM);
200 }, function() { 200 }, function() {
201 201
202 } 202 }
203 ); 203 );
204 }; 204 };
205 205
206 $scope.seleccionarChofer = function() { 206 $scope.seleccionarChofer = function() {
207 var modalInstance = $uibModal.open( 207 var modalInstance = $uibModal.open(
208 { 208 {
209 ariaLabelledBy: 'Busqueda de Chofer', 209 ariaLabelledBy: 'Busqueda de Chofer',
210 templateUrl: 'modal-chofer.html', 210 templateUrl: 'modal-chofer.html',
211 controller: 'focaModalChoferController', 211 controller: 'focaModalChoferController',
212 size: 'lg' 212 size: 'lg'
213 } 213 }
214 ); 214 );
215 215
216 modalInstance.result.then( 216 modalInstance.result.then(
217 function(chofer) { 217 function(chofer) {
218 $scope.hojaRuta.chofer = chofer; 218 $scope.hojaRuta.chofer = chofer;
219 addCabecera('Chofer: ', chofer.nombre); 219 addCabecera('Chofer: ', chofer.nombre);
220 }, function() { 220 }, function() {
221 // funcion ejecutada cuando se cancela el modal 221 // funcion ejecutada cuando se cancela el modal
222 } 222 }
223 ); 223 );
224 }; 224 };
225 225
226 $scope.seleccionarVehiculo = function() { 226 $scope.seleccionarVehiculo = function() {
227 var modalInstance = $uibModal.open( 227 var modalInstance = $uibModal.open(
228 { 228 {
229 ariaLabelledBy: 'Busqueda de Vehiculo', 229 ariaLabelledBy: 'Busqueda de Vehiculo',
230 templateUrl: 'modal-vehiculo.html', 230 templateUrl: 'modal-vehiculo.html',
231 controller: 'focaModalVehiculoController', 231 controller: 'focaModalVehiculoController',
232 size: 'lg' 232 size: 'lg'
233 } 233 }
234 ); 234 );
235 235
236 modalInstance.result.then( 236 modalInstance.result.then(
237 function(vehiculo) { 237 function(vehiculo) {
238 $scope.hojaRuta.vehiculo = vehiculo; 238 $scope.hojaRuta.vehiculo = vehiculo;
239 addCabecera('Tractor: ', vehiculo.tractor); 239 addCabecera('Tractor: ', vehiculo.tractor);
240 addCabecera('Semi: ', vehiculo.semi); 240 addCabecera('Semi: ', vehiculo.semi);
241 addCabecera('Capacidad: ', vehiculo.capacidad); 241 addCabecera('Capacidad: ', vehiculo.capacidad);
242 }, function() { 242 }, function() {
243 // funcion ejecutada cuando se cancela el modal 243 // funcion ejecutada cuando se cancela el modal
244 } 244 }
245 ); 245 );
246 }; 246 };
247 247
248 $scope.seleccionarTarifario = function() { 248 $scope.seleccionarTarifario = function() {
249 var modalInstance = $uibModal.open( 249 var modalInstance = $uibModal.open(
250 { 250 {
251 ariaLabelledBy: 'Busqueda de Tarifario', 251 ariaLabelledBy: 'Busqueda de Tarifario',
252 templateUrl: 'modal-tarifa-flete.html', 252 templateUrl: 'modal-tarifa-flete.html',
253 controller: 'focaModalTarifaFleteController', 253 controller: 'focaModalTarifaFleteController',
254 size: 'lg', 254 size: 'lg',
255 resolve: { 255 resolve: {
256 parametrosTarifaFlete: function() { 256 parametrosTarifaFlete: function() {
257 return $scope.hojaRuta.tarifario.costo; 257 return $scope.hojaRuta.tarifario.costo;
258 } 258 }
259 } 259 }
260 } 260 }
261 ); 261 );
262 262
263 modalInstance.result.then( 263 modalInstance.result.then(
264 function(tarifario) { 264 function(tarifario) {
265 $scope.hojaRuta.tarifario = tarifario; 265 $scope.hojaRuta.tarifario = tarifario;
266 addCabecera('Tarifario: ', tarifario.costo); 266 addCabecera('Tarifario: ', tarifario.costo);
267 }, function() { 267 }, function() {
268 // funcion ejecutada cuando se cancela el modal 268 // funcion ejecutada cuando se cancela el modal
269 } 269 }
270 ); 270 );
271 }; 271 };
272 272
273 $scope.seleccionarRemito = function() { 273 $scope.seleccionarRemito = function() {
274 var modalInstance = $uibModal.open( 274 var modalInstance = $uibModal.open(
275 { 275 {
276 ariaLabelledBy: 'Busqueda de Remito', 276 ariaLabelledBy: 'Busqueda de Remito',
277 templateUrl: 'foca-modal-remito.html', 277 templateUrl: 'foca-modal-remito.html',
278 controller: 'focaModalRemitoController', 278 controller: 'focaModalRemitoController',
279 size: 'lg' 279 size: 'lg'
280 } 280 }
281 ); 281 );
282 modalInstance.result.then( 282 modalInstance.result.then(
283 function(remito) { 283 function(remito) {
284 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 284 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
285 if ($scope.remitosTabla[i].id === remito.id) { 285 if ($scope.remitosTabla[i].id === remito.id) {
286 focaModalService.alert('Remito ya incluido'); 286 focaModalService.alert('Remito ya incluido');
287 return; 287 return;
288 } 288 }
289 } 289 }
290 290
291 var litros = 0; 291 var litros = 0;
292 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { 292 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) {
293 litros = litros + parseFloat(remito.articulosRemito[j].cantidad); 293 litros = litros + parseFloat(remito.articulosRemito[j].cantidad);
294 } 294 }
295 295
296 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { 296 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) {
297 focaModalService.alert( 297 focaModalService.alert(
298 'No se puede agregar mas recibos porque la ' + 298 'Debe ingresar toda la información para el transporte'
299 'capacidad del vehiculo esta llena o no esta definida'
300 ); 299 );
301 return; 300 return;
302 } 301 }
303 302
304 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) 303 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad)
305 { 304 {
306 var litrostotales = litros; 305 var litrostotales = litros;
307 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; 306 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros;
308 focaModalService.alert( 307 focaModalService.alert(
309 'La carga excede la capacidad disponible del vehiculo. ' + 308 'La carga excede la capacidad disponible del vehiculo. ' +
310 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' 309 'Excedente no cargado: ' + (litrostotales - litros) + ' litros'
311 ); 310 );
312 } 311 }
313 312
314 remito.litros = litros; 313 remito.litros = litros;
315 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; 314 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros;
316 $scope.remitosTabla.push(remito); 315 $scope.remitosTabla.push(remito);
317 }, function() { 316 }, function() {
318 // funcion ejecutada cuando se cancela el modal 317 // funcion ejecutada cuando se cancela el modal
319 } 318 }
320 ); 319 );
321 }; 320 };
322 321
323 $scope.getTotal = function() { 322 $scope.getTotal = function() {
324 var total = 0; 323 var total = 0;
325 var arrayTempArticulos = $scope.remitosTabla; 324 var arrayTempArticulos = $scope.remitosTabla;
326 for (var i = 0; i < arrayTempArticulos.length; i++) { 325 for (var i = 0; i < arrayTempArticulos.length; i++) {
327 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 326 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
328 } 327 }
329 return parseFloat(total.toFixed(2)); 328 return parseFloat(total.toFixed(2));
330 }; 329 };
331 330
332 $scope.getSubTotal = function() { 331 $scope.getSubTotal = function() {
333 if($scope.articuloACargar) { 332 if($scope.articuloACargar) {
334 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 333 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
335 } 334 }
336 }; 335 };
337 336
338 $scope.limpiarPantalla = function() { 337 $scope.limpiarPantalla = function() {
339 $scope.limpiarFlete(); 338 $scope.limpiarFlete();
340 $scope.hojaRuta.flete = '0'; 339 $scope.hojaRuta.flete = '0';
341 $scope.hojaRuta.bomba = '0'; 340 $scope.hojaRuta.bomba = '0';
342 $scope.hojaRuta.precioCondicion = ''; 341 $scope.hojaRuta.precioCondicion = '';
343 $scope.remitosTabla = []; 342 $scope.remitosTabla = [];
344 $scope.hojaRuta.vendedor.nombre = ''; 343 $scope.hojaRuta.vendedor.nombre = '';
345 $scope.hojaRuta.cliente = {nombre: ''}; 344 $scope.hojaRuta.cliente = {nombre: ''};
346 $scope.hojaRuta.domicilio = {dom: ''}; 345 $scope.hojaRuta.domicilio = {dom: ''};
347 $scope.hojaRuta.litros = 0; 346 $scope.hojaRuta.litros = 0;
348 $scope.domiciliosCliente = []; 347 $scope.domiciliosCliente = [];
349 }; 348 };
350 //Recibe aviso si el teclado está en uso 349 //Recibe aviso si el teclado está en uso
351 // $rootScope.$on('usarTeclado', function(event, data) { 350 // $rootScope.$on('usarTeclado', function(event, data) {
352 // if(data) { 351 // if(data) {
353 // $scope.mostrarTeclado = true; 352 // $scope.mostrarTeclado = true;
354 // return; 353 // return;
355 // } 354 // }
356 // $scope.mostrarTeclado = false; 355 // $scope.mostrarTeclado = false;
357 // }) 356 // })
358 $scope.selectFocus = function($event) { 357 $scope.selectFocus = function($event) {
359 //Si el teclado esta en uso no selecciona el valor 358 //Si el teclado esta en uso no selecciona el valor
360 // if($scope.mostrarTeclado) { 359 // if($scope.mostrarTeclado) {
361 // return; 360 // return;
362 // } 361 // }
363 $event.target.select(); 362 $event.target.select();
364 }; 363 };
365 364
366 $scope.salir = function() { 365 $scope.salir = function() {
367 $location.path('/'); 366 $location.path('/');
368 }; 367 };
369 368
370 $scope.parsearATexto = function(articulo) { 369 $scope.parsearATexto = function(articulo) {
371 articulo.cantidad = parseFloat(articulo.cantidad); 370 articulo.cantidad = parseFloat(articulo.cantidad);
372 articulo.precio = parseFloat(articulo.precio); 371 articulo.precio = parseFloat(articulo.precio);
373 }; 372 };
374 373
375 $scope.rellenar = function(relleno, longitud) { 374 $scope.rellenar = function(relleno, longitud) {
376 relleno = '' + relleno; 375 relleno = '' + relleno;
377 while (relleno.length < longitud) { 376 while (relleno.length < longitud) {
378 relleno = '0' + relleno; 377 relleno = '0' + relleno;
379 } 378 }
380 379
381 return relleno; 380 return relleno;
382 }; 381 };
383 382
384 $scope.quitarArticulo = function(key) { 383 $scope.quitarArticulo = function(key) {
385 $scope.remitosTabla.splice(key, 1); 384 $scope.remitosTabla.splice(key, 1);
386 var litros = 0; 385 var litros = 0;
387 386
388 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 387 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
389 litros += parseFloat($scope.remitosTabla[i].litros); 388 litros += parseFloat($scope.remitosTabla[i].litros);
390 } 389 }
391 390
392 $scope.hojaRuta.litros = litros; 391 $scope.hojaRuta.litros = litros;
393 392
394 }; 393 };
395 394
396 function addCabecera(label, valor) { 395 function addCabecera(label, valor) {
397 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 396 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
398 if(propiedad.length === 1) { 397 if(propiedad.length === 1) {
399 propiedad[0].valor = valor; 398 propiedad[0].valor = valor;
400 } else { 399 } else {
401 $scope.cabecera.push({label: label, valor: valor}); 400 $scope.cabecera.push({label: label, valor: valor});
402 } 401 }
403 } 402 }
404 403
405 /*function removeCabecera(label) { 404 /*function removeCabecera(label) {
406 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 405 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
407 if(propiedad.length === 1){ 406 if(propiedad.length === 1){
408 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 407 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
409 } 408 }
410 }*/ 409 }*/
411 } 410 }
412 ] 411 ]
413 ) 412 )
414 .controller('hojaRutaListaCtrl', [ 413 .controller('hojaRutaListaCtrl', [
415 '$scope', 414 '$scope',
416 'crearHojaRutaService', 415 'crearHojaRutaService',
417 '$location', 416 '$location',
418 function($scope, crearHojaRutaService, $location) { 417 function($scope, crearHojaRutaService, $location) {
419 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 418 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
420 $scope.hojaRutas = datos.data; 419 $scope.hojaRutas = datos.data;
421 }); 420 });
422 $scope.editar = function(hojaRuta) { 421 $scope.editar = function(hojaRuta) {
423 crearHojaRutaService.setHojaRuta(hojaRuta); 422 crearHojaRutaService.setHojaRuta(hojaRuta);
424 $location.path('/venta-nota-pedido/abm/'); 423 $location.path('/venta-nota-pedido/abm/');
425 }; 424 };
426 $scope.crearPedido = function() { 425 $scope.crearPedido = function() {
427 crearHojaRutaService.clearHojaRuta(); 426 crearHojaRutaService.clearHojaRuta();
428 $location.path('/venta-nota-pedido/abm/'); 427 $location.path('/venta-nota-pedido/abm/');
429 }; 428 };
430 } 429 }
431 ]) 430 ])
432 .controller('focaCrearHojaRutaFichaClienteController', [ 431 .controller('focaCrearHojaRutaFichaClienteController', [
433 '$scope', 432 '$scope',
434 'crearHojaRutaService', 433 'crearHojaRutaService',
435 '$location', 434 '$location',
436 function($scope, crearHojaRutaService, $location) { 435 function($scope, crearHojaRutaService, $location) {
437 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 436 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
438 $scope.hojaRutas = datos.data; 437 $scope.hojaRutas = datos.data;
439 }); 438 });
440 $scope.editar = function(hojaRuta) { 439 $scope.editar = function(hojaRuta) {
441 crearHojaRutaService.setHojaRuta(hojaRuta); 440 crearHojaRutaService.setHojaRuta(hojaRuta);
442 $location.path('/venta-nota-pedido/abm/'); 441 $location.path('/venta-nota-pedido/abm/');
443 }; 442 };
444 $scope.crearPedido = function() { 443 $scope.crearPedido = function() {
445 crearHojaRutaService.clearHojaRuta(); 444 crearHojaRutaService.clearHojaRuta();
446 $location.path('/venta-nota-pedido/abm/'); 445 $location.path('/venta-nota-pedido/abm/');
447 }; 446 };
448 } 447 }
449 ]); 448 ]);
450 449