Commit 1a818011ea7d1571b24304c5db57758a2ede8149
1 parent
536013389c
Exists in
master
- Cambios según code review.
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearNotaPedido') | 1 | angular.module('focaCrearNotaPedido') |
2 | .controller('notaPedidoCtrl', | 2 | .controller('notaPedidoCtrl', |
3 | ['$scope', '$uibModal', 'crearNotaPedidoService', 'focaModalService', | 3 | ['$scope', '$uibModal', 'crearNotaPedidoService', 'focaModalService', |
4 | function($scope, $uibModal, crearNotaPedidoService, focaModalService) { | 4 | function($scope, $uibModal, crearNotaPedidoService, focaModalService) { |
5 | $scope.botonera = [ | 5 | $scope.botonera = [ |
6 | {texto: 'moneda', accion: function(){console.log('moneda');}}, | 6 | {texto: 'moneda', accion: function() {console.log('moneda');}}, |
7 | { | 7 | { |
8 | texto: 'precios y condiciones', | 8 | texto: 'precios y condiciones', |
9 | accion: function(){$scope.abrirModalListaPrecio();}}, | 9 | accion: function() {$scope.abrirModalListaPrecio();}}, |
10 | {texto: 'flete', accion: function(){$scope.abrirModalFlete();}}, | 10 | {texto: 'flete', accion: function() {$scope.abrirModalFlete();}}, |
11 | {texto: 'bomba', accion: function(){}}, | 11 | {texto: 'bomba', accion: function() {}}, |
12 | {texto: 'detalle', accion: function(){}}, | 12 | {texto: 'detalle', accion: function() {}}, |
13 | {texto: 'totales', accion: function(){}} | 13 | {texto: 'totales', accion: function() {}} |
14 | ]; | 14 | ]; |
15 | $scope.show = false; | 15 | $scope.show = false; |
16 | $scope.cargando = true; | 16 | $scope.cargando = true; |
17 | $scope.dateOptions = { | 17 | $scope.dateOptions = { |
18 | maxDate: new Date(), | 18 | maxDate: new Date(), |
19 | minDate: new Date(2010, 0, 1) | 19 | minDate: new Date(2010, 0, 1) |
20 | }; | 20 | }; |
21 | $scope.notaPedido = { | 21 | $scope.notaPedido = { |
22 | vendedor: {}, | 22 | vendedor: {}, |
23 | cliente: {}, | 23 | cliente: {}, |
24 | domicilio: { dom: ''} | 24 | domicilio: { dom: ''} |
25 | }; | 25 | }; |
26 | $scope.articulosTabla = []; | 26 | $scope.articulosTabla = []; |
27 | var idLista; | 27 | var idLista; |
28 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 28 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
29 | crearNotaPedidoService.getPrecioCondicion().then( | 29 | crearNotaPedidoService.getPrecioCondicion().then( |
30 | function(res) { | 30 | function(res) { |
31 | $scope.precioCondiciones = res.data; | 31 | $scope.precioCondiciones = res.data; |
32 | } | 32 | } |
33 | ); | 33 | ); |
34 | if (notaPedidoTemp !== undefined) { | 34 | if (notaPedidoTemp !== undefined) { |
35 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 35 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
36 | $scope.notaPedido = notaPedidoTemp; | 36 | $scope.notaPedido = notaPedidoTemp; |
37 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 37 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
38 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 38 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
39 | idLista = $scope.notaPedido.precioCondicion; | 39 | idLista = $scope.notaPedido.precioCondicion; |
40 | crearNotaPedidoService | 40 | crearNotaPedidoService |
41 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 41 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
42 | function(res) { | 42 | function(res) { |
43 | $scope.articulosTabla = res.data; | 43 | $scope.articulosTabla = res.data; |
44 | } | 44 | } |
45 | ); | 45 | ); |
46 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 46 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
47 | //(NO REQUERIDO EN ESTA VERSION) | 47 | //(NO REQUERIDO EN ESTA VERSION) |
48 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 48 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
49 | // function(res) { | 49 | // function(res) { |
50 | // $scope.notaPedido.domicilio = res.data; | 50 | // $scope.notaPedido.domicilio = res.data; |
51 | // } | 51 | // } |
52 | // ); | 52 | // ); |
53 | } else { | 53 | } else { |
54 | $scope.notaPedido.fechaCarga = new Date(); | 54 | $scope.notaPedido.fechaCarga = new Date(); |
55 | $scope.notaPedido.bomba = '0'; | 55 | $scope.notaPedido.bomba = '0'; |
56 | $scope.notaPedido.flete = '0'; | 56 | $scope.notaPedido.flete = '0'; |
57 | idLista = undefined; | 57 | idLista = undefined; |
58 | } | 58 | } |
59 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 59 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
60 | // $scope.addNewDom = function() { | 60 | // $scope.addNewDom = function() { |
61 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 61 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
62 | // }; | 62 | // }; |
63 | // $scope.removeNewChoice = function(choice) { | 63 | // $scope.removeNewChoice = function(choice) { |
64 | // if ($scope.notaPedido.domicilio.length > 1) { | 64 | // if ($scope.notaPedido.domicilio.length > 1) { |
65 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 65 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
66 | // function(c) { | 66 | // function(c) { |
67 | // return c.$$hashKey === choice.$$hashKey; | 67 | // return c.$$hashKey === choice.$$hashKey; |
68 | // } | 68 | // } |
69 | // ), 1); | 69 | // ), 1); |
70 | // } | 70 | // } |
71 | // }; | 71 | // }; |
72 | $scope.crearNotaPedido = function() { | 72 | $scope.crearNotaPedido = function() { |
73 | if($scope.articulosTabla.length === 0) { | 73 | if($scope.articulosTabla.length === 0) { |
74 | focaModalService.alert('Debe cargar almenos un articulo'); | 74 | focaModalService.alert('Debe cargar almenos un articulo'); |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | if($scope.notaPedido.domicilio.id === undefined) { | 77 | if($scope.notaPedido.domicilio.id === undefined) { |
78 | $scope.notaPedido.domicilio.id = 0; | 78 | $scope.notaPedido.domicilio.id = 0; |
79 | } | 79 | } |
80 | var date = new Date(); | 80 | var date = new Date(); |
81 | var notaPedido = { | 81 | var notaPedido = { |
82 | id: 0, | 82 | id: 0, |
83 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 83 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
84 | .toISOString().slice(0, 19).replace('T', ' '), | 84 | .toISOString().slice(0, 19).replace('T', ' '), |
85 | vendedor: $scope.notaPedido.vendedor.nombre, | 85 | vendedor: $scope.notaPedido.vendedor.nombre, |
86 | idCliente: $scope.notaPedido.cliente.id, | 86 | idCliente: $scope.notaPedido.cliente.id, |
87 | domicilio: $scope.notaPedido.domicilio, | 87 | domicilio: $scope.notaPedido.domicilio, |
88 | precioCondicion: $scope.notaPedido.precioCondicion, | 88 | precioCondicion: $scope.notaPedido.precioCondicion, |
89 | bomba: $scope.notaPedido.bomba, | 89 | bomba: $scope.notaPedido.bomba, |
90 | flete: $scope.notaPedido.flete, | 90 | flete: $scope.notaPedido.flete, |
91 | total: $scope.getTotal() | 91 | total: $scope.getTotal() |
92 | }; | 92 | }; |
93 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 93 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
94 | function(data) { | 94 | function(data) { |
95 | focaModalService.alert('Nota pedido creada'); | 95 | focaModalService.alert('Nota pedido creada'); |
96 | if($scope.notaPedido.flete === 1) { | 96 | if($scope.notaPedido.flete === 1) { |
97 | var flete = { | 97 | var flete = { |
98 | idNotaPedido: data.data.id, | 98 | idNotaPedido: data.data.id, |
99 | idTransportista: $scope.notaPedido.fleteId, | 99 | idTransportista: $scope.notaPedido.fleteId, |
100 | idChofer: $scope.notaPedido.chofer.id, | 100 | idChofer: $scope.notaPedido.chofer.id, |
101 | idVehiculo: $scope.notaPedido.vehiculo.id, | 101 | idVehiculo: $scope.notaPedido.vehiculo.id, |
102 | kilometros: $scope.notaPedido.kilometros, | 102 | kilometros: $scope.notaPedido.kilometros, |
103 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 103 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
104 | }; | 104 | }; |
105 | crearNotaPedidoService.crearFlete(flete); | 105 | crearNotaPedidoService.crearFlete(flete); |
106 | } | 106 | } |
107 | var articulosNotaPedido = $scope.articulosTabla; | 107 | var articulosNotaPedido = $scope.articulosTabla; |
108 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 108 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
109 | delete articulosNotaPedido[i].edit; | 109 | delete articulosNotaPedido[i].edit; |
110 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 110 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
111 | crearNotaPedidoService | 111 | crearNotaPedidoService |
112 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 112 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
113 | } | 113 | } |
114 | $scope.limpiarPantalla(); | 114 | $scope.limpiarPantalla(); |
115 | } | 115 | } |
116 | ); | 116 | ); |
117 | }; | 117 | }; |
118 | $scope.seleccionarArticulo = function() { | 118 | $scope.seleccionarArticulo = function() { |
119 | if (idLista === undefined) { | 119 | if (idLista === undefined) { |
120 | focaModalService.alert( | 120 | focaModalService.alert( |
121 | 'Primero seleccione una lista de precio y condicion'); | 121 | 'Primero seleccione una lista de precio y condicion'); |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | var modalInstance = $uibModal.open( | 124 | var modalInstance = $uibModal.open( |
125 | { | 125 | { |
126 | ariaLabelledBy: 'Busqueda de Productos', | 126 | ariaLabelledBy: 'Busqueda de Productos', |
127 | templateUrl: 'modal-busqueda-productos.html', | 127 | templateUrl: 'modal-busqueda-productos.html', |
128 | controller: 'modalBusquedaProductosCtrl', | 128 | controller: 'modalBusquedaProductosCtrl', |
129 | resolve: { idLista: function() { return idLista; } }, | 129 | resolve: { idLista: function() { return idLista; } }, |
130 | size: 'lg' | 130 | size: 'lg' |
131 | } | 131 | } |
132 | ); | 132 | ); |
133 | modalInstance.result.then( | 133 | modalInstance.result.then( |
134 | function(producto) { | 134 | function(producto) { |
135 | var newArt = | 135 | var newArt = |
136 | { | 136 | { |
137 | id: 0, | 137 | id: 0, |
138 | codigo: producto.codigo, | 138 | codigo: producto.codigo, |
139 | sector: producto.sector, | 139 | sector: producto.sector, |
140 | descripcion: producto.descripcion, | 140 | descripcion: producto.descripcion, |
141 | item: $scope.articulosTabla.length + 1, | 141 | item: $scope.articulosTabla.length + 1, |
142 | nombre: producto.descripcion, | 142 | nombre: producto.descripcion, |
143 | precio: producto.precio.toFixed(2), | 143 | precio: producto.precio.toFixed(2), |
144 | costoUnitario: producto.costo, | 144 | costoUnitario: producto.costo, |
145 | edit: false | 145 | edit: false |
146 | }; | 146 | }; |
147 | $scope.articuloACargar = newArt; | 147 | $scope.articuloACargar = newArt; |
148 | $scope.cargando = false; | 148 | $scope.cargando = false; |
149 | }, function() { | 149 | }, function() { |
150 | // funcion ejecutada cuando se cancela el modal | 150 | // funcion ejecutada cuando se cancela el modal |
151 | } | 151 | } |
152 | ); | 152 | ); |
153 | }; | 153 | }; |
154 | $scope.seleccionarVendedor = function() { | 154 | $scope.seleccionarVendedor = function() { |
155 | var modalInstance = $uibModal.open( | 155 | var modalInstance = $uibModal.open( |
156 | { | 156 | { |
157 | ariaLabelledBy: 'Busqueda de Vendedores', | 157 | ariaLabelledBy: 'Busqueda de Vendedores', |
158 | templateUrl: 'modal-vendedores.html', | 158 | templateUrl: 'modal-vendedores.html', |
159 | controller: 'modalVendedoresCtrl', | 159 | controller: 'modalVendedoresCtrl', |
160 | size: 'lg' | 160 | size: 'lg' |
161 | } | 161 | } |
162 | ); | 162 | ); |
163 | modalInstance.result.then( | 163 | modalInstance.result.then( |
164 | function(vendedor) { | 164 | function(vendedor) { |
165 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 165 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
166 | }, function() { | 166 | }, function() { |
167 | 167 | ||
168 | } | 168 | } |
169 | ); | 169 | ); |
170 | }; | 170 | }; |
171 | $scope.seleccionarPetrolera = function() { | 171 | $scope.seleccionarPetrolera = function() { |
172 | var modalInstance = $uibModal.open( | 172 | var modalInstance = $uibModal.open( |
173 | { | 173 | { |
174 | ariaLabelledBy: 'Busqueda de Petrolera', | 174 | ariaLabelledBy: 'Busqueda de Petrolera', |
175 | templateUrl: 'modal-petroleras.html', | 175 | templateUrl: 'modal-petroleras.html', |
176 | controller: 'modalPetrolerasCtrl', | 176 | controller: 'modalPetrolerasCtrl', |
177 | size: 'lg' | 177 | size: 'lg' |
178 | } | 178 | } |
179 | ); | 179 | ); |
180 | modalInstance.result.then( | 180 | modalInstance.result.then( |
181 | function(petrolera) { | 181 | function(petrolera) { |
182 | $scope.notaPedido.petrolera = petrolera.NOM; | 182 | $scope.notaPedido.petrolera = petrolera.NOM; |
183 | }, function() { | 183 | }, function() { |
184 | 184 | ||
185 | } | 185 | } |
186 | ); | 186 | ); |
187 | }; | 187 | }; |
188 | $scope.seleccionarCliente = function() { | 188 | $scope.seleccionarCliente = function() { |
189 | var modalInstance = $uibModal.open( | 189 | var modalInstance = $uibModal.open( |
190 | { | 190 | { |
191 | ariaLabelledBy: 'Busqueda de Cliente', | 191 | ariaLabelledBy: 'Busqueda de Cliente', |
192 | templateUrl: 'foca-busqueda-cliente-modal.html', | 192 | templateUrl: 'foca-busqueda-cliente-modal.html', |
193 | controller: 'focaBusquedaClienteModalController', | 193 | controller: 'focaBusquedaClienteModalController', |
194 | size: 'lg' | 194 | size: 'lg' |
195 | } | 195 | } |
196 | ); | 196 | ); |
197 | modalInstance.result.then( | 197 | modalInstance.result.then( |
198 | function(cliente) { | 198 | function(cliente) { |
199 | $scope.limpiarPantalla(); | 199 | $scope.limpiarPantalla(); |
200 | $scope.notaPedido.cliente.nombre = cliente.nom; | 200 | $scope.notaPedido.cliente.nombre = cliente.nom; |
201 | $scope.notaPedido.cliente.id = cliente.cod; | 201 | $scope.notaPedido.cliente.id = cliente.cod; |
202 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 202 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
203 | function(data) { | 203 | function(data) { |
204 | if(data.data.length === 0){ | 204 | if(data.data.length === 0){ |
205 | focaModalService | 205 | focaModalService |
206 | .alert('El cliente no tienen domicilios de entrega') | 206 | .alert('El cliente no tienen domicilios de entrega') |
207 | .then( | 207 | .then( |
208 | function() { | 208 | function() { |
209 | $scope.seleccionarCliente(); | 209 | $scope.seleccionarCliente(); |
210 | $scope.notaPedido.cliente = {nombre: ''}; | 210 | $scope.notaPedido.cliente = {nombre: ''}; |
211 | } | 211 | } |
212 | ); | 212 | ); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | $scope.domiciliosCliente = data.data; | 215 | $scope.domiciliosCliente = data.data; |
216 | } | 216 | } |
217 | ); | 217 | ); |
218 | }, function() { | 218 | }, function() { |
219 | 219 | ||
220 | } | 220 | } |
221 | ); | 221 | ); |
222 | }; | 222 | }; |
223 | $scope.mostrarFichaCliente = function() { | 223 | $scope.mostrarFichaCliente = function() { |
224 | $uibModal.open( | 224 | $uibModal.open( |
225 | { | 225 | { |
226 | ariaLabelledBy: 'Datos del Cliente', | 226 | ariaLabelledBy: 'Datos del Cliente', |
227 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 227 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
228 | controller: 'focaCrearNotaPedidoFichaClienteController', | 228 | controller: 'focaCrearNotaPedidoFichaClienteController', |
229 | size: 'lg' | 229 | size: 'lg' |
230 | } | 230 | } |
231 | ); | 231 | ); |
232 | }; | 232 | }; |
233 | $scope.getTotal = function() { | 233 | $scope.getTotal = function() { |
234 | var total = 0; | 234 | var total = 0; |
235 | var arrayTempArticulos = $scope.articulosTabla; | 235 | var arrayTempArticulos = $scope.articulosTabla; |
236 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 236 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
237 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 237 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
238 | } | 238 | } |
239 | return total.toFixed(2); | 239 | return total.toFixed(2); |
240 | }; | 240 | }; |
241 | $scope.getSubTotal = function() { | 241 | $scope.getSubTotal = function() { |
242 | if($scope.articuloACargar) { | 242 | if($scope.articuloACargar) { |
243 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 243 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
244 | } | 244 | } |
245 | }; | 245 | }; |
246 | $scope.abrirModalListaPrecio = function() { | 246 | $scope.abrirModalListaPrecio = function() { |
247 | var modalInstance = $uibModal.open( | 247 | var modalInstance = $uibModal.open( |
248 | { | 248 | { |
249 | ariaLabelledBy: 'Busqueda de Precio Condición', | 249 | ariaLabelledBy: 'Busqueda de Precio Condición', |
250 | templateUrl: 'modal-precio-condicion.html', | 250 | templateUrl: 'modal-precio-condicion.html', |
251 | controller: 'focaModalPrecioCondicionController', | 251 | controller: 'focaModalPrecioCondicionController', |
252 | size: 'lg' | 252 | size: 'lg' |
253 | } | 253 | } |
254 | ); | 254 | ); |
255 | modalInstance.result.then( | 255 | modalInstance.result.then( |
256 | function(precioCondicion) { | 256 | function(precioCondicion) { |
257 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 257 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
258 | idLista = precioCondicion.idListaPrecio; | 258 | idLista = precioCondicion.idListaPrecio; |
259 | $scope.articulosTabla = []; | 259 | $scope.articulosTabla = []; |
260 | }, function() { | 260 | }, function() { |
261 | 261 | ||
262 | } | 262 | } |
263 | ); | 263 | ); |
264 | }; | 264 | }; |
265 | $scope.abrirModalFlete = function() { | 265 | $scope.abrirModalFlete = function() { |
266 | var modalInstance = $uibModal.open( | 266 | var modalInstance = $uibModal.open( |
267 | { | 267 | { |
268 | ariaLabelledBy: 'Busqueda de Flete', | 268 | ariaLabelledBy: 'Busqueda de Flete', |
269 | templateUrl: 'modal-flete.html', | 269 | templateUrl: 'modal-flete.html', |
270 | controller: 'focaModalFleteController', | 270 | controller: 'focaModalFleteController', |
271 | size: 'lg' | 271 | size: 'lg' |
272 | } | 272 | } |
273 | ); | 273 | ); |
274 | modalInstance.result.then( | 274 | modalInstance.result.then( |
275 | function(flete) { | 275 | function(flete) { |
276 | $scope.limpiarFlete(); | 276 | $scope.limpiarFlete(); |
277 | $scope.notaPedido.fleteNombre = flete.nombre; | 277 | $scope.notaPedido.fleteNombre = flete.nombre; |
278 | $scope.notaPedido.fleteId = flete.id; | 278 | $scope.notaPedido.fleteId = flete.id; |
279 | $scope.choferes = flete.chofer; | 279 | $scope.choferes = flete.chofer; |
280 | $scope.vehiculos = flete.vehiculo; | 280 | $scope.vehiculos = flete.vehiculo; |
281 | }, function() { | 281 | }, function() { |
282 | 282 | ||
283 | } | 283 | } |
284 | ); | 284 | ); |
285 | }; | 285 | }; |
286 | $scope.agregarATabla = function(key) { | 286 | $scope.agregarATabla = function(key) { |
287 | if(key === 13) { | 287 | if(key === 13) { |
288 | if($scope.articuloACargar.cantidad === undefined || | 288 | if($scope.articuloACargar.cantidad === undefined || |
289 | $scope.articuloACargar.cantidad === 0 || | 289 | $scope.articuloACargar.cantidad === 0 || |
290 | $scope.articuloACargar.cantidad === null ){ | 290 | $scope.articuloACargar.cantidad === null ){ |
291 | focaModalService.alert('El valor debe ser al menos 1'); | 291 | focaModalService.alert('El valor debe ser al menos 1'); |
292 | return; | 292 | return; |
293 | } | 293 | } |
294 | $scope.articulosTabla.unshift($scope.articuloACargar); | 294 | $scope.articulosTabla.unshift($scope.articuloACargar); |
295 | $scope.cargando = true; | 295 | $scope.cargando = true; |
296 | } | 296 | } |
297 | }; | 297 | }; |
298 | $scope.quitarArticulo = function(key) { | 298 | $scope.quitarArticulo = function(key) { |
299 | $scope.articulosTabla.splice(key, 1); | 299 | $scope.articulosTabla.splice(key, 1); |
300 | }; | 300 | }; |
301 | $scope.editarArticulo = function(key, articulo) { | 301 | $scope.editarArticulo = function(key, articulo) { |
302 | if(key === 13) { | 302 | if(key === 13) { |
303 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 303 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
304 | articulo.cantidad === undefined){ | 304 | articulo.cantidad === undefined){ |
305 | focaModalService.alert('El valor debe ser al menos 1'); | 305 | focaModalService.alert('El valor debe ser al menos 1'); |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | articulo.edit = false; | 308 | articulo.edit = false; |
309 | } | 309 | } |
310 | }; | 310 | }; |
311 | $scope.cambioEdit = function(articulo) { | 311 | $scope.cambioEdit = function(articulo) { |
312 | articulo.edit = true; | 312 | articulo.edit = true; |
313 | }; | 313 | }; |
314 | $scope.limpiarFlete = function() { | 314 | $scope.limpiarFlete = function() { |
315 | $scope.notaPedido.fleteNombre = ''; | 315 | $scope.notaPedido.fleteNombre = ''; |
316 | $scope.notaPedido.chofer = ''; | 316 | $scope.notaPedido.chofer = ''; |
317 | $scope.notaPedido.vehiculo = ''; | 317 | $scope.notaPedido.vehiculo = ''; |
318 | $scope.notaPedido.kilometros = ''; | 318 | $scope.notaPedido.kilometros = ''; |
319 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 319 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
320 | $scope.choferes = ''; | 320 | $scope.choferes = ''; |
321 | $scope.vehiculos = ''; | 321 | $scope.vehiculos = ''; |
322 | }; | 322 | }; |
323 | $scope.limpiarPantalla = function() { | 323 | $scope.limpiarPantalla = function() { |
324 | $scope.limpiarFlete(); | 324 | $scope.limpiarFlete(); |
325 | $scope.notaPedido.flete = '0'; | 325 | $scope.notaPedido.flete = '0'; |
326 | $scope.notaPedido.bomba = '0'; | 326 | $scope.notaPedido.bomba = '0'; |
327 | $scope.notaPedido.precioCondicion = ''; | 327 | $scope.notaPedido.precioCondicion = ''; |
328 | $scope.articulosTabla = []; | 328 | $scope.articulosTabla = []; |
329 | $scope.notaPedido.vendedor.nombre = ''; | 329 | $scope.notaPedido.vendedor.nombre = ''; |
330 | $scope.notaPedido.cliente = {nombre: ''}; | 330 | $scope.notaPedido.cliente = {nombre: ''}; |
331 | $scope.notaPedido.domicilio = {dom: ''}; | 331 | $scope.notaPedido.domicilio = {dom: ''}; |
332 | $scope.domiciliosCliente = []; | 332 | $scope.domiciliosCliente = []; |
333 | }; | 333 | }; |
334 | $scope.resetFilter = function() { | 334 | $scope.resetFilter = function() { |
335 | $scope.articuloACargar = {}; | 335 | $scope.articuloACargar = {}; |
336 | $scope.cargando = true; | 336 | $scope.cargando = true; |
337 | }; | 337 | }; |
338 | $scope.selectFocus = function($event) { | 338 | $scope.selectFocus = function($event) { |
339 | $event.target.select(); | 339 | $event.target.select(); |
340 | }; | 340 | }; |
341 | } | 341 | } |
342 | ] | 342 | ] |
343 | ) | 343 | ) |
344 | .controller('notaPedidoListaCtrl', [ | 344 | .controller('notaPedidoListaCtrl', [ |
345 | '$scope', | 345 | '$scope', |
346 | 'crearNotaPedidoService', | 346 | 'crearNotaPedidoService', |
347 | '$location', | 347 | '$location', |
348 | function($scope, crearNotaPedidoService, $location) { | 348 | function($scope, crearNotaPedidoService, $location) { |
349 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 349 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
350 | $scope.notaPedidos = datos.data; | 350 | $scope.notaPedidos = datos.data; |
351 | }); | 351 | }); |
352 | $scope.editar = function(notaPedido) { | 352 | $scope.editar = function(notaPedido) { |
353 | crearNotaPedidoService.setNotaPedido(notaPedido); | 353 | crearNotaPedidoService.setNotaPedido(notaPedido); |
354 | $location.path('/venta-nota-pedido/abm/'); | 354 | $location.path('/venta-nota-pedido/abm/'); |
355 | }; | 355 | }; |
356 | $scope.crearPedido = function() { | 356 | $scope.crearPedido = function() { |
357 | crearNotaPedidoService.clearNotaPedido(); | 357 | crearNotaPedidoService.clearNotaPedido(); |
358 | $location.path('/venta-nota-pedido/abm/'); | 358 | $location.path('/venta-nota-pedido/abm/'); |
359 | }; | 359 | }; |
360 | } | 360 | } |
361 | ]) | 361 | ]) |
362 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 362 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
363 | '$scope', | 363 | '$scope', |
364 | 'crearNotaPedidoService', | 364 | 'crearNotaPedidoService', |
365 | '$location', | 365 | '$location', |
366 | function($scope, crearNotaPedidoService, $location) { | 366 | function($scope, crearNotaPedidoService, $location) { |
367 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 367 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
368 | $scope.notaPedidos = datos.data; | 368 | $scope.notaPedidos = datos.data; |
369 | }); | 369 | }); |
370 | $scope.editar = function(notaPedido) { | 370 | $scope.editar = function(notaPedido) { |
371 | crearNotaPedidoService.setNotaPedido(notaPedido); | 371 | crearNotaPedidoService.setNotaPedido(notaPedido); |
372 | $location.path('/venta-nota-pedido/abm/'); | 372 | $location.path('/venta-nota-pedido/abm/'); |
373 | }; | 373 | }; |
374 | $scope.crearPedido = function() { | 374 | $scope.crearPedido = function() { |
375 | crearNotaPedidoService.clearNotaPedido(); | 375 | crearNotaPedidoService.clearNotaPedido(); |
376 | $location.path('/venta-nota-pedido/abm/'); | 376 | $location.path('/venta-nota-pedido/abm/'); |
377 | }; | 377 | }; |
378 | } | 378 | } |
379 | ]); | 379 | ]); |
380 | 380 |