Commit 8da07a79e7ac93a92da1748671346f9c74b9edb1

Authored by Jose Pinto
1 parent 399786fc57
Exists in master

Boton puntos de descarga

src/js/controller.js
... ... @@ -310,6 +310,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
310 310 $scope.notaPedido = notaPedido;
311 311 $scope.notaPedido.moneda = notaPedido.cotizacion.moneda;
312 312 $scope.plazosPagos = notaPedido.notaPedidoPlazo;
  313 + $scope.notaPedido.puntosDescarga =
  314 + formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga);
313 315 addArrayCabecera(cabeceras);
314 316  
315 317 }, function() {
... ... @@ -372,6 +374,39 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
372 374 );
373 375 };
374 376  
  377 + $scope.seleccionarPuntosDeDescarga = function() {
  378 + if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) {
  379 + focaModalService.alert('Primero seleccione un cliente y un domicilio');
  380 + return;
  381 + }else{
  382 + var modalInstance = $uibModal.open(
  383 + {
  384 + ariaLabelledBy: 'Búsqueda de Puntos de descarga',
  385 + templateUrl: 'modal-punto-descarga.html',
  386 + controller: 'focaModalPuntoDescargaController',
  387 + size: 'lg',
  388 + resolve: {
  389 + filters: {
  390 + /*TODO: al traer nota de pedido ya creada
  391 + obtener idDomicilio correctamente*/
  392 + idDomicilio: $scope.notaPedido.domicilio.id,
  393 + idCliente: $scope.notaPedido.cliente.COD,
  394 + articulos: $scope.articulosTabla,
  395 + puntosDescarga: $scope.notaPedido.puntosDescarga
  396 + }
  397 + }
  398 + }
  399 + );
  400 + modalInstance.result.then(
  401 + function(puntosDescarga) {
  402 + $scope.notaPedido.puntosDescarga = puntosDescarga;
  403 + }, function() {
  404 +
  405 + }
  406 + );
  407 + }
  408 + };
  409 +
375 410 $scope.seleccionarVendedor = function() {
376 411 if(validarNotaRemitada()) {
377 412 var modalInstance = $uibModal.open(
... ... @@ -452,7 +487,9 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
452 487 templateUrl: 'modal-domicilio.html',
453 488 controller: 'focaModalDomicilioController',
454 489 resolve: {
455   - idCliente: function() { return cliente.cod; },
  490 + idCliente: function() {
  491 + return cliente.cod;
  492 + },
456 493 esNuevo: function() { return cliente.esNuevo; },
457 494 articulos: function() {
458 495 return $scope.articulosTabla;
... ... @@ -767,5 +804,41 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl',
767 804 return false;
768 805 }
769 806 }
  807 +
  808 + function formatearPuntosDescarga(notaPedidoPuntoDescarga) {
  809 + var result = [];
  810 +
  811 + notaPedidoPuntoDescarga.forEach(function(el) {
  812 + var puntoDescarga = result.filter(function(resultPunto) {
  813 + return resultPunto.id == el.idPuntoDescarga;
  814 + });
  815 +
  816 + if(puntoDescarga.length) {
  817 + puntoDescarga[0].articulosAgregados.push({
  818 + cantidad: el.cantidad,
  819 + descripcion: el.producto.descripcion,
  820 + id: el.producto.id
  821 + });
  822 + }else {
  823 + result.push({
  824 + id: el.puntoDescarga.id,
  825 + id_cliente: el.puntoDescarga.id_cliente,
  826 + id_da_config_0: el.puntoDescarga.id_da_config_0,
  827 + latitud: el.puntoDescarga.latitud,
  828 + longitud: el.puntoDescarga.longitud,
  829 + descripcion: el.puntoDescarga.descripcion,
  830 + articulosAgregados: [
  831 + {
  832 + cantidad: el.cantidad,
  833 + descripcion: el.producto.descripcion,
  834 + id: el.producto.id
  835 + }
  836 + ]
  837 + });
  838 + }
  839 +
  840 + });
  841 + return result;
  842 + }
770 843 }
771 844 ]);
... ... @@ -56,8 +56,40 @@ angular.module('focaCrearNotaPedido')
56 56 return $http.get(route + '/nota-pedido/numero-siguiente');
57 57 },
58 58 getBotonera: function() {
59   - return ['Vendedor', 'Cliente', 'Proveedor', 'Moneda',
60   - 'Precios y condiciones', 'Flete', 'Productos'];
  59 + return [
  60 + {
  61 + label: 'Vendedor',
  62 + image: 'vendedor.png'
  63 + },
  64 + {
  65 + label: 'Cliente',
  66 + image: 'cliente.png'
  67 + },
  68 + {
  69 + label: 'Proveedor',
  70 + image: 'proveedor.png'
  71 + },
  72 + {
  73 + label: 'Moneda',
  74 + image: 'moneda.png'
  75 + },
  76 + {
  77 + label: 'Precios y condiciones',
  78 + image: 'precios-condiciones.png'
  79 + },
  80 + {
  81 + label: 'Flete',
  82 + image: 'flete.png'
  83 + },
  84 + {
  85 + label: 'Productos',
  86 + image: 'productos.png'
  87 + },
  88 + {
  89 + label: 'Puntos de descarga',
  90 + image: 'seguimientoCobranza.png'
  91 + }
  92 + ];
61 93 },
62 94 crearPuntosDescarga: function(puntosDescarga) {
63 95 return $http.post(route + '/puntos-descarga/nota-pedido',
src/views/nota-pedido.html
... ... @@ -11,7 +11,7 @@
11 11 <div class="col-12 col-md-10 col-lg-10 border border-light rounded">
12 12 <div class="row px-5 py-2 botonera-secundaria">
13 13 <div class="col-12">
14   - <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador>
  14 + <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador>
15 15 </div>
16 16 </div>
17 17 <!-- PC -->