Commit b994e4d5d2ead09aaa2e6cc84ab34cde56a99a95
1 parent
d6d63dae0f
Exists in
master
Saqué la lógica de seguimiento.
Showing
1 changed file
with
2 additions
and
4 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
2 | [ | 2 | [ |
3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
4 | 'focaModalService', 'focaSeguimientoService', 'notaPedidoBusinessService', | 4 | 'focaModalService', 'notaPedidoBusinessService', '$rootScope', |
5 | '$rootScope', | ||
6 | function( | 5 | function( |
7 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
8 | focaSeguimientoService, notaPedidoBusinessService, $rootScope | 7 | notaPedidoBusinessService, $rootScope |
9 | ) { | 8 | ) { |
10 | $scope.botonera = [ | 9 | $scope.botonera = [ |
11 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 10 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
12 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 11 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
13 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 12 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
14 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 13 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
15 | { | 14 | { |
16 | texto: 'Precios y condiciones', | 15 | texto: 'Precios y condiciones', |
17 | accion: function() {$scope.abrirModalListaPrecio();}}, | 16 | accion: function() {$scope.abrirModalListaPrecio();}}, |
18 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 17 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
19 | {texto: '', accion: function() {}}, | 18 | {texto: '', accion: function() {}}, |
20 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
21 | ]; | 20 | ]; |
22 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
23 | 22 | ||
24 | $scope.show = false; | 23 | $scope.show = false; |
25 | $scope.cargando = true; | 24 | $scope.cargando = true; |
26 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
27 | maxDate: new Date(), | 26 | maxDate: new Date(), |
28 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
29 | }; | 28 | }; |
30 | 29 | ||
31 | $scope.notaPedido = { | 30 | $scope.notaPedido = { |
32 | vendedor: {}, | 31 | vendedor: {}, |
33 | cliente: {}, | 32 | cliente: {}, |
34 | proveedor: {}, | 33 | proveedor: {}, |
35 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
36 | moneda: {}, | 35 | moneda: {}, |
37 | cotizacion: {} | 36 | cotizacion: {} |
38 | }; | 37 | }; |
39 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
40 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
41 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
42 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
43 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
44 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
45 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
46 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
47 | }; | 46 | }; |
48 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
49 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
50 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
51 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].VENDEDOR); |
52 | $scope.notaPedido.moneda = monedaPorDefecto; | 51 | $scope.notaPedido.moneda = monedaPorDefecto; |
53 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
54 | }); | 53 | }); |
55 | 54 | ||
56 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
57 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
58 | 57 | ||
59 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
60 | $scope.puntoVenta = '0000'; | 59 | $scope.puntoVenta = '0000'; |
61 | $scope.comprobante = '00000000'; | 60 | $scope.comprobante = '00000000'; |
62 | $scope.articulosTabla = []; | 61 | $scope.articulosTabla = []; |
63 | $scope.idLista = undefined; | 62 | $scope.idLista = undefined; |
64 | //La pantalla solo se usa para cargar pedidos | 63 | //La pantalla solo se usa para cargar pedidos |
65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
66 | 65 | ||
67 | crearNotaPedidoService.getPrecioCondicion().then( | 66 | crearNotaPedidoService.getPrecioCondicion().then( |
68 | function(res) { | 67 | function(res) { |
69 | $scope.precioCondiciones = res.data; | 68 | $scope.precioCondiciones = res.data; |
70 | } | 69 | } |
71 | ); | 70 | ); |
72 | 71 | ||
73 | crearNotaPedidoService.getNumeroNotaPedido().then( | 72 | crearNotaPedidoService.getNumeroNotaPedido().then( |
74 | function(res) { | 73 | function(res) { |
75 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | 74 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); |
76 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); | 75 | $scope.comprobante = rellenar(res.data.numeroNotaPedido, 8); |
77 | }, | 76 | }, |
78 | function(err) { | 77 | function(err) { |
79 | focaModalService.alert('La terminal no esta configurada correctamente'); | 78 | focaModalService.alert('La terminal no esta configurada correctamente'); |
80 | console.info(err); | 79 | console.info(err); |
81 | } | 80 | } |
82 | ); | 81 | ); |
83 | //La pantalla solo se usa para cargar pedidos | 82 | //La pantalla solo se usa para cargar pedidos |
84 | // if (notaPedidoTemp !== undefined) { | 83 | // if (notaPedidoTemp !== undefined) { |
85 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 84 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
86 | // $scope.notaPedido = notaPedidoTemp; | 85 | // $scope.notaPedido = notaPedidoTemp; |
87 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 86 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
88 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 87 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
89 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 88 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
90 | // crearNotaPedidoService | 89 | // crearNotaPedidoService |
91 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 90 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
92 | // function(res) { | 91 | // function(res) { |
93 | // $scope.articulosTabla = res.data; | 92 | // $scope.articulosTabla = res.data; |
94 | // } | 93 | // } |
95 | // ); | 94 | // ); |
96 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 95 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
97 | //(NO REQUERIDO EN ESTA VERSION) | 96 | //(NO REQUERIDO EN ESTA VERSION) |
98 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 97 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
99 | // function(res) { | 98 | // function(res) { |
100 | // $scope.notaPedido.domicilio = res.data; | 99 | // $scope.notaPedido.domicilio = res.data; |
101 | // } | 100 | // } |
102 | // ); | 101 | // ); |
103 | // } else { | 102 | // } else { |
104 | // $scope.notaPedido.fechaCarga = new Date(); | 103 | // $scope.notaPedido.fechaCarga = new Date(); |
105 | // $scope.notaPedido.bomba = '0'; | 104 | // $scope.notaPedido.bomba = '0'; |
106 | // $scope.notaPedido.flete = '0'; | 105 | // $scope.notaPedido.flete = '0'; |
107 | // $scope.idLista = undefined; | 106 | // $scope.idLista = undefined; |
108 | // } | 107 | // } |
109 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 108 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
110 | // $scope.addNewDom = function() { | 109 | // $scope.addNewDom = function() { |
111 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 110 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
112 | // }; | 111 | // }; |
113 | // $scope.removeNewChoice = function(choice) { | 112 | // $scope.removeNewChoice = function(choice) { |
114 | // if ($scope.notaPedido.domicilio.length > 1) { | 113 | // if ($scope.notaPedido.domicilio.length > 1) { |
115 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 114 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
116 | // function(c) { | 115 | // function(c) { |
117 | // return c.$$hashKey === choice.$$hashKey; | 116 | // return c.$$hashKey === choice.$$hashKey; |
118 | // } | 117 | // } |
119 | // ), 1); | 118 | // ), 1); |
120 | // } | 119 | // } |
121 | // }; | 120 | // }; |
122 | 121 | ||
123 | $scope.crearNotaPedido = function() { | 122 | $scope.crearNotaPedido = function() { |
124 | if(!$scope.notaPedido.vendedor.codigo) { | 123 | if(!$scope.notaPedido.vendedor.codigo) { |
125 | focaModalService.alert('Ingrese Vendedor'); | 124 | focaModalService.alert('Ingrese Vendedor'); |
126 | return; | 125 | return; |
127 | } else if(!$scope.notaPedido.cliente.cod) { | 126 | } else if(!$scope.notaPedido.cliente.cod) { |
128 | focaModalService.alert('Ingrese Cliente'); | 127 | focaModalService.alert('Ingrese Cliente'); |
129 | return; | 128 | return; |
130 | } else if(!$scope.notaPedido.proveedor.codigo) { | 129 | } else if(!$scope.notaPedido.proveedor.codigo) { |
131 | focaModalService.alert('Ingrese Proveedor'); | 130 | focaModalService.alert('Ingrese Proveedor'); |
132 | return; | 131 | return; |
133 | } else if(!$scope.notaPedido.moneda.id) { | 132 | } else if(!$scope.notaPedido.moneda.id) { |
134 | focaModalService.alert('Ingrese Moneda'); | 133 | focaModalService.alert('Ingrese Moneda'); |
135 | return; | 134 | return; |
136 | } else if(!$scope.notaPedido.cotizacion.ID) { | 135 | } else if(!$scope.notaPedido.cotizacion.ID) { |
137 | focaModalService.alert('Ingrese Cotización'); | 136 | focaModalService.alert('Ingrese Cotización'); |
138 | return; | 137 | return; |
139 | } else if(!$scope.plazosPagos) { | 138 | } else if(!$scope.plazosPagos) { |
140 | focaModalService.alert('Ingrese Precios y Condiciones'); | 139 | focaModalService.alert('Ingrese Precios y Condiciones'); |
141 | return; | 140 | return; |
142 | } else if( | 141 | } else if( |
143 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) | 142 | $scope.notaPedido.flete === undefined || $scope.notaPedido.flete === null) |
144 | { | 143 | { |
145 | focaModalService.alert('Ingrese Flete'); | 144 | focaModalService.alert('Ingrese Flete'); |
146 | return; | 145 | return; |
147 | } else if(!$scope.notaPedido.domicilio.id) { | 146 | } else if(!$scope.notaPedido.domicilio.id) { |
148 | focaModalService.alert('Ingrese Domicilio'); | 147 | focaModalService.alert('Ingrese Domicilio'); |
149 | return; | 148 | return; |
150 | } else if($scope.articulosTabla.length === 0) { | 149 | } else if($scope.articulosTabla.length === 0) { |
151 | focaModalService.alert('Debe cargar al menos un articulo'); | 150 | focaModalService.alert('Debe cargar al menos un articulo'); |
152 | return; | 151 | return; |
153 | } | 152 | } |
154 | var date = new Date(); | 153 | var date = new Date(); |
155 | var notaPedido = { | 154 | var notaPedido = { |
156 | id: 0, | 155 | id: 0, |
157 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 156 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
158 | .toISOString().slice(0, 19).replace('T', ' '), | 157 | .toISOString().slice(0, 19).replace('T', ' '), |
159 | idVendedor: $scope.notaPedido.vendedor.codigo, | 158 | idVendedor: $scope.notaPedido.vendedor.codigo, |
160 | idCliente: $scope.notaPedido.cliente.cod, | 159 | idCliente: $scope.notaPedido.cliente.cod, |
161 | nombreCliente: $scope.notaPedido.cliente.nom, | 160 | nombreCliente: $scope.notaPedido.cliente.nom, |
162 | cuitCliente: $scope.notaPedido.cliente.cuit, | 161 | cuitCliente: $scope.notaPedido.cliente.cuit, |
163 | idProveedor: $scope.notaPedido.proveedor.codigo, | 162 | idProveedor: $scope.notaPedido.proveedor.codigo, |
164 | idDomicilio: $scope.notaPedido.domicilio.id, | 163 | idDomicilio: $scope.notaPedido.domicilio.id, |
165 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 164 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
166 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, | 165 | idPrecioCondicion: $scope.notaPedido.idPrecioCondicion, |
167 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 166 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
168 | flete: $scope.notaPedido.flete, | 167 | flete: $scope.notaPedido.flete, |
169 | fob: $scope.notaPedido.fob, | 168 | fob: $scope.notaPedido.fob, |
170 | bomba: $scope.notaPedido.bomba, | 169 | bomba: $scope.notaPedido.bomba, |
171 | kilometros: $scope.notaPedido.kilometros, | 170 | kilometros: $scope.notaPedido.kilometros, |
172 | domicilioStamp: $scope.notaPedido.domicilioStamp, | 171 | domicilioStamp: $scope.notaPedido.domicilioStamp, |
173 | estado: 0, | 172 | estado: 0, |
174 | total: $scope.getTotal() | 173 | total: $scope.getTotal() |
175 | }; | 174 | }; |
176 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 175 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
177 | function(data) { | 176 | function(data) { |
178 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, | 177 | notaPedidoBusinessService.addArticulos($scope.articulosTabla, |
179 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); | 178 | data.data.id, $scope.notaPedido.cotizacion.VENDEDOR); |
180 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | ||
181 | var plazos = $scope.plazosPagos; | 179 | var plazos = $scope.plazosPagos; |
182 | 180 | ||
183 | for(var j = 0; j < plazos.length; j++) { | 181 | for(var j = 0; j < plazos.length; j++) { |
184 | var json = { | 182 | var json = { |
185 | idPedido: data.data.id, | 183 | idPedido: data.data.id, |
186 | dias: plazos[j].dias | 184 | dias: plazos[j].dias |
187 | }; | 185 | }; |
188 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 186 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
189 | } | 187 | } |
190 | notaPedidoBusinessService.addEstado(data.data.id, | 188 | notaPedidoBusinessService.addEstado(data.data.id, |
191 | $scope.notaPedido.vendedor.codigo); | 189 | $scope.notaPedido.vendedor.codigo); |
192 | 190 | ||
193 | focaModalService.alert('Nota pedido creada'); | 191 | focaModalService.alert('Nota pedido creada'); |
194 | $scope.cabecera = []; | 192 | $scope.cabecera = []; |
195 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 193 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
196 | addCabecera( | 194 | addCabecera( |
197 | 'Fecha cotizacion:', | 195 | 'Fecha cotizacion:', |
198 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 196 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
199 | ); | 197 | ); |
200 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); | 198 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); |
201 | $scope.notaPedido.vendedor = {}; | 199 | $scope.notaPedido.vendedor = {}; |
202 | $scope.notaPedido.cliente = {}; | 200 | $scope.notaPedido.cliente = {}; |
203 | $scope.notaPedido.proveedor = {}; | 201 | $scope.notaPedido.proveedor = {}; |
204 | $scope.notaPedido.domicilio = {}; | 202 | $scope.notaPedido.domicilio = {}; |
205 | $scope.notaPedido.flete = null; | 203 | $scope.notaPedido.flete = null; |
206 | $scope.notaPedido.fob = null; | 204 | $scope.notaPedido.fob = null; |
207 | $scope.notaPedido.bomba = null; | 205 | $scope.notaPedido.bomba = null; |
208 | $scope.notaPedido.kilometros = null; | 206 | $scope.notaPedido.kilometros = null; |
209 | $scope.articulosTabla = []; | 207 | $scope.articulosTabla = []; |
210 | }, | 208 | }, |
211 | function(error) { | 209 | function(error) { |
212 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | 210 | focaModalService.alert('Hubo un error al crear la nota de pedido'); |
213 | console.info(error); | 211 | console.info(error); |
214 | } | 212 | } |
215 | ); | 213 | ); |
216 | }; | 214 | }; |
217 | 215 | ||
218 | $scope.seleccionarArticulo = function() { | 216 | $scope.seleccionarArticulo = function() { |
219 | if ($scope.idLista === undefined) { | 217 | if ($scope.idLista === undefined) { |
220 | focaModalService.alert( | 218 | focaModalService.alert( |
221 | 'Primero seleccione una lista de precio y condicion'); | 219 | 'Primero seleccione una lista de precio y condicion'); |
222 | return; | 220 | return; |
223 | } | 221 | } |
224 | var modalInstance = $uibModal.open( | 222 | var modalInstance = $uibModal.open( |
225 | { | 223 | { |
226 | ariaLabelledBy: 'Busqueda de Productos', | 224 | ariaLabelledBy: 'Busqueda de Productos', |
227 | templateUrl: 'modal-busqueda-productos.html', | 225 | templateUrl: 'modal-busqueda-productos.html', |
228 | controller: 'modalBusquedaProductosCtrl', | 226 | controller: 'modalBusquedaProductosCtrl', |
229 | resolve: { | 227 | resolve: { |
230 | parametroProducto: { | 228 | parametroProducto: { |
231 | idLista: $scope.idLista, | 229 | idLista: $scope.idLista, |
232 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, | 230 | cotizacion: $scope.notaPedido.cotizacion.VENDEDOR, |
233 | simbolo: $scope.notaPedido.moneda.simbolo | 231 | simbolo: $scope.notaPedido.moneda.simbolo |
234 | } | 232 | } |
235 | }, | 233 | }, |
236 | size: 'lg' | 234 | size: 'lg' |
237 | } | 235 | } |
238 | ); | 236 | ); |
239 | modalInstance.result.then( | 237 | modalInstance.result.then( |
240 | function(producto) { | 238 | function(producto) { |
241 | var newArt = | 239 | var newArt = |
242 | { | 240 | { |
243 | id: 0, | 241 | id: 0, |
244 | codigo: producto.codigo, | 242 | codigo: producto.codigo, |
245 | sector: producto.sector, | 243 | sector: producto.sector, |
246 | sectorCodigo: producto.sector + '-' + producto.codigo, | 244 | sectorCodigo: producto.sector + '-' + producto.codigo, |
247 | descripcion: producto.descripcion, | 245 | descripcion: producto.descripcion, |
248 | item: $scope.articulosTabla.length + 1, | 246 | item: $scope.articulosTabla.length + 1, |
249 | nombre: producto.descripcion, | 247 | nombre: producto.descripcion, |
250 | precio: parseFloat(producto.precio.toFixed(4)), | 248 | precio: parseFloat(producto.precio.toFixed(4)), |
251 | costoUnitario: producto.costo, | 249 | costoUnitario: producto.costo, |
252 | editCantidad: false, | 250 | editCantidad: false, |
253 | editPrecio: false | 251 | editPrecio: false |
254 | }; | 252 | }; |
255 | $scope.articuloACargar = newArt; | 253 | $scope.articuloACargar = newArt; |
256 | $scope.cargando = false; | 254 | $scope.cargando = false; |
257 | }, function() { | 255 | }, function() { |
258 | // funcion ejecutada cuando se cancela el modal | 256 | // funcion ejecutada cuando se cancela el modal |
259 | } | 257 | } |
260 | ); | 258 | ); |
261 | }; | 259 | }; |
262 | 260 | ||
263 | $scope.seleccionarVendedor = function() { | 261 | $scope.seleccionarVendedor = function() { |
264 | var modalInstance = $uibModal.open( | 262 | var modalInstance = $uibModal.open( |
265 | { | 263 | { |
266 | ariaLabelledBy: 'Busqueda de Vendedores', | 264 | ariaLabelledBy: 'Busqueda de Vendedores', |
267 | templateUrl: 'modal-vendedores.html', | 265 | templateUrl: 'modal-vendedores.html', |
268 | controller: 'modalVendedoresCtrl', | 266 | controller: 'modalVendedoresCtrl', |
269 | size: 'lg' | 267 | size: 'lg' |
270 | } | 268 | } |
271 | ); | 269 | ); |
272 | modalInstance.result.then( | 270 | modalInstance.result.then( |
273 | function(vendedor) { | 271 | function(vendedor) { |
274 | addCabecera('Vendedor:', vendedor.NomVen); | 272 | addCabecera('Vendedor:', vendedor.NomVen); |
275 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 273 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
276 | }, function() { | 274 | }, function() { |
277 | 275 | ||
278 | } | 276 | } |
279 | ); | 277 | ); |
280 | }; | 278 | }; |
281 | 279 | ||
282 | $scope.seleccionarProveedor = function() { | 280 | $scope.seleccionarProveedor = function() { |
283 | var modalInstance = $uibModal.open( | 281 | var modalInstance = $uibModal.open( |
284 | { | 282 | { |
285 | ariaLabelledBy: 'Busqueda de Proveedor', | 283 | ariaLabelledBy: 'Busqueda de Proveedor', |
286 | templateUrl: 'modal-proveedor.html', | 284 | templateUrl: 'modal-proveedor.html', |
287 | controller: 'focaModalProveedorCtrl', | 285 | controller: 'focaModalProveedorCtrl', |
288 | size: 'lg', | 286 | size: 'lg', |
289 | resolve: { | 287 | resolve: { |
290 | transportista: function() { | 288 | transportista: function() { |
291 | return false; | 289 | return false; |
292 | } | 290 | } |
293 | } | 291 | } |
294 | } | 292 | } |
295 | ); | 293 | ); |
296 | modalInstance.result.then( | 294 | modalInstance.result.then( |
297 | function(proveedor) { | 295 | function(proveedor) { |
298 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 296 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
299 | addCabecera('Proveedor:', proveedor.NOM); | 297 | addCabecera('Proveedor:', proveedor.NOM); |
300 | }, function() { | 298 | }, function() { |
301 | 299 | ||
302 | } | 300 | } |
303 | ); | 301 | ); |
304 | }; | 302 | }; |
305 | 303 | ||
306 | $scope.seleccionarCliente = function() { | 304 | $scope.seleccionarCliente = function() { |
307 | 305 | ||
308 | var modalInstance = $uibModal.open( | 306 | var modalInstance = $uibModal.open( |
309 | { | 307 | { |
310 | ariaLabelledBy: 'Busqueda de Cliente', | 308 | ariaLabelledBy: 'Busqueda de Cliente', |
311 | templateUrl: 'foca-busqueda-cliente-modal.html', | 309 | templateUrl: 'foca-busqueda-cliente-modal.html', |
312 | controller: 'focaBusquedaClienteModalController', | 310 | controller: 'focaBusquedaClienteModalController', |
313 | size: 'lg' | 311 | size: 'lg' |
314 | } | 312 | } |
315 | ); | 313 | ); |
316 | modalInstance.result.then( | 314 | modalInstance.result.then( |
317 | function(cliente) { | 315 | function(cliente) { |
318 | $scope.abrirModalDomicilios(cliente); | 316 | $scope.abrirModalDomicilios(cliente); |
319 | }, function() { | 317 | }, function() { |
320 | 318 | ||
321 | } | 319 | } |
322 | ); | 320 | ); |
323 | }; | 321 | }; |
324 | 322 | ||
325 | $scope.abrirModalDomicilios = function(cliente) { | 323 | $scope.abrirModalDomicilios = function(cliente) { |
326 | var modalInstanceDomicilio = $uibModal.open( | 324 | var modalInstanceDomicilio = $uibModal.open( |
327 | { | 325 | { |
328 | ariaLabelledBy: 'Busqueda de Domicilios', | 326 | ariaLabelledBy: 'Busqueda de Domicilios', |
329 | templateUrl: 'modal-domicilio.html', | 327 | templateUrl: 'modal-domicilio.html', |
330 | controller: 'focaModalDomicilioController', | 328 | controller: 'focaModalDomicilioController', |
331 | resolve: { idCliente: function() { return cliente.cod; }}, | 329 | resolve: { idCliente: function() { return cliente.cod; }}, |
332 | size: 'lg', | 330 | size: 'lg', |
333 | } | 331 | } |
334 | ); | 332 | ); |
335 | modalInstanceDomicilio.result.then( | 333 | modalInstanceDomicilio.result.then( |
336 | function(domicilio) { | 334 | function(domicilio) { |
337 | $scope.notaPedido.domicilio.id = domicilio.id; | 335 | $scope.notaPedido.domicilio.id = domicilio.id; |
338 | $scope.notaPedido.cliente = cliente; | 336 | $scope.notaPedido.cliente = cliente; |
339 | addCabecera('Cliente:', cliente.nom); | 337 | addCabecera('Cliente:', cliente.nom); |
340 | var domicilioStamp = | 338 | var domicilioStamp = |
341 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + | 339 | domicilio.Calle + ' ' + domicilio.Numero + ', ' + |
342 | domicilio.Localidad + ', ' + domicilio.Provincia; | 340 | domicilio.Localidad + ', ' + domicilio.Provincia; |
343 | $scope.notaPedido.domicilioStamp = domicilioStamp; | 341 | $scope.notaPedido.domicilioStamp = domicilioStamp; |
344 | addCabecera('Domicilio:', domicilioStamp); | 342 | addCabecera('Domicilio:', domicilioStamp); |
345 | }, function() { | 343 | }, function() { |
346 | $scope.seleccionarCliente(); | 344 | $scope.seleccionarCliente(); |
347 | return; | 345 | return; |
348 | } | 346 | } |
349 | ); | 347 | ); |
350 | }; | 348 | }; |
351 | 349 | ||
352 | $scope.mostrarFichaCliente = function() { | 350 | $scope.mostrarFichaCliente = function() { |
353 | $uibModal.open( | 351 | $uibModal.open( |
354 | { | 352 | { |
355 | ariaLabelledBy: 'Datos del Cliente', | 353 | ariaLabelledBy: 'Datos del Cliente', |
356 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 354 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
357 | controller: 'focaCrearNotaPedidoFichaClienteController', | 355 | controller: 'focaCrearNotaPedidoFichaClienteController', |
358 | size: 'lg' | 356 | size: 'lg' |
359 | } | 357 | } |
360 | ); | 358 | ); |
361 | }; | 359 | }; |
362 | 360 | ||
363 | $scope.getTotal = function() { | 361 | $scope.getTotal = function() { |
364 | var total = 0; | 362 | var total = 0; |
365 | var arrayTempArticulos = $scope.articulosTabla; | 363 | var arrayTempArticulos = $scope.articulosTabla; |
366 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 364 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
367 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 365 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
368 | } | 366 | } |
369 | return parseFloat(total.toFixed(2)); | 367 | return parseFloat(total.toFixed(2)); |
370 | }; | 368 | }; |
371 | 369 | ||
372 | $scope.getSubTotal = function() { | 370 | $scope.getSubTotal = function() { |
373 | if($scope.articuloACargar) { | 371 | if($scope.articuloACargar) { |
374 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 372 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
375 | } | 373 | } |
376 | }; | 374 | }; |
377 | 375 | ||
378 | $scope.abrirModalListaPrecio = function() { | 376 | $scope.abrirModalListaPrecio = function() { |
379 | var modalInstance = $uibModal.open( | 377 | var modalInstance = $uibModal.open( |
380 | { | 378 | { |
381 | ariaLabelledBy: 'Busqueda de Precio Condición', | 379 | ariaLabelledBy: 'Busqueda de Precio Condición', |
382 | templateUrl: 'modal-precio-condicion.html', | 380 | templateUrl: 'modal-precio-condicion.html', |
383 | controller: 'focaModalPrecioCondicionController', | 381 | controller: 'focaModalPrecioCondicionController', |
384 | size: 'lg' | 382 | size: 'lg' |
385 | } | 383 | } |
386 | ); | 384 | ); |
387 | modalInstance.result.then( | 385 | modalInstance.result.then( |
388 | function(precioCondicion) { | 386 | function(precioCondicion) { |
389 | var cabecera = ''; | 387 | var cabecera = ''; |
390 | var plazosConcat = ''; | 388 | var plazosConcat = ''; |
391 | if(!Array.isArray(precioCondicion)) { | 389 | if(!Array.isArray(precioCondicion)) { |
392 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; | 390 | $scope.notaPedido.idPrecioCondicion = precioCondicion.id; |
393 | $scope.plazosPagos = precioCondicion.plazoPago; | 391 | $scope.plazosPagos = precioCondicion.plazoPago; |
394 | $scope.idLista = precioCondicion.idListaPrecio; | 392 | $scope.idLista = precioCondicion.idListaPrecio; |
395 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 393 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
396 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 394 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
397 | } | 395 | } |
398 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 396 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
399 | } else { //Cuando se ingresan los plazos manualmente | 397 | } else { //Cuando se ingresan los plazos manualmente |
400 | $scope.notaPedido.idPrecioCondicion = 0; | 398 | $scope.notaPedido.idPrecioCondicion = 0; |
401 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 399 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
402 | $scope.plazosPagos = precioCondicion; | 400 | $scope.plazosPagos = precioCondicion; |
403 | for(var j = 0; j < precioCondicion.length; j++) { | 401 | for(var j = 0; j < precioCondicion.length; j++) { |
404 | plazosConcat += precioCondicion[j].dias + ' '; | 402 | plazosConcat += precioCondicion[j].dias + ' '; |
405 | } | 403 | } |
406 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 404 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
407 | } | 405 | } |
408 | $scope.articulosTabla = []; | 406 | $scope.articulosTabla = []; |
409 | addCabecera('Precios y condiciones:', cabecera); | 407 | addCabecera('Precios y condiciones:', cabecera); |
410 | }, function() { | 408 | }, function() { |
411 | 409 | ||
412 | } | 410 | } |
413 | ); | 411 | ); |
414 | }; | 412 | }; |
415 | 413 | ||
416 | $scope.abrirModalFlete = function() { | 414 | $scope.abrirModalFlete = function() { |
417 | var modalInstance = $uibModal.open( | 415 | var modalInstance = $uibModal.open( |
418 | { | 416 | { |
419 | ariaLabelledBy: 'Busqueda de Flete', | 417 | ariaLabelledBy: 'Busqueda de Flete', |
420 | templateUrl: 'modal-flete.html', | 418 | templateUrl: 'modal-flete.html', |
421 | controller: 'focaModalFleteController', | 419 | controller: 'focaModalFleteController', |
422 | size: 'lg', | 420 | size: 'lg', |
423 | resolve: { | 421 | resolve: { |
424 | parametrosFlete: | 422 | parametrosFlete: |
425 | function() { | 423 | function() { |
426 | return { | 424 | return { |
427 | flete: $scope.notaPedido.flete ? '1' : | 425 | flete: $scope.notaPedido.flete ? '1' : |
428 | ($scope.notaPedido.fob ? 'FOB' : | 426 | ($scope.notaPedido.fob ? 'FOB' : |
429 | ($scope.notaPedido.flete === undefined ? null : '0')), | 427 | ($scope.notaPedido.flete === undefined ? null : '0')), |
430 | bomba: $scope.notaPedido.bomba ? '1' : | 428 | bomba: $scope.notaPedido.bomba ? '1' : |
431 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 429 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
432 | kilometros: $scope.notaPedido.kilometros | 430 | kilometros: $scope.notaPedido.kilometros |
433 | }; | 431 | }; |
434 | } | 432 | } |
435 | } | 433 | } |
436 | } | 434 | } |
437 | ); | 435 | ); |
438 | modalInstance.result.then( | 436 | modalInstance.result.then( |
439 | function(datos) { | 437 | function(datos) { |
440 | $scope.notaPedido.flete = datos.flete; | 438 | $scope.notaPedido.flete = datos.flete; |
441 | $scope.notaPedido.fob = datos.FOB; | 439 | $scope.notaPedido.fob = datos.FOB; |
442 | $scope.notaPedido.bomba = datos.bomba; | 440 | $scope.notaPedido.bomba = datos.bomba; |
443 | $scope.notaPedido.kilometros = datos.kilometros; | 441 | $scope.notaPedido.kilometros = datos.kilometros; |
444 | 442 | ||
445 | addCabecera('Flete:', datos.flete ? 'Si' : | 443 | addCabecera('Flete:', datos.flete ? 'Si' : |
446 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 444 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
447 | if(datos.flete) { | 445 | if(datos.flete) { |
448 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 446 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
449 | addCabecera('Kilometros:', datos.kilometros); | 447 | addCabecera('Kilometros:', datos.kilometros); |
450 | } else { | 448 | } else { |
451 | removeCabecera('Bomba:'); | 449 | removeCabecera('Bomba:'); |
452 | removeCabecera('Kilometros:'); | 450 | removeCabecera('Kilometros:'); |
453 | $scope.notaPedido.fob = false; | 451 | $scope.notaPedido.fob = false; |
454 | $scope.notaPedido.bomba = false; | 452 | $scope.notaPedido.bomba = false; |
455 | $scope.notaPedido.kilometros = null; | 453 | $scope.notaPedido.kilometros = null; |
456 | } | 454 | } |
457 | }, function() { | 455 | }, function() { |
458 | 456 | ||
459 | } | 457 | } |
460 | ); | 458 | ); |
461 | }; | 459 | }; |
462 | 460 | ||
463 | $scope.abrirModalMoneda = function() { | 461 | $scope.abrirModalMoneda = function() { |
464 | var modalInstance = $uibModal.open( | 462 | var modalInstance = $uibModal.open( |
465 | { | 463 | { |
466 | ariaLabelledBy: 'Busqueda de Moneda', | 464 | ariaLabelledBy: 'Busqueda de Moneda', |
467 | templateUrl: 'modal-moneda.html', | 465 | templateUrl: 'modal-moneda.html', |
468 | controller: 'focaModalMonedaController', | 466 | controller: 'focaModalMonedaController', |
469 | size: 'lg' | 467 | size: 'lg' |
470 | } | 468 | } |
471 | ); | 469 | ); |
472 | modalInstance.result.then( | 470 | modalInstance.result.then( |
473 | function(moneda) { | 471 | function(moneda) { |
474 | $scope.abrirModalCotizacion(moneda); | 472 | $scope.abrirModalCotizacion(moneda); |
475 | }, function() { | 473 | }, function() { |
476 | 474 | ||
477 | } | 475 | } |
478 | ); | 476 | ); |
479 | }; | 477 | }; |
480 | 478 | ||
481 | $scope.abrirModalCotizacion = function(moneda) { | 479 | $scope.abrirModalCotizacion = function(moneda) { |
482 | var modalInstance = $uibModal.open( | 480 | var modalInstance = $uibModal.open( |
483 | { | 481 | { |
484 | ariaLabelledBy: 'Busqueda de Cotización', | 482 | ariaLabelledBy: 'Busqueda de Cotización', |
485 | templateUrl: 'modal-cotizacion.html', | 483 | templateUrl: 'modal-cotizacion.html', |
486 | controller: 'focaModalCotizacionController', | 484 | controller: 'focaModalCotizacionController', |
487 | size: 'lg', | 485 | size: 'lg', |
488 | resolve: {idMoneda: function() {return moneda.ID;}} | 486 | resolve: {idMoneda: function() {return moneda.ID;}} |
489 | } | 487 | } |
490 | ); | 488 | ); |
491 | modalInstance.result.then( | 489 | modalInstance.result.then( |
492 | function(cotizacion) { | 490 | function(cotizacion) { |
493 | var articulosTablaTemp = $scope.articulosTabla; | 491 | var articulosTablaTemp = $scope.articulosTabla; |
494 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 492 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
495 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 493 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
496 | $scope.notaPedido.cotizacion.VENDEDOR; | 494 | $scope.notaPedido.cotizacion.VENDEDOR; |
497 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 495 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
498 | cotizacion.VENDEDOR; | 496 | cotizacion.VENDEDOR; |
499 | } | 497 | } |
500 | $scope.articulosTabla = articulosTablaTemp; | 498 | $scope.articulosTabla = articulosTablaTemp; |
501 | $scope.notaPedido.moneda = { | 499 | $scope.notaPedido.moneda = { |
502 | id: moneda.ID, | 500 | id: moneda.ID, |
503 | detalle: moneda.DETALLE, | 501 | detalle: moneda.DETALLE, |
504 | simbolo: moneda.SIMBOLO | 502 | simbolo: moneda.SIMBOLO |
505 | }; | 503 | }; |
506 | $scope.notaPedido.cotizacion = cotizacion; | 504 | $scope.notaPedido.cotizacion = cotizacion; |
507 | addCabecera('Moneda:', moneda.DETALLE); | 505 | addCabecera('Moneda:', moneda.DETALLE); |
508 | addCabecera( | 506 | addCabecera( |
509 | 'Fecha cotizacion:', | 507 | 'Fecha cotizacion:', |
510 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 508 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
511 | ); | 509 | ); |
512 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); | 510 | addCabecera('Cotizacion:', cotizacion.VENDEDOR); |
513 | }, function() { | 511 | }, function() { |
514 | 512 | ||
515 | } | 513 | } |
516 | ); | 514 | ); |
517 | }; | 515 | }; |
518 | 516 | ||
519 | $scope.agregarATabla = function(key) { | 517 | $scope.agregarATabla = function(key) { |
520 | if(key === 13) { | 518 | if(key === 13) { |
521 | if($scope.articuloACargar.cantidad === undefined || | 519 | if($scope.articuloACargar.cantidad === undefined || |
522 | $scope.articuloACargar.cantidad === 0 || | 520 | $scope.articuloACargar.cantidad === 0 || |
523 | $scope.articuloACargar.cantidad === null ) { | 521 | $scope.articuloACargar.cantidad === null ) { |
524 | focaModalService.alert('El valor debe ser al menos 1'); | 522 | focaModalService.alert('El valor debe ser al menos 1'); |
525 | return; | 523 | return; |
526 | } | 524 | } |
527 | delete $scope.articuloACargar.sectorCodigo; | 525 | delete $scope.articuloACargar.sectorCodigo; |
528 | $scope.articulosTabla.push($scope.articuloACargar); | 526 | $scope.articulosTabla.push($scope.articuloACargar); |
529 | $scope.cargando = true; | 527 | $scope.cargando = true; |
530 | } | 528 | } |
531 | }; | 529 | }; |
532 | 530 | ||
533 | $scope.quitarArticulo = function(key) { | 531 | $scope.quitarArticulo = function(key) { |
534 | $scope.articulosTabla.splice(key, 1); | 532 | $scope.articulosTabla.splice(key, 1); |
535 | }; | 533 | }; |
536 | 534 | ||
537 | $scope.editarArticulo = function(key, articulo) { | 535 | $scope.editarArticulo = function(key, articulo) { |
538 | if(key === 13) { | 536 | if(key === 13) { |
539 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 537 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
540 | articulo.cantidad === undefined) { | 538 | articulo.cantidad === undefined) { |
541 | focaModalService.alert('El valor debe ser al menos 1'); | 539 | focaModalService.alert('El valor debe ser al menos 1'); |
542 | return; | 540 | return; |
543 | } | 541 | } |
544 | articulo.editCantidad = false; | 542 | articulo.editCantidad = false; |
545 | articulo.editPrecio = false; | 543 | articulo.editPrecio = false; |
546 | } | 544 | } |
547 | }; | 545 | }; |
548 | 546 | ||
549 | $scope.cambioEdit = function(articulo, propiedad) { | 547 | $scope.cambioEdit = function(articulo, propiedad) { |
550 | if(propiedad === 'cantidad') { | 548 | if(propiedad === 'cantidad') { |
551 | articulo.editCantidad = true; | 549 | articulo.editCantidad = true; |
552 | } else if(propiedad === 'precio') { | 550 | } else if(propiedad === 'precio') { |
553 | articulo.editPrecio = true; | 551 | articulo.editPrecio = true; |
554 | } | 552 | } |
555 | }; | 553 | }; |
556 | 554 | ||
557 | $scope.limpiarFlete = function() { | 555 | $scope.limpiarFlete = function() { |
558 | $scope.notaPedido.fleteNombre = ''; | 556 | $scope.notaPedido.fleteNombre = ''; |
559 | $scope.notaPedido.chofer = ''; | 557 | $scope.notaPedido.chofer = ''; |
560 | $scope.notaPedido.vehiculo = ''; | 558 | $scope.notaPedido.vehiculo = ''; |
561 | $scope.notaPedido.kilometros = ''; | 559 | $scope.notaPedido.kilometros = ''; |
562 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 560 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
563 | $scope.choferes = ''; | 561 | $scope.choferes = ''; |
564 | $scope.vehiculos = ''; | 562 | $scope.vehiculos = ''; |
565 | }; | 563 | }; |
566 | 564 | ||
567 | $scope.limpiarPantalla = function() { | 565 | $scope.limpiarPantalla = function() { |
568 | $scope.limpiarFlete(); | 566 | $scope.limpiarFlete(); |
569 | $scope.notaPedido.flete = '0'; | 567 | $scope.notaPedido.flete = '0'; |
570 | $scope.notaPedido.bomba = '0'; | 568 | $scope.notaPedido.bomba = '0'; |
571 | $scope.notaPedido.precioCondicion = ''; | 569 | $scope.notaPedido.precioCondicion = ''; |
572 | $scope.articulosTabla = []; | 570 | $scope.articulosTabla = []; |
573 | $scope.notaPedido.vendedor.nombre = ''; | 571 | $scope.notaPedido.vendedor.nombre = ''; |
574 | $scope.notaPedido.cliente = {nombre: ''}; | 572 | $scope.notaPedido.cliente = {nombre: ''}; |
575 | $scope.notaPedido.domicilio = {dom: ''}; | 573 | $scope.notaPedido.domicilio = {dom: ''}; |
576 | $scope.domiciliosCliente = []; | 574 | $scope.domiciliosCliente = []; |
577 | }; | 575 | }; |
578 | 576 | ||
579 | $scope.resetFilter = function() { | 577 | $scope.resetFilter = function() { |
580 | $scope.articuloACargar = {}; | 578 | $scope.articuloACargar = {}; |
581 | $scope.cargando = true; | 579 | $scope.cargando = true; |
582 | }; | 580 | }; |
583 | //Recibe aviso si el teclado está en uso | 581 | //Recibe aviso si el teclado está en uso |
584 | $rootScope.$on('usarTeclado', function(event, data) { | 582 | $rootScope.$on('usarTeclado', function(event, data) { |
585 | if(data) { | 583 | if(data) { |
586 | $scope.mostrarTeclado = true; | 584 | $scope.mostrarTeclado = true; |
587 | return; | 585 | return; |
588 | } | 586 | } |
589 | $scope.mostrarTeclado = false; | 587 | $scope.mostrarTeclado = false; |
590 | }); | 588 | }); |
591 | 589 | ||
592 | $scope.selectFocus = function($event) { | 590 | $scope.selectFocus = function($event) { |
593 | // Si el teclado esta en uso no selecciona el valor | 591 | // Si el teclado esta en uso no selecciona el valor |
594 | if($scope.mostrarTeclado) { | 592 | if($scope.mostrarTeclado) { |
595 | return; | 593 | return; |
596 | } | 594 | } |
597 | $event.target.select(); | 595 | $event.target.select(); |
598 | }; | 596 | }; |
599 | 597 | ||
600 | $scope.salir = function() { | 598 | $scope.salir = function() { |
601 | $location.path('/'); | 599 | $location.path('/'); |
602 | }; | 600 | }; |
603 | 601 | ||
604 | $scope.parsearATexto = function(articulo) { | 602 | $scope.parsearATexto = function(articulo) { |
605 | articulo.cantidad = parseFloat(articulo.cantidad); | 603 | articulo.cantidad = parseFloat(articulo.cantidad); |
606 | articulo.precio = parseFloat(articulo.precio); | 604 | articulo.precio = parseFloat(articulo.precio); |
607 | }; | 605 | }; |
608 | 606 | ||
609 | function addCabecera(label, valor) { | 607 | function addCabecera(label, valor) { |
610 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 608 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
611 | if(propiedad.length === 1) { | 609 | if(propiedad.length === 1) { |
612 | propiedad[0].valor = valor; | 610 | propiedad[0].valor = valor; |
613 | } else { | 611 | } else { |
614 | $scope.cabecera.push({label: label, valor: valor}); | 612 | $scope.cabecera.push({label: label, valor: valor}); |
615 | } | 613 | } |
616 | } | 614 | } |
617 | 615 | ||
618 | function removeCabecera(label) { | 616 | function removeCabecera(label) { |
619 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 617 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
620 | if(propiedad.length === 1) { | 618 | if(propiedad.length === 1) { |
621 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 619 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
622 | } | 620 | } |
623 | } | 621 | } |
624 | 622 | ||
625 | function rellenar(relleno, longitud) { | 623 | function rellenar(relleno, longitud) { |
626 | relleno = '' + relleno; | 624 | relleno = '' + relleno; |
627 | while (relleno.length < longitud) { | 625 | while (relleno.length < longitud) { |
628 | relleno = '0' + relleno; | 626 | relleno = '0' + relleno; |
629 | } | 627 | } |
630 | 628 | ||
631 | return relleno; | 629 | return relleno; |
632 | } | 630 | } |
633 | } | 631 | } |
634 | ] | 632 | ] |
635 | ) | 633 | ) |
636 | .controller('notaPedidoListaCtrl', [ | 634 | .controller('notaPedidoListaCtrl', [ |
637 | '$scope', | 635 | '$scope', |
638 | 'crearNotaPedidoService', | 636 | 'crearNotaPedidoService', |
639 | '$location', | 637 | '$location', |
640 | function($scope, crearNotaPedidoService, $location) { | 638 | function($scope, crearNotaPedidoService, $location) { |
641 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 639 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
642 | $scope.notaPedidos = datos.data; | 640 | $scope.notaPedidos = datos.data; |
643 | }); | 641 | }); |
644 | $scope.editar = function(notaPedido) { | 642 | $scope.editar = function(notaPedido) { |
645 | crearNotaPedidoService.setNotaPedido(notaPedido); | 643 | crearNotaPedidoService.setNotaPedido(notaPedido); |
646 | $location.path('/venta-nota-pedido/abm/'); | 644 | $location.path('/venta-nota-pedido/abm/'); |
647 | }; | 645 | }; |
648 | $scope.crearPedido = function() { | 646 | $scope.crearPedido = function() { |
649 | crearNotaPedidoService.clearNotaPedido(); | 647 | crearNotaPedidoService.clearNotaPedido(); |
650 | $location.path('/venta-nota-pedido/abm/'); | 648 | $location.path('/venta-nota-pedido/abm/'); |
651 | }; | 649 | }; |
652 | } | 650 | } |
653 | ]) | 651 | ]) |
654 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 652 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
655 | '$scope', | 653 | '$scope', |
656 | 'crearNotaPedidoService', | 654 | 'crearNotaPedidoService', |
657 | '$location', | 655 | '$location', |
658 | function($scope, crearNotaPedidoService, $location) { | 656 | function($scope, crearNotaPedidoService, $location) { |
659 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 657 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
660 | $scope.notaPedidos = datos.data; | 658 | $scope.notaPedidos = datos.data; |
661 | }); | 659 | }); |
662 | $scope.editar = function(notaPedido) { | 660 | $scope.editar = function(notaPedido) { |
663 | crearNotaPedidoService.setNotaPedido(notaPedido); | 661 | crearNotaPedidoService.setNotaPedido(notaPedido); |
664 | $location.path('/venta-nota-pedido/abm/'); | 662 | $location.path('/venta-nota-pedido/abm/'); |
665 | }; | 663 | }; |
666 | $scope.crearPedido = function() { | 664 | $scope.crearPedido = function() { |
667 | crearNotaPedidoService.clearNotaPedido(); | 665 | crearNotaPedidoService.clearNotaPedido(); |
668 | $location.path('/venta-nota-pedido/abm/'); | 666 | $location.path('/venta-nota-pedido/abm/'); |
669 | }; | 667 | }; |
670 | } | 668 | } |
671 | ]); | 669 | ]); |
672 | 670 |