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