Commit d813bbe7a988244da2d507414b3abb52b93e43bd

Authored by Benjamin Rodriguez
1 parent 35d2a78d2a
Exists in develop

agrego descarga de remito sin valores

src/js/controller.js
... ... @@ -35,9 +35,9 @@ angular.module('focaModal')
35 35 $scope.parametros = parametros;
36 36 $scope.fecha = new Date();
37 37 $scope.options = {};
38   -
  38 +
39 39 if (parametros.minDate) $scope.options.minDate = parametros.minDate;
40   -
  40 +
41 41 $scope.cancelar = function() {
42 42 $uibModalInstance.dismiss();
43 43 };
src/js/controllerMail.js
... ... @@ -6,7 +6,7 @@ angular.module('focaModal')
6 6 'Blob',
7 7 'focaModalService',
8 8 'options',
9   - function($scope, $uibModalInstance, FileSaver, Blob,
  9 + function ($scope, $uibModalInstance, FileSaver, Blob,
10 10 focaModalService, options) {
11 11  
12 12 var regexMail = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
... ... @@ -16,29 +16,39 @@ angular.module(&#39;focaModal&#39;)
16 16 $scope.esperando = false;
17 17 $scope.titulo = options.titulo;
18 18 $scope.mailCliente = options.envio.mailCliente;
  19 + $scope.checkboxVar = false;
19 20  
20   - $scope.aceptar = function() {
  21 + $scope.aceptar = function () {
21 22 $uibModalInstance.close();
22 23 };
23   - $scope.salir = function() {
  24 + $scope.salir = function () {
24 25 $uibModalInstance.close($scope.descargado);
25 26 };
26   - $scope.imprimir = function () {
  27 + $scope.validarImpresion = function () {
  28 + var rutaComprobante;
  29 + if ($scope.checkboxVar === true) {
  30 + rutaComprobante = options.descargaSinValorizar;
  31 + } else {
  32 + rutaComprobante = options.descarga;
  33 + }
  34 + imprimir(rutaComprobante);
  35 + }
  36 + imprimir = function (rutaComprobante) {
27 37 $scope.descargado = true;
28 38 $scope.esperando = true;
29 39 focaModalService
30   - .imprimirComprobante(options.descarga.url, options.options)
31   - .then(function(res) {
32   - var data = new Blob([res.data], {type: 'application/pdf'});
  40 + .imprimirComprobante(rutaComprobante.url, options.options)
  41 + .then(function (res) {
  42 + var data = new Blob([res.data], { type: 'application/pdf' });
33 43  
34 44 FileSaver.saveAs(
35 45 data,
36   - options.descarga.nombre
  46 + rutaComprobante.nombre
37 47 );
38 48 $scope.esperando = false;
39 49 });
40 50 };
41   - $scope.enviarCorreo = function(key) {
  51 + $scope.enviarCorreo = function (key) {
42 52 if (key === 13) {
43 53 if (!validarMail()) {
44 54 focaModalService.alert('Ingrese email/s vรกlido/s');
... ... @@ -46,14 +56,14 @@ angular.module(&#39;focaModal&#39;)
46 56 }
47 57 $scope.descargado = true;
48 58 $scope.esperando = true;
49   - Object.assign(options.options, {receiver: $scope.mailCliente});
  59 + Object.assign(options.options, { receiver: $scope.mailCliente });
50 60  
51 61 focaModalService
52 62 .enviarCorreo(options.envio.url, options.options)
53   - .then(function() {
  63 + .then(function () {
54 64 $scope.correoEnviado = true;
55 65 $scope.esperando = false;
56   - }, function() {
  66 + }, function () {
57 67 $scope.esperando = false;
58 68 $scope.correoNoEnviado = true;
59 69 });
... ... @@ -62,7 +72,7 @@ angular.module(&#39;focaModal&#39;)
62 72 function validarMail() {
63 73 var emails = $scope.mailCliente.split(',');
64 74 var result = true;
65   - emails.forEach(function(email) {
  75 + emails.forEach(function (email) {
66 76 if (!regexMail.test(email.trim())) result = false;
67 77 });
68 78 return result;
... ... @@ -116,6 +116,7 @@ angular.module(&#39;focaModal&#39;)
116 116 );
117 117 },
118 118 imprimirComprobante: function(url, options) {
  119 + console.log('imprimirComprobante', url, options);
119 120 return $http.post(
120 121 API_ENDPOINT.URL + url,
121 122 options,
... ... @@ -123,6 +124,7 @@ angular.module(&#39;focaModal&#39;)
123 124 );
124 125 },
125 126 enviarCorreo: function(url, options) {
  127 + console.log('enviarCorreo', url, options);
126 128 return $http.post(API_ENDPOINT.URL + url, options);
127 129 }
128 130 };
src/views/modal-mail.html
... ... @@ -26,12 +26,24 @@
26 26 </div>
27 27 <hr>
28 28 <div>
29   - <label>Descargar comprobante en este dispositivo</label>
30   - <button
31   - class="btn btn-enviar float-right"
32   - ng-click="imprimir()"
33   - ladda="esperando"
34   - >Descargar</button>
  29 + <label>Descargar comprobante</label>
  30 + <div class="col my-1 d-flex justify-content-end">
  31 + <div class="custom-control custom-checkbox my-auto mr-2">
  32 + <input
  33 + type="checkbox"
  34 + class="custom-control-input"
  35 + id="check"
  36 + ng-click="checkboxVar = !checkboxVar">
  37 + <label class="custom-control-label disable-selection" for="check">
  38 + Combrobante sin valorizar
  39 + </label>
  40 + </div>
  41 + <button
  42 + class="btn btn-enviar float-right"
  43 + ng-click="validarImpresion()"
  44 + ladda="esperando"
  45 + >Descargar</button>
  46 + </div>
35 47 </div>
36 48 </div>
37 49 <div class="modal-footer">