diff --git a/src/js/controller.js b/src/js/controller.js index 6ae5aee..c4d5448 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -3,7 +3,7 @@ angular.module('focaCrearNotaPedido') ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { $scope.show = false; - $scope.edit = false; + $scope.cargando = true; $scope.dateOptions = { maxDate: new Date(), minDate: new Date(2010, 0, 1) @@ -60,25 +60,28 @@ angular.module('focaCrearNotaPedido') $scope.crearNotaPedido = function() { var notaPedido = { id: 0, - precioCondicion: $scope.notaPedido.precioCondicion, fechaCarga: $scope.notaPedido.fechaCarga, - vendedor: $scope.notaPedido.vendedor, - cliente: $scope.notaPedido.cliente, - producto: $scope.notaPedido.producto, + vendedor: $scope.notaPedido.vendedor.nombre, + cliente: $scope.notaPedido.cliente.nombre, + domicilio: $scope.notaPedido.domicilio.id, + precioCondicion: $scope.notaPedido.precioCondicion, bomba: $scope.notaPedido.bomba, - petrolera: $scope.notaPedido.petrolera, - domicilio: $scope.notaPedido.domicilio, - kilometros: $scope.notaPedido.kilometros, - jurisdiccionIIBB: $scope.notaPedido.jurisdiccionIIBB, - costoFinanciacion: $scope.notaPedido.costoFinanciacion, flete: $scope.notaPedido.flete, - costoUnitarioKmFlete: $scope.notaPedido.costoUnitarioKmFlete, - total: $scope.articulosTabla[0].subTotal + total: $scope.getTotal() }; crearNotaPedidoService.crearNotaPedido(notaPedido).then( function() { - focaModalService('Nota pedido creada'); - $location.path('/venta-nota-pedido'); + focaModalService.alert('Nota pedido creada'); + // $location.path('/venta-nota-pedido'); + // var flete = { + // idNotaPedido: data.data.id, + // idTransportista: $scope.notaPedido.fleteId, + // idChofer: $scope.chofer.id, + // idVehiculo: $scope.vehiculo.id, + // kilometros: $scope.notaPedido.kilometros, + // costoKilometro: $scope.notaPedido.costoUnitarioKmFlete + // }; + //TO DO - Insert de flete } ); var articulosNotaPedido = $scope.articulosTabla; @@ -90,6 +93,7 @@ angular.module('focaCrearNotaPedido') } ); } + }; $scope.siguienteTab = function() { $scope.active = 1; @@ -121,9 +125,10 @@ angular.module('focaCrearNotaPedido') nombre: producto.descripcion, precio: producto.precio.toFixed(2), costoUnitario: producto.costo, - cantidad: 1 + edit: false }; $scope.articuloACargar = newArt; + $scope.cargando = false; }, function() { // funcion ejecutada cuando se cancela el modal } @@ -247,8 +252,11 @@ angular.module('focaCrearNotaPedido') function(flete) { $scope.choferes = ''; $scope.vehiculos = ''; + $scope.notaPedido.chofer = ''; + $scope.notaPedido.vehiculo = ''; + $scope.notaPedido.costoUnitarioKmFlete = ''; $scope.notaPedido.fleteNombre = flete.nombre; - $scope.notaPedido.costoUnitarioKmFlete = flete.costoKilometro; + $scope.notaPedido.fleteId = flete.id; $scope.choferes = flete.chofer; $scope.vehiculos = flete.vehiculo; }, function() { @@ -260,19 +268,19 @@ angular.module('focaCrearNotaPedido') $scope.agregarATabla = function(key) { if(key === 13) { $scope.articulosTabla.unshift($scope.articuloACargar); - $scope.articuloACargar = undefined; + $scope.cargando = true; } }; $scope.quitarArticulo = function(key) { $scope.articulosTabla.splice(key, 1); }; - $scope.editarArticulo = function(key) { + $scope.editarArticulo = function(key, articulo) { if(key === 13) { - $scope.edit = false; - } + articulo.edit = false; + } }; - $scope.cambioEdit = function() { - $scope.edit = !$scope.edit ? true : false; + $scope.cambioEdit = function(articulo) { + articulo.edit = true; }; $scope.limpiarFlete = function() { $scope.notaPedido.fleteNombre = ''; @@ -295,6 +303,10 @@ angular.module('focaCrearNotaPedido') $scope.domicilio.dom = ''; $scope.notaPedido.flete = 0; }; + $scope.resetFilter = function() { + $scope.articuloACargar = {}; + $scope.cargando = true; + }; } ] )