diff --git a/src/js/controller.js b/src/js/controller.js index 8145ead..7c0f605 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -144,13 +144,23 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', focaModalService.alert('Nota pedido creada'); $scope.saveLoading = false; - $scope.cabecera = []; - addCabecera('Moneda:', $scope.notaPedido.moneda.DETALLE); - addCabecera( - 'Fecha cotizacion:', - $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') - ); - addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.VENDEDOR); + $scope.$broadcast('cleanCabecera'); + $scope.$broadcast('addCabecera', { + label: 'Moneda:', + valor: $scope.notaPedido.moneda.DETALLE + }); + $scope.$broadcast('addCabecera', { + label: 'Fecha cotizacion:', + valor: $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') + }); + $scope.$broadcast('addCabecera', { + label: 'Moneda:', + valor: $scope.notaPedido.moneda.DETALLE + }); + $scope.$broadcast('addCabecera', { + label: 'Cotizacion:', + valor: $scope.notaPedido.cotizacion.VENDEDOR + }); crearNotaPedidoService.getNumeroNotaPedido().then( function(res) { $scope.puntoVenta = rellenar(res.data.sucursal, 4); @@ -195,8 +205,8 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.now = new Date(notaPedido.fechaCarga); //añado cabeceras $scope.notaPedido.id = notaPedido.id; - removeCabecera('Bomba:'); - removeCabecera('Kilometros:'); + $scope.$broadcast('removeCabecera', 'Bomba:'); + $scope.$broadcast('removeCabecera', 'Kilometros:'); var cabeceras = [ { label: 'Moneda:', @@ -349,7 +359,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', ); modalInstance.result.then( function(vendedor) { - addCabecera('Vendedor:', vendedor.NomVen); + $scope.$broadcast('addCabecera',{ + label: 'Vendedor:', + valor: vendedor.NomVen + }); $scope.notaPedido.vendedor = vendedor; }, function() { @@ -376,7 +389,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', modalInstance.result.then( function(proveedor) { $scope.notaPedido.proveedor = proveedor; - addCabecera('Proveedor:', proveedor.NOM); + $scope.$broadcast('addCabecera',{ + label: 'Proveedor:', + valor: proveedor.NOM + }); }, function() { } @@ -422,12 +438,19 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', CUIT: cliente.cuit, NOM: cliente.nom }; - addCabecera('Cliente:', cliente.nom); var domicilioStamp = domicilio.Calle + ' ' + domicilio.Numero + ', ' + domicilio.Localidad + ', ' + domicilio.Provincia; $scope.notaPedido.domicilioStamp = domicilioStamp; - addCabecera('Domicilio:', domicilioStamp); + + $scope.$broadcast('addCabecera',{ + label: 'Cliente:', + valor: cliente.nom + }); + $scope.$broadcast('addCabecera',{ + label: 'Domicilio:', + valor: domicilioStamp + }); }, function() { $scope.seleccionarCliente(); return; @@ -483,7 +506,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', cabecera = 'Ingreso manual ' + plazosConcat.trim(); } $scope.articulosTabla = []; - addCabecera('Precios y condiciones:', cabecera); + $scope.$broadcast('addCabecera',{ + label: 'Precios y condiciones:', + valor: cabecera + }); }, function() { } @@ -522,13 +548,22 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.notaPedido.fob = datos.FOB; $scope.notaPedido.bomba = datos.bomba; $scope.notaPedido.kilometros = datos.kilometros; - addCabecera('Flete:', datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No')); + $scope.$broadcast('addCabecera',{ + label: 'Flete:', + valor: datos.FOB ? 'FOB' : (datos.flete ? 'Si' : 'No') + }); if(datos.flete) { - addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); - addCabecera('Kilometros:', datos.kilometros); + $scope.$broadcast('addCabecera',{ + label: 'Bomba:', + valor: datos.bomba ? 'Si' : 'No' + }); + $scope.$broadcast('addCabecera',{ + label: 'Kilometros:', + valor: datos.kilometros + }); } else { - removeCabecera('Bomba:'); - removeCabecera('Kilometros:'); + $scope.$broadcast('removeCabecera', 'Bomba:'); + $scope.$broadcast('removeCabecera', 'Kilometros:'); $scope.notaPedido.bomba = false; $scope.notaPedido.kilometros = null; } @@ -582,16 +617,22 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', $scope.notaPedido.moneda = moneda; $scope.notaPedido.cotizacion = cotizacion; if(moneda.DETALLE === 'PESOS ARGENTINOS'){ - removeCabecera('Moneda:'); - removeCabecera('Fecha cotizacion:'); - removeCabecera('Cotizacion:'); + $scope.$broadcast('removeCabecera', 'Moneda:'); + $scope.$broadcast('removeCabecera', 'Fecha cotizacion:'); + $scope.$broadcast('removeCabecera', 'Cotizacion:'); }else{ - addCabecera('Moneda:', moneda.DETALLE); - addCabecera( - 'Fecha cotizacion:', - $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') - ); - addCabecera('Cotizacion:', cotizacion.VENDEDOR); + $scope.$broadcast('addCabecera',{ + label: 'Moneda:', + valor: moneda.DETALLE + }); + $scope.$broadcast('addCabecera',{ + label: 'Fecha cotizacion:', + valor: $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') + }); + $scope.$broadcast('addCabecera',{ + label: 'Cotizacion:', + valor: cotizacion.VENDEDOR + }); } }, function() { @@ -669,23 +710,10 @@ angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', function addArrayCabecera(array) { for(var i = 0; i < array.length; i++) { - addCabecera(array[i].label, array[i].valor); - } - } - - function addCabecera(label, valor) { - var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); - if(propiedad.length === 1) { - propiedad[0].valor = valor; - } else { - $scope.cabecera.push({label: label, valor: valor}); - } - } - - function removeCabecera(label) { - var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); - if(propiedad.length === 1) { - $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); + $scope.$broadcast('addCabecera',{ + label: array[i].label, + valor: array[i].valor + }); } } diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index 9e57f2e..c9fa781 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -1,82 +1,11 @@
-
-
-
-
-
-
-
-
NOTA DE PEDIDO
-
-
Nº {{puntoVenta}}-{{comprobante}} - -
-
- Fecha: - - - -
-
- Hora: - - -
-
-
-
- - - -
- - - - -
-
-
- -
-
-
+