Commit f07e18559ecfb779d0ce3a6fb5e19ff347a88296
1 parent
d816745ff9
Exists in
master
agrego tipo de pago
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaModalFormaPago') | 1 | angular.module('focaModalFormaPago') |
2 | .controller('focaModalFormaPagoController', [ | 2 | .controller('focaModalFormaPagoController', [ |
3 | '$timeout', '$filter', '$scope', '$uibModal', | 3 | '$timeout', '$filter', '$scope', '$uibModal', |
4 | '$uibModalInstance', 'focaModalFormaPagoService', 'parametros', | 4 | '$uibModalInstance', 'focaModalFormaPagoService', 'parametros', |
5 | function ($timeout, $filter, $scope, $uibModal, | 5 | function ($timeout, $filter, $scope, $uibModal, |
6 | $uibModalInstance, focaModalFormaPagoService, parametros) { | 6 | $uibModalInstance, focaModalFormaPagoService, parametros) { |
7 | 7 | ||
8 | //#region Variables | 8 | //#region Variables |
9 | $scope.botones = []; | 9 | $scope.botones = []; |
10 | //#endregion | 10 | //#endregion |
11 | 11 | ||
12 | init(); | 12 | init(); |
13 | 13 | ||
14 | function init() { | 14 | function init() { |
15 | $scope.botones = focaModalFormaPagoService.getBotonera(); | 15 | $scope.botones = focaModalFormaPagoService.getBotonera(); |
16 | } | 16 | } |
17 | 17 | ||
18 | $scope.seleccionarEfectivo = function () { | 18 | $scope.seleccionarEfectivo = function () { |
19 | var modalInstance = abrirModal('modal-tarjetas.html', | 19 | var modalInstance = abrirModal('modal-tarjetas.html', |
20 | 'focaModalTarjetasController'); | 20 | 'focaModalTarjetasController'); |
21 | modalInstance.result | 21 | modalInstance.result |
22 | .then(function (data) { | 22 | .then(function (data) { |
23 | console.log(data); | 23 | console.log(data); |
24 | }) | 24 | }) |
25 | .catch(function (e) { console.error(e); }); | 25 | .catch(function (e) { console.error(e); }); |
26 | }; | 26 | }; |
27 | 27 | ||
28 | $scope.seleccionarTarjetas = function () { | 28 | $scope.seleccionarTarjetas = function () { |
29 | var modalInstance = abrirModal('modal-tarjetas.html', | 29 | var modalInstance = abrirModal('modal-tarjetas.html', |
30 | 'focaModalTarjetasController'); | 30 | 'focaModalTarjetasController'); |
31 | modalInstance.result | 31 | modalInstance.result |
32 | .then(function (data) { | 32 | .then(function (data) { |
33 | $uibModalInstance.close(data); | 33 | $uibModalInstance.close({data: data, tipo: 'tarjeta'}); |
34 | }) | 34 | }) |
35 | .catch(function (e) { console.error(e); }); | 35 | .catch(function (e) { console.error(e); }); |
36 | }; | 36 | }; |
37 | 37 | ||
38 | $scope.seleccionarCheque = function () { | 38 | $scope.seleccionarCheque = function () { |
39 | var modalInstance = abrirModal('modal-tarjetas.html', | 39 | var modalInstance = abrirModal('modal-tarjetas.html', |
40 | 'focaModalTarjetasController'); | 40 | 'focaModalTarjetasController'); |
41 | modalInstance.result | 41 | modalInstance.result |
42 | .then(function (data) { | 42 | .then(function (data) { |
43 | console.log(data); | 43 | console.log(data); |
44 | }) | 44 | }) |
45 | .catch(function (e) { console.error(e); }); | 45 | .catch(function (e) { console.error(e); }); |
46 | }; | 46 | }; |
47 | 47 | ||
48 | $scope.seleccionarVales = function () { | 48 | $scope.seleccionarVales = function () { |
49 | var modalInstance = abrirModal('modal-tarjetas.html', | 49 | var modalInstance = abrirModal('modal-tarjetas.html', |
50 | 'focaModalTarjetasController'); | 50 | 'focaModalTarjetasController'); |
51 | modalInstance.result | 51 | modalInstance.result |
52 | .then(function (data) { | 52 | .then(function (data) { |
53 | console.log(data); | 53 | console.log(data); |
54 | }) | 54 | }) |
55 | .catch(function (e) { console.error(e); }); | 55 | .catch(function (e) { console.error(e); }); |
56 | }; | 56 | }; |
57 | 57 | ||
58 | $scope.seleccionarPagoElectronico = function () { | 58 | $scope.seleccionarPagoElectronico = function () { |
59 | var modalInstance = abrirModal('modal-tarjetas.html', | 59 | var modalInstance = abrirModal('modal-tarjetas.html', |
60 | 'focaModalTarjetasController'); | 60 | 'focaModalTarjetasController'); |
61 | modalInstance.result | 61 | modalInstance.result |
62 | .then(function (data) { | 62 | .then(function (data) { |
63 | console.log(data); | 63 | console.log(data); |
64 | }) | 64 | }) |
65 | .catch(function (e) { console.error(e); }); | 65 | .catch(function (e) { console.error(e); }); |
66 | }; | 66 | }; |
67 | 67 | ||
68 | function abrirModal(templateUrl, controller) { | 68 | function abrirModal(templateUrl, controller) { |
69 | return $uibModal.open( | 69 | return $uibModal.open( |
70 | { | 70 | { |
71 | templateUrl: templateUrl, | 71 | templateUrl: templateUrl, |
72 | controller: controller, | 72 | controller: controller, |
73 | resolve: { | 73 | resolve: { |
74 | parametros: function () { return { | 74 | parametros: function () { return { |
75 | importe: parametros.importe | 75 | importe: parametros.importe |
76 | }; }, | 76 | }; }, |
77 | }, | 77 | }, |
78 | size: 'lg', | 78 | size: 'lg', |
79 | } | 79 | } |
80 | ); | 80 | ); |
81 | 81 | ||
82 | } | 82 | } |
83 | 83 | ||
84 | $scope.cancel = function () { | 84 | $scope.cancel = function () { |
85 | $uibModalInstance.dismiss('cancel'); | 85 | $uibModalInstance.dismiss('cancel'); |
86 | }; | 86 | }; |
87 | }] | 87 | }] |
88 | ) | 88 | ) |
89 | .controller('focaModalTarjetasController', [ | 89 | .controller('focaModalTarjetasController', [ |
90 | '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalTarjetasService', | 90 | '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalTarjetasService', |
91 | 'parametros', | 91 | 'parametros', |
92 | function ($timeout, $filter, $scope, $uibModalInstance, focaModalTarjetasService, | 92 | function ($timeout, $filter, $scope, $uibModalInstance, focaModalTarjetasService, |
93 | parametros) | 93 | parametros) |
94 | { | 94 | { |
95 | 95 | ||
96 | $scope.parametros = parametros; | 96 | $scope.parametros = parametros; |
97 | 97 | ||
98 | //#region Variables | 98 | //#region Variables |
99 | $scope.botonesTarjetas = []; | 99 | $scope.botonesTarjetas = []; |
100 | $scope.showForm = false; | 100 | $scope.showForm = false; |
101 | 101 | ||
102 | //#endregion | 102 | //#endregion |
103 | 103 | ||
104 | init(); | 104 | init(); |
105 | 105 | ||
106 | function init() { | 106 | function init() { |
107 | 107 | ||
108 | focaModalTarjetasService.getTarjetas().then(function(res) { | 108 | focaModalTarjetasService.getTarjetas().then(function(res) { |
109 | 109 | ||
110 | res.data.forEach(function (boton) { | 110 | res.data.forEach(function (boton) { |
111 | $scope.botonesTarjetas.push({ | 111 | $scope.botonesTarjetas.push({ |
112 | id: boton.ID, | 112 | id: boton.ID, |
113 | label: 'tarjeta', | 113 | label: 'tarjeta', |
114 | nombre: boton.NOM, | 114 | nombre: boton.NOM, |
115 | image: boton.nombreImagen, | 115 | image: boton.nombreImagen, |
116 | imageDefault: 'tarjetaDefault.svg' | 116 | imageDefault: 'tarjetaDefault.svg' |
117 | }); | 117 | }); |
118 | }); | 118 | }); |
119 | 119 | ||
120 | }); | 120 | }); |
121 | 121 | ||
122 | } | 122 | } |
123 | 123 | ||
124 | $scope.seleccionarTarjeta = function (tarjeta) { | 124 | $scope.seleccionarTarjeta = function (tarjeta) { |
125 | $scope.tarjeta = tarjeta; | 125 | $scope.tarjeta = tarjeta; |
126 | animateForm(); | 126 | animateForm(); |
127 | }; | 127 | }; |
128 | 128 | ||
129 | $scope.cancel = function () { | 129 | $scope.cancel = function () { |
130 | $uibModalInstance.dismiss('cancel'); | 130 | $uibModalInstance.dismiss('cancel'); |
131 | }; | 131 | }; |
132 | 132 | ||
133 | $scope.aceptarFormaDePago = function () { | 133 | $scope.aceptarFormaDePago = function () { |
134 | $uibModalInstance.close({ | 134 | $uibModalInstance.close({ |
135 | tarjeta: $scope.tarjeta, | 135 | tarjeta: $scope.tarjeta, |
136 | terminal: $scope.terminal, | 136 | terminal: $scope.terminal, |
137 | numeroCupon: $scope.numeroCupon, | 137 | numeroCupon: $scope.numeroCupon, |
138 | cuotas: $scope.cuotas | 138 | cuotas: $scope.cuotas |
139 | }); | 139 | }); |
140 | }; | 140 | }; |
141 | 141 | ||
142 | function animateForm() { | 142 | function animateForm() { |
143 | $scope.showForm = false; | 143 | $scope.showForm = false; |
144 | $timeout(function () { | 144 | $timeout(function () { |
145 | $scope.showForm = true; | 145 | $scope.showForm = true; |
146 | }, 100); | 146 | }, 100); |
147 | } | 147 | } |
148 | }] | 148 | }] |
149 | ); | 149 | ); |
150 | 150 |