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