Commit ba8f24b1ab2838feb270d16dee97462c642f9261

Authored by Nicolás Guarnieri
1 parent ff5c167401
Exists in master

resolve de idTransportista

Showing 1 changed file with 6 additions and 1 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 resolve: {
234 idTransportista: function() {
235 return -1;
236 }
237 }
233 } 238 }
234 ); 239 );
235 240
236 modalInstance.result.then( 241 modalInstance.result.then(
237 function(vehiculo) { 242 function(vehiculo) {
238 $scope.hojaRuta.vehiculo = vehiculo; 243 $scope.hojaRuta.vehiculo = vehiculo;
239 addCabecera('Tractor: ', vehiculo.tractor); 244 addCabecera('Tractor: ', vehiculo.tractor);
240 addCabecera('Semi: ', vehiculo.semi); 245 addCabecera('Semi: ', vehiculo.semi);
241 addCabecera('Capacidad: ', vehiculo.capacidad); 246 addCabecera('Capacidad: ', vehiculo.capacidad);
242 }, function() { 247 }, function() {
243 // funcion ejecutada cuando se cancela el modal 248 // funcion ejecutada cuando se cancela el modal
244 } 249 }
245 ); 250 );
246 }; 251 };
247 252
248 $scope.seleccionarTarifario = function() { 253 $scope.seleccionarTarifario = function() {
249 var modalInstance = $uibModal.open( 254 var modalInstance = $uibModal.open(
250 { 255 {
251 ariaLabelledBy: 'Busqueda de Tarifario', 256 ariaLabelledBy: 'Busqueda de Tarifario',
252 templateUrl: 'modal-tarifa-flete.html', 257 templateUrl: 'modal-tarifa-flete.html',
253 controller: 'focaModalTarifaFleteController', 258 controller: 'focaModalTarifaFleteController',
254 size: 'lg', 259 size: 'lg',
255 resolve: { 260 resolve: {
256 parametrosTarifaFlete: function() { 261 parametrosTarifaFlete: function() {
257 return $scope.hojaRuta.tarifario.costo; 262 return $scope.hojaRuta.tarifario.costo;
258 } 263 }
259 } 264 }
260 } 265 }
261 ); 266 );
262 267
263 modalInstance.result.then( 268 modalInstance.result.then(
264 function(tarifario) { 269 function(tarifario) {
265 $scope.hojaRuta.tarifario = tarifario; 270 $scope.hojaRuta.tarifario = tarifario;
266 addCabecera('Tarifario: ', tarifario.costo); 271 addCabecera('Tarifario: ', tarifario.costo);
267 }, function() { 272 }, function() {
268 // funcion ejecutada cuando se cancela el modal 273 // funcion ejecutada cuando se cancela el modal
269 } 274 }
270 ); 275 );
271 }; 276 };
272 277
273 $scope.seleccionarRemito = function() { 278 $scope.seleccionarRemito = function() {
274 var modalInstance = $uibModal.open( 279 var modalInstance = $uibModal.open(
275 { 280 {
276 ariaLabelledBy: 'Busqueda de Remito', 281 ariaLabelledBy: 'Busqueda de Remito',
277 templateUrl: 'foca-modal-remito.html', 282 templateUrl: 'foca-modal-remito.html',
278 controller: 'focaModalRemitoController', 283 controller: 'focaModalRemitoController',
279 size: 'lg', 284 size: 'lg',
280 resolve: {usadoPor: function() {return 'hojaRuta';}} 285 resolve: {usadoPor: function() {return 'hojaRuta';}}
281 } 286 }
282 ); 287 );
283 modalInstance.result.then( 288 modalInstance.result.then(
284 function(remito) { 289 function(remito) {
285 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 290 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
286 if ($scope.remitosTabla[i].id === remito.id) { 291 if ($scope.remitosTabla[i].id === remito.id) {
287 focaModalService.alert('Remito ya incluido'); 292 focaModalService.alert('Remito ya incluido');
288 return; 293 return;
289 } 294 }
290 } 295 }
291 296
292 var litros = 0; 297 var litros = 0;
293 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { 298 for (var j = remito.articulosRemito.length - 1; j >= 0; j--) {
294 litros = litros + parseFloat(remito.articulosRemito[j].cantidad); 299 litros = litros + parseFloat(remito.articulosRemito[j].cantidad);
295 } 300 }
296 301
297 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { 302 if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) {
298 focaModalService.alert( 303 focaModalService.alert(
299 'Debe ingresar toda la información para el transporte' 304 'Debe ingresar toda la información para el transporte'
300 ); 305 );
301 return; 306 return;
302 } 307 }
303 308
304 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) 309 if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad)
305 { 310 {
306 var litrostotales = litros; 311 var litrostotales = litros;
307 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; 312 litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros;
308 focaModalService.alert( 313 focaModalService.alert(
309 'La carga excede la capacidad disponible del vehiculo. ' + 314 'La carga excede la capacidad disponible del vehiculo. ' +
310 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' 315 'Excedente no cargado: ' + (litrostotales - litros) + ' litros'
311 ); 316 );
312 } 317 }
313 318
314 remito.litros = litros; 319 remito.litros = litros;
315 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; 320 $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros;
316 $scope.remitosTabla.push(remito); 321 $scope.remitosTabla.push(remito);
317 }, function() { 322 }, function() {
318 // funcion ejecutada cuando se cancela el modal 323 // funcion ejecutada cuando se cancela el modal
319 } 324 }
320 ); 325 );
321 }; 326 };
322 327
323 $scope.getTotal = function() { 328 $scope.getTotal = function() {
324 var total = 0; 329 var total = 0;
325 var arrayTempArticulos = $scope.remitosTabla; 330 var arrayTempArticulos = $scope.remitosTabla;
326 for (var i = 0; i < arrayTempArticulos.length; i++) { 331 for (var i = 0; i < arrayTempArticulos.length; i++) {
327 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 332 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
328 } 333 }
329 return parseFloat(total.toFixed(2)); 334 return parseFloat(total.toFixed(2));
330 }; 335 };
331 336
332 $scope.getSubTotal = function() { 337 $scope.getSubTotal = function() {
333 if($scope.articuloACargar) { 338 if($scope.articuloACargar) {
334 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 339 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
335 } 340 }
336 }; 341 };
337 342
338 $scope.limpiarPantalla = function() { 343 $scope.limpiarPantalla = function() {
339 $scope.limpiarFlete(); 344 $scope.limpiarFlete();
340 $scope.hojaRuta.flete = '0'; 345 $scope.hojaRuta.flete = '0';
341 $scope.hojaRuta.bomba = '0'; 346 $scope.hojaRuta.bomba = '0';
342 $scope.hojaRuta.precioCondicion = ''; 347 $scope.hojaRuta.precioCondicion = '';
343 $scope.remitosTabla = []; 348 $scope.remitosTabla = [];
344 $scope.hojaRuta.vendedor.nombre = ''; 349 $scope.hojaRuta.vendedor.nombre = '';
345 $scope.hojaRuta.cliente = {nombre: ''}; 350 $scope.hojaRuta.cliente = {nombre: ''};
346 $scope.hojaRuta.domicilio = {dom: ''}; 351 $scope.hojaRuta.domicilio = {dom: ''};
347 $scope.hojaRuta.litros = 0; 352 $scope.hojaRuta.litros = 0;
348 $scope.domiciliosCliente = []; 353 $scope.domiciliosCliente = [];
349 }; 354 };
350 //Recibe aviso si el teclado está en uso 355 //Recibe aviso si el teclado está en uso
351 // $rootScope.$on('usarTeclado', function(event, data) { 356 // $rootScope.$on('usarTeclado', function(event, data) {
352 // if(data) { 357 // if(data) {
353 // $scope.mostrarTeclado = true; 358 // $scope.mostrarTeclado = true;
354 // return; 359 // return;
355 // } 360 // }
356 // $scope.mostrarTeclado = false; 361 // $scope.mostrarTeclado = false;
357 // }) 362 // })
358 $scope.selectFocus = function($event) { 363 $scope.selectFocus = function($event) {
359 //Si el teclado esta en uso no selecciona el valor 364 //Si el teclado esta en uso no selecciona el valor
360 // if($scope.mostrarTeclado) { 365 // if($scope.mostrarTeclado) {
361 // return; 366 // return;
362 // } 367 // }
363 $event.target.select(); 368 $event.target.select();
364 }; 369 };
365 370
366 $scope.salir = function() { 371 $scope.salir = function() {
367 $location.path('/'); 372 $location.path('/');
368 }; 373 };
369 374
370 $scope.parsearATexto = function(articulo) { 375 $scope.parsearATexto = function(articulo) {
371 articulo.cantidad = parseFloat(articulo.cantidad); 376 articulo.cantidad = parseFloat(articulo.cantidad);
372 articulo.precio = parseFloat(articulo.precio); 377 articulo.precio = parseFloat(articulo.precio);
373 }; 378 };
374 379
375 $scope.rellenar = function(relleno, longitud) { 380 $scope.rellenar = function(relleno, longitud) {
376 relleno = '' + relleno; 381 relleno = '' + relleno;
377 while (relleno.length < longitud) { 382 while (relleno.length < longitud) {
378 relleno = '0' + relleno; 383 relleno = '0' + relleno;
379 } 384 }
380 385
381 return relleno; 386 return relleno;
382 }; 387 };
383 388
384 $scope.quitarArticulo = function(key) { 389 $scope.quitarArticulo = function(key) {
385 $scope.remitosTabla.splice(key, 1); 390 $scope.remitosTabla.splice(key, 1);
386 var litros = 0; 391 var litros = 0;
387 392
388 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 393 for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
389 litros += parseFloat($scope.remitosTabla[i].litros); 394 litros += parseFloat($scope.remitosTabla[i].litros);
390 } 395 }
391 396
392 $scope.hojaRuta.litros = litros; 397 $scope.hojaRuta.litros = litros;
393 398
394 }; 399 };
395 400
396 function addCabecera(label, valor) { 401 function addCabecera(label, valor) {
397 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 402 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
398 if(propiedad.length === 1) { 403 if(propiedad.length === 1) {
399 propiedad[0].valor = valor; 404 propiedad[0].valor = valor;
400 } else { 405 } else {
401 $scope.cabecera.push({label: label, valor: valor}); 406 $scope.cabecera.push({label: label, valor: valor});
402 } 407 }
403 } 408 }
404 409
405 /*function removeCabecera(label) { 410 /*function removeCabecera(label) {
406 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 411 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
407 if(propiedad.length === 1){ 412 if(propiedad.length === 1){
408 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 413 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
409 } 414 }
410 }*/ 415 }*/
411 } 416 }
412 ] 417 ]
413 ) 418 )
414 .controller('hojaRutaListaCtrl', [ 419 .controller('hojaRutaListaCtrl', [
415 '$scope', 420 '$scope',
416 'crearHojaRutaService', 421 'crearHojaRutaService',
417 '$location', 422 '$location',
418 function($scope, crearHojaRutaService, $location) { 423 function($scope, crearHojaRutaService, $location) {
419 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 424 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
420 $scope.hojaRutas = datos.data; 425 $scope.hojaRutas = datos.data;
421 }); 426 });
422 $scope.editar = function(hojaRuta) { 427 $scope.editar = function(hojaRuta) {
423 crearHojaRutaService.setHojaRuta(hojaRuta); 428 crearHojaRutaService.setHojaRuta(hojaRuta);
424 $location.path('/venta-nota-pedido/abm/'); 429 $location.path('/venta-nota-pedido/abm/');
425 }; 430 };
426 $scope.crearPedido = function() { 431 $scope.crearPedido = function() {
427 crearHojaRutaService.clearHojaRuta(); 432 crearHojaRutaService.clearHojaRuta();
428 $location.path('/venta-nota-pedido/abm/'); 433 $location.path('/venta-nota-pedido/abm/');
429 }; 434 };
430 } 435 }
431 ]) 436 ])
432 .controller('focaCrearHojaRutaFichaClienteController', [ 437 .controller('focaCrearHojaRutaFichaClienteController', [
433 '$scope', 438 '$scope',
434 'crearHojaRutaService', 439 'crearHojaRutaService',
435 '$location', 440 '$location',
436 function($scope, crearHojaRutaService, $location) { 441 function($scope, crearHojaRutaService, $location) {
437 crearHojaRutaService.obtenerHojaRuta().then(function(datos) { 442 crearHojaRutaService.obtenerHojaRuta().then(function(datos) {
438 $scope.hojaRutas = datos.data; 443 $scope.hojaRutas = datos.data;
439 }); 444 });
440 $scope.editar = function(hojaRuta) { 445 $scope.editar = function(hojaRuta) {
441 crearHojaRutaService.setHojaRuta(hojaRuta); 446 crearHojaRutaService.setHojaRuta(hojaRuta);
442 $location.path('/venta-nota-pedido/abm/'); 447 $location.path('/venta-nota-pedido/abm/');
443 }; 448 };
444 $scope.crearPedido = function() { 449 $scope.crearPedido = function() {
445 crearHojaRutaService.clearHojaRuta(); 450 crearHojaRutaService.clearHojaRuta();
446 $location.path('/venta-nota-pedido/abm/'); 451 $location.path('/venta-nota-pedido/abm/');
447 }; 452 };
448 } 453 }
449 ]); 454 ]);
450 455