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