Commit b131f7c474d7cae0fb69063299317a5ccf17cc9b

Authored by Pablo Marco del Pont
Exists in master

Merge branch 'master' of https://debo.suite.repo/modulos-npm/foca-crear-nota-pedido

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