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