Commit 71ac1c0cd300a7757b49adac37f80388001929a6
1 parent
436b00177a
Exists in
master
and in
1 other branch
agrega los plazo a la cabecera
Showing
2 changed files
with
21 additions
and
8 deletions
Show diff stats
package.json
| 1 | { | 1 | { |
| 2 | "name": "foca-crear-nota-pedido", | 2 | "name": "foca-crear-nota-pedido", |
| 3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
| 4 | "description": "Listado y ABM nota de pedidos", | 4 | "description": "Listado y ABM nota de pedidos", |
| 5 | "main": "index.js", | 5 | "main": "index.js", |
| 6 | "scripts": { | 6 | "scripts": { |
| 7 | "test": "echo \"Error: no test specified\" && exit 1", | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | "compile": "gulp uglify", | 8 | "compile": "gulp uglify", |
| 9 | "gulp-pre-commit": "gulp pre-commit", | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 10 | "postinstall": "npm run compile && gulp clean-post-install", | 10 | "postinstall": "npm run compile && gulp clean-post-install", |
| 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-route bootstrap ui-bootstrap4 font-awesome gulp gulp-angular-templatecache gulp-connect gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-uglify jquery jshint pump git+https://debo.suite.repo/modulos-npm/foca-directivas.git git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git git+https://debo.suite.repo/modulos-npm/foca-modal-flete git+https://debo.suite.repo/modulos-npm/foca-modal.git git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git" |
| 12 | }, | 12 | }, |
| 13 | "pre-commit": [ | 13 | "pre-commit": [ |
| 14 | "gulp-pre-commit" | 14 | "gulp-pre-commit" |
| 15 | ], | 15 | ], |
| 16 | "repository": { | 16 | "repository": { |
| 17 | "type": "git", | 17 | "type": "git", |
| 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" | 18 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido.git" |
| 19 | }, | 19 | }, |
| 20 | "author": "Foca Software", | 20 | "author": "Foca Software", |
| 21 | "license": "ISC", | 21 | "license": "ISC", |
| 22 | "peerDependencies": { | 22 | "peerDependencies": { |
| 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 23 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 24 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 25 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 26 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
| 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git" | 27 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git" |
| 28 | }, | 28 | }, |
| 29 | "devDependencies": { | 29 | "devDependencies": { |
| 30 | "angular": "^1.7.5", | 30 | "angular": "^1.7.5", |
| 31 | "angular-route": "^1.7.5", | 31 | "angular-route": "^1.7.5", |
| 32 | "bootstrap": "^4.1.3", | 32 | "bootstrap": "^4.1.3", |
| 33 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 33 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
| 34 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 34 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
| 35 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 35 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
| 36 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 36 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
| 37 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 37 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
| 38 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 38 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
| 39 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | ||
| 40 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 39 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
| 40 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | ||
| 41 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 41 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
| 42 | "font-awesome": "^4.7.0", | 42 | "font-awesome": "^4.7.0", |
| 43 | "gulp": "^3.9.1", | 43 | "gulp": "^3.9.1", |
| 44 | "gulp-angular-templatecache": "2.2.2", | 44 | "gulp-angular-templatecache": "^2.2.2", |
| 45 | "gulp-clean": "^0.4.0", | 45 | "gulp-clean": "^0.4.0", |
| 46 | "gulp-concat": "^2.6.1", | 46 | "gulp-concat": "^2.6.1", |
| 47 | "gulp-connect": "^5.6.1", | 47 | "gulp-connect": "^5.6.1", |
| 48 | "gulp-htmlmin": "^5.0.1", | 48 | "gulp-htmlmin": "^5.0.1", |
| 49 | "gulp-jshint": "^2.1.0", | 49 | "gulp-jshint": "^2.1.0", |
| 50 | "gulp-rename": "^1.4.0", | 50 | "gulp-rename": "^1.4.0", |
| 51 | "gulp-replace": "^1.0.0", | 51 | "gulp-replace": "^1.0.0", |
| 52 | "gulp-sequence": "^1.0.0", | 52 | "gulp-sequence": "^1.0.0", |
| 53 | "gulp-uglify": "^3.0.1", | 53 | "gulp-uglify": "^3.0.1", |
| 54 | "gulp-uglify-es": "^1.0.4", | 54 | "gulp-uglify-es": "^1.0.4", |
| 55 | "jasmine-core": "^3.2.1", | 55 | "jasmine-core": "^3.3.0", |
| 56 | "jquery": "^3.3.1", | 56 | "jquery": "^3.3.1", |
| 57 | "jshint": "^2.9.6", | 57 | "jshint": "^2.9.6", |
| 58 | "pre-commit": "^1.2.2", | 58 | "pre-commit": "^1.2.2", |
| 59 | "pump": "^3.0.0", | 59 | "pump": "^3.0.0", |
| 60 | "ui-bootstrap4": "^3.0.5" | 60 | "ui-bootstrap4": "^3.0.5" |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
src/js/controller.js
| 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', | 1 | angular.module('focaCrearNotaPedido') .controller('notaPedidoCtrl', |
| 2 | [ | 2 | [ |
| 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', | 3 | '$scope', '$uibModal', '$location', '$filter', 'crearNotaPedidoService', |
| 4 | 'focaModalService', | 4 | 'focaModalService', |
| 5 | function( | 5 | function( |
| 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService |
| 7 | ) { | 7 | ) { |
| 8 | $scope.botonera = [ | 8 | $scope.botonera = [ |
| 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
| 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
| 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
| 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
| 13 | { | 13 | { |
| 14 | texto: 'Precios y condiciones', | 14 | texto: 'Precios y condiciones', |
| 15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 15 | accion: function() {$scope.abrirModalListaPrecio();}}, |
| 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
| 17 | {texto: '', accion: function() {}}, | 17 | {texto: '', accion: function() {}}, |
| 18 | {texto: '', accion: function() {}} | 18 | {texto: '', accion: function() {}} |
| 19 | ]; | 19 | ]; |
| 20 | 20 | ||
| 21 | $scope.show = false; | 21 | $scope.show = false; |
| 22 | $scope.cargando = true; | 22 | $scope.cargando = true; |
| 23 | $scope.dateOptions = { | 23 | $scope.dateOptions = { |
| 24 | maxDate: new Date(), | 24 | maxDate: new Date(), |
| 25 | minDate: new Date(2010, 0, 1) | 25 | minDate: new Date(2010, 0, 1) |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | $scope.notaPedido = { | 28 | $scope.notaPedido = { |
| 29 | vendedor: {}, | 29 | vendedor: {}, |
| 30 | cliente: {}, | 30 | cliente: {}, |
| 31 | domicilio: {dom: ''}, | 31 | domicilio: {dom: ''}, |
| 32 | moneda: {detalle: ''} | 32 | moneda: {detalle: ''} |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | $scope.cabecera = []; | 35 | $scope.cabecera = []; |
| 36 | 36 | ||
| 37 | $scope.now = new Date(); | 37 | $scope.now = new Date(); |
| 38 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 38 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
| 39 | $scope.comprobante = Math.round(Math.random() * 1000000); | 39 | $scope.comprobante = Math.round(Math.random() * 1000000); |
| 40 | 40 | ||
| 41 | $scope.articulosTabla = []; | 41 | $scope.articulosTabla = []; |
| 42 | var idLista; | 42 | var idLista; |
| 43 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 43 | var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
| 44 | crearNotaPedidoService.getPrecioCondicion().then( | 44 | crearNotaPedidoService.getPrecioCondicion().then( |
| 45 | function(res) { | 45 | function(res) { |
| 46 | $scope.precioCondiciones = res.data; | 46 | $scope.precioCondiciones = res.data; |
| 47 | } | 47 | } |
| 48 | ); | 48 | ); |
| 49 | if (notaPedidoTemp !== undefined) { | 49 | if (notaPedidoTemp !== undefined) { |
| 50 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 50 | notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
| 51 | $scope.notaPedido = notaPedidoTemp; | 51 | $scope.notaPedido = notaPedidoTemp; |
| 52 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 52 | $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
| 53 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 53 | $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
| 54 | idLista = $scope.notaPedido.precioCondicion; | 54 | idLista = $scope.notaPedido.precioCondicion; |
| 55 | crearNotaPedidoService | 55 | crearNotaPedidoService |
| 56 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 56 | .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
| 57 | function(res) { | 57 | function(res) { |
| 58 | $scope.articulosTabla = res.data; | 58 | $scope.articulosTabla = res.data; |
| 59 | } | 59 | } |
| 60 | ); | 60 | ); |
| 61 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 61 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
| 62 | //(NO REQUERIDO EN ESTA VERSION) | 62 | //(NO REQUERIDO EN ESTA VERSION) |
| 63 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 63 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
| 64 | // function(res) { | 64 | // function(res) { |
| 65 | // $scope.notaPedido.domicilio = res.data; | 65 | // $scope.notaPedido.domicilio = res.data; |
| 66 | // } | 66 | // } |
| 67 | // ); | 67 | // ); |
| 68 | } else { | 68 | } else { |
| 69 | $scope.notaPedido.fechaCarga = new Date(); | 69 | $scope.notaPedido.fechaCarga = new Date(); |
| 70 | $scope.notaPedido.bomba = '0'; | 70 | $scope.notaPedido.bomba = '0'; |
| 71 | $scope.notaPedido.flete = '0'; | 71 | $scope.notaPedido.flete = '0'; |
| 72 | idLista = undefined; | 72 | idLista = undefined; |
| 73 | } | 73 | } |
| 74 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 74 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
| 75 | // $scope.addNewDom = function() { | 75 | // $scope.addNewDom = function() { |
| 76 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 76 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
| 77 | // }; | 77 | // }; |
| 78 | // $scope.removeNewChoice = function(choice) { | 78 | // $scope.removeNewChoice = function(choice) { |
| 79 | // if ($scope.notaPedido.domicilio.length > 1) { | 79 | // if ($scope.notaPedido.domicilio.length > 1) { |
| 80 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 80 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
| 81 | // function(c) { | 81 | // function(c) { |
| 82 | // return c.$$hashKey === choice.$$hashKey; | 82 | // return c.$$hashKey === choice.$$hashKey; |
| 83 | // } | 83 | // } |
| 84 | // ), 1); | 84 | // ), 1); |
| 85 | // } | 85 | // } |
| 86 | // }; | 86 | // }; |
| 87 | $scope.crearNotaPedido = function() { | 87 | $scope.crearNotaPedido = function() { |
| 88 | if($scope.articulosTabla.length === 0) { | 88 | if($scope.articulosTabla.length === 0) { |
| 89 | focaModalService.alert('Debe cargar almenos un articulo'); | 89 | focaModalService.alert('Debe cargar almenos un articulo'); |
| 90 | return; | 90 | return; |
| 91 | } | 91 | } |
| 92 | if($scope.notaPedido.domicilio.id === undefined) { | 92 | if($scope.notaPedido.domicilio.id === undefined) { |
| 93 | $scope.notaPedido.domicilio.id = 0; | 93 | $scope.notaPedido.domicilio.id = 0; |
| 94 | } | 94 | } |
| 95 | var date = new Date(); | 95 | var date = new Date(); |
| 96 | var notaPedido = { | 96 | var notaPedido = { |
| 97 | id: 0, | 97 | id: 0, |
| 98 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 98 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
| 99 | .toISOString().slice(0, 19).replace('T', ' '), | 99 | .toISOString().slice(0, 19).replace('T', ' '), |
| 100 | vendedor: $scope.notaPedido.vendedor.nombre, | 100 | vendedor: $scope.notaPedido.vendedor.nombre, |
| 101 | idCliente: $scope.notaPedido.cliente.id, | 101 | idCliente: $scope.notaPedido.cliente.id, |
| 102 | domicilio: $scope.notaPedido.domicilio, | 102 | domicilio: $scope.notaPedido.domicilio, |
| 103 | precioCondicion: $scope.notaPedido.precioCondicion, | ||
| 104 | bomba: $scope.notaPedido.bomba, | 103 | bomba: $scope.notaPedido.bomba, |
| 105 | flete: $scope.notaPedido.flete, | 104 | flete: $scope.notaPedido.flete, |
| 106 | total: $scope.getTotal() | 105 | total: $scope.getTotal() |
| 107 | }; | 106 | }; |
| 108 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 107 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
| 109 | function(data) { | 108 | function(data) { |
| 110 | focaModalService.alert('Nota pedido creada'); | 109 | focaModalService.alert('Nota pedido creada'); |
| 111 | if($scope.notaPedido.flete === 1) { | 110 | if($scope.notaPedido.flete === 1) { |
| 112 | var flete = { | 111 | var flete = { |
| 113 | idNotaPedido: data.data.id, | 112 | idNotaPedido: data.data.id, |
| 114 | idTransportista: $scope.notaPedido.fleteId, | 113 | idTransportista: $scope.notaPedido.fleteId, |
| 115 | idChofer: $scope.notaPedido.chofer.id, | 114 | idChofer: $scope.notaPedido.chofer.id, |
| 116 | idVehiculo: $scope.notaPedido.vehiculo.id, | 115 | idVehiculo: $scope.notaPedido.vehiculo.id, |
| 117 | kilometros: $scope.notaPedido.kilometros, | 116 | kilometros: $scope.notaPedido.kilometros, |
| 118 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete | 117 | costoKilometro: $scope.notaPedido.costoUnitarioKmFlete |
| 119 | }; | 118 | }; |
| 120 | crearNotaPedidoService.crearFlete(flete); | 119 | crearNotaPedidoService.crearFlete(flete); |
| 121 | } | 120 | } |
| 122 | var articulosNotaPedido = $scope.articulosTabla; | 121 | var articulosNotaPedido = $scope.articulosTabla; |
| 123 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 122 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
| 124 | delete articulosNotaPedido[i].edit; | 123 | delete articulosNotaPedido[i].edit; |
| 125 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 124 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
| 126 | crearNotaPedidoService | 125 | crearNotaPedidoService |
| 127 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 126 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
| 128 | } | 127 | } |
| 129 | $scope.limpiarPantalla(); | 128 | $scope.limpiarPantalla(); |
| 130 | } | 129 | } |
| 131 | ); | 130 | ); |
| 132 | }; | 131 | }; |
| 133 | 132 | ||
| 134 | $scope.seleccionarArticulo = function() { | 133 | $scope.seleccionarArticulo = function() { |
| 135 | if (idLista === undefined) { | 134 | if (idLista === undefined) { |
| 136 | focaModalService.alert( | 135 | focaModalService.alert( |
| 137 | 'Primero seleccione una lista de precio y condicion'); | 136 | 'Primero seleccione una lista de precio y condicion'); |
| 138 | return; | 137 | return; |
| 139 | } | 138 | } |
| 140 | var modalInstance = $uibModal.open( | 139 | var modalInstance = $uibModal.open( |
| 141 | { | 140 | { |
| 142 | ariaLabelledBy: 'Busqueda de Productos', | 141 | ariaLabelledBy: 'Busqueda de Productos', |
| 143 | templateUrl: 'modal-busqueda-productos.html', | 142 | templateUrl: 'modal-busqueda-productos.html', |
| 144 | controller: 'modalBusquedaProductosCtrl', | 143 | controller: 'modalBusquedaProductosCtrl', |
| 145 | resolve: { idLista: function() { return idLista; } }, | 144 | resolve: { idLista: function() { return idLista; } }, |
| 146 | size: 'lg' | 145 | size: 'lg' |
| 147 | } | 146 | } |
| 148 | ); | 147 | ); |
| 149 | modalInstance.result.then( | 148 | modalInstance.result.then( |
| 150 | function(producto) { | 149 | function(producto) { |
| 151 | var newArt = | 150 | var newArt = |
| 152 | { | 151 | { |
| 153 | id: 0, | 152 | id: 0, |
| 154 | codigo: producto.codigo, | 153 | codigo: producto.codigo, |
| 155 | sector: producto.sector, | 154 | sector: producto.sector, |
| 156 | sectorCodigo: producto.sector + '-' + producto.codigo, | 155 | sectorCodigo: producto.sector + '-' + producto.codigo, |
| 157 | descripcion: producto.descripcion, | 156 | descripcion: producto.descripcion, |
| 158 | item: $scope.articulosTabla.length + 1, | 157 | item: $scope.articulosTabla.length + 1, |
| 159 | nombre: producto.descripcion, | 158 | nombre: producto.descripcion, |
| 160 | precio: producto.precio.toFixed(2), | 159 | precio: producto.precio.toFixed(2), |
| 161 | costoUnitario: producto.costo, | 160 | costoUnitario: producto.costo, |
| 162 | edit: false | 161 | edit: false |
| 163 | }; | 162 | }; |
| 164 | $scope.articuloACargar = newArt; | 163 | $scope.articuloACargar = newArt; |
| 165 | $scope.cargando = false; | 164 | $scope.cargando = false; |
| 166 | }, function() { | 165 | }, function() { |
| 167 | // funcion ejecutada cuando se cancela el modal | 166 | // funcion ejecutada cuando se cancela el modal |
| 168 | } | 167 | } |
| 169 | ); | 168 | ); |
| 170 | }; | 169 | }; |
| 171 | 170 | ||
| 172 | $scope.seleccionarVendedor = function() { | 171 | $scope.seleccionarVendedor = function() { |
| 173 | var modalInstance = $uibModal.open( | 172 | var modalInstance = $uibModal.open( |
| 174 | { | 173 | { |
| 175 | ariaLabelledBy: 'Busqueda de Vendedores', | 174 | ariaLabelledBy: 'Busqueda de Vendedores', |
| 176 | templateUrl: 'modal-vendedores.html', | 175 | templateUrl: 'modal-vendedores.html', |
| 177 | controller: 'modalVendedoresCtrl', | 176 | controller: 'modalVendedoresCtrl', |
| 178 | size: 'lg' | 177 | size: 'lg' |
| 179 | } | 178 | } |
| 180 | ); | 179 | ); |
| 181 | modalInstance.result.then( | 180 | modalInstance.result.then( |
| 182 | function(vendedor) { | 181 | function(vendedor) { |
| 183 | addCabecera('Vendedor:', vendedor.NomVen); | 182 | addCabecera('Vendedor:', vendedor.NomVen); |
| 184 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; | 183 | $scope.notaPedido.vendedor.nombre = vendedor.NomVen; |
| 185 | }, function() { | 184 | }, function() { |
| 186 | 185 | ||
| 187 | } | 186 | } |
| 188 | ); | 187 | ); |
| 189 | }; | 188 | }; |
| 190 | 189 | ||
| 191 | $scope.seleccionarProveedor = function() { | 190 | $scope.seleccionarProveedor = function() { |
| 192 | var modalInstance = $uibModal.open( | 191 | var modalInstance = $uibModal.open( |
| 193 | { | 192 | { |
| 194 | ariaLabelledBy: 'Busqueda de Proveedor', | 193 | ariaLabelledBy: 'Busqueda de Proveedor', |
| 195 | templateUrl: 'modal-proveedor.html', | 194 | templateUrl: 'modal-proveedor.html', |
| 196 | controller: 'focaModalProveedorCtrl', | 195 | controller: 'focaModalProveedorCtrl', |
| 197 | size: 'lg' | 196 | size: 'lg' |
| 198 | } | 197 | } |
| 199 | ); | 198 | ); |
| 200 | modalInstance.result.then( | 199 | modalInstance.result.then( |
| 201 | function(proveedor) { | 200 | function(proveedor) { |
| 202 | $scope.notaPedido.proveedor = proveedor.NOM; | 201 | $scope.notaPedido.proveedor = proveedor.NOM; |
| 203 | addCabecera('Proveedor:', proveedor.NOM); | 202 | addCabecera('Proveedor:', proveedor.NOM); |
| 204 | }, function() { | 203 | }, function() { |
| 205 | 204 | ||
| 206 | } | 205 | } |
| 207 | ); | 206 | ); |
| 208 | }; | 207 | }; |
| 209 | 208 | ||
| 210 | $scope.seleccionarCliente = function() { | 209 | $scope.seleccionarCliente = function() { |
| 211 | var modalInstance = $uibModal.open( | 210 | var modalInstance = $uibModal.open( |
| 212 | { | 211 | { |
| 213 | ariaLabelledBy: 'Busqueda de Cliente', | 212 | ariaLabelledBy: 'Busqueda de Cliente', |
| 214 | templateUrl: 'foca-busqueda-cliente-modal.html', | 213 | templateUrl: 'foca-busqueda-cliente-modal.html', |
| 215 | controller: 'focaBusquedaClienteModalController', | 214 | controller: 'focaBusquedaClienteModalController', |
| 216 | size: 'lg' | 215 | size: 'lg' |
| 217 | } | 216 | } |
| 218 | ); | 217 | ); |
| 219 | modalInstance.result.then( | 218 | modalInstance.result.then( |
| 220 | function(cliente) { | 219 | function(cliente) { |
| 221 | $scope.notaPedido.cliente.nombre = cliente.nom; | 220 | $scope.notaPedido.cliente.nombre = cliente.nom; |
| 222 | $scope.notaPedido.cliente.id = cliente.cod; | 221 | $scope.notaPedido.cliente.id = cliente.cod; |
| 223 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 222 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
| 224 | function(data) { | 223 | function(data) { |
| 225 | if(data.data.length === 0){ | 224 | if(data.data.length === 0){ |
| 226 | focaModalService | 225 | focaModalService |
| 227 | .alert('El cliente no tienen domicilios de entrega') | 226 | .alert('El cliente no tienen domicilios de entrega') |
| 228 | .then( | 227 | .then( |
| 229 | function() { | 228 | function() { |
| 230 | $scope.seleccionarCliente(); | 229 | $scope.seleccionarCliente(); |
| 231 | $scope.notaPedido.cliente = {nombre: ''}; | 230 | $scope.notaPedido.cliente = {nombre: ''}; |
| 232 | } | 231 | } |
| 233 | ); | 232 | ); |
| 234 | return; | 233 | return; |
| 235 | } | 234 | } |
| 236 | var modalInstanceDomicilio = $uibModal.open( | 235 | var modalInstanceDomicilio = $uibModal.open( |
| 237 | { | 236 | { |
| 238 | ariaLabelledBy: 'Busqueda de Domicilios', | 237 | ariaLabelledBy: 'Busqueda de Domicilios', |
| 239 | templateUrl: 'modal-domicilio.html', | 238 | templateUrl: 'modal-domicilio.html', |
| 240 | controller: 'focaModalDomicilioController', | 239 | controller: 'focaModalDomicilioController', |
| 241 | resolve: { idCliente: function() { return cliente.cod; }}, | 240 | resolve: { idCliente: function() { return cliente.cod; }}, |
| 242 | size: 'lg', | 241 | size: 'lg', |
| 243 | backdrop: 'static', | 242 | backdrop: 'static', |
| 244 | } | 243 | } |
| 245 | ); | 244 | ); |
| 246 | modalInstanceDomicilio.result.then( | 245 | modalInstanceDomicilio.result.then( |
| 247 | function(domicilio) { | 246 | function(domicilio) { |
| 248 | focaModalService.alert('Domicilio elegido' + domicilio.dom); | 247 | focaModalService.alert('Domicilio elegido' + domicilio.dom); |
| 249 | }, function() { | 248 | }, function() { |
| 250 | $scope.notaPedido.cliente.nombre = ''; | 249 | $scope.notaPedido.cliente.nombre = ''; |
| 251 | $scope.notaPedido.cliente.id = ''; | 250 | $scope.notaPedido.cliente.id = ''; |
| 252 | removeCabecera('Cliente:'); | 251 | removeCabecera('Cliente:'); |
| 253 | $scope.seleccionarCliente(); | 252 | $scope.seleccionarCliente(); |
| 254 | return; | 253 | return; |
| 255 | } | 254 | } |
| 256 | ); | 255 | ); |
| 257 | } | 256 | } |
| 258 | ); | 257 | ); |
| 259 | addCabecera('Cliente:', cliente.nom); | 258 | addCabecera('Cliente:', cliente.nom); |
| 260 | }, function() { | 259 | }, function() { |
| 261 | 260 | ||
| 262 | } | 261 | } |
| 263 | ); | 262 | ); |
| 264 | }; | 263 | }; |
| 265 | 264 | ||
| 266 | $scope.mostrarFichaCliente = function() { | 265 | $scope.mostrarFichaCliente = function() { |
| 267 | $uibModal.open( | 266 | $uibModal.open( |
| 268 | { | 267 | { |
| 269 | ariaLabelledBy: 'Datos del Cliente', | 268 | ariaLabelledBy: 'Datos del Cliente', |
| 270 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 269 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
| 271 | controller: 'focaCrearNotaPedidoFichaClienteController', | 270 | controller: 'focaCrearNotaPedidoFichaClienteController', |
| 272 | size: 'lg' | 271 | size: 'lg' |
| 273 | } | 272 | } |
| 274 | ); | 273 | ); |
| 275 | }; | 274 | }; |
| 276 | 275 | ||
| 277 | $scope.getTotal = function() { | 276 | $scope.getTotal = function() { |
| 278 | var total = 0; | 277 | var total = 0; |
| 279 | var arrayTempArticulos = $scope.articulosTabla; | 278 | var arrayTempArticulos = $scope.articulosTabla; |
| 280 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 279 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
| 281 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 280 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
| 282 | } | 281 | } |
| 283 | return total.toFixed(2); | 282 | return total.toFixed(2); |
| 284 | }; | 283 | }; |
| 285 | 284 | ||
| 286 | $scope.getSubTotal = function() { | 285 | $scope.getSubTotal = function() { |
| 287 | if($scope.articuloACargar) { | 286 | if($scope.articuloACargar) { |
| 288 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 287 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
| 289 | } | 288 | } |
| 290 | }; | 289 | }; |
| 291 | 290 | ||
| 292 | $scope.abrirModalListaPrecio = function() { | 291 | $scope.abrirModalListaPrecio = function() { |
| 293 | var modalInstance = $uibModal.open( | 292 | var modalInstance = $uibModal.open( |
| 294 | { | 293 | { |
| 295 | ariaLabelledBy: 'Busqueda de Precio Condición', | 294 | ariaLabelledBy: 'Busqueda de Precio Condición', |
| 296 | templateUrl: 'modal-precio-condicion.html', | 295 | templateUrl: 'modal-precio-condicion.html', |
| 297 | controller: 'focaModalPrecioCondicionController', | 296 | controller: 'focaModalPrecioCondicionController', |
| 298 | size: 'lg' | 297 | size: 'lg' |
| 299 | } | 298 | } |
| 300 | ); | 299 | ); |
| 301 | modalInstance.result.then( | 300 | modalInstance.result.then( |
| 302 | function(precioCondicion) { | 301 | function(precioCondicion) { |
| 303 | $scope.notaPedido.precioCondicion = precioCondicion.nombre; | 302 | var cabecera = ''; |
| 304 | idLista = precioCondicion.idListaPrecio; | 303 | var plazosConcat = ''; |
| 304 | if(!Array.isArray(precioCondicion)) { | ||
| 305 | $scope.plazosPagos = precioCondicion.plazoPago; | ||
| 306 | idLista = precioCondicion.idListaPrecio; | ||
| 307 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | ||
| 308 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | ||
| 309 | } | ||
| 310 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | ||
| 311 | } else { //Cuando se ingresan los plazos manualmente | ||
| 312 | idLista = -1; //-1, el modal productos busca todos los productos | ||
| 313 | $scope.notaPedido.plazoPago = precioCondicion; | ||
| 314 | for(var j = 0; j < precioCondicion.length; j++) { | ||
| 315 | plazosConcat += precioCondicion[j].dias + ' '; | ||
| 316 | } | ||
| 317 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | ||
| 318 | } | ||
| 305 | $scope.articulosTabla = []; | 319 | $scope.articulosTabla = []; |
| 306 | 320 | addCabecera('Precios y condiciones:', cabecera); | |
| 307 | addCabecera('Precios y condiciones:', precioCondicion.nombre); | ||
| 308 | }, function() { | 321 | }, function() { |
| 309 | 322 | ||
| 310 | } | 323 | } |
| 311 | ); | 324 | ); |
| 312 | }; | 325 | }; |
| 313 | 326 | ||
| 314 | $scope.abrirModalFlete = function() { | 327 | $scope.abrirModalFlete = function() { |
| 315 | var modalInstance = $uibModal.open( | 328 | var modalInstance = $uibModal.open( |
| 316 | { | 329 | { |
| 317 | ariaLabelledBy: 'Busqueda de Flete', | 330 | ariaLabelledBy: 'Busqueda de Flete', |
| 318 | templateUrl: 'modal-flete.html', | 331 | templateUrl: 'modal-flete.html', |
| 319 | controller: 'focaModalFleteController', | 332 | controller: 'focaModalFleteController', |
| 320 | size: 'lg', | 333 | size: 'lg', |
| 321 | resolve: { | 334 | resolve: { |
| 322 | parametrosFlete: | 335 | parametrosFlete: |
| 323 | function() { | 336 | function() { |
| 324 | return { | 337 | return { |
| 325 | flete: $scope.notaPedido.flete, | 338 | flete: $scope.notaPedido.flete, |
| 326 | bomba: $scope.notaPedido.bomba, | 339 | bomba: $scope.notaPedido.bomba, |
| 327 | kilometros: $scope.notaPedido.kilometros | 340 | kilometros: $scope.notaPedido.kilometros |
| 328 | }; | 341 | }; |
| 329 | } | 342 | } |
| 330 | } | 343 | } |
| 331 | } | 344 | } |
| 332 | ); | 345 | ); |
| 333 | modalInstance.result.then( | 346 | modalInstance.result.then( |
| 334 | function(datos) { | 347 | function(datos) { |
| 335 | $scope.notaPedido.flete = datos.flete; | 348 | $scope.notaPedido.flete = datos.flete; |
| 336 | $scope.notaPedido.bomba = datos.bomba; | 349 | $scope.notaPedido.bomba = datos.bomba; |
| 337 | $scope.notaPedido.kilometros = datos.kilometros; | 350 | $scope.notaPedido.kilometros = datos.kilometros; |
| 338 | 351 | ||
| 339 | addCabecera('Flete:', datos.flete); | 352 | addCabecera('Flete:', datos.flete); |
| 340 | if(datos.flete === 'si') { | 353 | if(datos.flete === 'si') { |
| 341 | addCabecera('Bomba:', datos.bomba); | 354 | addCabecera('Bomba:', datos.bomba); |
| 342 | addCabecera('Kilometros:', datos.kilometros); | 355 | addCabecera('Kilometros:', datos.kilometros); |
| 343 | } else { | 356 | } else { |
| 344 | removeCabecera('Bomba:'); | 357 | removeCabecera('Bomba:'); |
| 345 | removeCabecera('Kilometros:'); | 358 | removeCabecera('Kilometros:'); |
| 346 | } | 359 | } |
| 347 | }, function() { | 360 | }, function() { |
| 348 | 361 | ||
| 349 | } | 362 | } |
| 350 | ); | 363 | ); |
| 351 | }; | 364 | }; |
| 352 | 365 | ||
| 353 | $scope.abrirModalMoneda = function() { | 366 | $scope.abrirModalMoneda = function() { |
| 354 | var modalInstance = $uibModal.open( | 367 | var modalInstance = $uibModal.open( |
| 355 | { | 368 | { |
| 356 | ariaLabelledBy: 'Busqueda de Moneda', | 369 | ariaLabelledBy: 'Busqueda de Moneda', |
| 357 | templateUrl: 'modal-moneda.html', | 370 | templateUrl: 'modal-moneda.html', |
| 358 | controller: 'focaModalMonedaController', | 371 | controller: 'focaModalMonedaController', |
| 359 | size: 'lg' | 372 | size: 'lg' |
| 360 | } | 373 | } |
| 361 | ); | 374 | ); |
| 362 | modalInstance.result.then( | 375 | modalInstance.result.then( |
| 363 | function(moneda) { | 376 | function(moneda) { |
| 364 | $scope.notaPedido.moneda = { | 377 | $scope.notaPedido.moneda = { |
| 365 | id: moneda.ID, | 378 | id: moneda.ID, |
| 366 | detalle: moneda.DETALLE, | 379 | detalle: moneda.DETALLE, |
| 367 | simbolo: moneda.SIMBOLO | 380 | simbolo: moneda.SIMBOLO |
| 368 | }; | 381 | }; |
| 369 | 382 | ||
| 370 | addCabecera('Moneda:', moneda.DETALLE); | 383 | addCabecera('Moneda:', moneda.DETALLE); |
| 371 | }, function() { | 384 | }, function() { |
| 372 | 385 | ||
| 373 | } | 386 | } |
| 374 | ); | 387 | ); |
| 375 | }; | 388 | }; |
| 376 | 389 | ||
| 377 | $scope.agregarATabla = function(key) { | 390 | $scope.agregarATabla = function(key) { |
| 378 | if(key === 13) { | 391 | if(key === 13) { |
| 379 | if($scope.articuloACargar.cantidad === undefined || | 392 | if($scope.articuloACargar.cantidad === undefined || |
| 380 | $scope.articuloACargar.cantidad === 0 || | 393 | $scope.articuloACargar.cantidad === 0 || |
| 381 | $scope.articuloACargar.cantidad === null ){ | 394 | $scope.articuloACargar.cantidad === null ){ |
| 382 | focaModalService.alert('El valor debe ser al menos 1'); | 395 | focaModalService.alert('El valor debe ser al menos 1'); |
| 383 | return; | 396 | return; |
| 384 | } | 397 | } |
| 385 | delete $scope.articuloACargar.sectorCodigo; | 398 | delete $scope.articuloACargar.sectorCodigo; |
| 386 | $scope.articulosTabla.push($scope.articuloACargar); | 399 | $scope.articulosTabla.push($scope.articuloACargar); |
| 387 | $scope.cargando = true; | 400 | $scope.cargando = true; |
| 388 | } | 401 | } |
| 389 | }; | 402 | }; |
| 390 | 403 | ||
| 391 | $scope.quitarArticulo = function(key) { | 404 | $scope.quitarArticulo = function(key) { |
| 392 | $scope.articulosTabla.splice(key, 1); | 405 | $scope.articulosTabla.splice(key, 1); |
| 393 | }; | 406 | }; |
| 394 | 407 | ||
| 395 | $scope.editarArticulo = function(key, articulo) { | 408 | $scope.editarArticulo = function(key, articulo) { |
| 396 | if(key === 13) { | 409 | if(key === 13) { |
| 397 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 410 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
| 398 | articulo.cantidad === undefined){ | 411 | articulo.cantidad === undefined){ |
| 399 | focaModalService.alert('El valor debe ser al menos 1'); | 412 | focaModalService.alert('El valor debe ser al menos 1'); |
| 400 | return; | 413 | return; |
| 401 | } | 414 | } |
| 402 | articulo.edit = false; | 415 | articulo.edit = false; |
| 403 | } | 416 | } |
| 404 | }; | 417 | }; |
| 405 | 418 | ||
| 406 | $scope.cambioEdit = function(articulo) { | 419 | $scope.cambioEdit = function(articulo) { |
| 407 | articulo.edit = true; | 420 | articulo.edit = true; |
| 408 | }; | 421 | }; |
| 409 | 422 | ||
| 410 | $scope.limpiarFlete = function() { | 423 | $scope.limpiarFlete = function() { |
| 411 | $scope.notaPedido.fleteNombre = ''; | 424 | $scope.notaPedido.fleteNombre = ''; |
| 412 | $scope.notaPedido.chofer = ''; | 425 | $scope.notaPedido.chofer = ''; |
| 413 | $scope.notaPedido.vehiculo = ''; | 426 | $scope.notaPedido.vehiculo = ''; |
| 414 | $scope.notaPedido.kilometros = ''; | 427 | $scope.notaPedido.kilometros = ''; |
| 415 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 428 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
| 416 | $scope.choferes = ''; | 429 | $scope.choferes = ''; |
| 417 | $scope.vehiculos = ''; | 430 | $scope.vehiculos = ''; |
| 418 | }; | 431 | }; |
| 419 | 432 | ||
| 420 | $scope.limpiarPantalla = function() { | 433 | $scope.limpiarPantalla = function() { |
| 421 | $scope.limpiarFlete(); | 434 | $scope.limpiarFlete(); |
| 422 | $scope.notaPedido.flete = '0'; | 435 | $scope.notaPedido.flete = '0'; |
| 423 | $scope.notaPedido.bomba = '0'; | 436 | $scope.notaPedido.bomba = '0'; |
| 424 | $scope.notaPedido.precioCondicion = ''; | 437 | $scope.notaPedido.precioCondicion = ''; |
| 425 | $scope.articulosTabla = []; | 438 | $scope.articulosTabla = []; |
| 426 | $scope.notaPedido.vendedor.nombre = ''; | 439 | $scope.notaPedido.vendedor.nombre = ''; |
| 427 | $scope.notaPedido.cliente = {nombre: ''}; | 440 | $scope.notaPedido.cliente = {nombre: ''}; |
| 428 | $scope.notaPedido.domicilio = {dom: ''}; | 441 | $scope.notaPedido.domicilio = {dom: ''}; |
| 429 | $scope.domiciliosCliente = []; | 442 | $scope.domiciliosCliente = []; |
| 430 | }; | 443 | }; |
| 431 | 444 | ||
| 432 | $scope.resetFilter = function() { | 445 | $scope.resetFilter = function() { |
| 433 | $scope.articuloACargar = {}; | 446 | $scope.articuloACargar = {}; |
| 434 | $scope.cargando = true; | 447 | $scope.cargando = true; |
| 435 | }; | 448 | }; |
| 436 | 449 | ||
| 437 | $scope.selectFocus = function($event) { | 450 | $scope.selectFocus = function($event) { |
| 438 | $event.target.select(); | 451 | $event.target.select(); |
| 439 | }; | 452 | }; |
| 440 | 453 | ||
| 441 | $scope.salir = function() { | 454 | $scope.salir = function() { |
| 442 | $location.path('/'); | 455 | $location.path('/'); |
| 443 | }; | 456 | }; |
| 444 | 457 | ||
| 445 | function addCabecera(label, valor) { | 458 | function addCabecera(label, valor) { |
| 446 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 459 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
| 447 | if(propiedad.length === 1) { | 460 | if(propiedad.length === 1) { |
| 448 | propiedad[0].valor = valor; | 461 | propiedad[0].valor = valor; |
| 449 | } else { | 462 | } else { |
| 450 | $scope.cabecera.push({label: label, valor: valor}); | 463 | $scope.cabecera.push({label: label, valor: valor}); |
| 451 | } | 464 | } |
| 452 | } | 465 | } |
| 453 | 466 | ||
| 454 | function removeCabecera(label) { | 467 | function removeCabecera(label) { |
| 455 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); | 468 | var propiedad = $filter('filter')($scope.cabecera, {label: label}); |
| 456 | if(propiedad.length === 1){ | 469 | if(propiedad.length === 1){ |
| 457 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 470 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
| 458 | } | 471 | } |
| 459 | } | 472 | } |
| 460 | } | 473 | } |
| 461 | ] | 474 | ] |
| 462 | ) | 475 | ) |
| 463 | .controller('notaPedidoListaCtrl', [ | 476 | .controller('notaPedidoListaCtrl', [ |
| 464 | '$scope', | 477 | '$scope', |
| 465 | 'crearNotaPedidoService', | 478 | 'crearNotaPedidoService', |
| 466 | '$location', | 479 | '$location', |
| 467 | function($scope, crearNotaPedidoService, $location) { | 480 | function($scope, crearNotaPedidoService, $location) { |
| 468 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 481 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 469 | $scope.notaPedidos = datos.data; | 482 | $scope.notaPedidos = datos.data; |
| 470 | }); | 483 | }); |
| 471 | $scope.editar = function(notaPedido) { | 484 | $scope.editar = function(notaPedido) { |
| 472 | crearNotaPedidoService.setNotaPedido(notaPedido); | 485 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 473 | $location.path('/venta-nota-pedido/abm/'); | 486 | $location.path('/venta-nota-pedido/abm/'); |
| 474 | }; | 487 | }; |
| 475 | $scope.crearPedido = function() { | 488 | $scope.crearPedido = function() { |
| 476 | crearNotaPedidoService.clearNotaPedido(); | 489 | crearNotaPedidoService.clearNotaPedido(); |
| 477 | $location.path('/venta-nota-pedido/abm/'); | 490 | $location.path('/venta-nota-pedido/abm/'); |
| 478 | }; | 491 | }; |
| 479 | } | 492 | } |
| 480 | ]) | 493 | ]) |
| 481 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 494 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
| 482 | '$scope', | 495 | '$scope', |
| 483 | 'crearNotaPedidoService', | 496 | 'crearNotaPedidoService', |
| 484 | '$location', | 497 | '$location', |
| 485 | function($scope, crearNotaPedidoService, $location) { | 498 | function($scope, crearNotaPedidoService, $location) { |
| 486 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 499 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
| 487 | $scope.notaPedidos = datos.data; | 500 | $scope.notaPedidos = datos.data; |
| 488 | }); | 501 | }); |
| 489 | $scope.editar = function(notaPedido) { | 502 | $scope.editar = function(notaPedido) { |
| 490 | crearNotaPedidoService.setNotaPedido(notaPedido); | 503 | crearNotaPedidoService.setNotaPedido(notaPedido); |
| 491 | $location.path('/venta-nota-pedido/abm/'); | 504 | $location.path('/venta-nota-pedido/abm/'); |
| 492 | }; | 505 | }; |
| 493 | $scope.crearPedido = function() { | 506 | $scope.crearPedido = function() { |
| 494 | crearNotaPedidoService.clearNotaPedido(); | 507 | crearNotaPedidoService.clearNotaPedido(); |
| 495 | $location.path('/venta-nota-pedido/abm/'); | 508 | $location.path('/venta-nota-pedido/abm/'); |
| 496 | }; | 509 | }; |
| 497 | } | 510 | } |