Commit 44ae6bc89b24a8829de61714dac627bb94b1dc63

Authored by Eric Fernandez
1 parent 3c10ff75a3
Exists in master

lineas al final

src/js/controllerComprobante.js
1 angular.module('focaCrearRemito') 1 angular.module('focaCrearRemito')
2 .controller('focaRemitoComprobanteController', [ 2 .controller('focaRemitoComprobanteController', [
3 '$scope', 3 '$scope',
4 '$uibModalInstance', 4 '$uibModalInstance',
5 'crearRemitoService', 5 'crearRemitoService',
6 '$window', 6 '$window',
7 'parametros', 7 'parametros',
8 function($scope, $uibModalInstance, crearRemitoService, $window, parametros) { 8 function($scope, $uibModalInstance, crearRemitoService, $window, parametros) {
9 9
10 $scope.correoEnviado = false; 10 $scope.correoEnviado = false;
11 $scope.correoNoEnviado = false; 11 $scope.correoNoEnviado = false;
12 $scope.esperando = false; 12 $scope.esperando = false;
13 $scope.remito = parametros.remito; 13 $scope.remito = parametros.remito;
14 14
15 crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then( 15 crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then(
16 function(res) { 16 function(res) {
17 $scope.htmlComprobante = res.data; 17 $scope.htmlComprobante = res.data;
18 }); 18 });
19 19
20 $scope.aceptar = function() { 20 $scope.aceptar = function() {
21 $uibModalInstance.close(); 21 $uibModalInstance.close();
22 }; 22 };
23 23
24 $scope.imprimir = function () { 24 $scope.imprimir = function () {
25 25
26 var printWindow = $window.open('', '', 'height=1000,width=800'); 26 var printWindow = $window.open('', '', 'height=1000,width=800');
27 printWindow.document.write($scope.htmlComprobante); 27 printWindow.document.write($scope.htmlComprobante);
28 printWindow.document.close(); 28 printWindow.document.close();
29 printWindow.print(); 29 printWindow.print();
30 }; 30 };
31 31
32 $scope.enviarCorreo = function(key) { 32 $scope.enviarCorreo = function(key) {
33 if(key !== 13) return; 33 if(key !== 13) return;
34 $scope.esperando = true; 34 $scope.esperando = true;
35 var options = { 35 var options = {
36 para: $scope.remito.cliente.MAIL, 36 para: $scope.remito.cliente.MAIL,
37 titulo: 'Recibo Mail', 37 titulo: 'Recibo Mail',
38 texto: '', 38 texto: '',
39 html: $scope.htmlComprobante 39 html: $scope.htmlComprobante
40 }; 40 };
41 41
42 crearRemitoService.enviarCorreo(options).then(function() { 42 crearRemitoService.enviarCorreo(options).then(function() {
43 $scope.correoEnviado = true; 43 $scope.correoEnviado = true;
44 $scope.esperando = false; 44 $scope.esperando = false;
45 }, function() { 45 }, function() {
46 $scope.esperando = false; 46 $scope.esperando = false;
47 $scope.correoNoEnviado = true; 47 $scope.correoNoEnviado = true;
48 }); 48 });
49 }; 49 };
50 } 50 }
51 ]);
51 ]);
src/views/remito-comprobante.html
1 <div class="modal-header"> 1 <div class="modal-header">
2 <h5>Comprobante de remito Nº 2 <h5>Comprobante de remito Nº
3 <span 3 <span
4 ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante"> 4 ng-bind="[remito.numeroRemito, remito.sucursal] | comprobante">
5 </span> 5 </span>
6 </h5> 6 </h5>
7 </div> 7 </div>
8 <div class="modal-body"> 8 <div class="modal-body">
9 <div class="col-12"> 9 <div class="col-12">
10 <label 10 <label
11 class="col-12 bg-success text-white" 11 class="col-12 bg-success text-white"
12 ng-show="correoEnviado">Correo enviado con éxito</label> 12 ng-show="correoEnviado">Correo enviado con éxito</label>
13 <label 13 <label
14 class="col-12 bg-danger text-white" 14 class="col-12 bg-danger text-white"
15 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label> 15 ng-show="correoNoEnviado">Hubo un error al enviar el correo</label>
16 <label>Enviar correo a </label> 16 <label>Enviar correo a </label>
17 <input 17 <input
18 class="form-control" 18 class="form-control"
19 ng-model="remito.cliente.MAIL" 19 ng-model="remito.cliente.MAIL"
20 ng-click="enviarCorreo($event.keyCode)"/> 20 ng-click="enviarCorreo($event.keyCode)"/>
21 </div> 21 </div>
22 </div> 22 </div>
23 <div class="modal-footer"> 23 <div class="modal-footer">
24 <button 24 <button
25 type="button" 25 type="button"
26 class="btn btn-info" 26 class="btn btn-info"
27 ng-click="imprimir()" 27 ng-click="imprimir()"
28 ladda="esperando" 28 ladda="esperando"
29 >Imprimir</button> 29 >Imprimir</button>
30 <button 30 <button
31 type="button" 31 type="button"
32 class="btn btn-primary" 32 class="btn btn-primary"
33 ng-click="aceptar()" 33 ng-click="aceptar()"
34 ladda="esperando" 34 ladda="esperando"
35 >Aceptar</button> 35 >Aceptar</button>
36 <button 36 <button
37 type="button" 37 type="button"
38 class="btn btn-primary" 38 class="btn btn-primary"
39 ng-click="enviarCorreo(13)" 39 ng-click="enviarCorreo(13)"
40 ladda="esperando" 40 ladda="esperando"
41 >Enviar</button> 41 >Enviar</button>
42 </div>
42 </div>