controllerComprobante.js
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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;
});
};
}
]);