Commit b4e49ed42ccdcf2d1ec3345d3e301b36aa02b93d
Merge branch 'develop' into 'master'
Develop See merge request !21
Showing
3 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -8,16 +8,15 @@ angular.module('focaModalPrecioCondicion') |
8 | 8 | '$uibModalInstance', |
9 | 9 | 'focaModalService', |
10 | 10 | 'focaModalPrecioCondicionService', |
11 | - 'idListaPrecio', | |
12 | - 'idCliente', | |
11 | + 'parametros', | |
13 | 12 | function ( |
14 | 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
15 | - focaModalService, focaModalPrecioCondicionService, idListaPrecio, idCliente | |
14 | + focaModalService, focaModalPrecioCondicionService, parametros | |
16 | 15 | ) { |
17 | 16 | $scope.plazos = [ |
18 | 17 | { |
19 | 18 | dias: 0, |
20 | - idCliente: idCliente, | |
19 | + idCliente: parametros.idCliente, | |
21 | 20 | activo: true |
22 | 21 | } |
23 | 22 | ]; |
... | ... | @@ -29,12 +28,12 @@ angular.module('focaModalPrecioCondicion') |
29 | 28 | |
30 | 29 | function onInit() { |
31 | 30 | //Metodo para traer la lista de precio asociada al cliente |
32 | - focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | |
31 | + focaModalPrecioCondicionService.getListaPrecio(parametros.idListaPrecio) | |
33 | 32 | .then(function (res) { |
34 | 33 | $scope.listaDePreciosAsociada = res.data[0]; |
35 | 34 | }) |
36 | 35 | .catch(function (e) { console.error(e) }); |
37 | - focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | |
36 | + focaModalPrecioCondicionService.getPlazosByIdCliente(parametros.idCliente) | |
38 | 37 | .then(function (res) { |
39 | 38 | res.data.forEach(function (item) { |
40 | 39 | $scope.plazos.push(item); |
... | ... | @@ -64,8 +63,13 @@ angular.module('focaModalPrecioCondicion') |
64 | 63 | } |
65 | 64 | ], |
66 | 65 | }).then(function (res) { |
67 | - $scope.associatedList = false; | |
68 | - $scope.listaDePreciosAlternativa = res; | |
66 | + focaModalService.confirm('¿Desea cambiar la lista de precios?\n'+ | |
67 | + 'Se perderan los productos ingresados').then(function (data){ | |
68 | + if (data) { | |
69 | + $scope.associatedList = false; | |
70 | + $scope.listaDePreciosAlternativa = res; | |
71 | + } | |
72 | + }); | |
69 | 73 | }).catch(function (e) { |
70 | 74 | console.error(e); |
71 | 75 | }); |
... | ... | @@ -104,7 +108,7 @@ angular.module('focaModalPrecioCondicion') |
104 | 108 | return; |
105 | 109 | } |
106 | 110 | } |
107 | - $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | |
111 | + $scope.plazos.unshift({ dias: 0, idCliente: parametros.idCliente, activo: true }); | |
108 | 112 | $scope.focused = 1; |
109 | 113 | }; |
110 | 114 | $scope.deletePlazo = function (index) { |
... | ... | @@ -131,16 +135,19 @@ angular.module('focaModalPrecioCondicion') |
131 | 135 | $uibModalInstance.dismiss('cancel'); |
132 | 136 | }; |
133 | 137 | $scope.guardarPrecioCondicion = function () { |
134 | - $scope.plazos.shift(); | |
135 | - focaModalPrecioCondicionService.createPlazo($scope.plazos) | |
136 | - .then(function () { | |
137 | - var precioCondicion = { | |
138 | - listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
139 | - plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | |
140 | - }; | |
141 | - $uibModalInstance.close(precioCondicion); | |
142 | - }) | |
143 | - .catch(function (e) { console.error(e) }) | |
144 | - } | |
138 | + var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | |
139 | + focaModalPrecioCondicionService.actualizarLista(parametros.idCliente, mod).then(function (){ | |
140 | + $scope.plazos.shift(); | |
141 | + focaModalPrecioCondicionService.createPlazo($scope.plazos) | |
142 | + .then(function () { | |
143 | + var precioCondicion = { | |
144 | + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
145 | + plazoPago: $filter('filter')($scope.plazos, { activo: true }, true) | |
146 | + }; | |
147 | + $uibModalInstance.close(precioCondicion); | |
148 | + }) | |
149 | + .catch(function (e) { console.error(e) }) | |
150 | + }); | |
151 | + }; | |
145 | 152 | } |
146 | 153 | ]); |
src/js/controllerCliente.js
... | ... | @@ -8,10 +8,10 @@ angular.module('focaModalPrecioCondicion') |
8 | 8 | '$uibModalInstance', |
9 | 9 | 'focaModalService', |
10 | 10 | 'focaModalPrecioCondicionService', |
11 | - 'idListaPrecio', | |
11 | + 'parametros', | |
12 | 12 | function ( |
13 | 13 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
14 | - focaModalService, focaModalPrecioCondicionService, idListaPrecio | |
14 | + focaModalService, focaModalPrecioCondicionService, parametros | |
15 | 15 | ) { |
16 | 16 | $scope.openModalListaDePrecios = false; |
17 | 17 | $scope.associatedList = true; |
... | ... | @@ -21,7 +21,7 @@ angular.module('focaModalPrecioCondicion') |
21 | 21 | |
22 | 22 | function onInit() { |
23 | 23 | //Metodo para traer la lista de precio asociada al cliente |
24 | - focaModalPrecioCondicionService.getListaPrecio(idListaPrecio) | |
24 | + focaModalPrecioCondicionService.getListaPrecio(parametros.idListaPrecio) | |
25 | 25 | .then(function (res) { |
26 | 26 | $scope.listaDePreciosAsociada = res.data[0]; |
27 | 27 | }) |
... | ... | @@ -82,10 +82,14 @@ angular.module('focaModalPrecioCondicion') |
82 | 82 | $uibModalInstance.dismiss('cancel'); |
83 | 83 | }; |
84 | 84 | $scope.guardarPrecioCondicion = function () { |
85 | - var precioCondicion = { | |
86 | - listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
87 | - }; | |
88 | - $uibModalInstance.close(precioCondicion); | |
85 | + var mod = $scope.associatedList ? parseInt($scope.listaDePreciosAsociada.ID) : parseInt($scope.listaDePreciosAlternativa.ID); | |
86 | + | |
87 | + focaModalPrecioCondicionService.actualizarLista(parametros.idCliente, mod).then(function (){ | |
88 | + var precioCondicion = { | |
89 | + listaPrecio: $scope.associatedList ? $scope.listaDePreciosAsociada : $scope.listaDePreciosAlternativa, | |
90 | + }; | |
91 | + $uibModalInstance.close(precioCondicion); | |
92 | + }); | |
89 | 93 | }; |
90 | 94 | } |
91 | 95 | ]) |
... | ... | @@ -99,15 +103,15 @@ angular.module('focaModalPrecioCondicion') |
99 | 103 | '$uibModalInstance', |
100 | 104 | 'focaModalService', |
101 | 105 | 'focaModalPrecioCondicionService', |
102 | - 'idCliente', | |
106 | + 'parametros', | |
103 | 107 | function ( |
104 | 108 | $timeout, $filter, $scope, $uibModal, $uibModalInstance, |
105 | - focaModalService, focaModalPrecioCondicionService,idCliente | |
109 | + focaModalService, focaModalPrecioCondicionService,parametros | |
106 | 110 | ) { |
107 | 111 | $scope.plazos = [ |
108 | 112 | { |
109 | 113 | dias: 0, |
110 | - idCliente: idCliente, | |
114 | + idCliente: parametros.idCliente, | |
111 | 115 | activo: true |
112 | 116 | } |
113 | 117 | ]; |
... | ... | @@ -115,7 +119,7 @@ angular.module('focaModalPrecioCondicion') |
115 | 119 | onInit(); |
116 | 120 | |
117 | 121 | function onInit() { |
118 | - focaModalPrecioCondicionService.getPlazosByIdCliente(idCliente) | |
122 | + focaModalPrecioCondicionService.getPlazosByIdCliente(parametros.idCliente) | |
119 | 123 | .then(function (res) { |
120 | 124 | res.data.forEach(function (item) { |
121 | 125 | $scope.plazos.push(item); |
... | ... | @@ -134,7 +138,7 @@ angular.module('focaModalPrecioCondicion') |
134 | 138 | return; |
135 | 139 | } |
136 | 140 | } |
137 | - $scope.plazos.unshift({ dias: 0, idCliente: idCliente, activo: true }); | |
141 | + $scope.plazos.unshift({ dias: 0, idCliente: parametros.idCliente, activo: true }); | |
138 | 142 | $scope.focused = 1; |
139 | 143 | }; |
140 | 144 | $scope.deletePlazo = function (index) { |
src/js/service.js
... | ... | @@ -26,6 +26,9 @@ angular.module('focaModalPrecioCondicion') |
26 | 26 | }, |
27 | 27 | createPlazo: function (plazosPago){ |
28 | 28 | return $http.post(API_ENDPOINT.URL + '/plazos-pago', { plazosPago: plazosPago }); |
29 | + }, | |
30 | + actualizarLista: function(id , mod) { | |
31 | + return $http.post(API_ENDPOINT.URL + '/cliente/update/mod', { id: id, mod: mod}); | |
29 | 32 | } |
30 | 33 | }; |
31 | 34 | } |