Commit ce0ef7f7b52f600fb0c8537f169dae433f6fb6db
1 parent
0ed74d25c8
Exists in
master
Revert "validacion domicilio antes de guardar"
This reverts commit 0ed74d25c8a6ebbd6e783d226e737c0520353971.
Showing
1 changed file
with
2 additions
and
5 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$timeout', | 7 | '$timeout', |
8 | 'crearNotaPedidoService', | 8 | 'crearNotaPedidoService', |
9 | 'focaBotoneraLateralService', | 9 | 'focaBotoneraLateralService', |
10 | 'focaModalService', | 10 | 'focaModalService', |
11 | 'notaPedidoBusinessService', | 11 | 'notaPedidoBusinessService', |
12 | '$rootScope', | 12 | '$rootScope', |
13 | 'focaSeguimientoService', | 13 | 'focaSeguimientoService', |
14 | 'APP', | 14 | 'APP', |
15 | 'focaLoginService', | 15 | 'focaLoginService', |
16 | function( | 16 | function( |
17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, | 17 | $scope, $uibModal, $location, $filter, $timeout, crearNotaPedidoService, |
18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 18 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, |
19 | $rootScope, focaSeguimientoService, APP, focaLoginService) | 19 | $rootScope, focaSeguimientoService, APP, focaLoginService) |
20 | { | 20 | { |
21 | config(); | 21 | config(); |
22 | 22 | ||
23 | function config() { | 23 | function config() { |
24 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 24 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA |
25 | $scope.isNumber = angular.isNumber; | 25 | $scope.isNumber = angular.isNumber; |
26 | $scope.datepickerAbierto = false; | 26 | $scope.datepickerAbierto = false; |
27 | $scope.show = false; | 27 | $scope.show = false; |
28 | $scope.cargando = true; | 28 | $scope.cargando = true; |
29 | $scope.now = new Date(); | 29 | $scope.now = new Date(); |
30 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 30 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
31 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 31 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
32 | $scope.dateOptions = { | 32 | $scope.dateOptions = { |
33 | maxDate: new Date(), | 33 | maxDate: new Date(), |
34 | minDate: new Date(2010, 0, 1) | 34 | minDate: new Date(2010, 0, 1) |
35 | }; | 35 | }; |
36 | 36 | ||
37 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 37 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
38 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
40 | monedaPorDefecto = res.data[0]; | 40 | monedaPorDefecto = res.data[0]; |
41 | 41 | ||
42 | $scope.notaPedido.moneda = monedaPorDefecto; | 42 | $scope.notaPedido.moneda = monedaPorDefecto; |
43 | $scope.inicial.notaPedido.moneda = $scope.notaPedido.moneda; | 43 | $scope.inicial.notaPedido.moneda = $scope.notaPedido.moneda; |
44 | 44 | ||
45 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 45 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
46 | $scope.inicial.notaPedido.cotizacion = $scope.notaPedido.cotizacion; | 46 | $scope.inicial.notaPedido.cotizacion = $scope.notaPedido.cotizacion; |
47 | }); | 47 | }); |
48 | 48 | ||
49 | //SETEO BOTONERA LATERAL | 49 | //SETEO BOTONERA LATERAL |
50 | $timeout(function() { | 50 | $timeout(function() { |
51 | focaBotoneraLateralService.showSalir(false); | 51 | focaBotoneraLateralService.showSalir(false); |
52 | focaBotoneraLateralService.showPausar(true); | 52 | focaBotoneraLateralService.showPausar(true); |
53 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | 53 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); |
54 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 54 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
55 | }); | 55 | }); |
56 | 56 | ||
57 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR | 57 | // SETEA BOTONERA DE FACTURADOR TENIENDO EN CUENTA SI ESTA SETEADO EL VENDEDOR |
58 | if (APP === 'distribuidor') { | 58 | if (APP === 'distribuidor') { |
59 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; | 59 | $scope.idVendedor = focaLoginService.getLoginData().vendedorCobrador; |
60 | $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); | 60 | $scope.botonera = crearNotaPedidoService.getBotonera($scope.idVendedor); |
61 | } else { | 61 | } else { |
62 | $scope.botonera = crearNotaPedidoService.getBotonera(); | 62 | $scope.botonera = crearNotaPedidoService.getBotonera(); |
63 | } | 63 | } |
64 | 64 | ||
65 | init(); | 65 | init(); |
66 | } | 66 | } |
67 | 67 | ||
68 | function init() { | 68 | function init() { |
69 | $scope.$broadcast('cleanCabecera'); | 69 | $scope.$broadcast('cleanCabecera'); |
70 | 70 | ||
71 | $scope.notaPedido = { | 71 | $scope.notaPedido = { |
72 | id: 0, | 72 | id: 0, |
73 | cliente: {}, | 73 | cliente: {}, |
74 | proveedor: {}, | 74 | proveedor: {}, |
75 | domicilio: {dom: ''}, | 75 | domicilio: {dom: ''}, |
76 | vendedor: {} | 76 | vendedor: {} |
77 | }; | 77 | }; |
78 | 78 | ||
79 | $scope.articulosTabla = []; | 79 | $scope.articulosTabla = []; |
80 | $scope.idLista = undefined; | 80 | $scope.idLista = undefined; |
81 | 81 | ||
82 | crearNotaPedidoService.getNumeroNotaPedido().then( | 82 | crearNotaPedidoService.getNumeroNotaPedido().then( |
83 | function(res) { | 83 | function(res) { |
84 | $scope.puntoVenta = $filter('rellenarDigitos')( | 84 | $scope.puntoVenta = $filter('rellenarDigitos')( |
85 | res.data.sucursal, 4 | 85 | res.data.sucursal, 4 |
86 | ); | 86 | ); |
87 | 87 | ||
88 | $scope.comprobante = $filter('rellenarDigitos')( | 88 | $scope.comprobante = $filter('rellenarDigitos')( |
89 | res.data.numeroNotaPedido, 8 | 89 | res.data.numeroNotaPedido, 8 |
90 | ); | 90 | ); |
91 | }, | 91 | }, |
92 | function(err) { | 92 | function(err) { |
93 | focaModalService.alert('La terminal no esta configurada correctamente'); | 93 | focaModalService.alert('La terminal no esta configurada correctamente'); |
94 | console.info(err); | 94 | console.info(err); |
95 | } | 95 | } |
96 | ); | 96 | ); |
97 | 97 | ||
98 | if (APP === 'distribuidor') { | 98 | if (APP === 'distribuidor') { |
99 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( | 99 | crearNotaPedidoService.getVendedorById($scope.idVendedor).then( |
100 | function(res) { | 100 | function(res) { |
101 | var vendedor = res.data; | 101 | var vendedor = res.data; |
102 | $scope.$broadcast('addCabecera', { | 102 | $scope.$broadcast('addCabecera', { |
103 | label: 'Vendedor:', | 103 | label: 'Vendedor:', |
104 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 104 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
105 | vendedor.NOM | 105 | vendedor.NOM |
106 | }); | 106 | }); |
107 | 107 | ||
108 | $scope.notaPedido.vendedor = vendedor; | 108 | $scope.notaPedido.vendedor = vendedor; |
109 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; | 109 | $scope.inicial.notaPedido.vendedor =$scope.notaPedido.vendedor; |
110 | } | 110 | } |
111 | ); | 111 | ); |
112 | } | 112 | } |
113 | 113 | ||
114 | $scope.inicial = { | 114 | $scope.inicial = { |
115 | notaPedido: angular.copy($scope.notaPedido), | 115 | notaPedido: angular.copy($scope.notaPedido), |
116 | articulosTabla: angular.copy($scope.articulosTabla), | 116 | articulosTabla: angular.copy($scope.articulosTabla), |
117 | idLista: angular.copy($scope.idLista) | 117 | idLista: angular.copy($scope.idLista) |
118 | }; | 118 | }; |
119 | } | 119 | } |
120 | 120 | ||
121 | $scope.crearNotaPedido = function() { | 121 | $scope.crearNotaPedido = function() { |
122 | if(!$scope.notaPedido.vendedor.id) { | 122 | if(!$scope.notaPedido.vendedor.id) { |
123 | focaModalService.alert('Ingrese Vendedor'); | 123 | focaModalService.alert('Ingrese Vendedor'); |
124 | return; | 124 | return; |
125 | } else if(!$scope.notaPedido.cliente.COD) { | 125 | } else if(!$scope.notaPedido.cliente.COD) { |
126 | focaModalService.alert('Ingrese Cliente'); | 126 | focaModalService.alert('Ingrese Cliente'); |
127 | return; | 127 | return; |
128 | } else if(!$scope.notaPedido.proveedor.COD) { | 128 | } else if(!$scope.notaPedido.proveedor.COD) { |
129 | focaModalService.alert('Ingrese Proveedor'); | 129 | focaModalService.alert('Ingrese Proveedor'); |
130 | return; | 130 | return; |
131 | } else if(!$scope.notaPedido.moneda.ID) { | 131 | } else if(!$scope.notaPedido.moneda.ID) { |
132 | focaModalService.alert('Ingrese Moneda'); | 132 | focaModalService.alert('Ingrese Moneda'); |
133 | return; | 133 | return; |
134 | } else if(!$scope.notaPedido.cotizacion.ID) { | 134 | } else if(!$scope.notaPedido.cotizacion.ID) { |
135 | focaModalService.alert('Ingrese Cotización'); | 135 | focaModalService.alert('Ingrese Cotización'); |
136 | return; | 136 | return; |
137 | } else if(!$scope.plazosPagos) { | 137 | } else if(!$scope.plazosPagos) { |
138 | focaModalService.alert('Ingrese Precios y Condiciones'); | 138 | focaModalService.alert('Ingrese Precios y Condiciones'); |
139 | return; | 139 | return; |
140 | } else if( | 140 | } else if( |
141 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 141 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
142 | { | 142 | { |
143 | focaModalService.alert('Ingrese Flete'); | 143 | focaModalService.alert('Ingrese Flete'); |
144 | return; | 144 | return; |
145 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto | 145 | } else if(!$scope.notaPedido.domicilioStamp) {//TODO validar domicilio correcto |
146 | focaModalService.alert('Ingrese Domicilio'); | 146 | focaModalService.alert('Ingrese Domicilio'); |
147 | return; | 147 | return; |
148 | } else if($scope.articulosTabla.length === 0) { | 148 | } else if($scope.articulosTabla.length === 0) { |
149 | focaModalService.alert('Debe cargar al menos un articulo'); | 149 | focaModalService.alert('Debe cargar al menos un articulo'); |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | focaBotoneraLateralService.startGuardar(); | 152 | focaBotoneraLateralService.startGuardar(); |
153 | $scope.saveLoading = true; | 153 | $scope.saveLoading = true; |
154 | var notaPedido = { | 154 | var notaPedido = { |
155 | id: $scope.notaPedido.id, | 155 | id: $scope.notaPedido.id, |
156 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 156 | fechaCarga: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
157 | idVendedor: $scope.notaPedido.vendedor.id, | 157 | idVendedor: $scope.notaPedido.vendedor.id, |
158 | idCliente: $scope.notaPedido.cliente.COD, | 158 | idCliente: $scope.notaPedido.cliente.COD, |
159 | nombreCliente: $scope.notaPedido.cliente.NOM, | 159 | nombreCliente: $scope.notaPedido.cliente.NOM, |
160 | cuitCliente: $scope.notaPedido.cliente.CUIT, | 160 | cuitCliente: $scope.notaPedido.cliente.CUIT, |
161 | idProveedor: $scope.notaPedido.proveedor.COD, | 161 | idProveedor: $scope.notaPedido.proveedor.COD, |
162 | idDomicilio: $scope.notaPedido.domicilio.id, | ||
162 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 163 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
163 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 164 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
164 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 165 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
165 | flete: $scope.notaPedido.flete, | 166 | flete: $scope.notaPedido.flete, |
166 | fob: $scope.notaPedido.fob, | 167 | fob: $scope.notaPedido.fob, |
167 | bomba: $scope.notaPedido.bomba, | 168 | bomba: $scope.notaPedido.bomba, |
168 | kilometros: $scope.notaPedido.kilometros, | 169 | kilometros: $scope.notaPedido.kilometros, |
170 | domicilioStamp: $scope.notaPedido.domicilioStamp, | ||
169 | observaciones: $scope.notaPedido.observaciones, | 171 | observaciones: $scope.notaPedido.observaciones, |
170 | estado: 0, | 172 | estado: 0, |
171 | total: $scope.getTotal() | 173 | total: $scope.getTotal() |
172 | }; | 174 | }; |
173 | |||
174 | if ($scope.notaPedido.domicilio) { | ||
175 | notaPedido.idDomicilio = $scope.notaPedido.domicilio.id; | ||
176 | notaPedido.domicilioStamp = $scope.notaPedido.domicilioStamp; | ||
177 | } | ||
178 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 175 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
179 | function(data) { | 176 | function(data) { |
180 | // Al guardar los datos de la nota de pedido logueamos la | 177 | // Al guardar los datos de la nota de pedido logueamos la |
181 | // actividad para su seguimiento. | 178 | // actividad para su seguimiento. |
182 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? | 179 | //TODO: GUARDAR POSISIONAMIENTO AL EDITAR? |
183 | focaSeguimientoService.guardarPosicion( | 180 | focaSeguimientoService.guardarPosicion( |
184 | 'Nota de pedido', | 181 | 'Nota de pedido', |
185 | data.data.id, | 182 | data.data.id, |
186 | '' | 183 | '' |
187 | ); | 184 | ); |
188 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 185 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
189 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 186 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
190 | 187 | ||
191 | if($scope.notaPedido.puntosDescarga) { | 188 | if($scope.notaPedido.puntosDescarga) { |
192 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, | 189 | notaPedidoBusinessService.addPuntosDescarga(data.data.id, |
193 | $scope.notaPedido.puntosDescarga); | 190 | $scope.notaPedido.puntosDescarga); |
194 | } | 191 | } |
195 | 192 | ||
196 | var plazos = $scope.plazosPagos; | 193 | var plazos = $scope.plazosPagos; |
197 | var plazosACrear = []; | 194 | var plazosACrear = []; |
198 | plazos.forEach(function(plazo) { | 195 | plazos.forEach(function(plazo) { |
199 | plazosACrear.push({ | 196 | plazosACrear.push({ |
200 | idNotaPedido: data.data.id, | 197 | idNotaPedido: data.data.id, |
201 | dias: plazo.dias | 198 | dias: plazo.dias |
202 | }); | 199 | }); |
203 | }); | 200 | }); |
204 | 201 | ||
205 | if (plazosACrear.length) { | 202 | if (plazosACrear.length) { |
206 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); | 203 | crearNotaPedidoService.crearPlazosParaNotaPedido(plazosACrear); |
207 | } | 204 | } |
208 | 205 | ||
209 | notaPedidoBusinessService.addEstado(data.data.id, | 206 | notaPedidoBusinessService.addEstado(data.data.id, |
210 | $scope.notaPedido.vendedor.id); | 207 | $scope.notaPedido.vendedor.id); |
211 | 208 | ||
212 | focaBotoneraLateralService.endGuardar(true); | 209 | focaBotoneraLateralService.endGuardar(true); |
213 | $scope.saveLoading = false; | 210 | $scope.saveLoading = false; |
214 | 211 | ||
215 | init(); | 212 | init(); |
216 | }, function(error) { | 213 | }, function(error) { |
217 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 214 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
218 | focaBotoneraLateralService.endGuardar(); | 215 | focaBotoneraLateralService.endGuardar(); |
219 | $scope.saveLoading = false; | 216 | $scope.saveLoading = false; |
220 | console.info(error); | 217 | console.info(error); |
221 | } | 218 | } |
222 | ); | 219 | ); |
223 | }; | 220 | }; |
224 | 221 | ||
225 | $scope.seleccionarNotaPedido = function() { | 222 | $scope.seleccionarNotaPedido = function() { |
226 | var modalInstance = $uibModal.open( | 223 | var modalInstance = $uibModal.open( |
227 | { | 224 | { |
228 | ariaLabelledBy: 'Busqueda de Nota de Pedido', | 225 | ariaLabelledBy: 'Busqueda de Nota de Pedido', |
229 | templateUrl: 'foca-modal-nota-pedido.html', | 226 | templateUrl: 'foca-modal-nota-pedido.html', |
230 | controller: 'focaModalNotaPedidoController', | 227 | controller: 'focaModalNotaPedidoController', |
231 | size: 'lg', | 228 | size: 'lg', |
232 | resolve: { | 229 | resolve: { |
233 | usadoPor: function() {return 'notaPedido';}, | 230 | usadoPor: function() {return 'notaPedido';}, |
234 | idVendedor: function() { | 231 | idVendedor: function() { |
235 | if(APP === 'distribuidor') | 232 | if(APP === 'distribuidor') |
236 | return $scope.notaPedido.vendedor.id; | 233 | return $scope.notaPedido.vendedor.id; |
237 | else | 234 | else |
238 | return null; | 235 | return null; |
239 | } | 236 | } |
240 | } | 237 | } |
241 | } | 238 | } |
242 | ); | 239 | ); |
243 | modalInstance.result.then( | 240 | modalInstance.result.then( |
244 | function(notaPedido) { | 241 | function(notaPedido) { |
245 | $scope.now = new Date(notaPedido.fechaCarga); | 242 | $scope.now = new Date(notaPedido.fechaCarga); |
246 | //añado cabeceras | 243 | //añado cabeceras |
247 | $scope.notaPedido.id = notaPedido.id; | 244 | $scope.notaPedido.id = notaPedido.id; |
248 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 245 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
249 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 246 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
250 | var cabeceras = [ | 247 | var cabeceras = [ |
251 | { | 248 | { |
252 | label: 'Moneda:', | 249 | label: 'Moneda:', |
253 | valor: notaPedido.cotizacion.moneda.DETALLE | 250 | valor: notaPedido.cotizacion.moneda.DETALLE |
254 | }, | 251 | }, |
255 | { | 252 | { |
256 | label: 'Fecha cotizacion:', | 253 | label: 'Fecha cotizacion:', |
257 | valor: $filter('date')(notaPedido.cotizacion.FECHA, | 254 | valor: $filter('date')(notaPedido.cotizacion.FECHA, |
258 | 'dd/MM/yyyy') | 255 | 'dd/MM/yyyy') |
259 | }, | 256 | }, |
260 | { | 257 | { |
261 | label: 'Cotizacion:', | 258 | label: 'Cotizacion:', |
262 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, | 259 | valor: $filter('number')(notaPedido.cotizacion.VENDEDOR, |
263 | '2') | 260 | '2') |
264 | }, | 261 | }, |
265 | { | 262 | { |
266 | label: 'Cliente:', | 263 | label: 'Cliente:', |
267 | valor: notaPedido.cliente.NOM | 264 | valor: notaPedido.cliente.NOM |
268 | }, | 265 | }, |
269 | { | 266 | { |
270 | label: 'Domicilio:', | 267 | label: 'Domicilio:', |
271 | valor: notaPedido.domicilioStamp | 268 | valor: notaPedido.domicilioStamp |
272 | }, | 269 | }, |
273 | { | 270 | { |
274 | label: 'Vendedor:', | 271 | label: 'Vendedor:', |
275 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + | 272 | valor: $filter('rellenarDigitos')(notaPedido.vendedor.NUM, 3) + |
276 | ' - ' + notaPedido.vendedor.NOM | 273 | ' - ' + notaPedido.vendedor.NOM |
277 | }, | 274 | }, |
278 | { | 275 | { |
279 | label: 'Proveedor:', | 276 | label: 'Proveedor:', |
280 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + | 277 | valor: $filter('rellenarDigitos')(notaPedido.proveedor.COD, 5) + |
281 | ' - ' + notaPedido.proveedor.NOM | 278 | ' - ' + notaPedido.proveedor.NOM |
282 | }, | 279 | }, |
283 | { | 280 | { |
284 | label: 'Precios y condiciones:', | 281 | label: 'Precios y condiciones:', |
285 | valor: valorPrecioCondicion() + ' ' + | 282 | valor: valorPrecioCondicion() + ' ' + |
286 | notaPedidoBusinessService | 283 | notaPedidoBusinessService |
287 | .plazoToString(notaPedido.notaPedidoPlazo) | 284 | .plazoToString(notaPedido.notaPedidoPlazo) |
288 | }, | 285 | }, |
289 | { | 286 | { |
290 | label: 'Flete:', | 287 | label: 'Flete:', |
291 | valor: notaPedido.fob === 1 ? 'FOB' : ( | 288 | valor: notaPedido.fob === 1 ? 'FOB' : ( |
292 | notaPedido.flete === 1 ? 'Si' : 'No') | 289 | notaPedido.flete === 1 ? 'Si' : 'No') |
293 | } | 290 | } |
294 | ]; | 291 | ]; |
295 | 292 | ||
296 | function valorPrecioCondicion() { | 293 | function valorPrecioCondicion() { |
297 | if(notaPedido.idPrecioCondicion > 0) { | 294 | if(notaPedido.idPrecioCondicion > 0) { |
298 | return notaPedido.precioCondicion.nombre; | 295 | return notaPedido.precioCondicion.nombre; |
299 | } else { | 296 | } else { |
300 | return 'Ingreso Manual'; | 297 | return 'Ingreso Manual'; |
301 | } | 298 | } |
302 | } | 299 | } |
303 | 300 | ||
304 | if(notaPedido.flete === 1) { | 301 | if(notaPedido.flete === 1) { |
305 | var cabeceraBomba = { | 302 | var cabeceraBomba = { |
306 | label: 'Bomba:', | 303 | label: 'Bomba:', |
307 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' | 304 | valor: notaPedido.bomba === 1 ? 'Si' : 'No' |
308 | }; | 305 | }; |
309 | if(notaPedido.kilometros) { | 306 | if(notaPedido.kilometros) { |
310 | var cabeceraKilometros = { | 307 | var cabeceraKilometros = { |
311 | label: 'Kilometros:', | 308 | label: 'Kilometros:', |
312 | valor: notaPedido.kilometros | 309 | valor: notaPedido.kilometros |
313 | }; | 310 | }; |
314 | cabeceras.push(cabeceraKilometros); | 311 | cabeceras.push(cabeceraKilometros); |
315 | } | 312 | } |
316 | cabeceras.push(cabeceraBomba); | 313 | cabeceras.push(cabeceraBomba); |
317 | } | 314 | } |
318 | 315 | ||
319 | $scope.articulosTabla = notaPedido.articulosNotaPedido; | 316 | $scope.articulosTabla = notaPedido.articulosNotaPedido; |
320 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, | 317 | notaPedidoBusinessService.calcularArticulos($scope.articulosTabla, |
321 | notaPedido.cotizacion.VENDEDOR); | 318 | notaPedido.cotizacion.VENDEDOR); |
322 | 319 | ||
323 | if(notaPedido.idPrecioCondicion > 0) { | 320 | if(notaPedido.idPrecioCondicion > 0) { |
324 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; | 321 | $scope.idLista = notaPedido.precioCondicion.idListaPrecio; |
325 | } else { | 322 | } else { |
326 | $scope.idLista = -1; | 323 | $scope.idLista = -1; |
327 | } | 324 | } |
328 | 325 | ||
329 | $scope.puntoVenta = $filter('rellenarDigitos')( | 326 | $scope.puntoVenta = $filter('rellenarDigitos')( |
330 | notaPedido.sucursal, 4 | 327 | notaPedido.sucursal, 4 |
331 | ); | 328 | ); |
332 | 329 | ||
333 | $scope.comprobante = $filter('rellenarDigitos')( | 330 | $scope.comprobante = $filter('rellenarDigitos')( |
334 | notaPedido.numeroNotaPedido, 8 | 331 | notaPedido.numeroNotaPedido, 8 |
335 | ); | 332 | ); |
336 | 333 | ||
337 | $scope.notaPedido = notaPedido; | 334 | $scope.notaPedido = notaPedido; |
338 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; | 335 | $scope.notaPedido.moneda = notaPedido.cotizacion.moneda; |
339 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; | 336 | $scope.plazosPagos = notaPedido.notaPedidoPlazo; |
340 | $scope.notaPedido.puntosDescarga = | 337 | $scope.notaPedido.puntosDescarga = |
341 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); | 338 | formatearPuntosDescarga(notaPedido.notaPedidoPuntoDescarga); |
342 | addArrayCabecera(cabeceras); | 339 | addArrayCabecera(cabeceras); |
343 | 340 | ||
344 | }, function() { | 341 | }, function() { |
345 | // funcion ejecutada cuando se cancela el modal | 342 | // funcion ejecutada cuando se cancela el modal |
346 | } | 343 | } |
347 | ); | 344 | ); |
348 | }; | 345 | }; |
349 | 346 | ||
350 | $scope.seleccionarProductos = function() { | 347 | $scope.seleccionarProductos = function() { |
351 | if ($scope.idLista === undefined) { | 348 | if ($scope.idLista === undefined) { |
352 | focaModalService.alert( | 349 | focaModalService.alert( |
353 | 'Primero seleccione una lista de precio y condicion'); | 350 | 'Primero seleccione una lista de precio y condicion'); |
354 | return; | 351 | return; |
355 | } | 352 | } |
356 | var modalInstance = $uibModal.open( | 353 | var modalInstance = $uibModal.open( |
357 | { | 354 | { |
358 | ariaLabelledBy: 'Busqueda de Productos', | 355 | ariaLabelledBy: 'Busqueda de Productos', |
359 | templateUrl: 'modal-busqueda-productos.html', | 356 | templateUrl: 'modal-busqueda-productos.html', |
360 | controller: 'modalBusquedaProductosCtrl', | 357 | controller: 'modalBusquedaProductosCtrl', |
361 | resolve: { | 358 | resolve: { |
362 | parametroProducto: { | 359 | parametroProducto: { |
363 | idLista: $scope.idLista, | 360 | idLista: $scope.idLista, |
364 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 361 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
365 | simbolo: $scope.notaPedido.moneda.SIMBOLO | 362 | simbolo: $scope.notaPedido.moneda.SIMBOLO |
366 | } | 363 | } |
367 | }, | 364 | }, |
368 | size: 'lg' | 365 | size: 'lg' |
369 | } | 366 | } |
370 | ); | 367 | ); |
371 | modalInstance.result.then( | 368 | modalInstance.result.then( |
372 | function(producto) { | 369 | function(producto) { |
373 | var newArt = | 370 | var newArt = |
374 | { | 371 | { |
375 | id: 0, | 372 | id: 0, |
376 | codigo: producto.codigo, | 373 | codigo: producto.codigo, |
377 | sector: producto.sector, | 374 | sector: producto.sector, |
378 | sectorCodigo: producto.sector + '-' + producto.codigo, | 375 | sectorCodigo: producto.sector + '-' + producto.codigo, |
379 | descripcion: producto.descripcion, | 376 | descripcion: producto.descripcion, |
380 | item: $scope.articulosTabla.length + 1, | 377 | item: $scope.articulosTabla.length + 1, |
381 | nombre: producto.descripcion, | 378 | nombre: producto.descripcion, |
382 | precio: parseFloat(producto.precio.toFixed(4)), | 379 | precio: parseFloat(producto.precio.toFixed(4)), |
383 | costoUnitario: producto.costo, | 380 | costoUnitario: producto.costo, |
384 | editCantidad: false, | 381 | editCantidad: false, |
385 | editPrecio: false, | 382 | editPrecio: false, |
386 | rubro: producto.CodRub, | 383 | rubro: producto.CodRub, |
387 | exentoUnitario: producto.precio, | 384 | exentoUnitario: producto.precio, |
388 | ivaUnitario: producto.IMPIVA, | 385 | ivaUnitario: producto.IMPIVA, |
389 | impuestoInternoUnitario: producto.ImpInt, | 386 | impuestoInternoUnitario: producto.ImpInt, |
390 | impuestoInterno1Unitario: producto.ImpInt2, | 387 | impuestoInterno1Unitario: producto.ImpInt2, |
391 | impuestoInterno2Unitario: producto.ImpInt3, | 388 | impuestoInterno2Unitario: producto.ImpInt3, |
392 | precioLista: producto.precio, | 389 | precioLista: producto.precio, |
393 | combustible: 1, | 390 | combustible: 1, |
394 | facturado: 0, | 391 | facturado: 0, |
395 | idArticulo: producto.id | 392 | idArticulo: producto.id |
396 | }; | 393 | }; |
397 | $scope.articuloACargar = newArt; | 394 | $scope.articuloACargar = newArt; |
398 | $scope.cargando = false; | 395 | $scope.cargando = false; |
399 | }, function() { | 396 | }, function() { |
400 | // funcion ejecutada cuando se cancela el modal | 397 | // funcion ejecutada cuando se cancela el modal |
401 | } | 398 | } |
402 | ); | 399 | ); |
403 | }; | 400 | }; |
404 | 401 | ||
405 | $scope.seleccionarPuntosDeDescarga = function() { | 402 | $scope.seleccionarPuntosDeDescarga = function() { |
406 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { | 403 | if(!$scope.notaPedido.cliente.COD || !$scope.notaPedido.domicilio.id) { |
407 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); | 404 | focaModalService.alert('Primero seleccione un cliente y un domicilio'); |
408 | return; | 405 | return; |
409 | }else { | 406 | }else { |
410 | var modalInstance = $uibModal.open( | 407 | var modalInstance = $uibModal.open( |
411 | { | 408 | { |
412 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', | 409 | ariaLabelledBy: 'Búsqueda de Puntos de descarga', |
413 | templateUrl: 'modal-punto-descarga.html', | 410 | templateUrl: 'modal-punto-descarga.html', |
414 | controller: 'focaModalPuntoDescargaController', | 411 | controller: 'focaModalPuntoDescargaController', |
415 | size: 'lg', | 412 | size: 'lg', |
416 | resolve: { | 413 | resolve: { |
417 | filters: { | 414 | filters: { |
418 | idDomicilio: $scope.notaPedido.idDomicilio, | 415 | idDomicilio: $scope.notaPedido.idDomicilio, |
419 | idCliente: $scope.notaPedido.cliente.COD, | 416 | idCliente: $scope.notaPedido.cliente.COD, |
420 | articulos: $scope.articulosTabla, | 417 | articulos: $scope.articulosTabla, |
421 | puntosDescarga: $scope.notaPedido.puntosDescarga | 418 | puntosDescarga: $scope.notaPedido.puntosDescarga |
422 | } | 419 | } |
423 | } | 420 | } |
424 | } | 421 | } |
425 | ); | 422 | ); |
426 | modalInstance.result.then( | 423 | modalInstance.result.then( |
427 | function(puntosDescarga) { | 424 | function(puntosDescarga) { |
428 | $scope.notaPedido.puntosDescarga = puntosDescarga; | 425 | $scope.notaPedido.puntosDescarga = puntosDescarga; |
429 | 426 | ||
430 | //AGREGO PUNTOS DE DESCARGA A CABECERA | 427 | //AGREGO PUNTOS DE DESCARGA A CABECERA |
431 | var puntosStamp = ''; | 428 | var puntosStamp = ''; |
432 | puntosDescarga.forEach(function(punto, idx, arr) { | 429 | puntosDescarga.forEach(function(punto, idx, arr) { |
433 | puntosStamp += punto.descripcion; | 430 | puntosStamp += punto.descripcion; |
434 | if((idx + 1) !== arr.length) puntosStamp += ', '; | 431 | if((idx + 1) !== arr.length) puntosStamp += ', '; |
435 | }); | 432 | }); |
436 | 433 | ||
437 | $scope.$broadcast('addCabecera', { | 434 | $scope.$broadcast('addCabecera', { |
438 | label: 'Puntos de descarga:', | 435 | label: 'Puntos de descarga:', |
439 | valor: puntosStamp | 436 | valor: puntosStamp |
440 | }); | 437 | }); |
441 | }, function() { | 438 | }, function() { |
442 | $scope.abrirModalDomicilios($scope.cliente); | 439 | $scope.abrirModalDomicilios($scope.cliente); |
443 | } | 440 | } |
444 | ); | 441 | ); |
445 | } | 442 | } |
446 | }; | 443 | }; |
447 | 444 | ||
448 | $scope.seleccionarVendedor = function() { | 445 | $scope.seleccionarVendedor = function() { |
449 | if(validarNotaRemitada()) { | 446 | if(validarNotaRemitada()) { |
450 | var parametrosModal = { | 447 | var parametrosModal = { |
451 | titulo: 'Búsqueda vendedores', | 448 | titulo: 'Búsqueda vendedores', |
452 | query: '/vendedor', | 449 | query: '/vendedor', |
453 | columnas: [ | 450 | columnas: [ |
454 | { | 451 | { |
455 | propiedad: 'NUM', | 452 | propiedad: 'NUM', |
456 | nombre: 'Código', | 453 | nombre: 'Código', |
457 | filtro: { | 454 | filtro: { |
458 | nombre: 'rellenarDigitos', | 455 | nombre: 'rellenarDigitos', |
459 | parametro: 3 | 456 | parametro: 3 |
460 | } | 457 | } |
461 | }, | 458 | }, |
462 | { | 459 | { |
463 | propiedad: 'NOM', | 460 | propiedad: 'NOM', |
464 | nombre: 'Nombre' | 461 | nombre: 'Nombre' |
465 | } | 462 | } |
466 | ], | 463 | ], |
467 | size: 'md' | 464 | size: 'md' |
468 | }; | 465 | }; |
469 | focaModalService.modal(parametrosModal).then( | 466 | focaModalService.modal(parametrosModal).then( |
470 | function(vendedor) { | 467 | function(vendedor) { |
471 | $scope.$broadcast('addCabecera', { | 468 | $scope.$broadcast('addCabecera', { |
472 | label: 'Vendedor:', | 469 | label: 'Vendedor:', |
473 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + | 470 | valor: $filter('rellenarDigitos')(vendedor.NUM, 3) + ' - ' + |
474 | vendedor.NOM | 471 | vendedor.NOM |
475 | }); | 472 | }); |
476 | $scope.notaPedido.vendedor = vendedor; | 473 | $scope.notaPedido.vendedor = vendedor; |
477 | }, function() { | 474 | }, function() { |
478 | 475 | ||
479 | } | 476 | } |
480 | ); | 477 | ); |
481 | } | 478 | } |
482 | }; | 479 | }; |
483 | 480 | ||
484 | $scope.seleccionarProveedor = function() { | 481 | $scope.seleccionarProveedor = function() { |
485 | if(validarNotaRemitada()) { | 482 | if(validarNotaRemitada()) { |
486 | var parametrosModal = { | 483 | var parametrosModal = { |
487 | titulo: 'Búsqueda de Proveedor', | 484 | titulo: 'Búsqueda de Proveedor', |
488 | query: '/proveedor', | 485 | query: '/proveedor', |
489 | columnas: [ | 486 | columnas: [ |
490 | { | 487 | { |
491 | nombre: 'Código', | 488 | nombre: 'Código', |
492 | propiedad: 'COD', | 489 | propiedad: 'COD', |
493 | filtro: { | 490 | filtro: { |
494 | nombre: 'rellenarDigitos', | 491 | nombre: 'rellenarDigitos', |
495 | parametro: 5 | 492 | parametro: 5 |
496 | } | 493 | } |
497 | }, | 494 | }, |
498 | { | 495 | { |
499 | nombre: 'Nombre', | 496 | nombre: 'Nombre', |
500 | propiedad: 'NOM' | 497 | propiedad: 'NOM' |
501 | }, | 498 | }, |
502 | { | 499 | { |
503 | nombre: 'CUIT', | 500 | nombre: 'CUIT', |
504 | propiedad: 'CUIT' | 501 | propiedad: 'CUIT' |
505 | } | 502 | } |
506 | ], | 503 | ], |
507 | tipo: 'POST', | 504 | tipo: 'POST', |
508 | json: {razonCuitCod: ''} | 505 | json: {razonCuitCod: ''} |
509 | }; | 506 | }; |
510 | focaModalService.modal(parametrosModal).then( | 507 | focaModalService.modal(parametrosModal).then( |
511 | function(proveedor) { | 508 | function(proveedor) { |
512 | $scope.notaPedido.proveedor = proveedor; | 509 | $scope.notaPedido.proveedor = proveedor; |
513 | $scope.$broadcast('addCabecera', { | 510 | $scope.$broadcast('addCabecera', { |
514 | label: 'Proveedor:', | 511 | label: 'Proveedor:', |
515 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 512 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
516 | proveedor.NOM | 513 | proveedor.NOM |
517 | }); | 514 | }); |
518 | }, function() { | 515 | }, function() { |
519 | 516 | ||
520 | } | 517 | } |
521 | ); | 518 | ); |
522 | } | 519 | } |
523 | }; | 520 | }; |
524 | 521 | ||
525 | $scope.seleccionarCliente = function() { | 522 | $scope.seleccionarCliente = function() { |
526 | if(!$scope.notaPedido.vendedor.NUM) { | 523 | if(!$scope.notaPedido.vendedor.NUM) { |
527 | focaModalService.alert('Primero seleccione un vendedor'); | 524 | focaModalService.alert('Primero seleccione un vendedor'); |
528 | return; | 525 | return; |
529 | } | 526 | } |
530 | if(validarNotaRemitada()) { | 527 | if(validarNotaRemitada()) { |
531 | var modalInstance = $uibModal.open( | 528 | var modalInstance = $uibModal.open( |
532 | { | 529 | { |
533 | ariaLabelledBy: 'Busqueda de Cliente', | 530 | ariaLabelledBy: 'Busqueda de Cliente', |
534 | templateUrl: 'foca-busqueda-cliente-modal.html', | 531 | templateUrl: 'foca-busqueda-cliente-modal.html', |
535 | controller: 'focaBusquedaClienteModalController', | 532 | controller: 'focaBusquedaClienteModalController', |
536 | resolve: { | 533 | resolve: { |
537 | vendedor: function() { return $scope.notaPedido.vendedor; } | 534 | vendedor: function() { return $scope.notaPedido.vendedor; } |
538 | }, | 535 | }, |
539 | size: 'lg' | 536 | size: 'lg' |
540 | } | 537 | } |
541 | ); | 538 | ); |
542 | modalInstance.result.then( | 539 | modalInstance.result.then( |
543 | function(cliente) { | 540 | function(cliente) { |
544 | $scope.abrirModalDomicilios(cliente); | 541 | $scope.abrirModalDomicilios(cliente); |
545 | $scope.cliente = cliente; | 542 | $scope.cliente = cliente; |
546 | }, function() {} | 543 | }, function() {} |
547 | ); | 544 | ); |
548 | } | 545 | } |
549 | }; | 546 | }; |
550 | 547 | ||
551 | $scope.abrirModalDomicilios = function(cliente) { | 548 | $scope.abrirModalDomicilios = function(cliente) { |
552 | var modalInstanceDomicilio = $uibModal.open( | 549 | var modalInstanceDomicilio = $uibModal.open( |
553 | { | 550 | { |
554 | ariaLabelledBy: 'Busqueda de Domicilios', | 551 | ariaLabelledBy: 'Busqueda de Domicilios', |
555 | templateUrl: 'modal-domicilio.html', | 552 | templateUrl: 'modal-domicilio.html', |
556 | controller: 'focaModalDomicilioController', | 553 | controller: 'focaModalDomicilioController', |
557 | resolve: { | 554 | resolve: { |
558 | idCliente: function() { return cliente.cod; }, | 555 | idCliente: function() { return cliente.cod; }, |
559 | esNuevo: function() { return cliente.esNuevo; } | 556 | esNuevo: function() { return cliente.esNuevo; } |
560 | }, | 557 | }, |
561 | size: 'lg', | 558 | size: 'lg', |
562 | } | 559 | } |
563 | ); | 560 | ); |
564 | modalInstanceDomicilio.result.then( | 561 | modalInstanceDomicilio.result.then( |
565 | function(domicilio) { | 562 | function(domicilio) { |
566 | $scope.notaPedido.domicilio = domicilio; | 563 | $scope.notaPedido.domicilio = domicilio; |
567 | $scope.notaPedido.cliente = { | 564 | $scope.notaPedido.cliente = { |
568 | COD: cliente.cod, | 565 | COD: cliente.cod, |
569 | CUIT: cliente.cuit, | 566 | CUIT: cliente.cuit, |
570 | NOM: cliente.nom | 567 | NOM: cliente.nom |
571 | }; | 568 | }; |
572 | var domicilioStamp = | 569 | var domicilioStamp = |
573 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 570 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
574 | domicilio.Localidad + ', ' + domicilio.Provincia; | 571 | domicilio.Localidad + ', ' + domicilio.Provincia; |
575 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 572 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
576 | 573 | ||
577 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; | 574 | $scope.notaPedido.puntosDescarga = domicilio.puntosDescarga; |
578 | 575 | ||
579 | $scope.$broadcast('addCabecera', { | 576 | $scope.$broadcast('addCabecera', { |
580 | label: 'Cliente:', | 577 | label: 'Cliente:', |
581 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom | 578 | valor: $filter('rellenarDigitos')(cliente.cod, 5) + ' - ' + cliente.nom |
582 | }); | 579 | }); |
583 | $scope.$broadcast('addCabecera', { | 580 | $scope.$broadcast('addCabecera', { |
584 | label: 'Domicilio:', | 581 | label: 'Domicilio:', |
585 | valor: domicilioStamp | 582 | valor: domicilioStamp |
586 | }); | 583 | }); |
587 | if(domicilio.verPuntos) { | 584 | if(domicilio.verPuntos) { |
588 | delete $scope.notaPedido.domicilio.verPuntos; | 585 | delete $scope.notaPedido.domicilio.verPuntos; |
589 | $scope.seleccionarPuntosDeDescarga(); | 586 | $scope.seleccionarPuntosDeDescarga(); |
590 | }else { | 587 | }else { |
591 | crearNotaPedidoService | 588 | crearNotaPedidoService |
592 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) | 589 | .getPuntosDescargaByClienDom(domicilio.id, cliente.cod) |
593 | .then(function(res) { | 590 | .then(function(res) { |
594 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); | 591 | if(res.data.length) $scope.seleccionarPuntosDeDescarga(); |
595 | }); | 592 | }); |
596 | } | 593 | } |
597 | }, function() { | 594 | }, function() { |
598 | $scope.seleccionarCliente(); | 595 | $scope.seleccionarCliente(); |
599 | return; | 596 | return; |
600 | } | 597 | } |
601 | ); | 598 | ); |
602 | }; | 599 | }; |
603 | 600 | ||
604 | $scope.getTotal = function() { | 601 | $scope.getTotal = function() { |
605 | var total = 0; | 602 | var total = 0; |
606 | var arrayTempArticulos = $scope.articulosTabla; | 603 | var arrayTempArticulos = $scope.articulosTabla; |
607 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 604 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
608 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 605 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
609 | } | 606 | } |
610 | return parseFloat(total.toFixed(2)); | 607 | return parseFloat(total.toFixed(2)); |
611 | }; | 608 | }; |
612 | 609 | ||
613 | $scope.getSubTotal = function() { | 610 | $scope.getSubTotal = function() { |
614 | if($scope.articuloACargar) { | 611 | if($scope.articuloACargar) { |
615 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 612 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
616 | } | 613 | } |
617 | }; | 614 | }; |
618 | 615 | ||
619 | $scope.seleccionarPreciosYCondiciones = function() { | 616 | $scope.seleccionarPreciosYCondiciones = function() { |
620 | if(validarNotaRemitada()) { | 617 | if(validarNotaRemitada()) { |
621 | var modalInstance = $uibModal.open( | 618 | var modalInstance = $uibModal.open( |
622 | { | 619 | { |
623 | ariaLabelledBy: 'Busqueda de Precio Condición', | 620 | ariaLabelledBy: 'Busqueda de Precio Condición', |
624 | templateUrl: 'modal-precio-condicion.html', | 621 | templateUrl: 'modal-precio-condicion.html', |
625 | controller: 'focaModalPrecioCondicionController', | 622 | controller: 'focaModalPrecioCondicionController', |
626 | size: 'lg' | 623 | size: 'lg' |
627 | } | 624 | } |
628 | ); | 625 | ); |
629 | modalInstance.result.then( | 626 | modalInstance.result.then( |
630 | function(precioCondicion) { | 627 | function(precioCondicion) { |
631 | var cabecera = ''; | 628 | var cabecera = ''; |
632 | var plazosConcat = ''; | 629 | var plazosConcat = ''; |
633 | if(!Array.isArray(precioCondicion)) { | 630 | if(!Array.isArray(precioCondicion)) { |
634 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 631 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
635 | $scope.plazosPagos = precioCondicion.plazoPago; | 632 | $scope.plazosPagos = precioCondicion.plazoPago; |
636 | $scope.idLista = precioCondicion.idListaPrecio; | 633 | $scope.idLista = precioCondicion.idListaPrecio; |
637 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 634 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
638 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 635 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
639 | } | 636 | } |
640 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + | 637 | cabecera = $filter('rellenarDigitos')(precioCondicion.id, 4) + |
641 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); | 638 | ' - ' + precioCondicion.nombre + ' ' + plazosConcat.trim(); |
642 | } else { //Cuando se ingresan los plazos manualmente | 639 | } else { //Cuando se ingresan los plazos manualmente |
643 | $scope.notaPedido.idPrecioCondicion = 0; | 640 | $scope.notaPedido.idPrecioCondicion = 0; |
644 | //-1, el modal productos busca todos los productos | 641 | //-1, el modal productos busca todos los productos |
645 | $scope.idLista = -1; | 642 | $scope.idLista = -1; |
646 | $scope.plazosPagos = precioCondicion; | 643 | $scope.plazosPagos = precioCondicion; |
647 | for(var j = 0; j < precioCondicion.length; j++) { | 644 | for(var j = 0; j < precioCondicion.length; j++) { |
648 | plazosConcat += precioCondicion[j].dias + ' '; | 645 | plazosConcat += precioCondicion[j].dias + ' '; |
649 | } | 646 | } |
650 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 647 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
651 | } | 648 | } |
652 | $scope.articulosTabla = []; | 649 | $scope.articulosTabla = []; |
653 | $scope.$broadcast('addCabecera', { | 650 | $scope.$broadcast('addCabecera', { |
654 | label: 'Precios y condiciones:', | 651 | label: 'Precios y condiciones:', |
655 | valor: cabecera | 652 | valor: cabecera |
656 | }); | 653 | }); |
657 | }, function() { | 654 | }, function() { |
658 | 655 | ||
659 | } | 656 | } |
660 | ); | 657 | ); |
661 | } | 658 | } |
662 | }; | 659 | }; |
663 | 660 | ||
664 | $scope.seleccionarFlete = function() { | 661 | $scope.seleccionarFlete = function() { |
665 | if(validarNotaRemitada()) { | 662 | if(validarNotaRemitada()) { |
666 | var modalInstance = $uibModal.open( | 663 | var modalInstance = $uibModal.open( |
667 | { | 664 | { |
668 | ariaLabelledBy: 'Busqueda de Flete', | 665 | ariaLabelledBy: 'Busqueda de Flete', |
669 | templateUrl: 'modal-flete.html', | 666 | templateUrl: 'modal-flete.html', |
670 | controller: 'focaModalFleteController', | 667 | controller: 'focaModalFleteController', |
671 | size: 'lg', | 668 | size: 'lg', |
672 | resolve: { | 669 | resolve: { |
673 | parametrosFlete: | 670 | parametrosFlete: |
674 | function() { | 671 | function() { |
675 | return { | 672 | return { |
676 | flete: $scope.notaPedido.fob ? 'FOB' : | 673 | flete: $scope.notaPedido.fob ? 'FOB' : |
677 | ( $scope.notaPedido.flete ? '1' : | 674 | ( $scope.notaPedido.flete ? '1' : |
678 | ($scope.notaPedido.flete === undefined ? | 675 | ($scope.notaPedido.flete === undefined ? |
679 | null : '0')), | 676 | null : '0')), |
680 | bomba: $scope.notaPedido.bomba ? '1' : | 677 | bomba: $scope.notaPedido.bomba ? '1' : |
681 | ($scope.notaPedido.bomba === undefined ? | 678 | ($scope.notaPedido.bomba === undefined ? |
682 | null : '0'), | 679 | null : '0'), |
683 | kilometros: $scope.notaPedido.kilometros | 680 | kilometros: $scope.notaPedido.kilometros |
684 | }; | 681 | }; |
685 | } | 682 | } |
686 | } | 683 | } |
687 | } | 684 | } |
688 | ); | 685 | ); |
689 | modalInstance.result.then( | 686 | modalInstance.result.then( |
690 | function(datos) { | 687 | function(datos) { |
691 | $scope.notaPedido.flete = datos.flete; | 688 | $scope.notaPedido.flete = datos.flete; |
692 | $scope.notaPedido.fob = datos.FOB; | 689 | $scope.notaPedido.fob = datos.FOB; |
693 | $scope.notaPedido.bomba = datos.bomba; | 690 | $scope.notaPedido.bomba = datos.bomba; |
694 | $scope.notaPedido.kilometros = datos.kilometros; | 691 | $scope.notaPedido.kilometros = datos.kilometros; |
695 | $scope.$broadcast('addCabecera', { | 692 | $scope.$broadcast('addCabecera', { |
696 | label: 'Flete:', | 693 | label: 'Flete:', |
697 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') | 694 | valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') |
698 | }); | 695 | }); |
699 | if(datos.flete) { | 696 | if(datos.flete) { |
700 | $scope.$broadcast('addCabecera', { | 697 | $scope.$broadcast('addCabecera', { |
701 | label: 'Bomba:', | 698 | label: 'Bomba:', |
702 | valor: datos.bomba ? 'Si' : 'No' | 699 | valor: datos.bomba ? 'Si' : 'No' |
703 | }); | 700 | }); |
704 | $scope.$broadcast('addCabecera', { | 701 | $scope.$broadcast('addCabecera', { |
705 | label: 'Kilometros:', | 702 | label: 'Kilometros:', |
706 | valor: datos.kilometros | 703 | valor: datos.kilometros |
707 | }); | 704 | }); |
708 | } else { | 705 | } else { |
709 | $scope.$broadcast('removeCabecera', 'Bomba:'); | 706 | $scope.$broadcast('removeCabecera', 'Bomba:'); |
710 | $scope.$broadcast('removeCabecera', 'Kilometros:'); | 707 | $scope.$broadcast('removeCabecera', 'Kilometros:'); |
711 | $scope.notaPedido.bomba = false; | 708 | $scope.notaPedido.bomba = false; |
712 | $scope.notaPedido.kilometros = null; | 709 | $scope.notaPedido.kilometros = null; |
713 | } | 710 | } |
714 | }, function() { | 711 | }, function() { |
715 | 712 | ||
716 | } | 713 | } |
717 | ); | 714 | ); |
718 | } | 715 | } |
719 | }; | 716 | }; |
720 | 717 | ||
721 | $scope.seleccionarMoneda = function() { | 718 | $scope.seleccionarMoneda = function() { |
722 | if(validarNotaRemitada()) { | 719 | if(validarNotaRemitada()) { |
723 | var parametrosModal = { | 720 | var parametrosModal = { |
724 | titulo: 'Búsqueda de monedas', | 721 | titulo: 'Búsqueda de monedas', |
725 | query: '/moneda', | 722 | query: '/moneda', |
726 | columnas: [ | 723 | columnas: [ |
727 | { | 724 | { |
728 | propiedad: 'DETALLE', | 725 | propiedad: 'DETALLE', |
729 | nombre: 'Nombre' | 726 | nombre: 'Nombre' |
730 | }, | 727 | }, |
731 | { | 728 | { |
732 | propiedad: 'SIMBOLO', | 729 | propiedad: 'SIMBOLO', |
733 | nombre: 'Símbolo' | 730 | nombre: 'Símbolo' |
734 | } | 731 | } |
735 | ], | 732 | ], |
736 | size: 'md' | 733 | size: 'md' |
737 | }; | 734 | }; |
738 | focaModalService.modal(parametrosModal).then( | 735 | focaModalService.modal(parametrosModal).then( |
739 | function(moneda) { | 736 | function(moneda) { |
740 | $scope.abrirModalCotizacion(moneda); | 737 | $scope.abrirModalCotizacion(moneda); |
741 | }, function() { | 738 | }, function() { |
742 | 739 | ||
743 | } | 740 | } |
744 | ); | 741 | ); |
745 | } | 742 | } |
746 | }; | 743 | }; |
747 | 744 | ||
748 | $scope.seleccionarObservaciones = function() { | 745 | $scope.seleccionarObservaciones = function() { |
749 | focaModalService | 746 | focaModalService |
750 | .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) | 747 | .prompt('Ingrese observaciones', $scope.notaPedido.observaciones, true) |
751 | .then(function(observaciones) { | 748 | .then(function(observaciones) { |
752 | $scope.notaPedido.observaciones = observaciones; | 749 | $scope.notaPedido.observaciones = observaciones; |
753 | }); | 750 | }); |
754 | }; | 751 | }; |
755 | 752 | ||
756 | $scope.abrirModalCotizacion = function(moneda) { | 753 | $scope.abrirModalCotizacion = function(moneda) { |
757 | var modalInstance = $uibModal.open( | 754 | var modalInstance = $uibModal.open( |
758 | { | 755 | { |
759 | ariaLabelledBy: 'Busqueda de Cotización', | 756 | ariaLabelledBy: 'Busqueda de Cotización', |
760 | templateUrl: 'modal-cotizacion.html', | 757 | templateUrl: 'modal-cotizacion.html', |
761 | controller: 'focaModalCotizacionController', | 758 | controller: 'focaModalCotizacionController', |
762 | size: 'lg', | 759 | size: 'lg', |
763 | resolve: {idMoneda: function() {return moneda.ID;}} | 760 | resolve: {idMoneda: function() {return moneda.ID;}} |
764 | } | 761 | } |
765 | ); | 762 | ); |
766 | modalInstance.result.then( | 763 | modalInstance.result.then( |
767 | function(cotizacion) { | 764 | function(cotizacion) { |
768 | var articulosTablaTemp = $scope.articulosTabla; | 765 | var articulosTablaTemp = $scope.articulosTabla; |
769 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 766 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
770 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 767 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
771 | $scope.notaPedido.cotizacion.VENDEDOR; | 768 | $scope.notaPedido.cotizacion.VENDEDOR; |
772 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 769 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
773 | cotizacion.VENDEDOR; | 770 | cotizacion.VENDEDOR; |
774 | } | 771 | } |
775 | $scope.articulosTabla = articulosTablaTemp; | 772 | $scope.articulosTabla = articulosTablaTemp; |
776 | $scope.notaPedido.moneda = moneda; | 773 | $scope.notaPedido.moneda = moneda; |
777 | $scope.notaPedido.cotizacion = cotizacion; | 774 | $scope.notaPedido.cotizacion = cotizacion; |
778 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { | 775 | if(moneda.DETALLE === 'PESOS ARGENTINOS') { |
779 | $scope.$broadcast('removeCabecera', 'Moneda:'); | 776 | $scope.$broadcast('removeCabecera', 'Moneda:'); |
780 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); | 777 | $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); |
781 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); | 778 | $scope.$broadcast('removeCabecera', 'Cotizacion:'); |
782 | }else { | 779 | }else { |
783 | $scope.$broadcast('addCabecera', { | 780 | $scope.$broadcast('addCabecera', { |
784 | label: 'Moneda:', | 781 | label: 'Moneda:', |
785 | valor: moneda.DETALLE | 782 | valor: moneda.DETALLE |
786 | }); | 783 | }); |
787 | $scope.$broadcast('addCabecera', { | 784 | $scope.$broadcast('addCabecera', { |
788 | label: 'Fecha cotizacion:', | 785 | label: 'Fecha cotizacion:', |
789 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 786 | valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
790 | }); | 787 | }); |
791 | $scope.$broadcast('addCabecera', { | 788 | $scope.$broadcast('addCabecera', { |
792 | label: 'Cotizacion:', | 789 | label: 'Cotizacion:', |
793 | valor: $filter('number')(cotizacion.VENDEDOR, '2') | 790 | valor: $filter('number')(cotizacion.VENDEDOR, '2') |
794 | }); | 791 | }); |
795 | } | 792 | } |
796 | }, function() { | 793 | }, function() { |
797 | 794 | ||
798 | } | 795 | } |
799 | ); | 796 | ); |
800 | }; | 797 | }; |
801 | 798 | ||
802 | $scope.agregarATabla = function(key) { | 799 | $scope.agregarATabla = function(key) { |
803 | if(key === 13) { | 800 | if(key === 13) { |
804 | if($scope.articuloACargar.cantidad === undefined || | 801 | if($scope.articuloACargar.cantidad === undefined || |
805 | $scope.articuloACargar.cantidad === 0 || | 802 | $scope.articuloACargar.cantidad === 0 || |
806 | $scope.articuloACargar.cantidad === null ) { | 803 | $scope.articuloACargar.cantidad === null ) { |
807 | focaModalService.alert('El valor debe ser al menos 1'); | 804 | focaModalService.alert('El valor debe ser al menos 1'); |
808 | return; | 805 | return; |
809 | } | 806 | } |
810 | delete $scope.articuloACargar.sectorCodigo; | 807 | delete $scope.articuloACargar.sectorCodigo; |
811 | $scope.articulosTabla.push($scope.articuloACargar); | 808 | $scope.articulosTabla.push($scope.articuloACargar); |
812 | $scope.cargando = true; | 809 | $scope.cargando = true; |
813 | } | 810 | } |
814 | }; | 811 | }; |
815 | 812 | ||
816 | $scope.quitarArticulo = function(key) { | 813 | $scope.quitarArticulo = function(key) { |
817 | $scope.articulosTabla.splice(key, 1); | 814 | $scope.articulosTabla.splice(key, 1); |
818 | }; | 815 | }; |
819 | 816 | ||
820 | $scope.editarArticulo = function(key, articulo) { | 817 | $scope.editarArticulo = function(key, articulo) { |
821 | if(key === 13) { | 818 | if(key === 13) { |
822 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 819 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
823 | articulo.cantidad === undefined) { | 820 | articulo.cantidad === undefined) { |
824 | focaModalService.alert('El valor debe ser al menos 1'); | 821 | focaModalService.alert('El valor debe ser al menos 1'); |
825 | return; | 822 | return; |
826 | } | 823 | } |
827 | articulo.editCantidad = false; | 824 | articulo.editCantidad = false; |
828 | articulo.editPrecio = false; | 825 | articulo.editPrecio = false; |
829 | } | 826 | } |
830 | }; | 827 | }; |
831 | 828 | ||
832 | $scope.cambioEdit = function(articulo, propiedad) { | 829 | $scope.cambioEdit = function(articulo, propiedad) { |
833 | if(propiedad === 'cantidad') { | 830 | if(propiedad === 'cantidad') { |
834 | articulo.editCantidad = true; | 831 | articulo.editCantidad = true; |
835 | } else if(propiedad === 'precio') { | 832 | } else if(propiedad === 'precio') { |
836 | articulo.editPrecio = true; | 833 | articulo.editPrecio = true; |
837 | } | 834 | } |
838 | }; | 835 | }; |
839 | 836 | ||
840 | $scope.resetFilter = function() { | 837 | $scope.resetFilter = function() { |
841 | $scope.articuloACargar = {}; | 838 | $scope.articuloACargar = {}; |
842 | $scope.cargando = true; | 839 | $scope.cargando = true; |
843 | }; | 840 | }; |
844 | //Recibe aviso si el teclado está en uso | 841 | //Recibe aviso si el teclado está en uso |
845 | $rootScope.$on('usarTeclado', function(event, data) { | 842 | $rootScope.$on('usarTeclado', function(event, data) { |
846 | if(data) { | 843 | if(data) { |
847 | $scope.mostrarTeclado = true; | 844 | $scope.mostrarTeclado = true; |
848 | return; | 845 | return; |
849 | } | 846 | } |
850 | $scope.mostrarTeclado = false; | 847 | $scope.mostrarTeclado = false; |
851 | }); | 848 | }); |
852 | 849 | ||
853 | $scope.selectFocus = function($event) { | 850 | $scope.selectFocus = function($event) { |
854 | // Si el teclado esta en uso no selecciona el valor | 851 | // Si el teclado esta en uso no selecciona el valor |
855 | if($scope.mostrarTeclado) { | 852 | if($scope.mostrarTeclado) { |
856 | return; | 853 | return; |
857 | } | 854 | } |
858 | $event.target.select(); | 855 | $event.target.select(); |
859 | }; | 856 | }; |
860 | 857 | ||
861 | $scope.salir = function() { | 858 | $scope.salir = function() { |
862 | $location.path('/'); | 859 | $location.path('/'); |
863 | }; | 860 | }; |
864 | 861 | ||
865 | $scope.parsearATexto = function(articulo) { | 862 | $scope.parsearATexto = function(articulo) { |
866 | articulo.cantidad = parseFloat(articulo.cantidad); | 863 | articulo.cantidad = parseFloat(articulo.cantidad); |
867 | articulo.precio = parseFloat(articulo.precio); | 864 | articulo.precio = parseFloat(articulo.precio); |
868 | }; | 865 | }; |
869 | 866 | ||
870 | function addArrayCabecera(array) { | 867 | function addArrayCabecera(array) { |
871 | for(var i = 0; i < array.length; i++) { | 868 | for(var i = 0; i < array.length; i++) { |
872 | $scope.$broadcast('addCabecera', { | 869 | $scope.$broadcast('addCabecera', { |
873 | label: array[i].label, | 870 | label: array[i].label, |
874 | valor: array[i].valor | 871 | valor: array[i].valor |
875 | }); | 872 | }); |
876 | } | 873 | } |
877 | } | 874 | } |
878 | 875 | ||
879 | function validarNotaRemitada() { | 876 | function validarNotaRemitada() { |
880 | if(!$scope.notaPedido.idRemito) { | 877 | if(!$scope.notaPedido.idRemito) { |
881 | return true; | 878 | return true; |
882 | }else{ | 879 | }else{ |
883 | focaModalService.alert('No se puede editar una nota de pedido remitada'); | 880 | focaModalService.alert('No se puede editar una nota de pedido remitada'); |
884 | return false; | 881 | return false; |
885 | } | 882 | } |
886 | } | 883 | } |
887 | 884 | ||
888 | function formatearPuntosDescarga(puntosDescarga) { | 885 | function formatearPuntosDescarga(puntosDescarga) { |
889 | var result = []; | 886 | var result = []; |
890 | 887 | ||
891 | puntosDescarga.forEach(function(el) { | 888 | puntosDescarga.forEach(function(el) { |
892 | var puntoDescarga = result.filter(function(resultPunto) { | 889 | var puntoDescarga = result.filter(function(resultPunto) { |
893 | return resultPunto.id === el.idPuntoDescarga; | 890 | return resultPunto.id === el.idPuntoDescarga; |
894 | }); | 891 | }); |
895 | 892 | ||
896 | if(puntoDescarga.length) { | 893 | if(puntoDescarga.length) { |
897 | puntoDescarga[0].articulosAgregados.push({ | 894 | puntoDescarga[0].articulosAgregados.push({ |
898 | cantidad: el.cantidad, | 895 | cantidad: el.cantidad, |
899 | descripcion: el.producto.descripcion, | 896 | descripcion: el.producto.descripcion, |
900 | id: el.producto.id | 897 | id: el.producto.id |
901 | }); | 898 | }); |
902 | }else { | 899 | }else { |
903 | result.push({ | 900 | result.push({ |
904 | id: el.puntoDescarga.id, | 901 | id: el.puntoDescarga.id, |
905 | id_cliente: el.puntoDescarga.id_cliente, | 902 | id_cliente: el.puntoDescarga.id_cliente, |
906 | id_da_config_0: el.puntoDescarga.id_da_config_0, | 903 | id_da_config_0: el.puntoDescarga.id_da_config_0, |
907 | latitud: el.puntoDescarga.latitud, | 904 | latitud: el.puntoDescarga.latitud, |
908 | longitud: el.puntoDescarga.longitud, | 905 | longitud: el.puntoDescarga.longitud, |
909 | descripcion: el.puntoDescarga.descripcion, | 906 | descripcion: el.puntoDescarga.descripcion, |
910 | articulosAgregados: [ | 907 | articulosAgregados: [ |
911 | { | 908 | { |
912 | cantidad: el.cantidad, | 909 | cantidad: el.cantidad, |
913 | descripcion: el.producto.descripcion, | 910 | descripcion: el.producto.descripcion, |
914 | id: el.producto.id | 911 | id: el.producto.id |
915 | } | 912 | } |
916 | ] | 913 | ] |
917 | }); | 914 | }); |
918 | } | 915 | } |
919 | }); | 916 | }); |
920 | return result; | 917 | return result; |
921 | } | 918 | } |
922 | 919 | ||
923 | function salir() { | 920 | function salir() { |
924 | var confirmacion = false; | 921 | var confirmacion = false; |
925 | 922 | ||
926 | angular.forEach($scope.inicial, function(valor, key) { | 923 | angular.forEach($scope.inicial, function(valor, key) { |
927 | if (!angular.equals($scope[key], $scope.inicial[key])) { | 924 | if (!angular.equals($scope[key], $scope.inicial[key])) { |
928 | confirmacion = true; | 925 | confirmacion = true; |
929 | } | 926 | } |
930 | }); | 927 | }); |
931 | 928 | ||
932 | if (confirmacion) { | 929 | if (confirmacion) { |
933 | focaModalService.confirm( | 930 | focaModalService.confirm( |
934 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 931 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
935 | ).then(function(data) { | 932 | ).then(function(data) { |
936 | if (data) { | 933 | if (data) { |
937 | $location.path('/'); | 934 | $location.path('/'); |
938 | } | 935 | } |
939 | }); | 936 | }); |
940 | } else { | 937 | } else { |
941 | $location.path('/'); | 938 | $location.path('/'); |
942 | } | 939 | } |
943 | } | 940 | } |
944 | } | 941 | } |