Commit aed93935daf5431da84374d6bccfc0841da62e33
1 parent
68357b30ab
Exists in
develop
Agregado modal para ingresar monto en forma de pago con efectivo.
Showing
2 changed files
with
14 additions
and
14 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', 'focaModalService', |
| 5 | function ($timeout, $filter, $scope, $uibModal, | 5 | function ($timeout, $filter, $scope, $uibModal, |
| 6 | $uibModalInstance, focaModalFormaPagoService, parametros) { | 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 = abrirModal('modal-tarjetas.html', | 19 | var modalInstance = focaModalService.prompt({ titulo: 'Ingrese monto' }); |
| 20 | 'focaModalTarjetasController'); | 20 | modalInstance |
| 21 | modalInstance.result | ||
| 22 | .then(function (data) { | 21 | .then(function (data) { |
| 23 | console.log(data); | 22 | $uibModalInstance.close({ data: data, tipo: 'efectivo' }); |
| 24 | }) | 23 | }) |
| 25 | .catch(function (e) { console.error(e); }); | 24 | .catch(function (e) { console.error(e); }); |
| 26 | }; | 25 | }; |
| 27 | 26 | ||
| 28 | $scope.seleccionarTarjetas = function () { | 27 | $scope.seleccionarTarjetas = function () { |
| 29 | var modalInstance = abrirModal('modal-tarjetas.html', | 28 | var modalInstance = abrirModal('modal-tarjetas.html', |
| 30 | 'focaModalTarjetasController'); | 29 | 'focaModalTarjetasController'); |
| 31 | modalInstance.result | 30 | modalInstance.result |
| 32 | .then(function (data) { | 31 | .then(function (data) { |
| 33 | $uibModalInstance.close({data: data, tipo: 'tarjeta'}); | 32 | $uibModalInstance.close({ data: data, tipo: 'tarjeta' }); |
| 34 | }) | 33 | }) |
| 35 | .catch(function (e) { console.error(e); }); | 34 | .catch(function (e) { console.error(e); }); |
| 36 | }; | 35 | }; |
| 37 | 36 | ||
| 38 | $scope.seleccionarCheque = function () { | 37 | $scope.seleccionarCheque = function () { |
| 39 | var modalInstance = abrirModal('modal-tarjetas.html', | 38 | var modalInstance = abrirModal('modal-tarjetas.html', |
| 40 | 'focaModalTarjetasController'); | 39 | 'focaModalTarjetasController'); |
| 41 | modalInstance.result | 40 | modalInstance.result |
| 42 | .then(function (data) { | 41 | .then(function (data) { |
| 43 | console.log(data); | 42 | console.log(data); |
| 44 | }) | 43 | }) |
| 45 | .catch(function (e) { console.error(e); }); | 44 | .catch(function (e) { console.error(e); }); |
| 46 | }; | 45 | }; |
| 47 | 46 | ||
| 48 | $scope.seleccionarVales = function () { | 47 | $scope.seleccionarVales = function () { |
| 49 | var modalInstance = abrirModal('modal-tarjetas.html', | 48 | var modalInstance = abrirModal('modal-tarjetas.html', |
| 50 | 'focaModalTarjetasController'); | 49 | 'focaModalTarjetasController'); |
| 51 | modalInstance.result | 50 | modalInstance.result |
| 52 | .then(function (data) { | 51 | .then(function (data) { |
| 53 | console.log(data); | 52 | console.log(data); |
| 54 | }) | 53 | }) |
| 55 | .catch(function (e) { console.error(e); }); | 54 | .catch(function (e) { console.error(e); }); |
| 56 | }; | 55 | }; |
| 57 | 56 | ||
| 58 | $scope.seleccionarPagoElectronico = function () { | 57 | $scope.seleccionarPagoElectronico = function () { |
| 59 | var modalInstance = abrirModal('modal-tarjetas.html', | 58 | var modalInstance = abrirModal('modal-tarjetas.html', |
| 60 | 'focaModalTarjetasController'); | 59 | 'focaModalTarjetasController'); |
| 61 | modalInstance.result | 60 | modalInstance.result |
| 62 | .then(function (data) { | 61 | .then(function (data) { |
| 63 | console.log(data); | 62 | console.log(data); |
| 64 | }) | 63 | }) |
| 65 | .catch(function (e) { console.error(e); }); | 64 | .catch(function (e) { console.error(e); }); |
| 66 | }; | 65 | }; |
| 67 | 66 | ||
| 68 | function abrirModal(templateUrl, controller) { | 67 | function abrirModal(templateUrl, controller) { |
| 69 | return $uibModal.open( | 68 | return $uibModal.open( |
| 70 | { | 69 | { |
| 71 | templateUrl: templateUrl, | 70 | templateUrl: templateUrl, |
| 72 | controller: controller, | 71 | controller: controller, |
| 73 | resolve: { | 72 | resolve: { |
| 74 | parametros: function () { return { | 73 | parametros: function () { |
| 75 | importe: parametros.importe | 74 | return { |
| 76 | }; }, | 75 | importe: parametros.importe |
| 76 | }; | ||
| 77 | }, | ||
| 77 | }, | 78 | }, |
| 78 | size: 'lg', | 79 | size: 'lg', |
| 79 | } | 80 | } |
| 80 | ); | 81 | ); |
| 81 | 82 | ||
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | $scope.cancel = function () { | 85 | $scope.cancel = function () { |
| 85 | $uibModalInstance.dismiss('cancel'); | 86 | $uibModalInstance.dismiss('cancel'); |
| 86 | }; | 87 | }; |
| 87 | }] | 88 | }] |
| 88 | ) | 89 | ) |
| 89 | .controller('focaModalTarjetasController', [ | 90 | .controller('focaModalTarjetasController', [ |
| 90 | '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalTarjetasService', | 91 | '$timeout', '$filter', '$scope', '$uibModalInstance', 'focaModalTarjetasService', |
| 91 | 'parametros', | 92 | 'parametros', |
| 92 | function ($timeout, $filter, $scope, $uibModalInstance, focaModalTarjetasService, | 93 | function ($timeout, $filter, $scope, $uibModalInstance, focaModalTarjetasService, |
| 93 | parametros) | 94 | parametros) { |
| 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 | }] |
src/js/service.js
| 1 | angular.module('focaModalFormaPago') | 1 | angular.module('focaModalFormaPago') |
| 2 | .factory('focaModalFormaPagoService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 2 | .factory('focaModalFormaPagoService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { |
| 3 | return { | 3 | return { |
| 4 | getBotonera: function () { | 4 | getBotonera: function () { |
| 5 | return [ | 5 | return [ |
| 6 | { | 6 | { |
| 7 | label: 'Efectivo', | 7 | label: 'Efectivo', |
| 8 | image: 'efectivo.png', | 8 | image: 'efectivo.png', |
| 9 | disabled: true | 9 | disabled: false |
| 10 | }, | 10 | }, |
| 11 | { | 11 | { |
| 12 | label: 'Tarjetas', | 12 | label: 'Tarjetas', |
| 13 | image: 'tarjeta.png', | 13 | image: 'tarjeta.png', |
| 14 | disabled: false | 14 | disabled: false |
| 15 | }, | 15 | }, |
| 16 | { | 16 | { |
| 17 | label: 'Cheque', | 17 | label: 'Cheque', |
| 18 | image: 'cheque.png', | 18 | image: 'cheque.png', |
| 19 | disabled: true | 19 | disabled: true |
| 20 | }, | 20 | }, |
| 21 | { | 21 | { |
| 22 | label: 'Vales', | 22 | label: 'Vales', |
| 23 | image: 'vale.png', | 23 | image: 'vale.png', |
| 24 | disabled: true | 24 | disabled: true |
| 25 | }, | 25 | }, |
| 26 | { | 26 | { |
| 27 | label: 'Pago Electronico', | 27 | label: 'Pago Electronico', |
| 28 | image: 'qr.png', | 28 | image: 'qr.png', |
| 29 | disabled: true | 29 | disabled: true |
| 30 | } | 30 | } |
| 31 | ]; | 31 | ]; |
| 32 | } | 32 | } |
| 33 | }; | 33 | }; |
| 34 | }]) | 34 | }]) |
| 35 | .factory('focaModalTarjetasService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 35 | .factory('focaModalTarjetasService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { |
| 36 | return { | 36 | return { |
| 37 | getTarjetas: function () { | 37 | getTarjetas: function () { |
| 38 | return $http.get(API_ENDPOINT.URL + '/tarjetas'); | 38 | return $http.get(API_ENDPOINT.URL + '/tarjetas'); |
| 39 | // return [ | 39 | // return [ |
| 40 | // { | 40 | // { |
| 41 | // label: 'tarjeta', | 41 | // label: 'tarjeta', |
| 42 | // image: 'visa.svg', | 42 | // image: 'visa.svg', |
| 43 | // active: false, | 43 | // active: false, |
| 44 | // }, | 44 | // }, |
| 45 | // { | 45 | // { |
| 46 | // label: 'tarjeta', | 46 | // label: 'tarjeta', |
| 47 | // image: 'mastercard.svg', | 47 | // image: 'mastercard.svg', |
| 48 | // active: false, | 48 | // active: false, |
| 49 | // }, | 49 | // }, |
| 50 | // { | 50 | // { |
| 51 | // label: 'tarjeta', | 51 | // label: 'tarjeta', |
| 52 | // image: 'maestro.svg', | 52 | // image: 'maestro.svg', |
| 53 | // active: false, | 53 | // active: false, |
| 54 | // }, | 54 | // }, |
| 55 | // { | 55 | // { |
| 56 | // label: 'tarjeta', | 56 | // label: 'tarjeta', |
| 57 | // image: 'americanExpress.svg', | 57 | // image: 'americanExpress.svg', |
| 58 | // active: false, | 58 | // active: false, |
| 59 | // }, | 59 | // }, |
| 60 | // { | 60 | // { |
| 61 | // label: 'tarjeta', | 61 | // label: 'tarjeta', |
| 62 | // image: 'naranja.png', | 62 | // image: 'naranja.png', |
| 63 | // active: false, | 63 | // active: false, |
| 64 | // }, | 64 | // }, |
| 65 | // { | 65 | // { |
| 66 | // label: 'tarjeta', | 66 | // label: 'tarjeta', |
| 67 | // image: 'cabal.svg', | 67 | // image: 'cabal.svg', |
| 68 | // active: false, | 68 | // active: false, |
| 69 | // }, | 69 | // }, |
| 70 | // { | 70 | // { |
| 71 | // label: 'tarjeta', | 71 | // label: 'tarjeta', |
| 72 | // image: 'argencard.svg', | 72 | // image: 'argencard.svg', |
| 73 | // active: false, | 73 | // active: false, |
| 74 | // }, | 74 | // }, |
| 75 | // { | 75 | // { |
| 76 | // label: 'tarjeta', | 76 | // label: 'tarjeta', |
| 77 | // image: 'nativa.png', | 77 | // image: 'nativa.png', |
| 78 | // active: false, | 78 | // active: false, |
| 79 | // }, | 79 | // }, |
| 80 | // { | 80 | // { |
| 81 | // label: 'tarjeta', | 81 | // label: 'tarjeta', |
| 82 | // image: 'cencosud.png', | 82 | // image: 'cencosud.png', |
| 83 | // active: false, | 83 | // active: false, |
| 84 | // }, | 84 | // }, |
| 85 | // ]; | 85 | // ]; |
| 86 | } | 86 | } |
| 87 | }; | 87 | }; |
| 88 | }]); | 88 | }]); |
| 89 | 89 |