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