Commit e4acefe54f3ec359ffd2bbce434389e8142a505b
1 parent
79a4a484d0
Exists in
master
Codigo identado
Showing
1 changed file
with
107 additions
and
104 deletions
Show diff stats
src/js/controller.js
| ... | ... | @@ -48,13 +48,13 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 48 | 48 | |
| 49 | 49 | var parametros = JSON.parse(res.data[0].jsonText); |
| 50 | 50 | |
| 51 | - $timeout(function () { | |
| 51 | + $timeout(function () { | |
| 52 | 52 | getLSBotoneraPrincipal(); |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | if ($localStorage.data) { |
| 56 | - $timeout(function () { | |
| 57 | - getLSHojaRuta(); | |
| 56 | + $timeout(function () { | |
| 57 | + getLSHojaRuta(); | |
| 58 | 58 | }); |
| 59 | 59 | |
| 60 | 60 | } else { |
| ... | ... | @@ -99,14 +99,15 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 99 | 99 | $scope.inicial = angular.copy($scope.hojaRuta); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $scope.$watchGroup(['hojaRuta','precargado','cargaRemito','remitoAbierto'], function(newValues) { | |
| 103 | - focaBotoneraLateralService.setPausarData( | |
| 104 | - { | |
| 105 | - label: 'data', | |
| 106 | - val: newValues | |
| 107 | - } | |
| 108 | - ); | |
| 109 | - }); | |
| 102 | + $scope.$watchGroup(['hojaRuta', 'precargado', 'cargaRemito', 'remitoAbierto'], | |
| 103 | + function (newValues) { | |
| 104 | + focaBotoneraLateralService.setPausarData( | |
| 105 | + { | |
| 106 | + label: 'data', | |
| 107 | + val: newValues | |
| 108 | + } | |
| 109 | + ); | |
| 110 | + }); | |
| 110 | 111 | |
| 111 | 112 | $scope.seleccionarRemitoAbierto = function () { |
| 112 | 113 | $scope.remitoAbierto = true; |
| ... | ... | @@ -271,7 +272,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 271 | 272 | |
| 272 | 273 | function getImporte(propiedad) { |
| 273 | 274 | var importe = 0; |
| 274 | - | |
| 275 | + | |
| 275 | 276 | $scope.articulos.forEach(function (articulo) { |
| 276 | 277 | |
| 277 | 278 | if (articulo[propiedad]) { |
| ... | ... | @@ -347,17 +348,17 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 347 | 348 | idVehiculo: $scope.hojaRuta.vehiculo.id |
| 348 | 349 | }, data.data.id); |
| 349 | 350 | $scope.remito.numeroRemito = data.data.numero; |
| 350 | - | |
| 351 | + | |
| 351 | 352 | // if ($scope.remito.remitoPuntoDescarga.length > 0) { |
| 352 | 353 | // remitoBusinessService.addPuntosDescarga(data.data.id, |
| 353 | 354 | // $scope.remito.remitoPuntoDescarga); |
| 354 | 355 | // } |
| 355 | - | |
| 356 | + | |
| 356 | 357 | hojaRutaBusinessService.addArticulos($scope.articulosRecibidos, |
| 357 | 358 | data.data.id, $scope.hojaRuta.cotizacion.VENDEDOR); |
| 358 | 359 | |
| 359 | 360 | guardarHojaRuta(data.data.id); |
| 360 | - | |
| 361 | + | |
| 361 | 362 | }, function (error) { |
| 362 | 363 | focaModalService.alert( |
| 363 | 364 | error.data || 'Hubo un error al crear el remito'); |
| ... | ... | @@ -368,7 +369,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 368 | 369 | ); |
| 369 | 370 | |
| 370 | 371 | function guardarHojaRuta(idRemito) { |
| 371 | - | |
| 372 | + | |
| 372 | 373 | var save2 = { |
| 373 | 374 | hojaRuta: { |
| 374 | 375 | id: 0, |
| ... | ... | @@ -384,7 +385,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 384 | 385 | estado: 0, |
| 385 | 386 | abierta: 1 |
| 386 | 387 | }, |
| 387 | - remitos: [{id: idRemito}] | |
| 388 | + remitos: [{ id: idRemito }] | |
| 388 | 389 | }; |
| 389 | 390 | |
| 390 | 391 | save2.hojaRuta = angular |
| ... | ... | @@ -392,7 +393,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 392 | 393 | focaCrearHojaRutaService.crearHojaRuta(save2).then( |
| 393 | 394 | function (data) { |
| 394 | 395 | var remitoNumero; |
| 395 | - data.data.remitos.forEach(function(idRemitos) { | |
| 396 | + data.data.remitos.forEach(function (idRemitos) { | |
| 396 | 397 | remitoNumero = idRemitos; |
| 397 | 398 | }); |
| 398 | 399 | focaModalService.alert( |
| ... | ... | @@ -401,20 +402,20 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 401 | 402 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) + |
| 402 | 403 | '\nRemito Abierto Nยบ: ' + |
| 403 | 404 | $filter('rellenarDigitos')(remitoNumero.sucursal, 4) + '-' + |
| 404 | - $filter('rellenarDigitos')(remitoNumero.numeroRemito,8) | |
| 405 | - ); | |
| 406 | - | |
| 407 | - config(); | |
| 408 | - }, | |
| 409 | - function (error) { | |
| 410 | - | |
| 411 | - focaModalService | |
| 405 | + $filter('rellenarDigitos')(remitoNumero.numeroRemito, 8) | |
| 406 | + ); | |
| 407 | + | |
| 408 | + config(); | |
| 409 | + }, | |
| 410 | + function (error) { | |
| 411 | + | |
| 412 | + focaModalService | |
| 412 | 413 | .alert('Hubo un error al crear la hoja de ruta'); |
| 413 | 414 | |
| 414 | - console.info(error); | |
| 415 | - } | |
| 416 | - ); | |
| 417 | - } | |
| 415 | + console.info(error); | |
| 416 | + } | |
| 417 | + ); | |
| 418 | + } | |
| 418 | 419 | } |
| 419 | 420 | } |
| 420 | 421 | |
| ... | ... | @@ -472,7 +473,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 472 | 473 | $scope.$broadcast('addCabecera', { |
| 473 | 474 | label: 'Vendedor:', |
| 474 | 475 | valor: $filter('rellenarDigitos')($scope.hojaRuta.vendedor |
| 475 | - .NUM, 3) +' - ' + $scope.hojaRuta.vendedor.NOM | |
| 476 | + .NUM, 3) + ' - ' + $scope.hojaRuta.vendedor.NOM | |
| 476 | 477 | }); |
| 477 | 478 | } |
| 478 | 479 | var domicilioStamp = |
| ... | ... | @@ -537,9 +538,9 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 537 | 538 | } |
| 538 | 539 | ); |
| 539 | 540 | modalInstance.result.then( |
| 540 | - function(puntosDescarga) { | |
| 541 | + function (puntosDescarga) { | |
| 541 | 542 | |
| 542 | - puntosDescarga.forEach(function(punto) { | |
| 543 | + puntosDescarga.forEach(function (punto) { | |
| 543 | 544 | $scope.hojaRuta.remitoPuntoDescarga.push( |
| 544 | 545 | { |
| 545 | 546 | puntoDescarga: punto |
| ... | ... | @@ -623,43 +624,43 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 623 | 624 | }; |
| 624 | 625 | |
| 625 | 626 | $scope.seleccionarProveedor = function () { |
| 626 | - var parametrosModal = { | |
| 627 | - titulo: 'Bรบsqueda de Proveedor', | |
| 628 | - query: '/proveedor', | |
| 629 | - columnas: [ | |
| 630 | - { | |
| 631 | - nombre: 'Cรณdigo', | |
| 632 | - propiedad: 'COD', | |
| 633 | - filtro: { | |
| 634 | - nombre: 'rellenarDigitos', | |
| 635 | - parametro: 5 | |
| 636 | - } | |
| 637 | - }, | |
| 638 | - { | |
| 639 | - nombre: 'Nombre', | |
| 640 | - propiedad: 'NOM' | |
| 641 | - }, | |
| 642 | - { | |
| 643 | - nombre: 'CUIT', | |
| 644 | - propiedad: 'CUIT' | |
| 627 | + var parametrosModal = { | |
| 628 | + titulo: 'Bรบsqueda de Proveedor', | |
| 629 | + query: '/proveedor', | |
| 630 | + columnas: [ | |
| 631 | + { | |
| 632 | + nombre: 'Cรณdigo', | |
| 633 | + propiedad: 'COD', | |
| 634 | + filtro: { | |
| 635 | + nombre: 'rellenarDigitos', | |
| 636 | + parametro: 5 | |
| 645 | 637 | } |
| 646 | - ], | |
| 647 | - tipo: 'POST', | |
| 648 | - json: { razonCuitCod: '' } | |
| 649 | - }; | |
| 650 | - focaModalService.modal(parametrosModal).then( | |
| 651 | - function (proveedor) { | |
| 652 | - $filter('filter')($scope.botonera, { | |
| 653 | - label: 'Proveedor', | |
| 654 | - })[0].checked = true; | |
| 638 | + }, | |
| 639 | + { | |
| 640 | + nombre: 'Nombre', | |
| 641 | + propiedad: 'NOM' | |
| 642 | + }, | |
| 643 | + { | |
| 644 | + nombre: 'CUIT', | |
| 645 | + propiedad: 'CUIT' | |
| 646 | + } | |
| 647 | + ], | |
| 648 | + tipo: 'POST', | |
| 649 | + json: { razonCuitCod: '' } | |
| 650 | + }; | |
| 651 | + focaModalService.modal(parametrosModal).then( | |
| 652 | + function (proveedor) { | |
| 653 | + $filter('filter')($scope.botonera, { | |
| 654 | + label: 'Proveedor', | |
| 655 | + })[0].checked = true; | |
| 655 | 656 | |
| 656 | - $scope.$broadcast('addCabecera', { | |
| 657 | - label: 'Proveedor:', | |
| 658 | - valor: proveedor.COD + ' - ' + proveedor.NOM | |
| 659 | - }); | |
| 660 | - $scope.hojaRuta.proveedor = proveedor; | |
| 661 | - }, function () { } | |
| 662 | - ); | |
| 657 | + $scope.$broadcast('addCabecera', { | |
| 658 | + label: 'Proveedor:', | |
| 659 | + valor: proveedor.COD + ' - ' + proveedor.NOM | |
| 660 | + }); | |
| 661 | + $scope.hojaRuta.proveedor = proveedor; | |
| 662 | + }, function () { } | |
| 663 | + ); | |
| 663 | 664 | }; |
| 664 | 665 | |
| 665 | 666 | $scope.seleccionarTransportista = function () { |
| ... | ... | @@ -791,8 +792,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 791 | 792 | resolve: { usadoPor: function () { return 'hojaRuta'; } } |
| 792 | 793 | } |
| 793 | 794 | ); |
| 794 | - modalInstance.result.then( | |
| 795 | - function (remito) { | |
| 795 | + modalInstance.result | |
| 796 | + .then(function (remito) { | |
| 796 | 797 | // TODO: borrar cuando no se use definitivamente |
| 797 | 798 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
| 798 | 799 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
| ... | ... | @@ -825,19 +826,20 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 825 | 826 | |
| 826 | 827 | // remito.litros = litros; |
| 827 | 828 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
| 828 | - $scope.cargarCisterna(remito.id).then(function () { | |
| 829 | - $scope.hojaRuta.remitosTabla.push(remito); | |
| 830 | - $filter('filter')($scope.botonera, { | |
| 831 | - label: 'Remitos', | |
| 832 | - })[0].checked = true; | |
| 829 | + $scope.cargarCisterna(remito.id) | |
| 830 | + .then(function () { | |
| 831 | + $scope.hojaRuta.remitosTabla.push(remito); | |
| 832 | + $filter('filter')($scope.botonera, { | |
| 833 | + label: 'Remitos', | |
| 834 | + })[0].checked = true; | |
| 833 | 835 | |
| 834 | - }, function (error) { | |
| 835 | - $scope.seleccionarRemitos(); | |
| 836 | - }); | |
| 837 | - }, function () { | |
| 838 | - // funcion ejecutada cuando se cancela el modal | |
| 839 | - } | |
| 840 | - ); | |
| 836 | + }) | |
| 837 | + .catch(function (error) { | |
| 838 | + console.error(error); | |
| 839 | + $scope.seleccionarRemitos(); | |
| 840 | + }); | |
| 841 | + }) | |
| 842 | + .catch(function (e) { console.error(e); }); | |
| 841 | 843 | }; |
| 842 | 844 | |
| 843 | 845 | $scope.seleccionarVehiculosPrecargados = function () { |
| ... | ... | @@ -856,8 +858,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 856 | 858 | resolve: { |
| 857 | 859 | idVehiculo: function () { return $scope.hojaRuta.vehiculo.id; }, |
| 858 | 860 | idRemito: function () { return idRemito; }, |
| 859 | - fechaReparto: function () { return $scope.hojaRuta.fechaReparto;}, | |
| 860 | - orden: function() { return $scope.hojaRuta.orden } | |
| 861 | + fechaReparto: function () { return $scope.hojaRuta.fechaReparto; }, | |
| 862 | + orden: function () { return $scope.hojaRuta.orden; } | |
| 861 | 863 | } |
| 862 | 864 | } |
| 863 | 865 | ); |
| ... | ... | @@ -968,8 +970,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 968 | 970 | }; |
| 969 | 971 | |
| 970 | 972 | $scope.mostrarDetalle = function (hojasRutas) { |
| 971 | - | |
| 972 | - var modalInstance =$uibModal.open( | |
| 973 | + var modalInstance = $uibModal.open( | |
| 973 | 974 | { |
| 974 | 975 | ariaLabelledBy: '', |
| 975 | 976 | templateUrl: 'modal-detalle-carga.html', |
| ... | ... | @@ -979,26 +980,26 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 979 | 980 | return { |
| 980 | 981 | hojasRutas: hojasRutas, |
| 981 | 982 | orden: $scope.hojaRuta.orden |
| 982 | - } | |
| 983 | + }; | |
| 983 | 984 | } |
| 984 | 985 | }, |
| 985 | 986 | size: 'lg', |
| 986 | 987 | backdrop: false |
| 987 | 988 | } |
| 988 | 989 | ); |
| 989 | - return modalInstance.result.then(function (res) { | |
| 990 | - res.cisternas.forEach( function (cisterna) { | |
| 991 | - $scope.cisternaCargas.push(cisterna.cisternaCarga); | |
| 992 | - }); | |
| 993 | - $scope.cisternaMovimientos = res.movimientos; | |
| 994 | - $scope.articulosRecibidos = res.articulos; | |
| 995 | - $scope.articulos = res.articulos; | |
| 996 | - $filter('filter')($scope.botonera, { | |
| 997 | - label: 'Detalle de Carga', | |
| 998 | - })[0].checked = true; | |
| 999 | - }, function () { | |
| 1000 | - //se ejecuta cuando se cancela el modal | |
| 1001 | - }); | |
| 990 | + return modalInstance.result | |
| 991 | + .then(function (res) { | |
| 992 | + res.cisternas.forEach(function (cisterna) { | |
| 993 | + $scope.cisternaCargas.push(cisterna.cisternaCarga); | |
| 994 | + }); | |
| 995 | + $scope.cisternaMovimientos = res.movimientos; | |
| 996 | + $scope.articulosRecibidos = res.articulos; | |
| 997 | + $scope.articulos = res.articulos; | |
| 998 | + $filter('filter')($scope.botonera, { | |
| 999 | + label: 'Detalle de Carga', | |
| 1000 | + })[0].checked = true; | |
| 1001 | + }) | |
| 1002 | + .catch(function (e) { console.error(e); }); | |
| 1002 | 1003 | }; |
| 1003 | 1004 | |
| 1004 | 1005 | function elegirFecha() { |
| ... | ... | @@ -1112,7 +1113,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1112 | 1113 | |
| 1113 | 1114 | focaCrearHojaRutaService |
| 1114 | 1115 | .getNumeroOrden(vehiculo.id, $scope.hojaRuta.fechaReparto) |
| 1115 | - .then(function(res) { | |
| 1116 | + .then(function (res) { | |
| 1116 | 1117 | $scope.hojaRuta.orden = res.data; |
| 1117 | 1118 | }); |
| 1118 | 1119 | |
| ... | ... | @@ -1247,7 +1248,7 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1247 | 1248 | function getLSHojaRuta() { |
| 1248 | 1249 | if ($localStorage.data === undefined) return; |
| 1249 | 1250 | |
| 1250 | - var hojaRuta = (JSON.parse($localStorage.data))[0] || null; | |
| 1251 | + var hojaRuta = (JSON.parse($localStorage.data))[0] || null; | |
| 1251 | 1252 | if (hojaRuta) { |
| 1252 | 1253 | setearHojaRuta(hojaRuta); |
| 1253 | 1254 | delete $localStorage.data; |
| ... | ... | @@ -1273,7 +1274,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1273 | 1274 | label: 'Precargados' |
| 1274 | 1275 | })[0].checked = $scope.precargado; |
| 1275 | 1276 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 1276 | - Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraPrecargado()); | |
| 1277 | + Array.prototype.push.apply($scope.botonera, | |
| 1278 | + focaCrearHojaRutaService.getBotoneraPrecargado()); | |
| 1277 | 1279 | } |
| 1278 | 1280 | if (cargaRemito) { |
| 1279 | 1281 | $scope.cargaRemito = cargaRemito; |
| ... | ... | @@ -1281,7 +1283,8 @@ angular.module('focaCrearHojaRuta').controller('hojaRutaCtrl', |
| 1281 | 1283 | label: 'Cargar Remitos' |
| 1282 | 1284 | })[0].checked = $scope.cargaRemito; |
| 1283 | 1285 | $scope.botonera = focaCrearHojaRutaService.getBotonFecha(); |
| 1284 | - Array.prototype.push.apply($scope.botonera,focaCrearHojaRutaService.getBotoneraCargarRemito()); | |
| 1286 | + Array.prototype.push.apply($scope.botonera, | |
| 1287 | + focaCrearHojaRutaService.getBotoneraCargarRemito()); | |
| 1285 | 1288 | } |
| 1286 | 1289 | } |
| 1287 | 1290 |