Commit ab82c56b5662addade3fd9c073b59501a6194e57

Authored by Marcelo Puebla
Exists in develop

Merge branch 'master' into 'develop'

Master(benjamin)

See merge request !42
src/js/controllerMail.js
1 angular.module('focaModal') 1 angular.module('focaModal')
2 .controller('focaModalMailController', [ 2 .controller('focaModalMailController', [
3 '$scope', 3 '$scope',
4 '$uibModalInstance', 4 '$uibModalInstance',
5 'FileSaver', 5 'FileSaver',
6 'Blob', 6 'Blob',
7 'focaModalService', 7 'focaModalService',
8 'options', 8 'options',
9 function ($scope, $uibModalInstance, FileSaver, Blob, 9 function ($scope, $uibModalInstance, FileSaver, Blob,
10 focaModalService, options) { 10 focaModalService, options) {
11 11
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,}))$/; 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,}))$/;
13 $scope.descargado = false; 13 $scope.descargado = false;
14 $scope.correoEnviado = false; 14 $scope.correoEnviado = false;
15 $scope.correoNoEnviado = false; 15 $scope.correoNoEnviado = false;
16 $scope.esperando = false; 16 $scope.esperando = false;
17 $scope.titulo = options.titulo; 17 $scope.titulo = options.titulo;
18 $scope.checkboxVar = false; 18 $scope.checkboxVar = false;
19 19
20 $scope.aceptar = function () { 20 $scope.aceptar = function () {
21 $uibModalInstance.close(); 21 $uibModalInstance.close();
22 }; 22 };
23 $scope.salir = function () { 23 $scope.salir = function () {
24 $uibModalInstance.close($scope.descargado); 24 $uibModalInstance.close($scope.descargado);
25 }; 25 };
26 $scope.validarImpresion = function () { 26 $scope.validarImpresion = function () {
27 var rutaComprobante; 27 var rutaComprobante;
28 rutaComprobante = $scope.checkboxVar === true ? options.descargaSinValorizar : options.descarga; 28 rutaComprobante = $scope.checkboxVar === true ? options.descargaSinValorizar : options.descarga;
29 imprimir(rutaComprobante); 29 imprimir(rutaComprobante);
30 } 30 }
31 imprimir = function (rutaComprobante) { 31 imprimir = function (rutaComprobante) {
32 $scope.descargado = true; 32 $scope.descargado = true;
33 $scope.esperando = true; 33 $scope.esperando = true;
34 focaModalService 34 focaModalService
35 .imprimirComprobante(rutaComprobante.url, options.options) 35 .imprimirComprobante(rutaComprobante.url, options.options)
36 .then(function (res) { 36 .then(function (res) {
37 var data = new Blob([res.data], { type: 'application/pdf' }); 37 var data = new Blob([res.data], { type: 'application/pdf' });
38 38
39 FileSaver.saveAs( 39 FileSaver.saveAs(
40 data, 40 data,
41 rutaComprobante.nombre 41 rutaComprobante.nombre
42 ); 42 );
43 $scope.esperando = false; 43 $scope.esperando = false;
44 }); 44 });
45 }; 45 };
46 $scope.enviarComprobante = function () { 46 $scope.enviarComprobante = function () {
47 var rutaEnvioComprobante; 47 var rutaEnvioComprobante;
48 rutaEnvioComprobante = $scope.checkboxVar === true ? options.envioSinValorizar : options.envio; 48 rutaEnvioComprobante = $scope.checkboxVar === true ? options.envioSinValorizar : options.envio;
49 enviarCorreo(rutaEnvioComprobante, 13); 49 enviarCorreo(rutaEnvioComprobante, 13);
50 } 50 }
51 enviarCorreo = function (rutaEnvioComprobante, key) { 51 enviarCorreo = function (rutaEnvioComprobante, key) {
52 if (key === 13) { 52 if (key === 13) {
53 if (!validarMail()) { 53 if (!validarMail()) {
54 focaModalService.alert('Ingrese email/s válido/s'); 54 focaModalService.alert('Ingrese email/s válido/s');
55 return; 55 return;
56 } 56 }
57 $scope.descargado = true; 57 $scope.descargado = true;
58 $scope.esperando = true; 58 $scope.esperando = true;
59 $scope.mailCliente = rutaEnvioComprobante.mailCliente; 59 rutaEnvioComprobante.mailCliente = $scope.mailCliente;
60 Object.assign(options.options, { receiver: $scope.mailCliente }); 60 Object.assign(options.options, { receiver: $scope.mailCliente });
61 61
62 focaModalService 62 focaModalService
63 .enviarCorreo(rutaEnvioComprobante.url, options.options) 63 .enviarCorreo(rutaEnvioComprobante.url, options.options)
64 .then(function () { 64 .then(function () {
65 $scope.correoEnviado = true; 65 $scope.correoEnviado = true;
66 $scope.esperando = false; 66 $scope.esperando = false;
67 }, function () { 67 }, function () {
68 $scope.esperando = false; 68 $scope.esperando = false;
69 $scope.correoNoEnviado = true; 69 $scope.correoNoEnviado = true;
70 }); 70 });
71 } 71 }
72 }; 72 };
73 function validarMail() { 73 function validarMail() {
74 var emails = $scope.mailCliente.split(','); 74 var emails = $scope.mailCliente.split(',');
75 var result = true; 75 var result = true;
76 emails.forEach(function (email) { 76 emails.forEach(function (email) {
77 if (!regexMail.test(email.trim())) result = false; 77 if (!regexMail.test(email.trim())) result = false;
78 }); 78 });
79 return result; 79 return result;
80 } 80 }
81 } 81 }
82 ]); 82 ]);
83 83
1 angular.module('focaModal') 1 angular.module('focaModal')
2 .factory('focaModalService', [ 2 .factory('focaModalService', [
3 '$uibModal', 'API_ENDPOINT', '$http', 3 '$uibModal', 'API_ENDPOINT', '$http',
4 function($uibModal, API_ENDPOINT, $http) { 4 function($uibModal, API_ENDPOINT, $http) {
5 return { 5 return {
6 confirm: function(textoModal) { 6 confirm: function(textoModal) {
7 return $uibModal.open({ 7 return $uibModal.open({
8 templateUrl: 'modal-confirm.html', 8 templateUrl: 'modal-confirm.html',
9 controller: 'focaModalConfirmController', 9 controller: 'focaModalConfirmController',
10 animation: false, 10 animation: false,
11 backdrop: false, 11 backdrop: false,
12 resolve: { textoModal: function() { return textoModal; } } 12 resolve: { textoModal: function() { return textoModal; } }
13 }) 13 })
14 .result.then( 14 .result.then(
15 function(resultado) { 15 function(resultado) {
16 return resultado; 16 return resultado;
17 } 17 }
18 ); 18 );
19 }, 19 },
20 info: function(textoModal) { 20 info: function(textoModal) {
21 return $uibModal.open({ 21 return $uibModal.open({
22 templateUrl: 'modal-info.html', 22 templateUrl: 'modal-info.html',
23 controller: 'focaModalInfoController', 23 controller: 'focaModalInfoController',
24 animation: false, 24 animation: false,
25 backdrop: false, 25 backdrop: false,
26 resolve: { textoModal: function() { return textoModal; } } 26 resolve: { textoModal: function() { return textoModal; } }
27 }) 27 })
28 .result.then( 28 .result.then(
29 function(resultado) { 29 function(resultado) {
30 return resultado; 30 return resultado;
31 } 31 }
32 ); 32 );
33 }, 33 },
34 alert: function(textoModal) { 34 alert: function(textoModal) {
35 return $uibModal.open({ 35 return $uibModal.open({
36 templateUrl: 'modal-alert.html', 36 templateUrl: 'modal-alert.html',
37 controller: 'focaModalAlertController', 37 controller: 'focaModalAlertController',
38 animation: false, 38 animation: false,
39 backdrop: false, 39 backdrop: false,
40 resolve: { textoModal: function() { return textoModal; } } 40 resolve: { textoModal: function() { return textoModal; } }
41 }) 41 })
42 .result.then( 42 .result.then(
43 function(resultado) { 43 function(resultado) {
44 return resultado; 44 return resultado;
45 } 45 }
46 ); 46 );
47 }, 47 },
48 modal: function(parametrosModal) { 48 modal: function(parametrosModal) {
49 parametrosModal.size = (typeof parametrosModal.size === 'undefined') ? 49 parametrosModal.size = (typeof parametrosModal.size === 'undefined') ?
50 'lg' : parametrosModal.size; 50 'lg' : parametrosModal.size;
51 51
52 return $uibModal.open({ 52 return $uibModal.open({
53 templateUrl: 'foca-modal.html', 53 templateUrl: 'foca-modal.html',
54 controller: 'focaModalController', 54 controller: 'focaModalController',
55 size: parametrosModal.size, 55 size: parametrosModal.size,
56 resolve: { 56 resolve: {
57 parametrosModal: function() { return parametrosModal; } 57 parametrosModal: function() { return parametrosModal; }
58 } 58 }
59 }) 59 })
60 .result.then( 60 .result.then(
61 function(resultado) { 61 function(resultado) {
62 return resultado; 62 return resultado;
63 } 63 }
64 ); 64 );
65 }, 65 },
66 getEntidad: function(filters, query, tipo, json) { 66 getEntidad: function(filters, query, tipo, json) {
67 if (tipo === 'POST') { 67 if (tipo === 'POST') {
68 return $http.post(API_ENDPOINT.URL + query, json); 68 return $http.post(API_ENDPOINT.URL + query, json);
69 } else { 69 } else {
70 return $http.get(API_ENDPOINT.URL + query, {nombre: filters}); 70 return $http.get(API_ENDPOINT.URL + query, {nombre: filters});
71 } 71 }
72 }, 72 },
73 modalFecha: function(parametros) { 73 modalFecha: function(parametros) {
74 return $uibModal.open({ 74 return $uibModal.open({
75 templateUrl: 'foca-fecha.html', 75 templateUrl: 'foca-fecha.html',
76 controller: 'focaModalFechaController', 76 controller: 'focaModalFechaController',
77 size: 'md', 77 size: 'md',
78 resolve: { 78 resolve: {
79 parametros: function() { return parametros; } 79 parametros: function() { return parametros; }
80 } 80 }
81 }) 81 })
82 .result.then( 82 .result.then(
83 function(resultado) { 83 function(resultado) {
84 return resultado; 84 return resultado;
85 } 85 }
86 ); 86 );
87 }, 87 },
88 prompt: function(options) { 88 prompt: function(options) {
89 return $uibModal.open({ 89 return $uibModal.open({
90 templateUrl: 'modal-prompt.html', 90 templateUrl: 'modal-prompt.html',
91 controller: 'focaModalPromptController', 91 controller: 'focaModalPromptController',
92 size: 'md', 92 size: 'md',
93 resolve: { 93 resolve: {
94 options: function() {return options;}, 94 options: function() {return options;},
95 } 95 }
96 }) 96 })
97 .result.then( 97 .result.then(
98 function(resultado) { 98 function(resultado) {
99 return resultado; 99 return resultado;
100 } 100 }
101 ); 101 );
102 }, 102 },
103 mail: function(options) { 103 mail: function(options) {
104 return $uibModal.open({ 104 return $uibModal.open({
105 templateUrl: 'modal-mail.html', 105 templateUrl: 'modal-mail.html',
106 controller: 'focaModalMailController', 106 controller: 'focaModalMailController',
107 size: 'md', 107 size: 'md',
108 backdrop: false,
108 resolve: { 109 resolve: {
109 options: function() {return options;}, 110 options: function() {return options;},
110 } 111 }
111 }) 112 })
112 .result.then( 113 .result.then(
113 function(resultado) { 114 function(resultado) {
114 return resultado; 115 return resultado;
115 } 116 }
116 ); 117 );
117 }, 118 },
118 imprimirComprobante: function(url, options) { 119 imprimirComprobante: function(url, options) {
119 return $http.post( 120 return $http.post(
120 API_ENDPOINT.URL + url, 121 API_ENDPOINT.URL + url,
121 options, 122 options,
122 {responseType: 'arraybuffer'} 123 {responseType: 'arraybuffer'}
123 ); 124 );
124 }, 125 },
125 enviarCorreo: function(url, options) { 126 enviarCorreo: function(url, options) {
126 return $http.post(API_ENDPOINT.URL + url, options); 127 return $http.post(API_ENDPOINT.URL + url, options);
127 } 128 }
128 }; 129 };
129 } 130 }
130 ]); 131 ]);
131 132
src/views/modal-info.html
1 <div class="focus-in"> 1 <div class="focus-in">
2
3 <div class="modal-header"> 2 <div class="modal-header">
4 <h4>Información</h4> 3 <h4>Información</h4>
5 </div> 4 </div>
6
7 <div class="modal-body"> 5 <div class="modal-body">
8 <p ng-bind="textoModal" class="line-break m-0 pb-2"></p> 6 <p ng-bind="textoModal" class="line-break m-0 pb-2"></p>
9 <!-- La versión está tipeada, después habria que hacer que se haga una consulta y devuelva la versión --> 7 <!-- La versión está tipeada, después habria que hacer que se haga una consulta y devuelva la versión -->
10 <p class="m-0 border-bottom border-top pt-2 pb-2">DEBO® Distribuidores: Versión 2.0</p> 8 <p class="m-0 border-bottom border-top pt-2 pb-2">DEBO® Distribuidores: Versión 2.0</p>
11 <p class="mt-1">Ante un inconveniente con el sistema,</br> 9 <p class="mt-1">Ante un inconveniente con el sistema,</br>
12 comuniquese con nuestra <a href="http://focasoftware.com" target="__blank">mesa de ayuda</a></p> 10 comuniquese con nuestra <a href="http://focasoftware.com" target="__blank">mesa de ayuda</a></p>
13 <a href="http://focasoftware.com" target="__blank"> 11 <a href="http://focasoftware.com" target="__blank">
14 <img src="img/logo-foca.png" class="w-25 rounded mx-auto d-block mt-4"> 12 <img src="img/logo-foca.png" class="w-25 rounded mx-auto d-block mt-4">
15 </a> 13 </a>
16 </div> 14 </div>
17 <div class="modal-footer"> 15 <div class="modal-footer">
18 <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> 16 <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button>
19 </div> 17 </div>
20 </div> 18 </div>
21 19
22 20
23 21
24 22
src/views/modal-mail.html
1 <div class="modal-header"> 1 <div class="modal-header">
2 <h5 ng-bind="titulo"></h5> 2 <h5 ng-bind="titulo"></h5>
3 </div> 3 </div>
4 <div class="modal-body"> 4 <div class="modal-body">
5 <div > 5 <div >
6 <label 6 <label
7 class="col-12 bg-success text-white" 7 class="col-12 bg-success text-white"
8 ng-show="correoEnviado">Correo enviado con éxito</label> 8 ng-show="correoEnviado">Correo enviado con éxito</label>
9 <label 9 <label
10 class="col-12 bg-danger text-white" 10 class="col-12 bg-danger text-white"
11 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label> 11 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label>
12 <label>Enviar correo a</label> 12 <label>Enviar correo a</label>
13 <div class="d-flex"> 13 <div class="d-flex">
14 <input 14 <input
15 type="email"
15 class="form-control col-9" 16 class="form-control col-9"
16 ng-model="mailCliente" 17 ng-model="mailCliente"
17 ng-keypress="enviarComprobante($event.keyCode)" 18 ng-keypress="enviarComprobante($event.keyCode)"
18 teclado-virtual/> 19 teclado-virtual/>
19 <button 20 <button
20 type="button" 21 type="button"
21 class="btn btn-enviar ml-auto" 22 class="btn btn-enviar ml-auto"
22 ng-click="enviarComprobante(13)" 23 ng-click="enviarComprobante(13)"
23 ladda="esperando" 24 ladda="esperando"
24 >Enviar</button> 25 >Enviar</button>
25 </div> 26 </div>
26 </div> 27 </div>
27 <hr> 28 <hr>
28 <div> 29 <div>
29 <label>Descargar comprobante</label> 30 <label>Descargar comprobante</label>
30 <div class="col my-1 d-flex justify-content-end"> 31 <div class="col my-1 d-flex justify-content-end">
31 <button 32 <button
32 class="btn btn-enviar float-right" 33 class="btn btn-enviar float-right"
33 ng-click="validarImpresion()" 34 ng-click="validarImpresion()"
34 ladda="esperando" 35 ladda="esperando"
35 >Descargar</button> 36 >Descargar</button>
36 </div> 37 </div>
37 </div> 38 </div>
38 </div> 39 </div>
39 <div class="modal-footer"> 40 <div class="modal-footer">
40 <div class="custom-control custom-checkbox my-auto mr-5"> 41 <div class="custom-control custom-checkbox my-auto mr-5">
41 <input 42 <input
42 type="checkbox" 43 type="checkbox"
43 class="custom-control-input mr-5" 44 class="custom-control-input mr-5"
44 id="check" 45 id="check"
45 ng-click="checkboxVar = !checkboxVar"> 46 ng-click="checkboxVar = !checkboxVar">
46 <label class="custom-control-label disable-selection" for="check"> 47 <label class="custom-control-label disable-selection" for="check">
47 Combrobante sin valorizar 48 Combrobante sin valorizar
48 </label> 49 </label>
49 </div> 50 </div>
50 <button 51 <button
51 type="button" 52 type="button"
52 class="btn btn-secondary" 53 class="btn btn-secondary"
53 ng-click="salir()" 54 ng-click="salir()"
54 ladda="esperando" 55 ladda="esperando"
55 >Salir</button> 56 >Salir</button>
56 <button 57 <button
57 type="button" 58 type="button"
58 class="btn btn-primary" 59 class="btn btn-primary"
59 ng-click="aceptar()" 60 ng-click="aceptar()"
60 ladda="esperando" 61 ladda="esperando"
61 ng-disabled="!descargado" 62 ng-disabled="!descargado"
62 >Aceptar</button> 63 >Aceptar</button>
63 </div> 64 </div>
64 65