Commit f79d0b0f524337fd42fd26346647abd0b0de2c22

Authored by Marcelo Puebla
Exists in develop

Merge branch 'master' into 'develop'

Master

See merge request !37
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,}))$/;
... ... @@ -15,30 +15,40 @@ angular.module(&#39;focaModal&#39;)
15 15 $scope.correoNoEnviado = false;
16 16 $scope.esperando = false;
17 17 $scope.titulo = options.titulo;
18   - $scope.mailCliente = options.envio.mailCliente;
  18 + $scope.checkboxVar = false;
19 19  
20   - $scope.aceptar = function() {
  20 + $scope.aceptar = function () {
21 21 $uibModalInstance.close();
22 22 };
23   - $scope.salir = function() {
  23 + $scope.salir = function () {
24 24 $uibModalInstance.close($scope.descargado);
25 25 };
26   - $scope.imprimir = function () {
  26 + $scope.validarImpresion = function () {
  27 + var rutaComprobante;
  28 + rutaComprobante = $scope.checkboxVar === true ? options.descargaSinValorizar : options.descarga;
  29 + imprimir(rutaComprobante);
  30 + }
  31 + imprimir = function (rutaComprobante) {
27 32 $scope.descargado = true;
28 33 $scope.esperando = true;
29 34 focaModalService
30   - .imprimirComprobante(options.descarga.url, options.options)
31   - .then(function(res) {
32   - var data = new Blob([res.data], {type: 'application/pdf'});
  35 + .imprimirComprobante(rutaComprobante.url, options.options)
  36 + .then(function (res) {
  37 + var data = new Blob([res.data], { type: 'application/pdf' });
33 38  
34 39 FileSaver.saveAs(
35 40 data,
36   - options.descarga.nombre
  41 + rutaComprobante.nombre
37 42 );
38 43 $scope.esperando = false;
39 44 });
40 45 };
41   - $scope.enviarCorreo = function(key) {
  46 + $scope.enviarComprobante = function () {
  47 + var rutaEnvioComprobante;
  48 + rutaEnvioComprobante = $scope.checkboxVar === true ? options.envioSinValorizar : options.envio;
  49 + enviarCorreo(rutaEnvioComprobante, 13);
  50 + }
  51 + enviarCorreo = function (rutaEnvioComprobante, key) {
42 52 if (key === 13) {
43 53 if (!validarMail()) {
44 54 focaModalService.alert('Ingrese email/s vรกlido/s');
... ... @@ -46,14 +56,15 @@ 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 + $scope.mailCliente = rutaEnvioComprobante.mailCliente;
  60 + Object.assign(options.options, { receiver: $scope.mailCliente });
50 61  
51 62 focaModalService
52   - .enviarCorreo(options.envio.url, options.options)
53   - .then(function() {
  63 + .enviarCorreo(rutaEnvioComprobante.url, options.options)
  64 + .then(function () {
54 65 $scope.correoEnviado = true;
55 66 $scope.esperando = false;
56   - }, function() {
  67 + }, function () {
57 68 $scope.esperando = false;
58 69 $scope.correoNoEnviado = true;
59 70 });
... ... @@ -62,7 +73,7 @@ angular.module(&#39;focaModal&#39;)
62 73 function validarMail() {
63 74 var emails = $scope.mailCliente.split(',');
64 75 var result = true;
65   - emails.forEach(function(email) {
  76 + emails.forEach(function (email) {
66 77 if (!regexMail.test(email.trim())) result = false;
67 78 });
68 79 return result;
src/views/modal-mail.html
... ... @@ -14,27 +14,39 @@
14 14 <input
15 15 class="form-control col-9"
16 16 ng-model="mailCliente"
17   - ng-keypress="enviarCorreo($event.keyCode)"
  17 + ng-keypress="enviarComprobante($event.keyCode)"
18 18 teclado-virtual/>
19 19 <button
20 20 type="button"
21 21 class="btn btn-enviar ml-auto"
22   - ng-click="enviarCorreo(13)"
  22 + ng-click="enviarComprobante(13)"
23 23 ladda="esperando"
24 24 >Enviar</button>
25 25 </div>
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 + <button
  32 + class="btn btn-enviar float-right"
  33 + ng-click="validarImpresion()"
  34 + ladda="esperando"
  35 + >Descargar</button>
  36 + </div>
35 37 </div>
36 38 </div>
37 39 <div class="modal-footer">
  40 + <div class="custom-control custom-checkbox my-auto mr-5">
  41 + <input
  42 + type="checkbox"
  43 + class="custom-control-input mr-5"
  44 + id="check"
  45 + ng-click="checkboxVar = !checkboxVar">
  46 + <label class="custom-control-label disable-selection" for="check">
  47 + Combrobante sin valorizar
  48 + </label>
  49 + </div>
38 50 <button
39 51 type="button"
40 52 class="btn btn-secondary"