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