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