Commit cf443cf3839408864eadf5e3c9aaa3ed22877c1b
Exists in
master
Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido
Showing
2 changed files
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: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
13 | { | 13 | { |
14 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
19 | ]; | 19 | ]; |
20 | 20 | ||
21 | $scope.show = false; | 21 | $scope.show = false; |
22 | $scope.cargando = true; | 22 | $scope.cargando = true; |
23 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
24 | maxDate: new Date(), | 24 | maxDate: new Date(), |
25 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
26 | }; | 26 | }; |
27 | 27 | ||
28 | $scope.notaPedido = { | 28 | $scope.notaPedido = { |
29 | vendedor: {}, | 29 | vendedor: {}, |
30 | cliente: {}, | 30 | cliente: {}, |
31 | domicilio: {dom: ''}, | 31 | domicilio: {dom: ''}, |
32 | moneda: {detalle: ''} | 32 | moneda: {detalle: ''} |
33 | }; | 33 | }; |
34 | 34 | ||
35 | $scope.cabecera = []; | 35 | $scope.cabecera = []; |
36 | $scope.showCabecera = false; | 36 | $scope.showCabecera = true; |
37 | 37 | ||
38 | $scope.now = new Date(); | 38 | $scope.now = new Date(); |
39 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 39 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
40 | $scope.comprobante = Math.round(Math.random() * 1000000); | 40 | $scope.comprobante = Math.round(Math.random() * 1000000); |
41 | 41 | ||
42 | $scope.articulosTabla = []; | 42 | $scope.articulosTabla = []; |
43 | var idLista; | 43 | var idLista; |
44 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 44 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
45 | crearNotaPedidoService.getPrecioCondicion().then( | 45 | crearNotaPedidoService.getPrecioCondicion().then( |
46 | function(res) { | 46 | function(res) { |
47 | $scope.precioCondiciones = res.data; | 47 | $scope.precioCondiciones = res.data; |
48 | } | 48 | } |
49 | ); | 49 | ); |
50 | if (notaPedidoTemp !== undefined) { | 50 | if (notaPedidoTemp !== undefined) { |
51 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 51 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
52 | $scope.notaPedido = notaPedidoTemp; | 52 | $scope.notaPedido = notaPedidoTemp; |
53 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 53 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
54 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 54 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
55 | idLista = $scope.notaPedido.precioCondicion; | 55 | idLista = $scope.notaPedido.precioCondicion; |
56 | crearNotaPedidoService | 56 | crearNotaPedidoService |
57 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 57 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
58 | function(res) { | 58 | function(res) { |
59 | $scope.articulosTabla = res.data; | 59 | $scope.articulosTabla = res.data; |
60 | } | 60 | } |
61 | ); | 61 | ); |
62 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 62 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
63 | //(NO REQUERIDO EN ESTA VERSION) | 63 | //(NO REQUERIDO EN ESTA VERSION) |
64 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 64 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
65 | // function(res) { | 65 | // function(res) { |
66 | // $scope.notaPedido.domicilio = res.data; | 66 | // $scope.notaPedido.domicilio = res.data; |
67 | // } | 67 | // } |
68 | // ); | 68 | // ); |
69 | } else { | 69 | } else { |
70 | $scope.notaPedido.fechaCarga = new Date(); | 70 | $scope.notaPedido.fechaCarga = new Date(); |
71 | $scope.notaPedido.bomba = '0'; | 71 | $scope.notaPedido.bomba = '0'; |
72 | $scope.notaPedido.flete = '0'; | 72 | $scope.notaPedido.flete = '0'; |
73 | idLista = undefined; | 73 | idLista = undefined; |
74 | } | 74 | } |
75 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 75 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
76 | // $scope.addNewDom = function() { | 76 | // $scope.addNewDom = function() { |
77 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 77 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
78 | // }; | 78 | // }; |
79 | // $scope.removeNewChoice = function(choice) { | 79 | // $scope.removeNewChoice = function(choice) { |
80 | // if ($scope.notaPedido.domicilio.length > 1) { | 80 | // if ($scope.notaPedido.domicilio.length > 1) { |
81 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 81 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
82 | // function(c) { | 82 | // function(c) { |
83 | // return c.$$hashKey === choice.$$hashKey; | 83 | // return c.$$hashKey === choice.$$hashKey; |
84 | // } | 84 | // } |
85 | // ), 1); | 85 | // ), 1); |
86 | // } | 86 | // } |
87 | // }; | 87 | // }; |
88 | $scope.crearNotaPedido = function() { | 88 | $scope.crearNotaPedido = function() { |
89 | if($scope.articulosTabla.length === 0) { | 89 | if($scope.articulosTabla.length === 0) { |
90 | focaModalService.alert('Debe cargar almenos un articulo'); | 90 | focaModalService.alert('Debe cargar almenos un articulo'); |
91 | return; | 91 | return; |
92 | } | 92 | } |
93 | if($scope.notaPedido.domicilio.id === undefined) { | 93 | if($scope.notaPedido.domicilio.id === undefined) { |
94 | $scope.notaPedido.domicilio.id = 0; | 94 | $scope.notaPedido.domicilio.id = 0; |
95 | } | 95 | } |
96 | var date = new Date(); | 96 | var date = new Date(); |
97 | var notaPedido = { | 97 | var notaPedido = { |
98 | id: 0, | 98 | id: 0, |
99 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 99 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
100 | .toISOString().slice(0, 19).replace('T', ' '), | 100 | .toISOString().slice(0, 19).replace('T', ' '), |
101 | vendedor: $scope.notaPedido.vendedor.nombre, | 101 | vendedor: $scope.notaPedido.vendedor.nombre, |
102 | idCliente: $scope.notaPedido.cliente.id, | 102 | idCliente: $scope.notaPedido.cliente.id, |
103 | domicilio: $scope.notaPedido.domicilio, | 103 | domicilio: $scope.notaPedido.domicilio, |
104 | bomba: $scope.notaPedido.bomba, | 104 | bomba: $scope.notaPedido.bomba, |
105 | flete: $scope.notaPedido.flete, | 105 | flete: $scope.notaPedido.flete, |
106 | total: $scope.getTotal() | 106 | total: $scope.getTotal() |
107 | }; | 107 | }; |
108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
109 | function(data) { | 109 | function(data) { |
110 | focaModalService.alert('Nota pedido creada'); | 110 | focaModalService.alert('Nota pedido creada'); |
111 | if($scope.notaPedido.flete === 1) { | 111 | if($scope.notaPedido.flete === 1) { |
112 | var flete = { | 112 | var flete = { |
113 | idNotaPedido: data.data.id, | 113 | idNotaPedido: data.data.id, |
114 | idTransportista: $scope.notaPedido.fleteId, | 114 | idTransportista: $scope.notaPedido.fleteId, |
115 | idChofer: $scope.notaPedido.chofer.id, | 115 | idChofer: $scope.notaPedido.chofer.id, |
116 | idVehiculo: $scope.notaPedido.vehiculo.id, | 116 | idVehiculo: $scope.notaPedido.vehiculo.id, |
117 | kilometros: $scope.notaPedido.kilometros, | 117 | kilometros: $scope.notaPedido.kilometros, |
118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
119 | }; | 119 | }; |
120 | crearNotaPedidoService.crearFlete(flete); | 120 | crearNotaPedidoService.crearFlete(flete); |
121 | } | 121 | } |
122 | var articulosNotaPedido = $scope.articulosTabla; | 122 | var articulosNotaPedido = $scope.articulosTabla; |
123 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
124 | delete articulosNotaPedido[i].edit; | 124 | delete articulosNotaPedido[i].edit; |
125 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 125 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
126 | crearNotaPedidoService | 126 | crearNotaPedidoService |
127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
128 | } | 128 | } |
129 | $scope.limpiarPantalla(); | 129 | $scope.limpiarPantalla(); |
130 | } | 130 | } |
131 | ); | 131 | ); |
132 | }; | 132 | }; |
133 | 133 | ||
134 | $scope.seleccionarArticulo = function() { | 134 | $scope.seleccionarArticulo = function() { |
135 | if (idLista === undefined) { | 135 | if (idLista === undefined) { |
136 | focaModalService.alert( | 136 | focaModalService.alert( |
137 | 'Primero seleccione una lista de precio y condicion'); | 137 | 'Primero seleccione una lista de precio y condicion'); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | var modalInstance = $uibModal.open( | 140 | var modalInstance = $uibModal.open( |
141 | { | 141 | { |
142 | ariaLabelledBy: 'Busqueda de Productos', | 142 | ariaLabelledBy: 'Busqueda de Productos', |
143 | templateUrl: 'modal-busqueda-productos.html', | 143 | templateUrl: 'modal-busqueda-productos.html', |
144 | controller: 'modalBusquedaProductosCtrl', | 144 | controller: 'modalBusquedaProductosCtrl', |
145 | resolve: { idLista: function() { return idLista; } }, | 145 | resolve: { idLista: function() { return idLista; } }, |
146 | size: 'lg' | 146 | size: 'lg' |
147 | } | 147 | } |
148 | ); | 148 | ); |
149 | modalInstance.result.then( | 149 | modalInstance.result.then( |
150 | function(producto) { | 150 | function(producto) { |
151 | var newArt = | 151 | var newArt = |
152 | { | 152 | { |
153 | id: 0, | 153 | id: 0, |
154 | codigo: producto.codigo, | 154 | codigo: producto.codigo, |
155 | sector: producto.sector, | 155 | sector: producto.sector, |
156 | sectorCodigo: producto.sector + '-' + producto.codigo, | 156 | sectorCodigo: producto.sector + '-' + producto.codigo, |
157 | descripcion: producto.descripcion, | 157 | descripcion: producto.descripcion, |
158 | item: $scope.articulosTabla.length + 1, | 158 | item: $scope.articulosTabla.length + 1, |
159 | nombre: producto.descripcion, | 159 | nombre: producto.descripcion, |
160 | precio: producto.precio.toFixed(2), | 160 | precio: producto.precio.toFixed(2), |
161 | costoUnitario: producto.costo, | 161 | costoUnitario: producto.costo, |
162 | edit: false | 162 | edit: false |
163 | }; | 163 | }; |
164 | $scope.articuloACargar = newArt; | 164 | $scope.articuloACargar = newArt; |
165 | $scope.cargando = false; | 165 | $scope.cargando = false; |
166 | }, function() { | 166 | }, function() { |
167 | // funcion ejecutada cuando se cancela el modal | 167 | // funcion ejecutada cuando se cancela el modal |
168 | } | 168 | } |
169 | ); | 169 | ); |
170 | }; | 170 | }; |
171 | 171 | ||
172 | $scope.seleccionarVendedor = function() { | 172 | $scope.seleccionarVendedor = function() { |
173 | var modalInstance = $uibModal.open( | 173 | var modalInstance = $uibModal.open( |
174 | { | 174 | { |
175 | ariaLabelledBy: 'Busqueda de Vendedores', | 175 | ariaLabelledBy: 'Busqueda de Vendedores', |
176 | templateUrl: 'modal-vendedores.html', | 176 | templateUrl: 'modal-vendedores.html', |
177 | controller: 'modalVendedoresCtrl', | 177 | controller: 'modalVendedoresCtrl', |
178 | size: 'lg' | 178 | size: 'lg' |
179 | } | 179 | } |
180 | ); | 180 | ); |
181 | modalInstance.result.then( | 181 | modalInstance.result.then( |
182 | function(vendedor) { | 182 | function(vendedor) { |
183 | addCabecera('Vendedor:', vendedor.NomVen); | 183 | addCabecera('Vendedor:', vendedor.NomVen); |
184 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 184 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
185 | }, function() { | 185 | }, function() { |
186 | 186 | ||
187 | } | 187 | } |
188 | ); | 188 | ); |
189 | }; | 189 | }; |
190 | 190 | ||
191 | $scope.seleccionarProveedor = function() { | 191 | $scope.seleccionarProveedor = function() { |
192 | var modalInstance = $uibModal.open( | 192 | var modalInstance = $uibModal.open( |
193 | { | 193 | { |
194 | ariaLabelledBy: 'Busqueda de Proveedor', | 194 | ariaLabelledBy: 'Busqueda de Proveedor', |
195 | templateUrl: 'modal-proveedor.html', | 195 | templateUrl: 'modal-proveedor.html', |
196 | controller: 'focaModalProveedorCtrl', | 196 | controller: 'focaModalProveedorCtrl', |
197 | size: 'lg' | 197 | size: 'lg' |
198 | } | 198 | } |
199 | ); | 199 | ); |
200 | modalInstance.result.then( | 200 | modalInstance.result.then( |
201 | function(proveedor) { | 201 | function(proveedor) { |
202 | $scope.notaPedido.proveedor = proveedor.NOM; | 202 | $scope.notaPedido.proveedor = proveedor.NOM; |
203 | addCabecera('Proveedor:', proveedor.NOM); | 203 | addCabecera('Proveedor:', proveedor.NOM); |
204 | }, function() { | 204 | }, function() { |
205 | 205 | ||
206 | } | 206 | } |
207 | ); | 207 | ); |
208 | }; | 208 | }; |
209 | 209 | ||
210 | $scope.seleccionarCliente = function() { | 210 | $scope.seleccionarCliente = function() { |
211 | var modalInstance = $uibModal.open( | 211 | var modalInstance = $uibModal.open( |
212 | { | 212 | { |
213 | ariaLabelledBy: 'Busqueda de Cliente', | 213 | ariaLabelledBy: 'Busqueda de Cliente', |
214 | templateUrl: 'foca-busqueda-cliente-modal.html', | 214 | templateUrl: 'foca-busqueda-cliente-modal.html', |
215 | controller: 'focaBusquedaClienteModalController', | 215 | controller: 'focaBusquedaClienteModalController', |
216 | size: 'lg' | 216 | size: 'lg' |
217 | } | 217 | } |
218 | ); | 218 | ); |
219 | modalInstance.result.then( | 219 | modalInstance.result.then( |
220 | function(cliente) { | 220 | function(cliente) { |
221 | $scope.notaPedido.cliente.nombre = cliente.nom; | 221 | $scope.notaPedido.cliente.nombre = cliente.nom; |
222 | $scope.notaPedido.cliente.id = cliente.cod; | 222 | $scope.notaPedido.cliente.id = cliente.cod; |
223 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 223 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
224 | function(data) { | 224 | function(data) { |
225 | if(data.data.length === 0){ | 225 | if(data.data.length === 0){ |
226 | focaModalService | 226 | focaModalService |
227 | .alert('El cliente no tienen domicilios de entrega') | 227 | .alert('El cliente no tienen domicilios de entrega') |
228 | .then( | 228 | .then( |
229 | function() { | 229 | function() { |
230 | $scope.seleccionarCliente(); | 230 | $scope.seleccionarCliente(); |
231 | $scope.notaPedido.cliente = {nombre: ''}; | 231 | $scope.notaPedido.cliente = {nombre: ''}; |
232 | } | 232 | } |
233 | ); | 233 | ); |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | var modalInstanceDomicilio = $uibModal.open( | 236 | var modalInstanceDomicilio = $uibModal.open( |
237 | { | 237 | { |
238 | ariaLabelledBy: 'Busqueda de Domicilios', | 238 | ariaLabelledBy: 'Busqueda de Domicilios', |
239 | templateUrl: 'modal-domicilio.html', | 239 | templateUrl: 'modal-domicilio.html', |
240 | controller: 'focaModalDomicilioController', | 240 | controller: 'focaModalDomicilioController', |
241 | resolve: { idCliente: function() { return cliente.cod; }}, | 241 | resolve: { idCliente: function() { return cliente.cod; }}, |
242 | size: 'lg', | 242 | size: 'lg', |
243 | backdrop: 'static', | 243 | backdrop: 'static', |
244 | } | 244 | } |
245 | ); | 245 | ); |
246 | modalInstanceDomicilio.result.then( | 246 | modalInstanceDomicilio.result.then( |
247 | function(domicilio) { | 247 | function(domicilio) { |
248 | focaModalService.alert('Domicilio elegido' + domicilio.dom); | 248 | focaModalService.alert('Domicilio elegido' + domicilio.dom); |
249 | }, function() { | 249 | }, function() { |
250 | $scope.notaPedido.cliente.nombre = ''; | 250 | $scope.notaPedido.cliente.nombre = ''; |
251 | $scope.notaPedido.cliente.id = ''; | 251 | $scope.notaPedido.cliente.id = ''; |
252 | removeCabecera('Cliente:'); | 252 | removeCabecera('Cliente:'); |
253 | $scope.seleccionarCliente(); | 253 | $scope.seleccionarCliente(); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | ); | 256 | ); |
257 | } | 257 | } |
258 | ); | 258 | ); |
259 | addCabecera('Cliente:', cliente.nom); | 259 | addCabecera('Cliente:', cliente.nom); |
260 | }, function() { | 260 | }, function() { |
261 | 261 | ||
262 | } | 262 | } |
263 | ); | 263 | ); |
264 | }; | 264 | }; |
265 | 265 | ||
266 | $scope.mostrarFichaCliente = function() { | 266 | $scope.mostrarFichaCliente = function() { |
267 | $uibModal.open( | 267 | $uibModal.open( |
268 | { | 268 | { |
269 | ariaLabelledBy: 'Datos del Cliente', | 269 | ariaLabelledBy: 'Datos del Cliente', |
270 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 270 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
271 | controller: 'focaCrearNotaPedidoFichaClienteController', | 271 | controller: 'focaCrearNotaPedidoFichaClienteController', |
272 | size: 'lg' | 272 | size: 'lg' |
273 | } | 273 | } |
274 | ); | 274 | ); |
275 | }; | 275 | }; |
276 | 276 | ||
277 | $scope.getTotal = function() { | 277 | $scope.getTotal = function() { |
278 | var total = 0; | 278 | var total = 0; |
279 | var arrayTempArticulos = $scope.articulosTabla; | 279 | var arrayTempArticulos = $scope.articulosTabla; |
280 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 280 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
281 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 281 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
282 | } | 282 | } |
283 | return total.toFixed(2); | 283 | return total.toFixed(2); |
284 | }; | 284 | }; |
285 | 285 | ||
286 | $scope.getSubTotal = function() { | 286 | $scope.getSubTotal = function() { |
287 | if($scope.articuloACargar) { | 287 | if($scope.articuloACargar) { |
288 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 288 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
289 | } | 289 | } |
290 | }; | 290 | }; |
291 | 291 | ||
292 | $scope.abrirModalListaPrecio = function() { | 292 | $scope.abrirModalListaPrecio = function() { |
293 | var modalInstance = $uibModal.open( | 293 | var modalInstance = $uibModal.open( |
294 | { | 294 | { |
295 | ariaLabelledBy: 'Busqueda de Precio Condición', | 295 | ariaLabelledBy: 'Busqueda de Precio Condición', |
296 | templateUrl: 'modal-precio-condicion.html', | 296 | templateUrl: 'modal-precio-condicion.html', |
297 | controller: 'focaModalPrecioCondicionController', | 297 | controller: 'focaModalPrecioCondicionController', |
298 | size: 'lg' | 298 | size: 'lg' |
299 | } | 299 | } |
300 | ); | 300 | ); |
301 | modalInstance.result.then( | 301 | modalInstance.result.then( |
302 | function(precioCondicion) { | 302 | function(precioCondicion) { |
303 | var cabecera = ''; | 303 | var cabecera = ''; |
304 | var plazosConcat = ''; | 304 | var plazosConcat = ''; |
305 | if(!Array.isArray(precioCondicion)) { | 305 | if(!Array.isArray(precioCondicion)) { |
306 | $scope.plazosPagos = precioCondicion.plazoPago; | 306 | $scope.plazosPagos = precioCondicion.plazoPago; |
307 | idLista = precioCondicion.idListaPrecio; | 307 | idLista = precioCondicion.idListaPrecio; |
308 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 308 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
309 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 309 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
310 | } | 310 | } |
311 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 311 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
312 | } else { //Cuando se ingresan los plazos manualmente | 312 | } else { //Cuando se ingresan los plazos manualmente |
313 | idLista = -1; //-1, el modal productos busca todos los productos | 313 | idLista = -1; //-1, el modal productos busca todos los productos |
314 | $scope.notaPedido.plazoPago = precioCondicion; | 314 | $scope.notaPedido.plazoPago = precioCondicion; |
315 | for(var j = 0; j < precioCondicion.length; j++) { | 315 | for(var j = 0; j < precioCondicion.length; j++) { |
316 | plazosConcat += precioCondicion[j].dias + ' '; | 316 | plazosConcat += precioCondicion[j].dias + ' '; |
317 | } | 317 | } |
318 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 318 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
319 | } | 319 | } |
320 | $scope.articulosTabla = []; | 320 | $scope.articulosTabla = []; |
321 | addCabecera('Precios y condiciones:', cabecera); | 321 | addCabecera('Precios y condiciones:', cabecera); |
322 | }, function() { | 322 | }, function() { |
323 | 323 | ||
324 | } | 324 | } |
325 | ); | 325 | ); |
326 | }; | 326 | }; |
327 | 327 | ||
328 | $scope.abrirModalFlete = function() { | 328 | $scope.abrirModalFlete = function() { |
329 | var modalInstance = $uibModal.open( | 329 | var modalInstance = $uibModal.open( |
330 | { | 330 | { |
331 | ariaLabelledBy: 'Busqueda de Flete', | 331 | ariaLabelledBy: 'Busqueda de Flete', |
332 | templateUrl: 'modal-flete.html', | 332 | templateUrl: 'modal-flete.html', |
333 | controller: 'focaModalFleteController', | 333 | controller: 'focaModalFleteController', |
334 | size: 'lg', | 334 | size: 'lg', |
335 | resolve: { | 335 | resolve: { |
336 | parametrosFlete: | 336 | parametrosFlete: |
337 | function() { | 337 | function() { |
338 | return { | 338 | return { |
339 | flete: $scope.notaPedido.flete, | 339 | flete: $scope.notaPedido.flete, |
340 | bomba: $scope.notaPedido.bomba, | 340 | bomba: $scope.notaPedido.bomba, |
341 | kilometros: $scope.notaPedido.kilometros | 341 | kilometros: $scope.notaPedido.kilometros |
342 | }; | 342 | }; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | } | 345 | } |
346 | ); | 346 | ); |
347 | modalInstance.result.then( | 347 | modalInstance.result.then( |
348 | function(datos) { | 348 | function(datos) { |
349 | $scope.notaPedido.flete = datos.flete; | 349 | $scope.notaPedido.flete = datos.flete; |
350 | $scope.notaPedido.bomba = datos.bomba; | 350 | $scope.notaPedido.bomba = datos.bomba; |
351 | $scope.notaPedido.kilometros = datos.kilometros; | 351 | $scope.notaPedido.kilometros = datos.kilometros; |
352 | 352 | ||
353 | addCabecera('Flete:', datos.flete); | 353 | addCabecera('Flete:', datos.flete); |
354 | if(datos.flete === 'si') { | 354 | if(datos.flete === 'si') { |
355 | addCabecera('Bomba:', datos.bomba); | 355 | addCabecera('Bomba:', datos.bomba); |
356 | addCabecera('Kilometros:', datos.kilometros); | 356 | addCabecera('Kilometros:', datos.kilometros); |
357 | } else { | 357 | } else { |
358 | removeCabecera('Bomba:'); | 358 | removeCabecera('Bomba:'); |
359 | removeCabecera('Kilometros:'); | 359 | removeCabecera('Kilometros:'); |
360 | } | 360 | } |
361 | }, function() { | 361 | }, function() { |
362 | 362 | ||
363 | } | 363 | } |
364 | ); | 364 | ); |
365 | }; | 365 | }; |
366 | 366 | ||
367 | $scope.abrirModalMoneda = function() { | 367 | $scope.abrirModalMoneda = function() { |
368 | var modalInstance = $uibModal.open( | 368 | var modalInstance = $uibModal.open( |
369 | { | 369 | { |
370 | ariaLabelledBy: 'Busqueda de Moneda', | 370 | ariaLabelledBy: 'Busqueda de Moneda', |
371 | templateUrl: 'modal-moneda.html', | 371 | templateUrl: 'modal-moneda.html', |
372 | controller: 'focaModalMonedaController', | 372 | controller: 'focaModalMonedaController', |
373 | size: 'lg' | 373 | size: 'lg' |
374 | } | 374 | } |
375 | ); | 375 | ); |
376 | modalInstance.result.then( | 376 | modalInstance.result.then( |
377 | function(moneda) { | 377 | function(moneda) { |
378 | $scope.notaPedido.moneda = { | 378 | $scope.notaPedido.moneda = { |
379 | id: moneda.ID, | 379 | id: moneda.ID, |
380 | detalle: moneda.DETALLE, | 380 | detalle: moneda.DETALLE, |
381 | simbolo: moneda.SIMBOLO | 381 | simbolo: moneda.SIMBOLO |
382 | }; | 382 | }; |
383 | 383 | ||
384 | addCabecera('Moneda:', moneda.DETALLE); | 384 | addCabecera('Moneda:', moneda.DETALLE); |
385 | }, function() { | 385 | }, function() { |
386 | 386 | ||
387 | } | 387 | } |
388 | ); | 388 | ); |
389 | }; | 389 | }; |
390 | 390 | ||
391 | $scope.agregarATabla = function(key) { | 391 | $scope.agregarATabla = function(key) { |
392 | if(key === 13) { | 392 | if(key === 13) { |
393 | if($scope.articuloACargar.cantidad === undefined || | 393 | if($scope.articuloACargar.cantidad === undefined || |
394 | $scope.articuloACargar.cantidad === 0 || | 394 | $scope.articuloACargar.cantidad === 0 || |
395 | $scope.articuloACargar.cantidad === null ){ | 395 | $scope.articuloACargar.cantidad === null ){ |
396 | focaModalService.alert('El valor debe ser al menos 1'); | 396 | focaModalService.alert('El valor debe ser al menos 1'); |
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | delete $scope.articuloACargar.sectorCodigo; | 399 | delete $scope.articuloACargar.sectorCodigo; |
400 | $scope.articulosTabla.push($scope.articuloACargar); | 400 | $scope.articulosTabla.push($scope.articuloACargar); |
401 | $scope.cargando = true; | 401 | $scope.cargando = true; |
402 | } | 402 | } |
403 | }; | 403 | }; |
404 | 404 | ||
405 | $scope.quitarArticulo = function(key) { | 405 | $scope.quitarArticulo = function(key) { |
406 | $scope.articulosTabla.splice(key, 1); | 406 | $scope.articulosTabla.splice(key, 1); |
407 | }; | 407 | }; |
408 | 408 | ||
409 | $scope.editarArticulo = function(key, articulo) { | 409 | $scope.editarArticulo = function(key, articulo) { |
410 | if(key === 13) { | 410 | if(key === 13) { |
411 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 411 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
412 | articulo.cantidad === undefined){ | 412 | articulo.cantidad === undefined){ |
413 | focaModalService.alert('El valor debe ser al menos 1'); | 413 | focaModalService.alert('El valor debe ser al menos 1'); |
414 | return; | 414 | return; |
415 | } | 415 | } |
416 | articulo.edit = false; | 416 | articulo.edit = false; |
417 | } | 417 | } |
418 | }; | 418 | }; |
419 | 419 | ||
420 | $scope.cambioEdit = function(articulo) { | 420 | $scope.cambioEdit = function(articulo) { |
421 | articulo.edit = true; | 421 | articulo.edit = true; |
422 | }; | 422 | }; |
423 | 423 | ||
424 | $scope.limpiarFlete = function() { | 424 | $scope.limpiarFlete = function() { |
425 | $scope.notaPedido.fleteNombre = ''; | 425 | $scope.notaPedido.fleteNombre = ''; |
426 | $scope.notaPedido.chofer = ''; | 426 | $scope.notaPedido.chofer = ''; |
427 | $scope.notaPedido.vehiculo = ''; | 427 | $scope.notaPedido.vehiculo = ''; |
428 | $scope.notaPedido.kilometros = ''; | 428 | $scope.notaPedido.kilometros = ''; |
429 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 429 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
430 | $scope.choferes = ''; | 430 | $scope.choferes = ''; |
431 | $scope.vehiculos = ''; | 431 | $scope.vehiculos = ''; |
432 | }; | 432 | }; |
433 | 433 | ||
434 | $scope.limpiarPantalla = function() { | 434 | $scope.limpiarPantalla = function() { |
435 | $scope.limpiarFlete(); | 435 | $scope.limpiarFlete(); |
436 | $scope.notaPedido.flete = '0'; | 436 | $scope.notaPedido.flete = '0'; |
437 | $scope.notaPedido.bomba = '0'; | 437 | $scope.notaPedido.bomba = '0'; |
438 | $scope.notaPedido.precioCondicion = ''; | 438 | $scope.notaPedido.precioCondicion = ''; |
439 | $scope.articulosTabla = []; | 439 | $scope.articulosTabla = []; |
440 | $scope.notaPedido.vendedor.nombre = ''; | 440 | $scope.notaPedido.vendedor.nombre = ''; |
441 | $scope.notaPedido.cliente = {nombre: ''}; | 441 | $scope.notaPedido.cliente = {nombre: ''}; |
442 | $scope.notaPedido.domicilio = {dom: ''}; | 442 | $scope.notaPedido.domicilio = {dom: ''}; |
443 | $scope.domiciliosCliente = []; | 443 | $scope.domiciliosCliente = []; |
444 | }; | 444 | }; |
445 | 445 | ||
446 | $scope.resetFilter = function() { | 446 | $scope.resetFilter = function() { |
447 | $scope.articuloACargar = {}; | 447 | $scope.articuloACargar = {}; |
448 | $scope.cargando = true; | 448 | $scope.cargando = true; |
449 | }; | 449 | }; |
450 | 450 | ||
451 | $scope.selectFocus = function($event) { | 451 | $scope.selectFocus = function($event) { |
452 | $event.target.select(); | 452 | $event.target.select(); |
453 | }; | 453 | }; |
454 | 454 | ||
455 | $scope.salir = function() { | 455 | $scope.salir = function() { |
456 | $location.path('/'); | 456 | $location.path('/'); |
457 | }; | 457 | }; |
458 | 458 | ||
459 | function addCabecera(label, valor) { | 459 | function addCabecera(label, valor) { |
460 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 460 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
461 | if(propiedad.length === 1) { | 461 | if(propiedad.length === 1) { |
462 | propiedad[0].valor = valor; | 462 | propiedad[0].valor = valor; |
463 | } else { | 463 | } else { |
464 | $scope.cabecera.push({label: label, valor: valor}); | 464 | $scope.cabecera.push({label: label, valor: valor}); |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | function removeCabecera(label) { | 468 | function removeCabecera(label) { |
469 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 469 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
470 | if(propiedad.length === 1){ | 470 | if(propiedad.length === 1){ |
471 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 471 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | ] | 475 | ] |
476 | ) | 476 | ) |
477 | .controller('notaPedidoListaCtrl', [ | 477 | .controller('notaPedidoListaCtrl', [ |
478 | '$scope', | 478 | '$scope', |
479 | 'crearNotaPedidoService', | 479 | 'crearNotaPedidoService', |
480 | '$location', | 480 | '$location', |
481 | function($scope, crearNotaPedidoService, $location) { | 481 | function($scope, crearNotaPedidoService, $location) { |
482 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 482 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
483 | $scope.notaPedidos = datos.data; | 483 | $scope.notaPedidos = datos.data; |
484 | }); | 484 | }); |
485 | $scope.editar = function(notaPedido) { | 485 | $scope.editar = function(notaPedido) { |
486 | crearNotaPedidoService.setNotaPedido(notaPedido); | 486 | crearNotaPedidoService.setNotaPedido(notaPedido); |
487 | $location.path('/venta-nota-pedido/abm/'); | 487 | $location.path('/venta-nota-pedido/abm/'); |
488 | }; | 488 | }; |
489 | $scope.crearPedido = function() { | 489 | $scope.crearPedido = function() { |
490 | crearNotaPedidoService.clearNotaPedido(); | 490 | crearNotaPedidoService.clearNotaPedido(); |
491 | $location.path('/venta-nota-pedido/abm/'); | 491 | $location.path('/venta-nota-pedido/abm/'); |
492 | }; | 492 | }; |
493 | } | 493 | } |
494 | ]) | 494 | ]) |
495 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 495 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
496 | '$scope', | 496 | '$scope', |
497 | 'crearNotaPedidoService', | 497 | 'crearNotaPedidoService', |
498 | '$location', | 498 | '$location', |
499 | function($scope, crearNotaPedidoService, $location) { | 499 | function($scope, crearNotaPedidoService, $location) { |
500 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 500 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
501 | $scope.notaPedidos = datos.data; | 501 | $scope.notaPedidos = datos.data; |
502 | }); | 502 | }); |
503 | $scope.editar = function(notaPedido) { | 503 | $scope.editar = function(notaPedido) { |
504 | crearNotaPedidoService.setNotaPedido(notaPedido); | 504 | crearNotaPedidoService.setNotaPedido(notaPedido); |
505 | $location.path('/venta-nota-pedido/abm/'); | 505 | $location.path('/venta-nota-pedido/abm/'); |
506 | }; | 506 | }; |
507 | $scope.crearPedido = function() { | 507 | $scope.crearPedido = function() { |
508 | crearNotaPedidoService.clearNotaPedido(); | 508 | crearNotaPedidoService.clearNotaPedido(); |
509 | $location.path('/venta-nota-pedido/abm/'); | 509 | $location.path('/venta-nota-pedido/abm/'); |
510 | }; | 510 | }; |
511 | } | 511 | } |
512 | ]); | 512 | ]); |
513 | 513 |
src/views/nota-pedido.html
1 | <div class="crear-nota-pedido"> | 1 | <div class="crear-nota-pedido"> |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> | 2 | <form name="formCrearNota" ng-submit="crearNotaPedido()"> |
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | 4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> |
5 | <div class="row p-1 panel-informativo"> | 5 | <div class="row p-1 panel-informativo"> |
6 | <div class="col-12"> | 6 | <div class="col-12"> |
7 | <div class="row"> | 7 | <div class="row"> |
8 | <div class="col-12 col-sm-4 nota-pedido"> | 8 | <div class="col-12 col-sm-4 nota-pedido"> |
9 | <h5>NOTA DE PEDIDO</h5> | 9 | <h5>NOTA DE PEDIDO</h5> |
10 | </div> | 10 | </div> |
11 | <div class="col-6 col-sm-4 numero-pedido">Nº {{puntoVenta}}-{{comprobante}}</div> | 11 | <div class="col-6 col-sm-4 numero-pedido">Nº {{puntoVenta}}-{{comprobante}}</div> |
12 | <div class="col-6 col-sm-4 text-right"> | 12 | <div class="col-6 col-sm-4 text-right"> |
13 | Fecha: {{ now | date:'dd/MM/yyyy HH:mm'}} | 13 | Fecha: {{ now | date:'dd/MM/yyyy HH:mm'}} |
14 | </div> | 14 | </div> |
15 | </div> | 15 | </div> |
16 | <div class="row"> | 16 | <div class="row"> |
17 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | 17 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> |
18 | <span class="label" ng-bind="cab.label"></span> | 18 | <span class="label" ng-bind="cab.label"></span> |
19 | <span class="valor" ng-bind="cab.valor"></span> | 19 | <span class="valor" ng-bind="cab.valor"></span> |
20 | </div> | 20 | </div> |
21 | <a | 21 | <a |
22 | class="btn col-12 btn-secondary d-sm-none" | 22 | class="btn col-12 btn-secondary d-sm-none" |
23 | ng-show="cabecera.length > 0" | 23 | ng-show="cabecera.length > 0" |
24 | ng-click="showCabecera = !showCabecera" | 24 | ng-click="showCabecera = !showCabecera" |
25 | > | 25 | > |
26 | <i | 26 | <i |
27 | class="fa fa-chevron-down" | 27 | class="fa fa-chevron-down" |
28 | ng-hide="showCabecera" | 28 | ng-hide="showCabecera" |
29 | aria-hidden="true" | 29 | aria-hidden="true" |
30 | > | 30 | > |
31 | </i> | 31 | </i> |
32 | <i | 32 | <i |
33 | class="fa fa-chevron-up" | 33 | class="fa fa-chevron-up" |
34 | ng-show="showCabecera" | 34 | ng-show="showCabecera" |
35 | aria-hidden="true"> | 35 | aria-hidden="true"> |
36 | </i> | 36 | </i> |
37 | </a> | 37 | </a> |
38 | </div> | 38 | </div> |
39 | </div> | 39 | </div> |
40 | </div> | 40 | </div> |
41 | <div class="row p-1 botonera-secundaria"> | 41 | <div class="row p-1 botonera-secundaria"> |
42 | <div class="col-12"> | 42 | <div class="col-12"> |
43 | <div class="row"> | 43 | <div class="row"> |
44 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | 44 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> |
45 | <button | 45 | <button |
46 | type="button" | 46 | type="button" |
47 | class="btn btn-default btn-block btn-xs text-left py-2" | 47 | class="btn btn-default btn-block btn-xs text-left py-2" |
48 | ng-click="boton.accion()" | 48 | ng-click="boton.accion()" |
49 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | 49 | ng-class="{'d-none d-sm-block': boton.texto == ''}" |
50 | > | 50 | > |
51 | <i | 51 | <i |
52 | class="fa fa-arrow-circle-right" | 52 | class="fa fa-arrow-circle-right" |
53 | ng-show="boton.texto != ''" | 53 | ng-show="boton.texto != ''" |
54 | ></i> | 54 | ></i> |
55 | | 55 | |
56 | {{boton.texto}} | 56 | {{boton.texto}} |
57 | </button> | 57 | </button> |
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | </div> | 60 | </div> |
61 | </div> | 61 | </div> |
62 | </div> | 62 | </div> |
63 | </div> | 63 | </div> |
64 | </form> | 64 | </form> |
65 | <div class="row"> | 65 | <div class="row"> |
66 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | 66 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> |
67 | <!-- PC --> | 67 | <!-- PC --> |
68 | <div class="row grilla-articulo align-items-end"> | 68 | <div class="row grilla-articulo align-items-end"> |
69 | <table class="table tabla-articulo table-striped table-sm table-dark"> | 69 | <table class="table tabla-articulo table-striped table-sm table-dark"> |
70 | <thead> | 70 | <thead> |
71 | <tr class="d-flex"> | 71 | <tr class="d-flex"> |
72 | <th class="">#</th> | 72 | <th class="">#</th> |
73 | <th class="col">Código</th> | 73 | <th class="col">Código</th> |
74 | <th class="col-4">Descripción</th> | 74 | <th class="col-4">Descripción</th> |
75 | <th class="col text-right">Cantidad</th> | 75 | <th class="col text-right">Cantidad</th> |
76 | <th class="col text-right">Precio Unitario</th> | 76 | <th class="col text-right">Precio Unitario</th> |
77 | <th class="col text-right">SubTotal</th> | 77 | <th class="col text-right">SubTotal</th> |
78 | <th class="text-right"> | 78 | <th class="text-right"> |
79 | <button | 79 | <button |
80 | class="btn btn-outline-secondary selectable" | 80 | class="btn btn-outline-secondary selectable" |
81 | ng-click="show = !show; masMenos()" | 81 | ng-click="show = !show; masMenos()" |
82 | > | 82 | > |
83 | <i | 83 | <i |
84 | class="fa fa-chevron-down" | 84 | class="fa fa-chevron-down" |
85 | ng-show="show" | 85 | ng-show="show" |
86 | aria-hidden="true" | 86 | aria-hidden="true" |
87 | > | 87 | > |
88 | </i> | 88 | </i> |
89 | <i | 89 | <i |
90 | class="fa fa-chevron-up" | 90 | class="fa fa-chevron-up" |
91 | ng-hide="show" | 91 | ng-hide="show" |
92 | aria-hidden="true"> | 92 | aria-hidden="true"> |
93 | </i> | 93 | </i> |
94 | </button> | 94 | </button> |
95 | </th> | 95 | </th> |
96 | </tr> | 96 | </tr> |
97 | </thead> | 97 | </thead> |
98 | <tbody class="tabla-articulo-body"> | 98 | <tbody class="tabla-articulo-body"> |
99 | <tr | 99 | <tr |
100 | ng-repeat="(key, articulo) in articulosTabla" | 100 | ng-repeat="(key, articulo) in articulosTabla" |
101 | ng-show="show || key == (articulosTabla.length - 1)" | 101 | ng-show="show || key == (articulosTabla.length - 1)" |
102 | class="d-flex" | 102 | class="d-flex" |
103 | > | 103 | > |
104 | <td ng-bind="key + 1"></td> | 104 | <td ng-bind="key + 1"></td> |
105 | <td | 105 | <td |
106 | class="col" | 106 | class="col" |
107 | ng-bind="articulo.sector + '-' + articulo.codigo" | 107 | ng-bind="articulo.sector + '-' + articulo.codigo" |
108 | ></td> | 108 | ></td> |
109 | <td | 109 | <td |
110 | class="col-4" | 110 | class="col-4" |
111 | ng-bind="articulo.descripcion" | 111 | ng-bind="articulo.descripcion" |
112 | ></td> | 112 | ></td> |
113 | <td class="col text-right"> | 113 | <td class="col text-right"> |
114 | <input | 114 | <input |
115 | ng-show="articulo.edit" | 115 | ng-show="articulo.edit" |
116 | ng-model="articulo.cantidad" | 116 | ng-model="articulo.cantidad" |
117 | class="form-control" | 117 | class="form-control" |
118 | type="number" | 118 | type="number" |
119 | min="1" | 119 | min="1" |
120 | foca-focus="articulo.edit" | 120 | foca-focus="articulo.edit" |
121 | ng-keypress="editarArticulo($event.keyCode, articulo)" | 121 | ng-keypress="editarArticulo($event.keyCode, articulo)" |
122 | ng-focus="selectFocus($event)" | 122 | ng-focus="selectFocus($event)" |
123 | > | 123 | > |
124 | <i | 124 | <i |
125 | class="selectable" | 125 | class="selectable" |
126 | ng-click="cambioEdit(articulo)" | 126 | ng-click="cambioEdit(articulo)" |
127 | ng-hide="articulo.edit" | 127 | ng-hide="articulo.edit" |
128 | ng-bind="articulo.cantidad"> | 128 | ng-bind="articulo.cantidad"> |
129 | </i> | 129 | </i> |
130 | </td> | 130 | </td> |
131 | <td | 131 | <td |
132 | class="col text-right" | 132 | class="col text-right" |
133 | ng-bind="articulo.precio | currency: '$'" | 133 | ng-bind="articulo.precio | currency: '$'" |
134 | ></td> | 134 | ></td> |
135 | <td | 135 | <td |
136 | class="col text-right" | 136 | class="col text-right" |
137 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> | 137 | ng-bind="(articulo.precio * articulo.cantidad) | currency: '$'"> |
138 | </td> | 138 | </td> |
139 | <td class="text-center"> | 139 | <td class="text-center"> |
140 | <button | 140 | <button |
141 | class="btn btn-outline-secondary" | 141 | class="btn btn-outline-secondary" |
142 | ng-click="quitarArticulo(key)" | 142 | ng-click="quitarArticulo(key)" |
143 | > | 143 | > |
144 | <i class="fa fa-trash"></i> | 144 | <i class="fa fa-trash"></i> |
145 | </button> | 145 | </button> |
146 | </td> | 146 | </td> |
147 | </tr> | 147 | </tr> |
148 | </tbody> | 148 | </tbody> |
149 | <tfoot> | 149 | <tfoot> |
150 | <tr ng-show="!cargando" class="d-flex"> | 150 | <tr ng-show="!cargando" class="d-flex"> |
151 | <td | 151 | <td |
152 | class="align-middle" | 152 | class="align-middle" |
153 | ng-bind="articulosTabla.length + 1" | 153 | ng-bind="articulosTabla.length + 1" |
154 | ></td> | 154 | ></td> |
155 | <td class="col"> | 155 | <td class="col"> |
156 | <input | 156 | <input |
157 | class="form-control" | 157 | class="form-control" |
158 | ng-model="articuloACargar.sectorCodigo" | 158 | ng-model="articuloACargar.sectorCodigo" |
159 | readonly | 159 | readonly |
160 | > | 160 | > |
161 | </td> | 161 | </td> |
162 | <td class="col-3 tabla-articulo-descripcion"> | 162 | <td class="col-4 tabla-articulo-descripcion"> |
163 | <input | 163 | <input |
164 | class="form-control" | 164 | class="form-control" |
165 | ng-model="articuloACargar.descripcion" | 165 | ng-model="articuloACargar.descripcion" |
166 | readonly | 166 | readonly |
167 | > | 167 | > |
168 | </td> | 168 | </td> |
169 | <td class="col text-right"> | 169 | <td class="col text-right"> |
170 | <input | 170 | <input |
171 | class="form-control" | 171 | class="form-control" |
172 | type="number" | 172 | type="number" |
173 | min="1" | 173 | min="1" |
174 | ng-model="articuloACargar.cantidad" | 174 | ng-model="articuloACargar.cantidad" |
175 | foca-focus="!cargando" | 175 | foca-focus="!cargando" |
176 | esc-key="resetFilter()" | 176 | esc-key="resetFilter()" |
177 | ng-keypress="agregarATabla($event.keyCode)" | 177 | ng-keypress="agregarATabla($event.keyCode)" |
178 | > | 178 | > |
179 | </td> | 179 | </td> |
180 | <td class="col text-right"> | 180 | <td class="col text-right"> |
181 | <input | 181 | <input |
182 | class="form-control" | 182 | class="form-control" |
183 | ng-value="articuloACargar.precio | currency: '$'" | 183 | ng-value="articuloACargar.precio | currency: '$'" |
184 | readonly | 184 | readonly |
185 | > | 185 | > |
186 | </td> | 186 | </td> |
187 | <td class="col text-right"> | 187 | <td class="col text-right"> |
188 | <input | 188 | <input |
189 | class="form-control" | 189 | class="form-control" |
190 | ng-value="getSubTotal() | currency: '$'" | 190 | ng-value="getSubTotal() | currency: '$'" |
191 | readonly | 191 | readonly |
192 | ></td> | 192 | ></td> |
193 | <td class="text-center align-middle"> | 193 | <td class="text-center align-middle"> |
194 | <button | 194 | <button |
195 | class="btn btn-outline-secondary" | 195 | class="btn btn-outline-secondary" |
196 | ng-click="agregarATabla(13)" | 196 | ng-click="agregarATabla(13)" |
197 | > | 197 | > |
198 | <i class="fa fa-save"></i> | 198 | <i class="fa fa-save"></i> |
199 | </button> | 199 | </button> |
200 | </td> | 200 | </td> |
201 | </tr> | 201 | </tr> |
202 | <tr ng-show="cargando" class="d-flex"> | 202 | <tr ng-show="cargando" class="d-flex"> |
203 | <td colspan="7" class="col-12"> | 203 | <td colspan="7" class="col-12"> |
204 | <input | 204 | <input |
205 | placeholder="Seleccione Articulo" | 205 | placeholder="Seleccione Articulo" |
206 | class="form-control form-control-sm" | 206 | class="form-control form-control-sm" |
207 | readonly | 207 | readonly |
208 | ng-click="seleccionarArticulo()" | 208 | ng-click="seleccionarArticulo()" |
209 | /> | 209 | /> |
210 | </td> | 210 | </td> |
211 | </tr> | 211 | </tr> |
212 | <tr class="d-flex"> | 212 | <tr class="d-flex"> |
213 | <td colspan="4"> | 213 | <td colspan="4"> |
214 | <strong>Cantidad Items:</strong> | 214 | <strong>Cantidad Items:</strong> |
215 | <a ng-bind="articulosTabla.length"></a> | 215 | <a ng-bind="articulosTabla.length"></a> |
216 | </td> | 216 | </td> |
217 | <td class="text-right ml-auto table-celda-total"><h3>Total:</h3></td> | 217 | <td class="text-right ml-auto table-celda-total"><h3>Total:</h3></td> |
218 | <td class="table-celda-total text-right" colspan="1"> | 218 | <td class="table-celda-total text-right" colspan="1"> |
219 | <h3>{{getTotal() | currency: '$'}}</h3> | 219 | <h3>{{getTotal() | currency: '$'}}</h3> |
220 | </td> | 220 | </td> |
221 | <td class="text-right"> | 221 | <td class="text-right"> |
222 | <button | 222 | <button |
223 | type="button" | 223 | type="button" |
224 | class="btn btn-default btn-sm" | 224 | class="btn btn-default btn-sm" |
225 | > | 225 | > |
226 | Totales | 226 | Totales |
227 | </button> | 227 | </button> |
228 | </td> | 228 | </td> |
229 | </tr> | 229 | </tr> |
230 | </tfoot> | 230 | </tfoot> |
231 | </table> | 231 | </table> |
232 | </div> | 232 | </div> |
233 | </div> | 233 | </div> |
234 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> | 234 | <div class="col-auto my-2 col-lg-2 botonera-lateral"> |
235 | <div class="row align-items-end"> | 235 | <div class="row align-items-end"> |
236 | <div class="col-12"> | 236 | <div class="col-12"> |
237 | <button | 237 | <button |
238 | ng-click="crearNotaPedido()" | 238 | ng-click="crearNotaPedido()" |
239 | type="submit" | 239 | type="submit" |
240 | title="Crear nota pedido" | 240 | title="Crear nota pedido" |
241 | class="btn btn-default btn-block mb-2"> | 241 | class="btn btn-default btn-block mb-2"> |
242 | Guardar | 242 | Guardar |
243 | </button> | 243 | </button> |
244 | <button | 244 | <button |
245 | ng-click="salir()" | 245 | ng-click="salir()" |
246 | type="button" | 246 | type="button" |
247 | title="Salir" | 247 | title="Salir" |
248 | class="btn btn-default btn-block"> | 248 | class="btn btn-default btn-block"> |
249 | Salir | 249 | Salir |
250 | </button> | 250 | </button> |
251 | </div> | 251 | </div> |
252 | </div> | 252 | </div> |
253 | </div> | 253 | </div> |
254 | </div> | 254 | </div> |
255 | </div> | 255 | </div> |
256 | 256 |