Commit fff86d0098846bb7dd0bcd24b5faae35d2b51384
Exists in
master
Merge branch 'master' into 'master'
Master See merge request modulos-npm/foca-crear-nota-pedido!16
Showing
2 changed files
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 | 36 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
37 | //(NO REQUERIDO EN ESTA VERSION) | 37 | //(NO REQUERIDO EN ESTA VERSION) |
38 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 38 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
39 | // function(res) { | 39 | // function(res) { |
40 | // $scope.notaPedido.domicilio = res.data; | 40 | // $scope.notaPedido.domicilio = res.data; |
41 | // } | 41 | // } |
42 | // ); | 42 | // ); |
43 | } else { | 43 | } else { |
44 | $scope.notaPedido.fechaCarga = new Date(); | 44 | $scope.notaPedido.fechaCarga = new Date(); |
45 | $scope.notaPedido.bomba = '0'; | 45 | $scope.notaPedido.bomba = '0'; |
46 | $scope.notaPedido.flete = '0'; | 46 | $scope.notaPedido.flete = '0'; |
47 | idLista = undefined; | 47 | idLista = undefined; |
48 | } | 48 | } |
49 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 49 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
50 | // $scope.addNewDom = function() { | 50 | // $scope.addNewDom = function() { |
51 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 51 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
52 | // }; | 52 | // }; |
53 | // $scope.removeNewChoice = function(choice) { | 53 | // $scope.removeNewChoice = function(choice) { |
54 | // if ($scope.notaPedido.domicilio.length > 1) { | 54 | // if ($scope.notaPedido.domicilio.length > 1) { |
55 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 55 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
56 | // function(c) { | 56 | // function(c) { |
57 | // return c.$$hashKey === choice.$$hashKey; | 57 | // return c.$$hashKey === choice.$$hashKey; |
58 | // } | 58 | // } |
59 | // ), 1); | 59 | // ), 1); |
60 | // } | 60 | // } |
61 | // }; | 61 | // }; |
62 | $scope.crearNotaPedido = function() { | 62 | $scope.crearNotaPedido = function() { |
63 | if($scope.articulosTabla.length === 0) { | 63 | if($scope.articulosTabla.length === 0) { |
64 | focaModalService.alert('Debe cargar almenos un articulo'); | 64 | focaModalService.alert('Debe cargar almenos un articulo'); |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | if($scope.notaPedido.domicilio.id === undefined) { | 67 | if($scope.notaPedido.domicilio.id === undefined) { |
68 | $scope.notaPedido.domicilio.id = 0; | 68 | $scope.notaPedido.domicilio.id = 0; |
69 | } | 69 | } |
70 | var date = new Date(); | 70 | var date = new Date(); |
71 | var notaPedido = { | 71 | var notaPedido = { |
72 | id: 0, | 72 | id: 0, |
73 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 73 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
74 | .toISOString().slice(0, 19).replace('T', ' '), | 74 | .toISOString().slice(0, 19).replace('T', ' '), |
75 | vendedor: $scope.notaPedido.vendedor.nombre, | 75 | vendedor: $scope.notaPedido.vendedor.nombre, |
76 | idCliente: $scope.notaPedido.cliente.id, | 76 | idCliente: $scope.notaPedido.cliente.id, |
77 | domicilio: $scope.notaPedido.domicilio, | 77 | domicilio: $scope.notaPedido.domicilio, |
78 | precioCondicion: $scope.notaPedido.precioCondicion, | 78 | precioCondicion: $scope.notaPedido.precioCondicion, |
79 | bomba: $scope.notaPedido.bomba, | 79 | bomba: $scope.notaPedido.bomba, |
80 | flete: $scope.notaPedido.flete, | 80 | flete: $scope.notaPedido.flete, |
81 | total: $scope.getTotal() | 81 | total: $scope.getTotal() |
82 | }; | 82 | }; |
83 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 83 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
84 | function(data) { | 84 | function(data) { |
85 | focaModalService.alert('Nota pedido creada'); | 85 | focaModalService.alert('Nota pedido creada'); |
86 | if($scope.notaPedido.flete === 1) { | 86 | if($scope.notaPedido.flete === 1) { |
87 | var flete = { | 87 | var flete = { |
88 | idNotaPedido: data.data.id, | 88 | idNotaPedido: data.data.id, |
89 | idTransportista: $scope.notaPedido.fleteId, | 89 | idTransportista: $scope.notaPedido.fleteId, |
90 | idChofer: $scope.notaPedido.chofer.id, | 90 | idChofer: $scope.notaPedido.chofer.id, |
91 | idVehiculo: $scope.notaPedido.vehiculo.id, | 91 | idVehiculo: $scope.notaPedido.vehiculo.id, |
92 | kilometros: $scope.notaPedido.kilometros, | 92 | kilometros: $scope.notaPedido.kilometros, |
93 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 93 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
94 | }; | 94 | }; |
95 | crearNotaPedidoService.crearFlete(flete); | 95 | crearNotaPedidoService.crearFlete(flete); |
96 | } | 96 | } |
97 | var articulosNotaPedido = $scope.articulosTabla; | 97 | var articulosNotaPedido = $scope.articulosTabla; |
98 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 98 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
99 | delete articulosNotaPedido[i].edit; | 99 | delete articulosNotaPedido[i].edit; |
100 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 100 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
101 | crearNotaPedidoService | 101 | crearNotaPedidoService |
102 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 102 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
103 | } | 103 | } |
104 | $scope.limpiarPantalla(); | 104 | $scope.limpiarPantalla(); |
105 | } | 105 | } |
106 | ); | 106 | ); |
107 | }; | 107 | }; |
108 | $scope.seleccionarArticulo = function() { | 108 | $scope.seleccionarArticulo = function() { |
109 | if (idLista === undefined) { | 109 | if (idLista === undefined) { |
110 | focaModalService.alert( | 110 | focaModalService.alert( |
111 | 'primero seleccione una lista de precio y condicion'); | 111 | 'Primero seleccione una lista de precio y condicion'); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | var modalInstance = $uibModal.open( | 114 | var modalInstance = $uibModal.open( |
115 | { | 115 | { |
116 | ariaLabelledBy: 'Busqueda de Productos', | 116 | ariaLabelledBy: 'Busqueda de Productos', |
117 | templateUrl: 'modal-busqueda-productos.html', | 117 | templateUrl: 'modal-busqueda-productos.html', |
118 | controller: 'modalBusquedaProductosCtrl', | 118 | controller: 'modalBusquedaProductosCtrl', |
119 | resolve: { idLista: function() { return idLista; } }, | 119 | resolve: { idLista: function() { return idLista; } }, |
120 | size: 'lg' | 120 | size: 'lg' |
121 | } | 121 | } |
122 | ); | 122 | ); |
123 | modalInstance.result.then( | 123 | modalInstance.result.then( |
124 | function(producto) { | 124 | function(producto) { |
125 | var newArt = | 125 | var newArt = |
126 | { | 126 | { |
127 | id: 0, | 127 | id: 0, |
128 | codigo: producto.codigo, | 128 | codigo: producto.codigo, |
129 | sector: producto.sector, | 129 | sector: producto.sector, |
130 | descripcion: producto.descripcion, | 130 | descripcion: producto.descripcion, |
131 | item: $scope.articulosTabla.length + 1, | 131 | item: $scope.articulosTabla.length + 1, |
132 | nombre: producto.descripcion, | 132 | nombre: producto.descripcion, |
133 | precio: producto.precio.toFixed(2), | 133 | precio: producto.precio.toFixed(2), |
134 | costoUnitario: producto.costo, | 134 | costoUnitario: producto.costo, |
135 | edit: false | 135 | edit: false |
136 | }; | 136 | }; |
137 | $scope.articuloACargar = newArt; | 137 | $scope.articuloACargar = newArt; |
138 | $scope.cargando = false; | 138 | $scope.cargando = false; |
139 | }, function() { | 139 | }, function() { |
140 | // funcion ejecutada cuando se cancela el modal | 140 | // funcion ejecutada cuando se cancela el modal |
141 | } | 141 | } |
142 | ); | 142 | ); |
143 | }; | 143 | }; |
144 | $scope.seleccionarVendedor = function() { | 144 | $scope.seleccionarVendedor = function() { |
145 | var modalInstance = $uibModal.open( | 145 | var modalInstance = $uibModal.open( |
146 | { | 146 | { |
147 | ariaLabelledBy: 'Busqueda de Vendedores', | 147 | ariaLabelledBy: 'Busqueda de Vendedores', |
148 | templateUrl: 'modal-vendedores.html', | 148 | templateUrl: 'modal-vendedores.html', |
149 | controller: 'modalVendedoresCtrl', | 149 | controller: 'modalVendedoresCtrl', |
150 | size: 'lg' | 150 | size: 'lg' |
151 | } | 151 | } |
152 | ); | 152 | ); |
153 | modalInstance.result.then( | 153 | modalInstance.result.then( |
154 | function(vendedor) { | 154 | function(vendedor) { |
155 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 155 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
156 | }, function() { | 156 | }, function() { |
157 | 157 | ||
158 | } | 158 | } |
159 | ); | 159 | ); |
160 | }; | 160 | }; |
161 | $scope.seleccionarPetrolera = function() { | 161 | $scope.seleccionarPetrolera = function() { |
162 | var modalInstance = $uibModal.open( | 162 | var modalInstance = $uibModal.open( |
163 | { | 163 | { |
164 | ariaLabelledBy: 'Busqueda de Petrolera', | 164 | ariaLabelledBy: 'Busqueda de Petrolera', |
165 | templateUrl: 'modal-petroleras.html', | 165 | templateUrl: 'modal-petroleras.html', |
166 | controller: 'modalPetrolerasCtrl', | 166 | controller: 'modalPetrolerasCtrl', |
167 | size: 'lg' | 167 | size: 'lg' |
168 | } | 168 | } |
169 | ); | 169 | ); |
170 | modalInstance.result.then( | 170 | modalInstance.result.then( |
171 | function(petrolera) { | 171 | function(petrolera) { |
172 | $scope.notaPedido.petrolera = petrolera.NOM; | 172 | $scope.notaPedido.petrolera = petrolera.NOM; |
173 | }, function() { | 173 | }, function() { |
174 | 174 | ||
175 | } | 175 | } |
176 | ); | 176 | ); |
177 | }; | 177 | }; |
178 | $scope.seleccionarCliente = function() { | 178 | $scope.seleccionarCliente = function() { |
179 | var modalInstance = $uibModal.open( | 179 | var modalInstance = $uibModal.open( |
180 | { | 180 | { |
181 | ariaLabelledBy: 'Busqueda de Cliente', | 181 | ariaLabelledBy: 'Busqueda de Cliente', |
182 | templateUrl: 'foca-busqueda-cliente-modal.html', | 182 | templateUrl: 'foca-busqueda-cliente-modal.html', |
183 | controller: 'focaBusquedaClienteModalController', | 183 | controller: 'focaBusquedaClienteModalController', |
184 | size: 'lg' | 184 | size: 'lg' |
185 | } | 185 | } |
186 | ); | 186 | ); |
187 | modalInstance.result.then( | 187 | modalInstance.result.then( |
188 | function(cliente) { | 188 | function(cliente) { |
189 | $scope.limpiarPantalla(); | 189 | $scope.limpiarPantalla(); |
190 | $scope.notaPedido.cliente.nombre = cliente.nom; | 190 | $scope.notaPedido.cliente.nombre = cliente.nom; |
191 | $scope.notaPedido.cliente.id = cliente.cod; | 191 | $scope.notaPedido.cliente.id = cliente.cod; |
192 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 192 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
193 | function(data) { | 193 | function(data) { |
194 | if(data.data.length === 0){ | 194 | if(data.data.length === 0){ |
195 | focaModalService | 195 | focaModalService |
196 | .alert('El cliente no tienen domicilios de entrega') | 196 | .alert('El cliente no tienen domicilios de entrega') |
197 | .then( | 197 | .then( |
198 | function() { | 198 | function() { |
199 | $scope.seleccionarCliente(); | 199 | $scope.seleccionarCliente(); |
200 | $scope.notaPedido.cliente = {nombre: ''}; | 200 | $scope.notaPedido.cliente = {nombre: ''}; |
201 | } | 201 | } |
202 | ); | 202 | ); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | $scope.domiciliosCliente = data.data; | 205 | $scope.domiciliosCliente = data.data; |
206 | } | 206 | } |
207 | ); | 207 | ); |
208 | }, function() { | 208 | }, function() { |
209 | 209 | ||
210 | } | 210 | } |
211 | ); | 211 | ); |
212 | }; | 212 | }; |
213 | $scope.mostrarFichaCliente = function() { | 213 | $scope.mostrarFichaCliente = function() { |
214 | $uibModal.open( | 214 | $uibModal.open( |
215 | { | 215 | { |
216 | ariaLabelledBy: 'Datos del Cliente', | 216 | ariaLabelledBy: 'Datos del Cliente', |
217 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 217 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
218 | controller: 'focaCrearNotaPedidoFichaClienteController', | 218 | controller: 'focaCrearNotaPedidoFichaClienteController', |
219 | size: 'lg' | 219 | size: 'lg' |
220 | } | 220 | } |
221 | ); | 221 | ); |
222 | }; | 222 | }; |
223 | $scope.getTotal = function() { | 223 | $scope.getTotal = function() { |
224 | var total = 0; | 224 | var total = 0; |
225 | var arrayTempArticulos = $scope.articulosTabla; | 225 | var arrayTempArticulos = $scope.articulosTabla; |
226 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 226 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
227 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 227 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
228 | } | 228 | } |
229 | return total.toFixed(2); | 229 | return total.toFixed(2); |
230 | }; | 230 | }; |
231 | $scope.getSubTotal = function() { | 231 | $scope.getSubTotal = function() { |
232 | if($scope.articuloACargar) { | 232 | if($scope.articuloACargar) { |
233 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 233 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
234 | } | 234 | } |
235 | }; | 235 | }; |
236 | $scope.abrirModalListaPrecio = function() { | 236 | $scope.abrirModalListaPrecio = function() { |
237 | var modalInstance = $uibModal.open( | 237 | var modalInstance = $uibModal.open( |
238 | { | 238 | { |
239 | ariaLabelledBy: 'Busqueda de Precio Condición', | 239 | ariaLabelledBy: 'Busqueda de Precio Condición', |
240 | templateUrl: 'modal-precio-condicion.html', | 240 | templateUrl: 'modal-precio-condicion.html', |
241 | controller: 'focaModalPrecioCondicionController', | 241 | controller: 'focaModalPrecioCondicionController', |
242 | size: 'lg' | 242 | size: 'lg' |
243 | } | 243 | } |
244 | ); | 244 | ); |
245 | modalInstance.result.then( | 245 | modalInstance.result.then( |
246 | function(precioCondicion) { | 246 | function(precioCondicion) { |
247 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 247 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; |
248 | idLista = precioCondicion.idListaPrecio; | 248 | idLista = precioCondicion.idListaPrecio; |
249 | $scope.articulosTabla = []; | 249 | $scope.articulosTabla = []; |
250 | }, function() { | 250 | }, function() { |
251 | 251 | ||
252 | } | 252 | } |
253 | ); | 253 | ); |
254 | }; | 254 | }; |
255 | $scope.abrirModalFlete = function() { | 255 | $scope.abrirModalFlete = function() { |
256 | if($scope.notaPedido.flete === '1') { | 256 | if($scope.notaPedido.flete === '1') { |
257 | var modalInstance = $uibModal.open( | 257 | var modalInstance = $uibModal.open( |
258 | { | 258 | { |
259 | ariaLabelledBy: 'Busqueda de Flete', | 259 | ariaLabelledBy: 'Busqueda de Flete', |
260 | templateUrl: 'modal-flete.html', | 260 | templateUrl: 'modal-flete.html', |
261 | controller: 'focaModalFleteController', | 261 | controller: 'focaModalFleteController', |
262 | size: 'lg' | 262 | size: 'lg' |
263 | } | 263 | } |
264 | ); | 264 | ); |
265 | modalInstance.result.then( | 265 | modalInstance.result.then( |
266 | function(flete) { | 266 | function(flete) { |
267 | $scope.limpiarFlete(); | 267 | $scope.limpiarFlete(); |
268 | $scope.notaPedido.fleteNombre = flete.nombre; | 268 | $scope.notaPedido.fleteNombre = flete.nombre; |
269 | $scope.notaPedido.fleteId = flete.id; | 269 | $scope.notaPedido.fleteId = flete.id; |
270 | $scope.choferes = flete.chofer; | 270 | $scope.choferes = flete.chofer; |
271 | $scope.vehiculos = flete.vehiculo; | 271 | $scope.vehiculos = flete.vehiculo; |
272 | }, function() { | 272 | }, function() { |
273 | 273 | ||
274 | } | 274 | } |
275 | ); | 275 | ); |
276 | } | 276 | } |
277 | }; | 277 | }; |
278 | $scope.agregarATabla = function(key) { | 278 | $scope.agregarATabla = function(key) { |
279 | if(key === 13) { | 279 | if(key === 13) { |
280 | if($scope.articuloACargar.cantidad === undefined || | 280 | if($scope.articuloACargar.cantidad === undefined || |
281 | $scope.articuloACargar.cantidad === 0 || | 281 | $scope.articuloACargar.cantidad === 0 || |
282 | $scope.articuloACargar.cantidad === null ){ | 282 | $scope.articuloACargar.cantidad === null ){ |
283 | focaModalService.alert('El valor debe ser al menos 1'); | 283 | focaModalService.alert('El valor debe ser al menos 1'); |
284 | return; | 284 | return; |
285 | } | 285 | } |
286 | $scope.articulosTabla.unshift($scope.articuloACargar); | 286 | $scope.articulosTabla.unshift($scope.articuloACargar); |
287 | $scope.cargando = true; | 287 | $scope.cargando = true; |
288 | } | 288 | } |
289 | }; | 289 | }; |
290 | $scope.quitarArticulo = function(key) { | 290 | $scope.quitarArticulo = function(key) { |
291 | $scope.articulosTabla.splice(key, 1); | 291 | $scope.articulosTabla.splice(key, 1); |
292 | }; | 292 | }; |
293 | $scope.editarArticulo = function(key, articulo) { | 293 | $scope.editarArticulo = function(key, articulo) { |
294 | if(key === 13) { | 294 | if(key === 13) { |
295 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 295 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
296 | articulo.cantidad === undefined){ | 296 | articulo.cantidad === undefined){ |
297 | focaModalService.alert('El valor debe ser al menos 1'); | 297 | focaModalService.alert('El valor debe ser al menos 1'); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | articulo.edit = false; | 300 | articulo.edit = false; |
301 | } | 301 | } |
302 | }; | 302 | }; |
303 | $scope.cambioEdit = function(articulo) { | 303 | $scope.cambioEdit = function(articulo) { |
304 | articulo.edit = true; | 304 | articulo.edit = true; |
305 | }; | 305 | }; |
306 | $scope.limpiarFlete = function() { | 306 | $scope.limpiarFlete = function() { |
307 | $scope.notaPedido.fleteNombre = ''; | 307 | $scope.notaPedido.fleteNombre = ''; |
308 | $scope.notaPedido.chofer = ''; | 308 | $scope.notaPedido.chofer = ''; |
309 | $scope.notaPedido.vehiculo = ''; | 309 | $scope.notaPedido.vehiculo = ''; |
310 | $scope.notaPedido.kilometros = ''; | 310 | $scope.notaPedido.kilometros = ''; |
311 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 311 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
312 | $scope.choferes = ''; | 312 | $scope.choferes = ''; |
313 | $scope.vehiculos = ''; | 313 | $scope.vehiculos = ''; |
314 | }; | 314 | }; |
315 | $scope.limpiarPantalla = function() { | 315 | $scope.limpiarPantalla = function() { |
316 | $scope.limpiarFlete(); | 316 | $scope.limpiarFlete(); |
317 | $scope.notaPedido.flete = '0'; | 317 | $scope.notaPedido.flete = '0'; |
318 | $scope.notaPedido.bomba = '0'; | 318 | $scope.notaPedido.bomba = '0'; |
319 | $scope.notaPedido.precioCondicion = ''; | 319 | $scope.notaPedido.precioCondicion = ''; |
320 | $scope.articulosTabla = []; | 320 | $scope.articulosTabla = []; |
321 | $scope.notaPedido.vendedor.nombre = ''; | 321 | $scope.notaPedido.vendedor.nombre = ''; |
322 | $scope.notaPedido.cliente = {nombre: ''}; | 322 | $scope.notaPedido.cliente = {nombre: ''}; |
323 | $scope.notaPedido.domicilio = {dom: ''}; | 323 | $scope.notaPedido.domicilio = {dom: ''}; |
324 | $scope.domiciliosCliente = []; | 324 | $scope.domiciliosCliente = []; |
325 | }; | 325 | }; |
326 | $scope.resetFilter = function() { | 326 | $scope.resetFilter = function() { |
327 | $scope.articuloACargar = {}; | 327 | $scope.articuloACargar = {}; |
328 | $scope.cargando = true; | 328 | $scope.cargando = true; |
329 | }; | 329 | }; |
330 | $scope.selectFocus = function ($event) { | 330 | $scope.selectFocus = function($event) { |
331 | $event.target.select(); | 331 | $event.target.select(); |
332 | }; | 332 | }; |
333 | } | 333 | } |
334 | ] | 334 | ] |
335 | ) | 335 | ) |
336 | .controller('notaPedidoListaCtrl', [ | 336 | .controller('notaPedidoListaCtrl', [ |
337 | '$scope', | 337 | '$scope', |
338 | 'crearNotaPedidoService', | 338 | 'crearNotaPedidoService', |
339 | '$location', | 339 | '$location', |
340 | function($scope, crearNotaPedidoService, $location) { | 340 | function($scope, crearNotaPedidoService, $location) { |
341 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 341 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
342 | $scope.notaPedidos = datos.data; | 342 | $scope.notaPedidos = datos.data; |
343 | }); | 343 | }); |
344 | $scope.editar = function(notaPedido) { | 344 | $scope.editar = function(notaPedido) { |
345 | crearNotaPedidoService.setNotaPedido(notaPedido); | 345 | crearNotaPedidoService.setNotaPedido(notaPedido); |
346 | $location.path('/venta-nota-pedido/abm/'); | 346 | $location.path('/venta-nota-pedido/abm/'); |
347 | }; | 347 | }; |
348 | $scope.crearPedido = function() { | 348 | $scope.crearPedido = function() { |
349 | crearNotaPedidoService.clearNotaPedido(); | 349 | crearNotaPedidoService.clearNotaPedido(); |
350 | $location.path('/venta-nota-pedido/abm/'); | 350 | $location.path('/venta-nota-pedido/abm/'); |
351 | }; | 351 | }; |
352 | } | 352 | } |
353 | ]) | 353 | ]) |
354 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 354 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
355 | '$scope', | 355 | '$scope', |
356 | 'crearNotaPedidoService', | 356 | 'crearNotaPedidoService', |
357 | '$location', | 357 | '$location', |
358 | function($scope, crearNotaPedidoService, $location) { | 358 | function($scope, crearNotaPedidoService, $location) { |
359 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 359 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
360 | $scope.notaPedidos = datos.data; | 360 | $scope.notaPedidos = datos.data; |
361 | }); | 361 | }); |
362 | $scope.editar = function(notaPedido) { | 362 | $scope.editar = function(notaPedido) { |
363 | crearNotaPedidoService.setNotaPedido(notaPedido); | 363 | crearNotaPedidoService.setNotaPedido(notaPedido); |
364 | $location.path('/venta-nota-pedido/abm/'); | 364 | $location.path('/venta-nota-pedido/abm/'); |
365 | }; | 365 | }; |
366 | $scope.crearPedido = function() { | 366 | $scope.crearPedido = function() { |
367 | crearNotaPedidoService.clearNotaPedido(); | 367 | crearNotaPedidoService.clearNotaPedido(); |
368 | $location.path('/venta-nota-pedido/abm/'); | 368 | $location.path('/venta-nota-pedido/abm/'); |
369 | }; | 369 | }; |
370 | } | 370 | } |
371 | ]); | 371 | ]); |
372 | 372 |
src/views/nota-pedido.html
1 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> | 1 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> |
2 | <div class="row"> | 2 | <div class="row"> |
3 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 3 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
4 | <div class="row bg-secondary p-3"> | 4 | <div class="row bg-secondary p-3"> |
5 | <div class="form-group col-12 col-sm-6 col-md-4"> | 5 | <div class="form-group col-12 col-sm-6 col-md-4"> |
6 | <div class="input-group"> | 6 | <div class="input-group"> |
7 | <input | 7 | <input |
8 | type="text" | 8 | type="text" |
9 | class="form-control" | 9 | class="form-control" |
10 | uib-datepicker-popup="dd/MM/yyyy" | 10 | uib-datepicker-popup="dd/MM/yyyy" |
11 | ng-model="notaPedido.fechaCarga" | 11 | ng-model="notaPedido.fechaCarga" |
12 | is-open="popup1.opened" | 12 | is-open="popup1.opened" |
13 | datepicker-options="dateOptions" | 13 | datepicker-options="dateOptions" |
14 | close-text="Cerrar" | 14 | close-text="Cerrar" |
15 | current-text="Hoy" | 15 | current-text="Hoy" |
16 | clear-text="Borrar" | 16 | clear-text="Borrar" |
17 | alt-input-formats="altInputFormats" | 17 | alt-input-formats="altInputFormats" |
18 | ng-required="true" | 18 | ng-required="true" |
19 | /> | 19 | /> |
20 | <span class="input-group-append"> | 20 | <span class="input-group-append"> |
21 | <button type="button" class="btn btn-default" ng-click="popup1.opened = true"> | 21 | <button type="button" class="btn btn-default" ng-click="popup1.opened = true"> |
22 | <i class="fa fa-calendar"></i> | 22 | <i class="fa fa-calendar"></i> |
23 | </button> | 23 | </button> |
24 | </span> | 24 | </span> |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
27 | <div class="form-group col-12 col-sm-6 col-md-4"> | 27 | <div class="form-group col-12 col-sm-6 col-md-4"> |
28 | <div class="input-group"> | 28 | <div class="input-group"> |
29 | <input | 29 | <input |
30 | class="form-control selectable" | 30 | class="form-control selectable" |
31 | type="text" | 31 | type="text" |
32 | ng-model="notaPedido.cliente.nombre" | 32 | ng-model="notaPedido.cliente.nombre" |
33 | placeholder="Seleccione Cliente" | 33 | placeholder="Seleccione Cliente" |
34 | readonly="true" | 34 | readonly="true" |
35 | ng-click="seleccionarCliente()" | 35 | ng-click="seleccionarCliente()" |
36 | ng-required="true" | 36 | ng-required="true" |
37 | foca-focus="true" | ||
37 | > | 38 | > |
38 | <span class="input-group-append"> | 39 | <span class="input-group-append"> |
39 | <button type="button" class="btn btn-default" ng-click="seleccionarCliente()"> | 40 | <button type="button" class="btn btn-default" ng-click="seleccionarCliente()"> |
40 | <i class="fa fa-search"></i> | 41 | <i class="fa fa-search"></i> |
41 | </button> | 42 | </button> |
42 | </span> | 43 | </span> |
43 | </div> | 44 | </div> |
44 | </div> | 45 | </div> |
45 | <div class="form-group col-12 col-sm-6 col-md-4"> | 46 | <div class="form-group col-12 col-sm-6 col-md-4"> |
46 | <div class="input-group"> | 47 | <div class="input-group"> |
47 | <input | 48 | <input |
48 | class="form-control" | 49 | class="form-control" |
49 | type="text" | 50 | type="text" |
50 | ng-model="notaPedido.vendedor.nombre" | 51 | ng-model="notaPedido.vendedor.nombre" |
51 | placeholder="Seleccione Vendedor" | 52 | placeholder="Seleccione Vendedor" |
52 | readonly="true" | 53 | readonly="true" |
53 | > | 54 | > |
54 | <span class="input-group-append"> | 55 | <span class="input-group-append"> |
55 | <button type="button" class="btn btn-default" ng-click="seleccionarVendedor()"> | 56 | <button type="button" class="btn btn-default" ng-click="seleccionarVendedor()"> |
56 | <i class="fa fa-search"></i> | 57 | <i class="fa fa-search"></i> |
57 | </button> | 58 | </button> |
58 | </span> | 59 | </span> |
59 | </div> | 60 | </div> |
60 | </div> | 61 | </div> |
61 | <div class="form-group col-12 col-sm-6 col-md-4"> | 62 | <div class="form-group col-12 col-sm-6 col-md-4"> |
62 | <input | 63 | <input |
63 | class="form-control selectable" | 64 | class="form-control selectable" |
64 | type="text" | 65 | type="text" |
65 | ng-model="notaPedido.domicilio" | 66 | ng-model="notaPedido.domicilio" |
66 | placeholder="Seleccione Domicilio" | 67 | placeholder="Seleccione Domicilio" |
67 | typeahead-min-length="0" | 68 | typeahead-min-length="0" |
68 | uib-typeahead="domi as domi.dom for domi in domiciliosCliente" | 69 | uib-typeahead="domi as domi.dom for domi in domiciliosCliente" |
69 | > | 70 | > |
70 | </div> | 71 | </div> |
71 | <div class="form-group col-12 col-sm-6 col-md-4"> | 72 | <div class="form-group col-12 col-sm-6 col-md-4"> |
72 | <input | 73 | <input |
73 | class="form-control selectable" | 74 | class="form-control selectable" |
74 | type="text" | 75 | type="text" |
75 | readonly="true" | 76 | readonly="true" |
76 | ng-model="notaPedido.precioCondicion" | 77 | ng-model="notaPedido.precioCondicion" |
77 | ng-click="abrirModalListaPrecio()" | 78 | ng-click="abrirModalListaPrecio()" |
78 | placeholder="Seleccione Lista de precio" | 79 | placeholder="Seleccione Lista de precio" |
79 | > | 80 | > |
80 | </div> | 81 | </div> |
81 | <div class="form-group col-12 col-sm-6 col-md-4"> | 82 | <div class="form-group col-12 col-sm-6 col-md-4"> |
82 | <label>Bomba</label> | 83 | <label>Bomba</label> |
83 | <div class="form-check custom-radio custom-control-inline"> | 84 | <div class="form-check custom-radio custom-control-inline"> |
84 | <input | 85 | <input |
85 | class="form-check-input" | 86 | class="form-check-input" |
86 | type="radio" | 87 | type="radio" |
87 | name="radioBomba" | 88 | name="radioBomba" |
88 | value="1" | 89 | value="1" |
89 | ng-model="notaPedido.bomba"> | 90 | ng-model="notaPedido.bomba"> |
90 | <label class="form-check-label">Si</label> | 91 | <label class="form-check-label">Si</label> |
91 | </div> | 92 | </div> |
92 | <div class="form-check custom-radio custom-control-inline"> | 93 | <div class="form-check custom-radio custom-control-inline"> |
93 | <input | 94 | <input |
94 | class="form-check-input" | 95 | class="form-check-input" |
95 | type="radio" | 96 | type="radio" |
96 | name="radioBomba" | 97 | name="radioBomba" |
97 | value="0" | 98 | value="0" |
98 | ng-model="notaPedido.bomba"> | 99 | ng-model="notaPedido.bomba"> |
99 | <label class="form-check-label">No</label> | 100 | <label class="form-check-label">No</label> |
100 | </div> | 101 | </div> |
101 | </div> | 102 | </div> |
102 | <div class="form-group col-12 col-sm-6 col-md-4"> | 103 | <div class="form-group col-12 col-sm-6 col-md-4"> |
103 | <label>Flete</label> | 104 | <label>Flete</label> |
104 | <div class="form-check custom-radio custom-control-inline"> | 105 | <div class="form-check custom-radio custom-control-inline"> |
105 | <input | 106 | <input |
106 | ng-change="limpiarFlete()" | 107 | ng-change="limpiarFlete()" |
107 | class="form-check-input" | 108 | class="form-check-input" |
108 | type="radio" | 109 | type="radio" |
109 | name="radioFlete" | 110 | name="radioFlete" |
110 | value="1" | 111 | value="1" |
111 | ng-model="notaPedido.flete"> | 112 | ng-model="notaPedido.flete"> |
112 | <label class="form-check-label">Si</label> | 113 | <label class="form-check-label">Si</label> |
113 | </div> | 114 | </div> |
114 | <div class="form-check custom-radio custom-control-inline"> | 115 | <div class="form-check custom-radio custom-control-inline"> |
115 | <input | 116 | <input |
116 | class="form-check-input" | 117 | class="form-check-input" |
117 | type="radio" | 118 | type="radio" |
118 | name="radioFlete" | 119 | name="radioFlete" |
119 | value="0" | 120 | value="0" |
120 | ng-model="notaPedido.flete"> | 121 | ng-model="notaPedido.flete"> |
121 | <label class="form-check-label">No</label> | 122 | <label class="form-check-label">No</label> |
122 | </div> | 123 | </div> |
123 | </div> | 124 | </div> |
124 | <div class="form-group col-12 col-sm-6 col-md-4"> | 125 | <div class="form-group col-12 col-sm-6 col-md-4"> |
125 | <input | 126 | <input |
126 | class="form-control selectable" | 127 | class="form-control selectable" |
127 | type="text" | 128 | type="text" |
128 | readonly="true" | 129 | readonly="true" |
129 | ng-show="notaPedido.flete == 1" | 130 | ng-show="notaPedido.flete == 1" |
130 | ng-model="notaPedido.fleteNombre" | 131 | ng-model="notaPedido.fleteNombre" |
131 | ng-click="abrirModalFlete()" | 132 | ng-click="abrirModalFlete()" |
132 | placeholder="Seleccione Flete" | 133 | placeholder="Seleccione Flete" |
133 | > | 134 | > |
134 | </div> | 135 | </div> |
135 | <div class="form-group col-12 col-sm-6 col-md-4"> | 136 | <div class="form-group col-12 col-sm-6 col-md-4"> |
136 | <input | 137 | <input |
137 | class="form-control selectable" | 138 | class="form-control selectable" |
138 | type="text" | 139 | type="text" |
139 | ng-show="notaPedido.flete == 1" | 140 | ng-show="notaPedido.flete == 1" |
140 | ng-model="notaPedido.chofer" | 141 | ng-model="notaPedido.chofer" |
141 | placeholder="Seleccione Chofer" | 142 | placeholder="Seleccione Chofer" |
142 | uib-typeahead="chofer as chofer.nombre for chofer in choferes" | 143 | uib-typeahead="chofer as chofer.nombre for chofer in choferes" |
143 | typeahead-min-length="0" | 144 | typeahead-min-length="0" |
144 | > | 145 | > |
145 | </div> | 146 | </div> |
146 | <div class="form-group col-12 col-sm-6 col-md-4"> | 147 | <div class="form-group col-12 col-sm-6 col-md-4"> |
147 | <input | 148 | <input |
148 | class="form-control selectable" | 149 | class="form-control selectable" |
149 | type="text" | 150 | type="text" |
150 | ng-show="notaPedido.flete == 1" | 151 | ng-show="notaPedido.flete == 1" |
151 | ng-model="notaPedido.vehiculo" | 152 | ng-model="notaPedido.vehiculo" |
152 | placeholder="Seleccione Vehículo" | 153 | placeholder="Seleccione Vehículo" |
153 | uib-typeahead="vehiculo as vehiculo.tractor for vehiculo in vehiculos" | 154 | uib-typeahead="vehiculo as vehiculo.tractor for vehiculo in vehiculos" |
154 | typeahead-min-length="0" | 155 | typeahead-min-length="0" |
155 | > | 156 | > |
156 | </div> | 157 | </div> |
157 | <div class="form-group col-12 col-sm-6 col-md-4"> | 158 | <div class="form-group col-12 col-sm-6 col-md-4"> |
158 | <input | 159 | <input |
159 | class="form-control selectable" | 160 | class="form-control selectable" |
160 | type="number" | 161 | type="number" |
161 | step="0.01" | 162 | step="0.01" |
162 | ng-show="notaPedido.flete == 1" | 163 | ng-show="notaPedido.flete == 1" |
163 | ng-model="notaPedido.costoUnitarioKmFlete" | 164 | ng-model="notaPedido.costoUnitarioKmFlete" |
164 | placeholder="Costo por kilómetro" | 165 | placeholder="Costo por kilómetro" |
165 | > | 166 | > |
166 | </div> | 167 | </div> |
167 | <div class="form-group col-12 col-sm-6 col-md-4"> | 168 | <div class="form-group col-12 col-sm-6 col-md-4"> |
168 | <input | 169 | <input |
169 | class="form-control selectable" | 170 | class="form-control selectable" |
170 | type="number" | 171 | type="number" |
171 | step="0.1" | 172 | step="0.1" |
172 | ng-show="notaPedido.flete == 1" | 173 | ng-show="notaPedido.flete == 1" |
173 | ng-model="notaPedido.kilometros" | 174 | ng-model="notaPedido.kilometros" |
174 | placeholder="Kilómetros recorridos" | 175 | placeholder="Kilómetros recorridos" |
175 | > | 176 | > |
176 | </div> | 177 | </div> |
177 | </div> | 178 | </div> |
178 | </div> | 179 | </div> |
179 | <div class="col-auto my-2"> | 180 | <div class="col-auto my-2"> |
180 | <button | 181 | <button |
181 | ng-click="crearNotaPedido()" | 182 | ng-click="crearNotaPedido()" |
182 | type="submit" | 183 | type="submit" |
183 | title="Crear nota pedido" | 184 | title="Crear nota pedido" |
184 | class="btn btn-primary float-right"> | 185 | class="btn btn-primary float-right"> |
185 | Guardar | 186 | Guardar |
186 | </button> | 187 | </button> |
187 | </div> | 188 | </div> |
188 | </div> | 189 | </div> |
189 | </form> | 190 | </form> |
190 | <div class="row"> | 191 | <div class="row"> |
191 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 192 | <div class="col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
192 | <div class="row"> | 193 | <div class="row"> |
193 | </div> | 194 | </div> |
194 | <div class="row"> | 195 | <div class="row"> |
195 | <table class="table table-striped table-sm"> | 196 | <table class="table table-striped table-sm"> |
196 | <thead> | 197 | <thead> |
197 | <tr> | 198 | <tr> |
198 | <th>Sector</th> | 199 | <th>Sector</th> |
199 | <th>Código</th> | 200 | <th>Código</th> |
200 | <th>Descripción</th> | 201 | <th>Descripción</th> |
201 | <th>Precio Unitario</th> | 202 | <th>Precio Unitario</th> |
202 | <th>Cantidad</th> | 203 | <th>Cantidad</th> |
203 | <th>SubTotal</th> | 204 | <th>SubTotal</th> |
204 | <th> | 205 | <th> |
205 | <button class="btn btn-outline-secondary selectable" style="float: right;" ng-click="show = !show; masMenos()" > | 206 | <button class="btn btn-outline-secondary selectable" style="float: right;" ng-click="show = !show; masMenos()" > |
206 | <i class="fa fa-chevron-down" ng-hide="show" aria-hidden="true"></i> | 207 | <i class="fa fa-chevron-down" ng-hide="show" aria-hidden="true"></i> |
207 | <i class="fa fa-chevron-up" ng-show="show" aria-hidden="true"></i> | 208 | <i class="fa fa-chevron-up" ng-show="show" aria-hidden="true"></i> |
208 | </button> | 209 | </button> |
209 | </th> | 210 | </th> |
210 | </tr> | 211 | </tr> |
211 | </thead> | 212 | </thead> |
212 | <tbody> | 213 | <tbody> |
213 | <tr ng-show="cargando"> | 214 | <tr ng-show="cargando"> |
214 | <td colspan="2"><input | 215 | <td colspan="2"><input |
215 | placeholder="Seleccione Articulo" | 216 | placeholder="Seleccione Articulo" |
216 | class="form-control" | 217 | class="form-control" |
217 | readonly | 218 | readonly |
218 | ng-click="seleccionarArticulo()" | 219 | ng-click="seleccionarArticulo()" |
219 | foca-focus="cargando"></td> | 220 | > |
221 | </td> | ||
220 | <td></td> | 222 | <td></td> |
221 | <td></td> | 223 | <td></td> |
222 | <td></td> | 224 | <td></td> |
223 | <td></td> | 225 | <td></td> |
224 | <td></td> | 226 | <td></td> |
225 | </tr> | 227 | </tr> |
226 | <tr ng-show="!cargando"> | 228 | <tr ng-show="!cargando"> |
227 | <td><input | 229 | <td><input |
228 | class="form-control" | 230 | class="form-control" |
229 | ng-model="articuloACargar.sector" | 231 | ng-model="articuloACargar.sector" |
230 | readonly></td> | 232 | readonly></td> |
231 | <td><input | 233 | <td><input |
232 | class="form-control" | 234 | class="form-control" |
233 | ng-model="articuloACargar.codigo" | 235 | ng-model="articuloACargar.codigo" |
234 | readonly></td> | 236 | readonly></td> |
235 | <td><input | 237 | <td><input |
236 | class="form-control" | 238 | class="form-control" |
237 | ng-model="articuloACargar.descripcion" | 239 | ng-model="articuloACargar.descripcion" |
238 | readonly></td> | 240 | readonly></td> |
239 | <td><input | 241 | <td><input |
240 | class="form-control" | 242 | class="form-control" |
241 | ng-value="articuloACargar.precio | currency:'$'" | 243 | ng-value="articuloACargar.precio | currency:'$'" |
242 | readonly></td> | 244 | readonly></td> |
243 | <td><input | 245 | <td><input |
244 | class="form-control" | 246 | class="form-control" |
245 | type="number" | 247 | type="number" |
246 | min="1" | 248 | min="1" |
247 | ng-model="articuloACargar.cantidad" | 249 | ng-model="articuloACargar.cantidad" |
248 | foca-focus="!cargando" | 250 | foca-focus="!cargando" |
249 | esc-key="resetFilter()" | 251 | esc-key="resetFilter()" |
250 | ng-keypress="agregarATabla($event.keyCode)"></td> | 252 | ng-keypress="agregarATabla($event.keyCode)"></td> |
251 | <td><input | 253 | <td><input |
252 | class="form-control" | 254 | class="form-control" |
253 | ng-value="getSubTotal() | currency:'$'" | 255 | ng-value="getSubTotal() | currency:'$'" |
254 | readonly></td> | 256 | readonly></td> |
255 | <td class="text-center"><button | 257 | <td class="text-center"><button |
256 | class="btn btn-outline-secondary btn-sm" | 258 | class="btn btn-outline-secondary btn-sm" |
257 | ng-click="agregarATabla(13)"> | 259 | ng-click="agregarATabla(13)"> |
258 | <i class="fa fa-save"></i> | 260 | <i class="fa fa-save"></i> |
259 | </button></td> | 261 | </button></td> |
260 | </tr> | 262 | </tr> |
261 | <tr ng-repeat="(key, articulo) in articulosTabla" ng-show="show || key == 0"> | 263 | <tr ng-repeat="(key, articulo) in articulosTabla" ng-show="show || key == 0"> |
262 | <td ng-bind="articulo.sector"></td> | 264 | <td ng-bind="articulo.sector"></td> |
263 | <td ng-bind="articulo.codigo"></td> | 265 | <td ng-bind="articulo.codigo"></td> |
264 | <td ng-bind="articulo.descripcion"></td> | 266 | <td ng-bind="articulo.descripcion"></td> |
265 | <td ng-bind="articulo.precio | currency:'$'"></td> | 267 | <td ng-bind="articulo.precio | currency:'$'"></td> |
266 | <td><input | 268 | <td><input |
267 | ng-show="articulo.edit" | 269 | ng-show="articulo.edit" |
268 | ng-model="articulo.cantidad" | 270 | ng-model="articulo.cantidad" |
269 | class="form-control" | 271 | class="form-control" |
270 | type="number" | 272 | type="number" |
271 | min="1" | 273 | min="1" |
272 | foca-focus="articulo.edit" | 274 | foca-focus="articulo.edit" |
273 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 275 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
274 | ng-focus="selectFocus($event)" | 276 | ng-focus="selectFocus($event)" |
275 | > | 277 | > |
276 | <i | 278 | <i |
277 | class="selectable" | 279 | class="selectable" |
278 | ng-click="cambioEdit(articulo)" | 280 | ng-click="cambioEdit(articulo)" |
279 | ng-hide="articulo.edit" | 281 | ng-hide="articulo.edit" |
280 | ng-bind="articulo.cantidad"> | 282 | ng-bind="articulo.cantidad"> |
281 | </i> | 283 | </i> |
282 | </td> | 284 | </td> |
283 | <td ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"></td> | 285 | <td ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"></td> |
284 | <td class="text-center"> | 286 | <td class="text-center"> |
285 | <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo(key)"> | 287 | <button class="btn btn-outline-secondary btn-sm" ng-click="quitarArticulo(key)"> |
286 | <i class="fa fa-trash"></i> | 288 | <i class="fa fa-trash"></i> |
287 | </button> | 289 | </button> |
288 | </td> | 290 | </td> |
289 | </tr> | 291 | </tr> |
290 | </tbody> | 292 | </tbody> |
291 | <tfoot> | 293 | <tfoot> |
292 | <tr class="table-secondary"> | 294 | <tr class="table-secondary"> |
293 | <td colspan="5"><b>Cantidad Items:</b> <a ng-bind="articulosTabla.length"></a> </td> | 295 | <td colspan="5"><b>Cantidad Items:</b> <a ng-bind="articulosTabla.length"></a> </td> |
294 | <td colspan="3">{{getTotal() | currency:'$'}}</td> | 296 | <td colspan="3">{{getTotal() | currency:'$'}}</td> |
295 | </tr> | 297 | </tr> |
296 | </tfoot> | 298 | </tfoot> |
297 | </table> | 299 | </table> |
298 | </div> | 300 | </div> |
299 | </div> | 301 | </div> |
300 | </div> | 302 | </div> |
301 | 303 | ||
302 | <!-- | 304 | <!-- |
303 | <form name="formCrearNota"> | 305 | <form name="formCrearNota"> |
304 | <uib-tabset active="active"> | 306 | <uib-tabset active="active"> |
305 | <uib-tab index="0" heading="General"> | 307 | <uib-tab index="0" heading="General"> |
306 | <input type="hidden" name="id" ng-model="notaPedido.id" /> | 308 | <input type="hidden" name="id" ng-model="notaPedido.id" /> |
307 | <div> | 309 | <div> |
308 | <div class="col-auto my-2"> | 310 | <div class="col-auto my-2"> |
309 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Siguiente</button> | 311 | <button type="submit" title="Siguiente" class="btn btn-primary float-right">Siguiente</button> |
310 | </div> | 312 | </div> |
311 | </div> | 313 | </div> |
312 | <br> | 314 | <br> |
313 | <br> | 315 | <br> |
314 | <div class="row"> | 316 | <div class="row"> |
315 | <div class="col-md-2"> | 317 | <div class="col-md-2"> |
316 | <div class="col-auto"> | 318 | <div class="col-auto"> |
317 | <label>Fecha de carga</label> | 319 | <label>Fecha de carga</label> |
318 | </div> | 320 | </div> |
319 | </div> | 321 | </div> |
320 | <div class="col-md-3"> | 322 | <div class="col-md-3"> |
321 | <div class="col-auto"> | 323 | <div class="col-auto"> |
322 | <input type="date" class="form-control" ng-model="notaPedido.fechaCarga" ng-required="true"> | 324 | <input type="date" class="form-control" ng-model="notaPedido.fechaCarga" ng-required="true"> |
323 | </div> | 325 | </div> |
324 | </div> | 326 | </div> |
325 | <div class="col-md-2"> | 327 | <div class="col-md-2"> |
326 | <div class="col-auto"> | 328 | <div class="col-auto"> |
327 | <label>Kilómetros</label> | 329 | <label>Kilómetros</label> |
328 | </div> | 330 | </div> |
329 | </div> | 331 | </div> |
330 | <div class="col-md-3"> | 332 | <div class="col-md-3"> |
331 | <div class="col-auto"> | 333 | <div class="col-auto"> |
332 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Kilómetros recorridos para la entrega en el cliente" | 334 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Kilómetros recorridos para la entrega en el cliente" |
333 | ng-model="notaPedido.kilometros" ng-required="true"> | 335 | ng-model="notaPedido.kilometros" ng-required="true"> |
334 | </div> | 336 | </div> |
335 | </div> | 337 | </div> |
336 | </div> | 338 | </div> |
337 | <div class="row my-3"> | 339 | <div class="row my-3"> |
338 | <div class="col-md-2"> | 340 | <div class="col-md-2"> |
339 | <div class="col-auto"> | 341 | <div class="col-auto"> |
340 | <label>Jurisdicción de IIBB</label> | 342 | <label>Jurisdicción de IIBB</label> |
341 | </div> | 343 | </div> |
342 | </div> | 344 | </div> |
343 | <div class="col-md-3"> | 345 | <div class="col-md-3"> |
344 | <div class="col-auto"> | 346 | <div class="col-auto"> |
345 | <input type="text" class="form-control" placeholder="Jurisdicción de IIBB donde se realiza la entrega" | 347 | <input type="text" class="form-control" placeholder="Jurisdicción de IIBB donde se realiza la entrega" |
346 | ng-model="notaPedido.jurisdiccionIIBB" ng-required="true"> | 348 | ng-model="notaPedido.jurisdiccionIIBB" ng-required="true"> |
347 | </div> | 349 | </div> |
348 | </div> | 350 | </div> |
349 | <div class="col-md-2"> | 351 | <div class="col-md-2"> |
350 | <div class="col-auto"> | 352 | <div class="col-auto"> |
351 | <label>Costo de financiación</label> | 353 | <label>Costo de financiación</label> |
352 | </div> | 354 | </div> |
353 | </div> | 355 | </div> |
354 | <div class="col-md-3"> | 356 | <div class="col-md-3"> |
355 | <div class="col-auto"> | 357 | <div class="col-auto"> |
356 | <div class="input-group mb-2"> | 358 | <div class="input-group mb-2"> |
357 | <div class="input-group-prepend"> | 359 | <div class="input-group-prepend"> |
358 | <div class="input-group-text">$</div> | 360 | <div class="input-group-text">$</div> |
359 | </div> | 361 | </div> |
360 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo de financiación" | 362 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo de financiación" |
361 | ng-model="notaPedido.costoFinanciacion"> | 363 | ng-model="notaPedido.costoFinanciacion"> |
362 | </div> | 364 | </div> |
363 | </div> | 365 | </div> |
364 | </div> | 366 | </div> |
365 | </div> | 367 | </div> |
366 | <div class="row"> | 368 | <div class="row"> |
367 | <div class="col-md-2"> | 369 | <div class="col-md-2"> |
368 | <div class="col-auto"> | 370 | <div class="col-auto"> |
369 | <label>Bomba</label> | 371 | <label>Bomba</label> |
370 | </div> | 372 | </div> |
371 | </div> | 373 | </div> |
372 | <div class="col-md-1"> | 374 | <div class="col-md-1"> |
373 | <div class="col-auto"> | 375 | <div class="col-auto"> |
374 | <div class="form-check custom-radio custom-control-inline"> | 376 | <div class="form-check custom-radio custom-control-inline"> |
375 | <input class="form-check-input" type="radio" name="radioBomba" value="1" ng-model="notaPedido.bomba"> | 377 | <input class="form-check-input" type="radio" name="radioBomba" value="1" ng-model="notaPedido.bomba"> |
376 | <label class="form-check-label"> | 378 | <label class="form-check-label"> |
377 | Si | 379 | Si |
378 | </label> | 380 | </label> |
379 | </div> | 381 | </div> |
380 | <div class="form-check custom-radio custom-control-inline"> | 382 | <div class="form-check custom-radio custom-control-inline"> |
381 | <input class="form-check-input" type="radio" name="radioBomba" value="0" ng-model="notaPedido.bomba"> | 383 | <input class="form-check-input" type="radio" name="radioBomba" value="0" ng-model="notaPedido.bomba"> |
382 | <label class="form-check-label"> | 384 | <label class="form-check-label"> |
383 | No | 385 | No |
384 | </label> | 386 | </label> |
385 | </div> | 387 | </div> |
386 | </div> | 388 | </div> |
387 | </div> | 389 | </div> |
388 | <div class="col-md-1"> | 390 | <div class="col-md-1"> |
389 | <div class="col-auto"> | 391 | <div class="col-auto"> |
390 | <label>Flete</label> | 392 | <label>Flete</label> |
391 | </div> | 393 | </div> |
392 | </div> | 394 | </div> |
393 | <div class="col-md-1"> | 395 | <div class="col-md-1"> |
394 | <div class="col-auto"> | 396 | <div class="col-auto"> |
395 | <div class="form-check custom-radio custom-control-inline"> | 397 | <div class="form-check custom-radio custom-control-inline"> |
396 | <input class="form-check-input" type="radio" name="radioFlete" value="1" ng-model="notaPedido.flete"> | 398 | <input class="form-check-input" type="radio" name="radioFlete" value="1" ng-model="notaPedido.flete"> |
397 | <label class="form-check-label"> | 399 | <label class="form-check-label"> |
398 | Si | 400 | Si |
399 | </label> | 401 | </label> |
400 | </div> | 402 | </div> |
401 | <div class="form-check custom-radio custom-control-inline"> | 403 | <div class="form-check custom-radio custom-control-inline"> |
402 | <input class="form-check-input" type="radio" name="radioFlete" value="0" ng-model="notaPedido.flete"> | 404 | <input class="form-check-input" type="radio" name="radioFlete" value="0" ng-model="notaPedido.flete"> |
403 | <label class="form-check-label"> | 405 | <label class="form-check-label"> |
404 | FOB | 406 | FOB |
405 | </label> | 407 | </label> |
406 | </div> | 408 | </div> |
407 | </div> | 409 | </div> |
408 | </div> | 410 | </div> |
409 | <div class="col-md-2"> | 411 | <div class="col-md-2"> |
410 | <div class="col-auto"> | 412 | <div class="col-auto"> |
411 | <label>Costo unitario kilometro flete</label> | 413 | <label>Costo unitario kilometro flete</label> |
412 | </div> | 414 | </div> |
413 | </div> | 415 | </div> |
414 | <div class="col-md-3"> | 416 | <div class="col-md-3"> |
415 | <div class="col-auto"> | 417 | <div class="col-auto"> |
416 | <div class="input-group mb-2"> | 418 | <div class="input-group mb-2"> |
417 | <div class="input-group-prepend"> | 419 | <div class="input-group-prepend"> |
418 | <div class="input-group-text">$</div> | 420 | <div class="input-group-text">$</div> |
419 | </div> | 421 | </div> |
420 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo unitario del kilometro del flete" | 422 | <input type="number" min="0" step="0.01" class="form-control" placeholder="Costo unitario del kilometro del flete" |
421 | ng-model="notaPedido.costoUnitarioKmFlete" ng-required="true"> | 423 | ng-model="notaPedido.costoUnitarioKmFlete" ng-required="true"> |
422 | </div> | 424 | </div> |
423 | </div> | 425 | </div> |
424 | </div> | 426 | </div> |
425 | </div> | 427 | </div> |
426 | <div class="row my-3"> | 428 | <div class="row my-3"> |
427 | <div class="col-md-2"> | 429 | <div class="col-md-2"> |
428 | <div class="col-auto"> | 430 | <div class="col-auto"> |
429 | <label>Vendedor</label> | 431 | <label>Vendedor</label> |
430 | </div> | 432 | </div> |
431 | </div> | 433 | </div> |
432 | <div class="col-md-3"> | 434 | <div class="col-md-3"> |
433 | <div class="col-auto"> | 435 | <div class="col-auto"> |
434 | <input type="text" class="form-control" placeholder="Seleccione vendedor" ng-model="notaPedido.vendedor" | 436 | <input type="text" class="form-control" placeholder="Seleccione vendedor" ng-model="notaPedido.vendedor" |
435 | ng-click="seleccionarVendedor()" readonly> | 437 | ng-click="seleccionarVendedor()" readonly> |
436 | </div> | 438 | </div> |
437 | </div> | 439 | </div> |
438 | <div class="col-md-2"> | 440 | <div class="col-md-2"> |
439 | <div class="col-auto"> | 441 | <div class="col-auto"> |
440 | <label>Petrolera</label> | 442 | <label>Petrolera</label> |
441 | </div> | 443 | </div> |
442 | </div> | 444 | </div> |
443 | <div class="col-md-3"> | 445 | <div class="col-md-3"> |
444 | <div class="col-auto"> | 446 | <div class="col-auto"> |
445 | <input type="text" class="form-control" placeholder="Seleccione petrolera" ng-model="notaPedido.petrolera" | 447 | <input type="text" class="form-control" placeholder="Seleccione petrolera" ng-model="notaPedido.petrolera" |
446 | ng-click="seleccionarPetrolera()" readonly> | 448 | ng-click="seleccionarPetrolera()" readonly> |
447 | </div> | 449 | </div> |
448 | </div> | 450 | </div> |
449 | </div> | 451 | </div> |
450 | </div> | 452 | </div> |
451 | <div class="row"> | 453 | <div class="row"> |
452 | <div class="col-md-2"> | 454 | <div class="col-md-2"> |
453 | <div class="col-auto"> | 455 | <div class="col-auto"> |
454 | <label>Cliente</label> | 456 | <label>Cliente</label> |
455 | </div> | 457 | </div> |
456 | </div> | 458 | </div> |
457 | <div class="col-md-3"> | 459 | <div class="col-md-3"> |
458 | <div class="col-auto"> | 460 | <div class="col-auto"> |
459 | <input type="text" class="form-control" placeholder="Seleccione cliente" ng-model="notaPedido.cliente" | 461 | <input type="text" class="form-control" placeholder="Seleccione cliente" ng-model="notaPedido.cliente" |
460 | ng-click="seleccionarCliente()" ng-change="obtenerDomicilios()" readonly> | 462 | ng-click="seleccionarCliente()" ng-change="obtenerDomicilios()" readonly> |
461 | </div> | 463 | </div> |
462 | </div> | 464 | </div> |
463 | <div class="col-md-2"> | 465 | <div class="col-md-2"> |
464 | <div class="col-auto"> | 466 | <div class="col-auto"> |
465 | <label>Domicilio</label> | 467 | <label>Domicilio</label> |
466 | </div> | 468 | </div> |
467 | </div> | 469 | </div> |
468 | <div class="col-md-4"> | 470 | <div class="col-md-4"> |
469 | <div class="col-md-12 row" ng-repeat="domicilio in notaPedido.domicilio"> | 471 | <div class="col-md-12 row" ng-repeat="domicilio in notaPedido.domicilio"> |
470 | <div class="col-auto"> | 472 | <div class="col-auto"> |
471 | <input type="text" ng-model="domicilio.dom" placeholder="Domicilio" uib-typeahead=" | 473 | <input type="text" ng-model="domicilio.dom" placeholder="Domicilio" uib-typeahead=" |
472 | domi.dom | 474 | domi.dom |
473 | for domi | 475 | for domi |
474 | in domiciliosCliente | 476 | in domiciliosCliente |
475 | " | 477 | " |
476 | typeahead-no-results="sinResultados" typeahead-min-length="0" typeahead-on-select="seleccionar($item)" | 478 | typeahead-no-results="sinResultados" typeahead-min-length="0" typeahead-on-select="seleccionar($item)" |
477 | class="form-control mb-2" ng-disabled="domicilio.id > 0" ng-required="true"> | 479 | class="form-control mb-2" ng-disabled="domicilio.id > 0" ng-required="true"> |
478 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> | 480 | <i ng-show="cargandoClientes" class="fas fa-sync"></i> |
479 | <div ng-show="sinResultados"> | 481 | <div ng-show="sinResultados"> |
480 | No se encontraron resultados. | 482 | No se encontraron resultados. |
481 | </div> | 483 | </div> |
482 | </div> | 484 | </div> |
483 | <a class="btn" ng-click="removeNewChoice(domicilio)" ng-if="domicilio.id==0">-</a> | 485 | <a class="btn" ng-click="removeNewChoice(domicilio)" ng-if="domicilio.id==0">-</a> |
484 | <a class="btn" ng-click="addNewDom()">+</a> | 486 | <a class="btn" ng-click="addNewDom()">+</a> |
485 | </div> | 487 | </div> |
486 | </div> | 488 | </div> |
487 | </div> | 489 | </div> |
488 | </uib-tab> | 490 | </uib-tab> |
489 | <uib-tab index="1" heading="Producto" disable="formCrearNota.$invalid"> | 491 | <uib-tab index="1" heading="Producto" disable="formCrearNota.$invalid"> |
490 | <div> | 492 | <div> |
491 | <div class="col-auto my-2"> | 493 | <div class="col-auto my-2"> |
492 | <button ng-click="crearNotaPedido()" type="button" title="Crear nota pedido" class="btn btn-primary float-right">Crear</button> | 494 | <button ng-click="crearNotaPedido()" type="button" title="Crear nota pedido" class="btn btn-primary float-right">Crear</button> |
493 | </div> | 495 | </div> |
494 | </div> | 496 | </div> |
495 | <br> | 497 | <br> |
496 | <br> | 498 | <br> |
497 | <div class="row"> | 499 | <div class="row"> |
498 | <div class="col-md-2"> | 500 | <div class="col-md-2"> |
499 | <div class="col-auto"> | 501 | <div class="col-auto"> |
500 | <label>Precios y condiciones</label> | 502 | <label>Precios y condiciones</label> |
501 | </div> | 503 | </div> |
502 | </div> | 504 | </div> |
503 | <div class="col-md-4"> | 505 | <div class="col-md-4"> |
504 | <div class="col-auto"> | 506 | <div class="col-auto"> |
505 | <select class="form-control" ng-change="cargarArticulos()" ng-model="notaPedido.precioCondicion" ng-options="preCond.id as preCond.nombre for preCond in precioCondiciones"> | 507 | <select class="form-control" ng-change="cargarArticulos()" ng-model="notaPedido.precioCondicion" ng-options="preCond.id as preCond.nombre for preCond in precioCondiciones"> |
506 | </select> | 508 | </select> |
507 | </div> | 509 | </div> |
508 | </div> | 510 | </div> |
509 | <div class="col-md-2"> | 511 | <div class="col-md-2"> |
510 | <div class="col-auto"> | 512 | <div class="col-auto"> |
511 | <label>Producto</label> | 513 | <label>Producto</label> |
512 | </div> | 514 | </div> |
513 | </div> | 515 | </div> |
514 | <div class="col-md-4"> | 516 | <div class="col-md-4"> |
515 | <div class="col-auto"> | 517 | <div class="col-auto"> |
516 | <input type="text" class="form-control" placeholder="Seleccione producto" ng-model="notaPedido.producto" | 518 | <input type="text" class="form-control" placeholder="Seleccione producto" ng-model="notaPedido.producto" |
517 | ng-click="seleccionarArticulo()" readonly> | 519 | ng-click="seleccionarArticulo()" readonly> |
518 | </div> | 520 | </div> |
519 | </div> | 521 | </div> |
520 | </div> | 522 | </div> |
521 | <div class="col-md-12"> | 523 | <div class="col-md-12"> |
522 | <table class="table my-3 table-hover table-nonfluid"> | 524 | <table class="table my-3 table-hover table-nonfluid"> |
523 | <thead> | 525 | <thead> |
524 | <tr> | 526 | <tr> |
525 | <th>Código</th> | 527 | <th>Código</th> |
526 | <th>Nombre</th> | 528 | <th>Nombre</th> |
527 | <th>Precio unitario</th> | 529 | <th>Precio unitario</th> |
528 | <th>Costo unitario bruto</th> | 530 | <th>Costo unitario bruto</th> |
529 | <th>Cantidad</th> | 531 | <th>Cantidad</th> |
530 | <th>Subtotal</th> | 532 | <th>Subtotal</th> |
531 | </tr> | 533 | </tr> |
532 | </thead> | 534 | </thead> |
533 | <tbody> | 535 | <tbody> |
534 | <tr ng-repeat="articulo in articulosTabla"> | 536 | <tr ng-repeat="articulo in articulosTabla"> |
535 | <td ng-bind="articulo.codigo"></td> | 537 | <td ng-bind="articulo.codigo"></td> |
536 | <td ng-bind="articulo.nombre"></td> | 538 | <td ng-bind="articulo.nombre"></td> |
537 | <td ng-bind="articulo.precio"></td> | 539 | <td ng-bind="articulo.precio"></td> |
538 | <td ng-bind="articulo.costoUnitario"></td> | 540 | <td ng-bind="articulo.costoUnitario"></td> |
539 | <td><input ng-model="articulo.cantidad" class="form-control" type="number" min="0" value="1"></td> | 541 | <td><input ng-model="articulo.cantidad" class="form-control" type="number" min="0" value="1"></td> |
540 | <td ng-bind="getSubTotal(articulo.item)"></td> | 542 | <td ng-bind="getSubTotal(articulo.item)"></td> |
541 | </tr> | 543 | </tr> |
542 | </tbody> | 544 | </tbody> |
543 | </table> | 545 | </table> |
544 | </div> | 546 | </div> |
545 | </uib-tab> | 547 | </uib-tab> |
546 | </uib-tabset> | 548 | </uib-tabset> |
547 | </form>--> | 549 | </form>--> |