Commit aba9729a8df7f2116e642c164a3c4fa92729cf44

Authored by Nicolás Guarnieri
1 parent 8647c3864d
Exists in master

fix para compilar

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