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