diff --git a/src/js/controller.js b/src/js/controller.js index 643be44..2a186e8 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -1,405 +1,462 @@ -angular.module('focaCrearNotaPedido') - .controller('notaPedidoCtrl', - ['$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', - function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { - $scope.botonera = [ - {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, - {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, - {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, - { - texto: 'Precios y condiciones', - accion: function() {$scope.abrirModalListaPrecio();}}, - {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, - {texto: 'Bomba', accion: function() {}}, - {texto: 'Detalle', accion: function() {}}, - {texto: 'Totales', accion: function() {}} - ]; - $scope.show = false; - $scope.cargando = true; - $scope.dateOptions = { - maxDate: new Date(), - minDate: new Date(2010, 0, 1) - }; - $scope.notaPedido = { - vendedor: {}, - cliente: {}, - domicilio: {dom: ''}, - moneda: {detalle: ''} - }; - $scope.articulosTabla = []; - var idLista; - var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); - crearNotaPedidoService.getPrecioCondicion().then( - function(res) { - $scope.precioCondiciones = res.data; - } - ); - if (notaPedidoTemp !== undefined) { - notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); - $scope.notaPedido = notaPedidoTemp; - $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); - $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); - idLista = $scope.notaPedido.precioCondicion; - crearNotaPedidoService - .getArticulosByIdNotaPedido($scope.notaPedido.id).then( - function(res) { - $scope.articulosTabla = res.data; - } - ); - //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO - //(NO REQUERIDO EN ESTA VERSION) - // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( - // function(res) { - // $scope.notaPedido.domicilio = res.data; - // } - // ); - } else { - $scope.notaPedido.fechaCarga = new Date(); - $scope.notaPedido.bomba = '0'; - $scope.notaPedido.flete = '0'; - idLista = undefined; +angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', + [ + '$scope', '$uibModal', '$location', 'crearNotaPedidoService', 'focaModalService', + function($scope, $uibModal, $location, crearNotaPedidoService, focaModalService) { + $scope.botonera = [ + {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, + {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, + {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, + { + texto: 'Precios y condiciones', + accion: function() {$scope.abrirModalListaPrecio();}}, + {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, + {texto: 'Bomba', accion: function() {}}, + {texto: 'Detalle', accion: function() {}}, + {texto: 'Totales', accion: function() {}} + ]; + + $scope.show = false; + $scope.cargando = true; + $scope.dateOptions = { + maxDate: new Date(), + minDate: new Date(2010, 0, 1) + }; + + $scope.notaPedido = { + vendedor: {}, + cliente: {}, + domicilio: {dom: ''}, + moneda: {detalle: ''} + }; + + $scope.cabecera = []; + + $scope.now = new Date(); + $scope.puntoVenta = Math.round(Math.random() * 10000); + $scope.comprobante = Math.round(Math.random() * 1000000); + + $scope.articulosTabla = []; + var idLista; + var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); + crearNotaPedidoService.getPrecioCondicion().then( + function(res) { + $scope.precioCondiciones = res.data; } - //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO - // $scope.addNewDom = function() { - // $scope.notaPedido.domicilio.push({ 'id': 0 }); - // }; - // $scope.removeNewChoice = function(choice) { - // if ($scope.notaPedido.domicilio.length > 1) { - // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( - // function(c) { - // return c.$$hashKey === choice.$$hashKey; - // } - // ), 1); - // } - // }; - $scope.crearNotaPedido = function() { - if($scope.articulosTabla.length === 0) { - focaModalService.alert('Debe cargar almenos un articulo'); - return; - } - if($scope.notaPedido.domicilio.id === undefined) { - $scope.notaPedido.domicilio.id = 0; - } - var date = new Date(); - var notaPedido = { - id: 0, - fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) - .toISOString().slice(0, 19).replace('T', ' '), - vendedor: $scope.notaPedido.vendedor.nombre, - idCliente: $scope.notaPedido.cliente.id, - domicilio: $scope.notaPedido.domicilio, - precioCondicion: $scope.notaPedido.precioCondicion, - bomba: $scope.notaPedido.bomba, - flete: $scope.notaPedido.flete, - total: $scope.getTotal() - }; - crearNotaPedidoService.crearNotaPedido(notaPedido).then( - function(data) { - focaModalService.alert('Nota pedido creada'); - if($scope.notaPedido.flete === 1) { - var flete = { - idNotaPedido: data.data.id, - idTransportista: $scope.notaPedido.fleteId, - idChofer: $scope.notaPedido.chofer.id, - idVehiculo: $scope.notaPedido.vehiculo.id, - kilometros: $scope.notaPedido.kilometros, - costoKilometro: $scope.notaPedido.costoUnitarioKmFlete - }; - crearNotaPedidoService.crearFlete(flete); - } - var articulosNotaPedido = $scope.articulosTabla; - for(var i = 0; i < articulosNotaPedido.length; i++) { - delete articulosNotaPedido[i].edit; - articulosNotaPedido[i].idNotaPedido = data.data.id; - crearNotaPedidoService - .crearArticulosParaNotaPedido(articulosNotaPedido[i]); - } - $scope.limpiarPantalla(); + ); + if (notaPedidoTemp !== undefined) { + notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); + $scope.notaPedido = notaPedidoTemp; + $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); + $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); + idLista = $scope.notaPedido.precioCondicion; + crearNotaPedidoService + .getArticulosByIdNotaPedido($scope.notaPedido.id).then( + function(res) { + $scope.articulosTabla = res.data; } ); + //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO + //(NO REQUERIDO EN ESTA VERSION) + // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( + // function(res) { + // $scope.notaPedido.domicilio = res.data; + // } + // ); + } else { + $scope.notaPedido.fechaCarga = new Date(); + $scope.notaPedido.bomba = '0'; + $scope.notaPedido.flete = '0'; + idLista = undefined; + } + //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO + // $scope.addNewDom = function() { + // $scope.notaPedido.domicilio.push({ 'id': 0 }); + // }; + // $scope.removeNewChoice = function(choice) { + // if ($scope.notaPedido.domicilio.length > 1) { + // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( + // function(c) { + // return c.$$hashKey === choice.$$hashKey; + // } + // ), 1); + // } + // }; + $scope.crearNotaPedido = function() { + if($scope.articulosTabla.length === 0) { + focaModalService.alert('Debe cargar almenos un articulo'); + return; + } + if($scope.notaPedido.domicilio.id === undefined) { + $scope.notaPedido.domicilio.id = 0; + } + var date = new Date(); + var notaPedido = { + id: 0, + fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) + .toISOString().slice(0, 19).replace('T', ' '), + vendedor: $scope.notaPedido.vendedor.nombre, + idCliente: $scope.notaPedido.cliente.id, + domicilio: $scope.notaPedido.domicilio, + precioCondicion: $scope.notaPedido.precioCondicion, + bomba: $scope.notaPedido.bomba, + flete: $scope.notaPedido.flete, + total: $scope.getTotal() }; - $scope.seleccionarArticulo = function() { - if (idLista === undefined) { - focaModalService.alert( - 'Primero seleccione una lista de precio y condicion'); - return; - } - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Productos', - templateUrl: 'modal-busqueda-productos.html', - controller: 'modalBusquedaProductosCtrl', - resolve: { idLista: function() { return idLista; } }, - size: 'lg' - } - ); - modalInstance.result.then( - function(producto) { - var newArt = - { - id: 0, - codigo: producto.codigo, - sector: producto.sector, - descripcion: producto.descripcion, - item: $scope.articulosTabla.length + 1, - nombre: producto.descripcion, - precio: producto.precio.toFixed(2), - costoUnitario: producto.costo, - edit: false + crearNotaPedidoService.crearNotaPedido(notaPedido).then( + function(data) { + focaModalService.alert('Nota pedido creada'); + if($scope.notaPedido.flete === 1) { + var flete = { + idNotaPedido: data.data.id, + idTransportista: $scope.notaPedido.fleteId, + idChofer: $scope.notaPedido.chofer.id, + idVehiculo: $scope.notaPedido.vehiculo.id, + kilometros: $scope.notaPedido.kilometros, + costoKilometro: $scope.notaPedido.costoUnitarioKmFlete }; - $scope.articuloACargar = newArt; - $scope.cargando = false; - }, function() { - // funcion ejecutada cuando se cancela el modal + crearNotaPedidoService.crearFlete(flete); } - ); - }; - $scope.seleccionarVendedor = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Vendedores', - templateUrl: 'modal-vendedores.html', - controller: 'modalVendedoresCtrl', - size: 'lg' + var articulosNotaPedido = $scope.articulosTabla; + for(var i = 0; i < articulosNotaPedido.length; i++) { + delete articulosNotaPedido[i].edit; + articulosNotaPedido[i].idNotaPedido = data.data.id; + crearNotaPedidoService + .crearArticulosParaNotaPedido(articulosNotaPedido[i]); } - ); - modalInstance.result.then( - function(vendedor) { - $scope.notaPedido.vendedor.nombre = vendedor.NomVen; - }, function() { + $scope.limpiarPantalla(); + } + ); + }; - } - ); - }; - $scope.seleccionarPetrolera = function() { - var modalInstance = $uibModal.open( + $scope.seleccionarArticulo = function() { + if (idLista === undefined) { + focaModalService.alert( + 'Primero seleccione una lista de precio y condicion'); + return; + } + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Productos', + templateUrl: 'modal-busqueda-productos.html', + controller: 'modalBusquedaProductosCtrl', + resolve: { idLista: function() { return idLista; } }, + size: 'lg' + } + ); + modalInstance.result.then( + function(producto) { + var newArt = { - ariaLabelledBy: 'Busqueda de Petrolera', - templateUrl: 'modal-petroleras.html', - controller: 'modalPetrolerasCtrl', - size: 'lg' - } - ); - modalInstance.result.then( - function(petrolera) { - $scope.notaPedido.petrolera = petrolera.NOM; - }, function() { + id: 0, + codigo: producto.codigo, + sector: producto.sector, + descripcion: producto.descripcion, + item: $scope.articulosTabla.length + 1, + nombre: producto.descripcion, + precio: producto.precio.toFixed(2), + costoUnitario: producto.costo, + edit: false + }; + $scope.articuloACargar = newArt; + $scope.cargando = false; + }, function() { + // funcion ejecutada cuando se cancela el modal + } + ); + }; - } - ); - }; - $scope.seleccionarCliente = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Cliente', - templateUrl: 'foca-busqueda-cliente-modal.html', - controller: 'focaBusquedaClienteModalController', - size: 'lg' - } - ); - modalInstance.result.then( - function(cliente) { - $scope.notaPedido.cliente.nombre = cliente.nom; - $scope.notaPedido.cliente.id = cliente.cod; - crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( - function(data) { - if(data.data.length === 0){ - focaModalService - .alert('El cliente no tienen domicilios de entrega') - .then( - function() { - $scope.seleccionarCliente(); - $scope.notaPedido.cliente = {nombre: ''}; - } - ); - return; - } - $scope.domiciliosCliente = data.data; + $scope.seleccionarVendedor = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Vendedores', + templateUrl: 'modal-vendedores.html', + controller: 'modalVendedoresCtrl', + size: 'lg' + } + ); + modalInstance.result.then( + function(vendedor) { + addCabecera('Vendedor:', vendedor.NomVen); + $scope.notaPedido.vendedor.nombre = vendedor.NomVen; + }, function() { + + } + ); + }; + + $scope.seleccionarPetrolera = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Petrolera', + templateUrl: 'modal-petroleras.html', + controller: 'modalPetrolerasCtrl', + size: 'lg' + } + ); + modalInstance.result.then( + function(petrolera) { + $scope.notaPedido.petrolera = petrolera.NOM; + }, function() { + + } + ); + }; + + $scope.seleccionarCliente = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Cliente', + templateUrl: 'foca-busqueda-cliente-modal.html', + controller: 'focaBusquedaClienteModalController', + size: 'lg' + } + ); + modalInstance.result.then( + function(cliente) { + $scope.notaPedido.cliente.nombre = cliente.nom; + $scope.notaPedido.cliente.id = cliente.cod; + crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( + function(data) { + if(data.data.length === 0){ + focaModalService + .alert('El cliente no tienen domicilios de entrega') + .then( + function() { + $scope.seleccionarCliente(); + $scope.notaPedido.cliente = {nombre: ''}; + } + ); + return; } - ); - }, function() { + $scope.domiciliosCliente = data.data; + } + ); + + addCabecera('Cliente:', cliente.nom); + }, function() { - } - ); - }; - $scope.mostrarFichaCliente = function() { - $uibModal.open( - { - ariaLabelledBy: 'Datos del Cliente', - templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', - controller: 'focaCrearNotaPedidoFichaClienteController', - size: 'lg' - } - ); - }; - $scope.getTotal = function() { - var total = 0; - var arrayTempArticulos = $scope.articulosTabla; - for (var i = 0; i < arrayTempArticulos.length; i++) { - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; } - return total.toFixed(2); - }; - $scope.getSubTotal = function() { - if($scope.articuloACargar) { - return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; + ); + }; + + $scope.mostrarFichaCliente = function() { + $uibModal.open( + { + ariaLabelledBy: 'Datos del Cliente', + templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', + controller: 'focaCrearNotaPedidoFichaClienteController', + size: 'lg' } - }; - $scope.abrirModalListaPrecio = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Precio Condición', - templateUrl: 'modal-precio-condicion.html', - controller: 'focaModalPrecioCondicionController', - size: 'lg' - } - ); - modalInstance.result.then( - function(precioCondicion) { - $scope.notaPedido.precioCondicion = precioCondicion.nombre; - idLista = precioCondicion.idListaPrecio; - $scope.articulosTabla = []; - }, function() { + ); + }; - } - ); - }; - $scope.abrirModalFlete = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Flete', - templateUrl: 'modal-flete.html', - controller: 'focaModalFleteController', - size: 'lg' - } - ); - modalInstance.result.then( - function(flete) { - $scope.limpiarFlete(); - $scope.notaPedido.fleteNombre = flete.nombre; - $scope.notaPedido.fleteId = flete.id; - $scope.choferes = flete.chofer; - $scope.vehiculos = flete.vehiculo; - }, function() { + $scope.getTotal = function() { + var total = 0; + var arrayTempArticulos = $scope.articulosTabla; + for (var i = 0; i < arrayTempArticulos.length; i++) { + total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; + } + return total.toFixed(2); + }; - } - ); - }; - $scope.abrirModalMoneda = function() { - var modalInstance = $uibModal.open( - { - ariaLabelledBy: 'Busqueda de Moneda', - templateUrl: 'modal-moneda.html', - controller: 'focaModalMonedaController', - size: 'lg' - } - ); - modalInstance.result.then( - function(moneda) { - $scope.notaPedido.moneda = { - id: moneda.ID, - detalle: moneda.DETALLE, - simbolo: moneda.SIMBOLO - }; - }, function() { + $scope.getSubTotal = function() { + if($scope.articuloACargar) { + return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; + } + }; - } - ); - }; - $scope.agregarATabla = function(key) { - if(key === 13) { - if($scope.articuloACargar.cantidad === undefined || - $scope.articuloACargar.cantidad === 0 || - $scope.articuloACargar.cantidad === null ){ - focaModalService.alert('El valor debe ser al menos 1'); - return; - } - $scope.articulosTabla.unshift($scope.articuloACargar); - $scope.cargando = true; + $scope.abrirModalListaPrecio = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Precio Condición', + templateUrl: 'modal-precio-condicion.html', + controller: 'focaModalPrecioCondicionController', + size: 'lg' } - }; - $scope.quitarArticulo = function(key) { - $scope.articulosTabla.splice(key, 1); - }; - $scope.editarArticulo = function(key, articulo) { - if(key === 13) { - if(articulo.cantidad === null || articulo.cantidad === 0 || - articulo.cantidad === undefined){ + ); + modalInstance.result.then( + function(precioCondicion) { + $scope.notaPedido.precioCondicion = precioCondicion.nombre; + idLista = precioCondicion.idListaPrecio; + $scope.articulosTabla = []; + + addCabecera('Precios y condiciones:', precioCondicion.nombre); + }, function() { + + } + ); + }; + + $scope.abrirModalFlete = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Flete', + templateUrl: 'modal-flete.html', + controller: 'focaModalFleteController', + size: 'lg' + } + ); + modalInstance.result.then( + function(flete) { + $scope.limpiarFlete(); + $scope.notaPedido.fleteNombre = flete.nombre; + $scope.notaPedido.fleteId = flete.id; + $scope.choferes = flete.chofer; + $scope.vehiculos = flete.vehiculo; + + addCabecera('Flete:', flete.nombre); + }, function() { + + } + ); + }; + + $scope.abrirModalMoneda = function() { + var modalInstance = $uibModal.open( + { + ariaLabelledBy: 'Busqueda de Moneda', + templateUrl: 'modal-moneda.html', + controller: 'focaModalMonedaController', + size: 'lg' + } + ); + modalInstance.result.then( + function(moneda) { + $scope.notaPedido.moneda = { + id: moneda.ID, + detalle: moneda.DETALLE, + simbolo: moneda.SIMBOLO + }; + + addCabecera('Moneda:', moneda.DETALLE); + }, function() { + + } + ); + }; + + $scope.agregarATabla = function(key) { + if(key === 13) { + if($scope.articuloACargar.cantidad === undefined || + $scope.articuloACargar.cantidad === 0 || + $scope.articuloACargar.cantidad === null ){ focaModalService.alert('El valor debe ser al menos 1'); return; - } - articulo.edit = false; } - }; - $scope.cambioEdit = function(articulo) { - articulo.edit = true; - }; - $scope.limpiarFlete = function() { - $scope.notaPedido.fleteNombre = ''; - $scope.notaPedido.chofer = ''; - $scope.notaPedido.vehiculo = ''; - $scope.notaPedido.kilometros = ''; - $scope.notaPedido.costoUnitarioKmFlete = ''; - $scope.choferes = ''; - $scope.vehiculos = ''; - }; - $scope.limpiarPantalla = function() { - $scope.limpiarFlete(); - $scope.notaPedido.flete = '0'; - $scope.notaPedido.bomba = '0'; - $scope.notaPedido.precioCondicion = ''; - $scope.articulosTabla = []; - $scope.notaPedido.vendedor.nombre = ''; - $scope.notaPedido.cliente = {nombre: ''}; - $scope.notaPedido.domicilio = {dom: ''}; - $scope.domiciliosCliente = []; - }; - $scope.resetFilter = function() { - $scope.articuloACargar = {}; + $scope.articulosTabla.unshift($scope.articuloACargar); $scope.cargando = true; - }; - $scope.selectFocus = function($event) { - $event.target.select(); - }; - $scope.salir = function() { - $location.path('/'); } - } - ] - ) - .controller('notaPedidoListaCtrl', [ - '$scope', - 'crearNotaPedidoService', - '$location', - function($scope, crearNotaPedidoService, $location) { - crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { - $scope.notaPedidos = datos.data; - }); - $scope.editar = function(notaPedido) { - crearNotaPedidoService.setNotaPedido(notaPedido); - $location.path('/venta-nota-pedido/abm/'); }; - $scope.crearPedido = function() { - crearNotaPedidoService.clearNotaPedido(); - $location.path('/venta-nota-pedido/abm/'); + + $scope.quitarArticulo = function(key) { + $scope.articulosTabla.splice(key, 1); }; - } - ]) - .controller('focaCrearNotaPedidoFichaClienteController', [ - '$scope', - 'crearNotaPedidoService', - '$location', - function($scope, crearNotaPedidoService, $location) { - crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { - $scope.notaPedidos = datos.data; - }); - $scope.editar = function(notaPedido) { - crearNotaPedidoService.setNotaPedido(notaPedido); - $location.path('/venta-nota-pedido/abm/'); + + $scope.editarArticulo = function(key, articulo) { + if(key === 13) { + if(articulo.cantidad === null || articulo.cantidad === 0 || + articulo.cantidad === undefined){ + focaModalService.alert('El valor debe ser al menos 1'); + return; + } + articulo.edit = false; + } + }; + + $scope.cambioEdit = function(articulo) { + articulo.edit = true; + }; + + $scope.limpiarFlete = function() { + $scope.notaPedido.fleteNombre = ''; + $scope.notaPedido.chofer = ''; + $scope.notaPedido.vehiculo = ''; + $scope.notaPedido.kilometros = ''; + $scope.notaPedido.costoUnitarioKmFlete = ''; + $scope.choferes = ''; + $scope.vehiculos = ''; + }; + + $scope.limpiarPantalla = function() { + $scope.limpiarFlete(); + $scope.notaPedido.flete = '0'; + $scope.notaPedido.bomba = '0'; + $scope.notaPedido.precioCondicion = ''; + $scope.articulosTabla = []; + $scope.notaPedido.vendedor.nombre = ''; + $scope.notaPedido.cliente = {nombre: ''}; + $scope.notaPedido.domicilio = {dom: ''}; + $scope.domiciliosCliente = []; + }; + + $scope.resetFilter = function() { + $scope.articuloACargar = {}; + $scope.cargando = true; + }; + + $scope.selectFocus = function($event) { + $event.target.select(); }; - $scope.crearPedido = function() { - crearNotaPedidoService.clearNotaPedido(); - $location.path('/venta-nota-pedido/abm/'); + + $scope.salir = function() { + $location.path('/'); }; + + function addCabecera(label, valor) { + let existe = false; + + for (var i = $scope.cabecera.length - 1; i >= 0; i--) { + if ($scope.cabecera[i].label === label) { + $scope.cabecera[i].valor = valor; + existe = true; + break; + } + + } + + if (!existe) { + $scope.cabecera.push({ + label: label, + valor: valor + }); + } + } } - ]); + ] +) +.controller('notaPedidoListaCtrl', [ + '$scope', + 'crearNotaPedidoService', + '$location', + function($scope, crearNotaPedidoService, $location) { + crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { + $scope.notaPedidos = datos.data; + }); + $scope.editar = function(notaPedido) { + crearNotaPedidoService.setNotaPedido(notaPedido); + $location.path('/venta-nota-pedido/abm/'); + }; + $scope.crearPedido = function() { + crearNotaPedidoService.clearNotaPedido(); + $location.path('/venta-nota-pedido/abm/'); + }; + } +]) +.controller('focaCrearNotaPedidoFichaClienteController', [ + '$scope', + 'crearNotaPedidoService', + '$location', + function($scope, crearNotaPedidoService, $location) { + crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { + $scope.notaPedidos = datos.data; + }); + $scope.editar = function(notaPedido) { + crearNotaPedidoService.setNotaPedido(notaPedido); + $location.path('/venta-nota-pedido/abm/'); + }; + $scope.crearPedido = function() { + crearNotaPedidoService.clearNotaPedido(); + $location.path('/venta-nota-pedido/abm/'); + }; + } +]); diff --git a/src/views/nota-pedido.html b/src/views/nota-pedido.html index 41d7dae..8d7f7ea 100644 --- a/src/views/nota-pedido.html +++ b/src/views/nota-pedido.html @@ -5,31 +5,18 @@