angular.module('focaCrearRemito') .controller('focaRemitoComprobanteController', [ '$scope', '$uibModalInstance', 'crearRemitoService', '$window', 'parametros', function($scope, $uibModalInstance, crearRemitoService, $window, parametros) { $scope.correoEnviado = false; $scope.correoNoEnviado = false; $scope.esperando = false; $scope.remito = parametros.remito; crearRemitoService.imprimirRemitoByIdRemito($scope.remito.id).then( function(res) { $scope.htmlComprobante = res.data; }); $scope.aceptar = function() { $uibModalInstance.close(); }; $scope.imprimir = function () { var printWindow = $window.open('', '', 'height=1000,width=800'); printWindow.document.write($scope.htmlComprobante); printWindow.document.close(); printWindow.print(); }; $scope.enviarCorreo = function(key) { if(key !== 13) return; $scope.esperando = true; var options = { para: $scope.remito.cliente.MAIL, titulo: 'Recibo Mail', texto: '', html: $scope.htmlComprobante }; crearRemitoService.enviarCorreo(options).then(function() { $scope.correoEnviado = true; $scope.esperando = false; }, function() { $scope.esperando = false; $scope.correoNoEnviado = true; }); }; } ]);