Commit b50408f1941aa7091a4356c0fb134c764f5ecc0c
Exists in
master
and in
1 other branch
Merge branch 'master' into 'develop'
Master See merge request !54
Showing
4 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -91,7 +91,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
91 | 91 | }, true); |
92 | 92 | |
93 | 93 | $scope.seleccionarNotaPedido = function() { |
94 | - if(varlidarRemitoFacturado()) { | |
94 | + if (varlidarRemitoFacturado()) { | |
95 | 95 | var modalInstance = $uibModal.open( |
96 | 96 | { |
97 | 97 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
... | ... | @@ -202,7 +202,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
202 | 202 | remitoBusinessService.calcularArticulos($scope.remito.articulosRemito, |
203 | 203 | notaPedido.cotizacion.VENDEDOR); |
204 | 204 | |
205 | - if(notaPedido.idPrecioCondicion > 0) { | |
205 | + if (notaPedido.idPrecioCondicion > 0) { | |
206 | 206 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
207 | 207 | }else { |
208 | 208 | $scope.idLista = -1; |
... | ... | @@ -321,7 +321,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
321 | 321 | $scope.saveLoading = false; |
322 | 322 | |
323 | 323 | //TODO: updatear plazos |
324 | - if($scope.remito.id === 0) { | |
324 | + if ($scope.remito.id === 0) { | |
325 | 325 | var plazos = $scope.remito.remitoPlazo; |
326 | 326 | |
327 | 327 | for(var j = 0; j < plazos.length; j++) { |
... | ... | @@ -332,16 +332,10 @@ angular.module('focaCrearRemito') .controller('remitoController', |
332 | 332 | crearRemitoService.crearPlazosParaRemito(json); |
333 | 333 | } |
334 | 334 | } |
335 | - | |
336 | - $uibModal.open({ | |
337 | - templateUrl: 'remito-comprobante.html', | |
338 | - controller: 'focaRemitoComprobanteController', | |
339 | - resolve: { | |
340 | - parametros: { | |
341 | - idRemito: data.data.id | |
342 | - } | |
343 | - } | |
344 | - }); | |
335 | + abrirModalMail(data.data.id, $scope.remito.cliente, $filter('comprobante')([ | |
336 | + data.data.sucursal, | |
337 | + data.data.numero | |
338 | + ])); | |
345 | 339 | |
346 | 340 | init(); |
347 | 341 | |
... | ... | @@ -355,7 +349,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
355 | 349 | }; |
356 | 350 | |
357 | 351 | $scope.seleccionarProductos = function() { |
358 | - if($scope.idLista === undefined) { | |
352 | + if ($scope.idLista === undefined) { | |
359 | 353 | focaModalService.alert( |
360 | 354 | 'Primero seleccione una lista de precio y condicion'); |
361 | 355 | return; |
... | ... | @@ -409,7 +403,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
409 | 403 | }; |
410 | 404 | |
411 | 405 | $scope.seleccionarPuntosDeDescarga = function() { |
412 | - if(!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | |
406 | + if (!$scope.remito.cliente.COD || !$scope.remito.domicilio.id) { | |
413 | 407 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
414 | 408 | return; |
415 | 409 | }else { |
... | ... | @@ -437,7 +431,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
437 | 431 | var puntosStamp = ''; |
438 | 432 | puntosDescarga.forEach(function(punto, idx, arr) { |
439 | 433 | puntosStamp += punto.descripcion; |
440 | - if((idx + 1) !== arr.length) puntosStamp += ', '; | |
434 | + if ((idx + 1) !== arr.length) puntosStamp += ', '; | |
441 | 435 | }); |
442 | 436 | |
443 | 437 | $scope.$broadcast('addCabecera', { |
... | ... | @@ -457,7 +451,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
457 | 451 | return; |
458 | 452 | } |
459 | 453 | |
460 | - if(varlidarRemitoFacturado()) { | |
454 | + if (varlidarRemitoFacturado()) { | |
461 | 455 | var parametrosModal = { |
462 | 456 | titulo: 'Búsqueda vendedores', |
463 | 457 | query: '/vendedor', |
... | ... | @@ -524,7 +518,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
524 | 518 | }; |
525 | 519 | |
526 | 520 | $scope.seleccionarProveedor = function(callback) { |
527 | - if(varlidarRemitoFacturado()) { | |
521 | + if (varlidarRemitoFacturado()) { | |
528 | 522 | var parametrosModal = { |
529 | 523 | titulo: 'Búsqueda de Proveedor', |
530 | 524 | query: '/proveedor', |
... | ... | @@ -604,14 +598,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
604 | 598 | valor: domicilioStamp |
605 | 599 | }); |
606 | 600 | |
607 | - if(domicilio.verPuntos) { | |
601 | + if (domicilio.verPuntos) { | |
608 | 602 | delete $scope.remito.domicilio.verPuntos; |
609 | 603 | $scope.seleccionarPuntosDeDescarga(); |
610 | 604 | }else { |
611 | 605 | crearRemitoService |
612 | 606 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
613 | 607 | .then(function(res) { |
614 | - if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
608 | + if (res.data.length) $scope.seleccionarPuntosDeDescarga(); | |
615 | 609 | }); |
616 | 610 | } |
617 | 611 | }, function() { |
... | ... | @@ -642,7 +636,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
642 | 636 | }; |
643 | 637 | |
644 | 638 | $scope.getSubTotal = function() { |
645 | - if($scope.articuloACargar) { | |
639 | + if ($scope.articuloACargar) { | |
646 | 640 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
647 | 641 | } |
648 | 642 | }; |
... | ... | @@ -652,7 +646,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
652 | 646 | focaModalService.alert('Primero seleccione un cliente'); |
653 | 647 | return; |
654 | 648 | } |
655 | - if(varlidarRemitoFacturado()) { | |
649 | + if (varlidarRemitoFacturado()) { | |
656 | 650 | var modalInstance = $uibModal.open( |
657 | 651 | { |
658 | 652 | ariaLabelledBy: 'Busqueda de Precio Condición', |
... | ... | @@ -670,7 +664,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
670 | 664 | function(precioCondicion) { |
671 | 665 | var cabecera = ''; |
672 | 666 | var plazosConcat = ''; |
673 | - if(!Array.isArray(precioCondicion)) { | |
667 | + if (!Array.isArray(precioCondicion)) { | |
674 | 668 | $scope.remito.idPrecioCondicion = precioCondicion.id; |
675 | 669 | $scope.remito.remitoPlazo = precioCondicion.plazoPago; |
676 | 670 | $scope.idLista = precioCondicion.idListaPrecio; |
... | ... | @@ -765,7 +759,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
765 | 759 | }; |
766 | 760 | |
767 | 761 | $scope.seleccionarMoneda = function() { |
768 | - if(varlidarRemitoFacturado()) { | |
762 | + if (varlidarRemitoFacturado()) { | |
769 | 763 | var parametrosModal = { |
770 | 764 | titulo: 'Búsqueda de monedas', |
771 | 765 | query: '/moneda', |
... | ... | @@ -826,7 +820,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
826 | 820 | $scope.remito.articulosRemito = articulosTablaTemp; |
827 | 821 | $scope.remito.cotizacion.moneda = moneda; |
828 | 822 | $scope.remito.cotizacion = cotizacion; |
829 | - if(moneda.DETALLE === 'PESOS ARGENTINOS') { | |
823 | + if (moneda.DETALLE === 'PESOS ARGENTINOS') { | |
830 | 824 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
831 | 825 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
832 | 826 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
... | ... | @@ -851,8 +845,8 @@ angular.module('focaCrearRemito') .controller('remitoController', |
851 | 845 | }; |
852 | 846 | |
853 | 847 | $scope.agregarATabla = function(key) { |
854 | - if(key === 13) { | |
855 | - if($scope.articuloACargar.cantidad === undefined || | |
848 | + if (key === 13) { | |
849 | + if ($scope.articuloACargar.cantidad === undefined || | |
856 | 850 | $scope.articuloACargar.cantidad === 0 || |
857 | 851 | $scope.articuloACargar.cantidad === null ) { |
858 | 852 | focaModalService.alert('El valor debe ser al menos 1'); |
... | ... | @@ -882,9 +876,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
882 | 876 | }; |
883 | 877 | |
884 | 878 | $scope.cambioEdit = function(articulo, propiedad) { |
885 | - if(propiedad === 'cantidad') { | |
879 | + if (propiedad === 'cantidad') { | |
886 | 880 | articulo.editCantidad = true; |
887 | - }else if(propiedad === 'precio') { | |
881 | + } else if (propiedad === 'precio') { | |
888 | 882 | articulo.editPrecio = true; |
889 | 883 | } |
890 | 884 | }; |
... | ... | @@ -917,7 +911,7 @@ angular.module('focaCrearRemito') .controller('remitoController', |
917 | 911 | }; |
918 | 912 | //Recibe aviso si el teclado está en uso |
919 | 913 | $rootScope.$on('usarTeclado', function(event, data) { |
920 | - if(data) { | |
914 | + if (data) { | |
921 | 915 | $scope.mostrarTeclado = true; |
922 | 916 | return; |
923 | 917 | } |
... | ... | @@ -926,14 +920,14 @@ angular.module('focaCrearRemito') .controller('remitoController', |
926 | 920 | |
927 | 921 | $scope.selectFocus = function($event) { |
928 | 922 | // Si el teclado esta en uso no selecciona el valor |
929 | - if($scope.mostrarTeclado) { | |
923 | + if ($scope.mostrarTeclado) { | |
930 | 924 | return; |
931 | 925 | } |
932 | 926 | $event.target.select(); |
933 | 927 | }; |
934 | 928 | |
935 | 929 | function addArrayCabecera(array) { |
936 | - for(var i = 0; i < array.length; i++) { | |
930 | + for (var i = 0; i < array.length; i++) { | |
937 | 931 | $scope.$broadcast('addCabecera',{ |
938 | 932 | label: array[i].label, |
939 | 933 | valor: array[i].valor |
... | ... | @@ -951,9 +945,9 @@ angular.module('focaCrearRemito') .controller('remitoController', |
951 | 945 | } |
952 | 946 | |
953 | 947 | function varlidarRemitoFacturado() { |
954 | - if($scope.remito.estado !== 5) { | |
948 | + if ($scope.remito.estado !== 5) { | |
955 | 949 | return true; |
956 | - }else { | |
950 | + } else { | |
957 | 951 | focaModalService.alert('No se puede editar un remito facturado'); |
958 | 952 | return false(); |
959 | 953 | } |
... | ... | @@ -1104,5 +1098,31 @@ angular.module('focaCrearRemito') .controller('remitoController', |
1104 | 1098 | $scope.$broadcast('removeCabecera', 'Domicilio:'); |
1105 | 1099 | $scope.$broadcast('removeCabecera', 'Puntos de descarga:'); |
1106 | 1100 | } |
1101 | + | |
1102 | + function abrirModalMail(id, cliente, numeroRemito) { | |
1103 | + focaModalService.mail( | |
1104 | + { | |
1105 | + titulo: 'Comprobante de remito Nº ' + numeroRemito, | |
1106 | + descarga: { | |
1107 | + nombre: numeroRemito + '.pdf', | |
1108 | + url: '/remito/comprobante', | |
1109 | + }, | |
1110 | + envio: { | |
1111 | + mailCliente: cliente.MAIL, | |
1112 | + url: '/remito/mail', | |
1113 | + }, | |
1114 | + options: { | |
1115 | + idRemito: id | |
1116 | + } | |
1117 | + } | |
1118 | + ) | |
1119 | + .then(function(res) { | |
1120 | + if (res === false) { | |
1121 | + abrirModalMail(id); | |
1122 | + focaModalService.alert('Descarga o envíe su remito ' + | |
1123 | + 'antes de cerrar esta ventana'); | |
1124 | + } | |
1125 | + }); | |
1126 | + } | |
1107 | 1127 | } |
1108 | 1128 | ]); |
src/js/controllerComprobante.js
... | ... | @@ -1,61 +0,0 @@ |
1 | -angular.module('focaCrearRemito') | |
2 | - .controller('focaRemitoComprobanteController', [ | |
3 | - '$scope', | |
4 | - '$uibModalInstance', | |
5 | - 'crearRemitoService', | |
6 | - '$filter', | |
7 | - 'parametros', | |
8 | - 'FileSaver', | |
9 | - 'Blob', | |
10 | - function( | |
11 | - $scope, $uibModalInstance, crearRemitoService, $filter, | |
12 | - parametros, FileSaver, Blob | |
13 | - ) { | |
14 | - crearRemitoService.getRemitoById(parametros.idRemito).then(function(res) { | |
15 | - | |
16 | - $scope.remito = res.data; | |
17 | - }); | |
18 | - $scope.correoEnviado = false; | |
19 | - $scope.correoNoEnviado = false; | |
20 | - $scope.esperando = false; | |
21 | - | |
22 | - $scope.aceptar = function() { | |
23 | - $uibModalInstance.close(); | |
24 | - }; | |
25 | - | |
26 | - $scope.imprimir = function () { | |
27 | - $scope.esperando = true; | |
28 | - crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then( | |
29 | - function(res) { | |
30 | - var data = new Blob([res.data], {type: 'application/pdf'}); | |
31 | - | |
32 | - FileSaver.saveAs( | |
33 | - data, | |
34 | - 'RE-R-' + $filter('comprobante')([ | |
35 | - $scope.remito.sucursal, | |
36 | - $scope.remito.numeroRemito | |
37 | - ]) + '.pdf' | |
38 | - ); | |
39 | - $scope.esperando = false; | |
40 | - } | |
41 | - ); | |
42 | - }; | |
43 | - | |
44 | - $scope.enviarCorreo = function(key) { | |
45 | - if(key !== 13) return; | |
46 | - $scope.esperando = true; | |
47 | - var options = { | |
48 | - para: $scope.remito.cliente.MAIL, | |
49 | - remito: $scope.remito.id | |
50 | - }; | |
51 | - | |
52 | - crearRemitoService.enviarCorreo(options).then(function() { | |
53 | - $scope.correoEnviado = true; | |
54 | - $scope.esperando = false; | |
55 | - }, function() { | |
56 | - $scope.esperando = false; | |
57 | - $scope.correoNoEnviado = true; | |
58 | - }); | |
59 | - }; | |
60 | - } | |
61 | - ]); |
src/js/service.js
... | ... | @@ -60,9 +60,8 @@ angular.module('focaCrearRemito') |
60 | 60 | getNumeroRemito: function() { |
61 | 61 | return $http.get(route + '/remito/numero-siguiente'); |
62 | 62 | }, |
63 | - imprimirRemitoByIdRemito: function(idRemito, original) { | |
64 | - var tipo = original ? '/original' : ''; | |
65 | - return $http.get(route + '/remito/comprobante/' + idRemito + tipo, { | |
63 | + imprimirRemitoByIdRemito: function(idRemito) { | |
64 | + return $http.get(route + '/remito/comprobante/' + idRemito , { | |
66 | 65 | responseType: 'arraybuffer' |
67 | 66 | }); |
68 | 67 | }, |
src/views/remito-comprobante.html
... | ... | @@ -1,42 +0,0 @@ |
1 | -<div class="modal-header"> | |
2 | - <h5>Comprobante de remito Nº | |
3 | - <span | |
4 | - ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"> | |
5 | - </span> | |
6 | - </h5> | |
7 | -</div> | |
8 | -<div class="modal-body"> | |
9 | - <div class="col-12"> | |
10 | - <label | |
11 | - class="col-12 bg-success text-white" | |
12 | - ng-show="correoEnviado">Correo enviado con éxito</label> | |
13 | - <label | |
14 | - class="col-12 bg-danger text-white" | |
15 | - ng-show="correoNoEnviado">Hubo un error al enviar el correo</label> | |
16 | - <label>Enviar correo a </label> | |
17 | - <input | |
18 | - class="form-control" | |
19 | - ng-model="remito.cliente.MAIL" | |
20 | - ng-click="enviarCorreo($event.keyCode)"/> | |
21 | - </div> | |
22 | -</div> | |
23 | -<div class="modal-footer"> | |
24 | - <button | |
25 | - type="button" | |
26 | - class="btn btn-info" | |
27 | - ng-click="imprimir()" | |
28 | - ladda="esperando" | |
29 | - >Imprimir</button> | |
30 | - <button | |
31 | - type="button" | |
32 | - class="btn btn-primary" | |
33 | - ng-click="aceptar()" | |
34 | - ladda="esperando" | |
35 | - >Aceptar</button> | |
36 | - <button | |
37 | - type="button" | |
38 | - class="btn btn-primary" | |
39 | - ng-click="enviarCorreo(13)" | |
40 | - ladda="esperando" | |
41 | - >Enviar</button> | |
42 | -</div> |