Commit 1e642e9f73c067c864c9b906aed1ba5818d14cbb

Authored by Jose Pinto
1 parent be760b98e6
Exists in master and in 1 other branch develop

fix modal puntos descarga

Showing 2 changed files with 59 additions and 0 deletions   Show diff stats
src/js/controller.js
... ... @@ -468,6 +468,49 @@ angular.module('focaCrearRemito') .controller('remitoController',
468 468 );
469 469 };
470 470  
  471 + $scope.seleccionarPuntosDeDescarga = function() {
  472 + if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) {
  473 + focaModalService.alert('Primero seleccione un cliente y un domicilio');
  474 + return;
  475 + }else {
  476 + var modalInstance = $uibModal.open(
  477 + {
  478 + ariaLabelledBy: 'Búsqueda de Puntos de descarga',
  479 + templateUrl: 'modal-punto-descarga.html',
  480 + controller: 'focaModalPuntoDescargaController',
  481 + size: 'lg',
  482 + resolve: {
  483 + filters: {
  484 + idDomicilio: $scope.remito.domicilio.id,
  485 + idCliente: $scope.remito.cliente.COD,
  486 + articulos: $scope.articulosTabla,
  487 + puntosDescarga: $scope.remito.domicilio.puntosDescarga
  488 + }
  489 + }
  490 + }
  491 + );
  492 + modalInstance.result.then(
  493 + function(puntosDescarga) {
  494 + $scope.remito.puntosDescarga = puntosDescarga;
  495 +
  496 + //AGREGO PUNTOS DE DESCARGA A CABECERA
  497 + var puntosStamp = '';
  498 + puntosDescarga.forEach(function(punto, idx, arr) {
  499 + puntosStamp += punto.descripcion;
  500 + if((idx + 1) !== arr.length) puntosStamp += ', ';
  501 + });
  502 +
  503 + $scope.$broadcast('addCabecera', {
  504 + label: 'Puntos de descarga:',
  505 + valor: puntosStamp
  506 + });
  507 + }, function() {
  508 + $scope.abrirModalDomicilios($scope.cliente);
  509 + }
  510 + );
  511 + }
  512 + };
  513 +
471 514 $scope.seleccionarVendedor = function() {
472 515 if(varlidarRemitoFacturado()) {
473 516 var parametrosModal = {
... ... @@ -567,6 +610,7 @@ angular.module('focaCrearRemito') .controller('remitoController',
567 610 modalInstance.result.then(
568 611 function(cliente) {
569 612 $scope.abrirModalDomicilios(cliente);
  613 + $scope.cliente = cliente;
570 614 }, function() {
571 615  
572 616 }
... ... @@ -610,6 +654,17 @@ angular.module('focaCrearRemito') .controller('remitoController',
610 654 label: 'Domicilio:',
611 655 valor: domicilioStamp
612 656 });
  657 +
  658 + if(domicilio.verPuntos) {
  659 + delete $scope.remito.domicilio.verPuntos;
  660 + $scope.seleccionarPuntosDeDescarga();
  661 + }else {
  662 + crearRemitoService
  663 + .getPuntosDescargaByClienDom(domicilio.id, cliente.cod)
  664 + .then(function(res) {
  665 + if(res.data.length) $scope.seleccionarPuntosDeDescarga();
  666 + });
  667 + }
613 668 }, function() {
614 669 $scope.seleccionarCliente();
615 670 return;
... ... @@ -56,6 +56,10 @@ angular.module('focaCrearRemito')
56 56 getNumeroRemito: function() {
57 57 return $http.get(route + '/remito/numero-siguiente');
58 58 },
  59 + getPuntosDescargaByClienDom: function(idDomicilio, idCliente) {
  60 + return $http.get(API_ENDPOINT.URL + '/punto-descarga/' +
  61 + idDomicilio + '/' + idCliente);
  62 + },
59 63 getBotonera: function() {
60 64 return [
61 65 {