Commit 38f891643075cce3581119de47be3c4138e5ab78

Authored by Jose Pinto
1 parent 13f6590098
Exists in master

ok espacios

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