Commit d2986e26f751fa7e154510d37ee752a71f68da2d
Exists in
master
Merge branch 'master' into 'master'
Master (pmarco) See merge request modulos-npm/foca-crear-nota-pedido!47
Showing
5 changed files
Show diff stats
gulpfile.js
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 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ | 47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ |
48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ | 48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ |
49 | '"angular-ladda","focaModalMoneda","focaModalCotizacion"', ''), | 49 | '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda"', ''), |
50 | gulp.dest(paths.dist) | 50 | gulp.dest(paths.dist) |
51 | ] | 51 | ] |
52 | ); | 52 | ); |
53 | }); | 53 | }); |
54 | 54 | ||
55 | gulp.task('clean', function(){ | 55 | gulp.task('clean', function(){ |
56 | return gulp.src(['tmp', 'dist'], {read: false}) | 56 | return gulp.src(['tmp', 'dist'], {read: false}) |
57 | .pipe(clean()); | 57 | .pipe(clean()); |
58 | }); | 58 | }); |
59 | 59 | ||
60 | gulp.task('pre-commit', function() { | 60 | gulp.task('pre-commit', function() { |
61 | return pump( | 61 | return pump( |
62 | [ | 62 | [ |
63 | gulp.src(paths.srcJS), | 63 | gulp.src(paths.srcJS), |
64 | jshint('.jshintrc'), | 64 | jshint('.jshintrc'), |
65 | jshint.reporter('default'), | 65 | jshint.reporter('default'), |
66 | jshint.reporter('fail') | 66 | jshint.reporter('fail') |
67 | ] | 67 | ] |
68 | ); | 68 | ); |
69 | 69 | ||
70 | gulp.start('uglify'); | 70 | gulp.start('uglify'); |
71 | }); | 71 | }); |
72 | 72 | ||
73 | gulp.task('webserver', function() { | 73 | gulp.task('webserver', function() { |
74 | pump [ | 74 | pump [ |
75 | connect.server({port: 3300, host: '0.0.0.0'}) | 75 | connect.server({port: 3300, host: '0.0.0.0'}) |
76 | ] | 76 | ] |
77 | }); | 77 | }); |
78 | 78 | ||
79 | gulp.task('clean-post-install', function() { | 79 | gulp.task('clean-post-install', function() { |
80 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 80 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
81 | 'index.html'], {read: false}) | 81 | 'index.html'], {read: false}) |
82 | .pipe(clean()); | 82 | .pipe(clean()); |
83 | }); | 83 | }); |
84 | 84 | ||
85 | gulp.task('default', ['webserver']); | 85 | gulp.task('default', ['webserver']); |
86 | 86 | ||
87 | gulp.task('watch', function() { | 87 | gulp.task('watch', function() { |
88 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 88 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
89 | }); | 89 | }); |
90 | 90 |
index.html
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 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> | 9 | <link href="node_modules/ladda/dist/ladda-themeless.min.css" rel="stylesheet"> |
10 | 10 | ||
11 | <!--VENDOR JS--> | 11 | <!--VENDOR JS--> |
12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> | 12 | <script src="node_modules/jquery/dist/jquery.min.js"></script> |
13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> | 13 | <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script> |
14 | <script src="node_modules/angular/angular.min.js"></script> | 14 | <script src="node_modules/angular/angular.min.js"></script> |
15 | <script src="node_modules/angular-route/angular-route.min.js"></script> | 15 | <script src="node_modules/angular-route/angular-route.min.js"></script> |
16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> | 16 | <script src="node_modules/ui-bootstrap4/dist/ui-bootstrap-tpls.js"></script> |
17 | <script src="node_modules/ladda/dist/spin.min.js"></script> | 17 | <script src="node_modules/ladda/dist/spin.min.js"></script> |
18 | <script src="node_modules/ladda/dist/ladda.min.js"></script> | 18 | <script src="node_modules/ladda/dist/ladda.min.js"></script> |
19 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> | 19 | <script src="node_modules/angular-ladda/dist/angular-ladda.min.js"></script> |
20 | 20 | ||
21 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> | 21 | <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> |
22 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> | 22 | <script src="node_modules/foca-modal-vendedores/dist/foca-modal-vendedores.min.js"></script> |
23 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> | 23 | <script src="node_modules/foca-modal-busqueda-productos/dist/foca-busqueda-productos.min.js"></script> |
24 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> | 24 | <script src="node_modules/foca-modal-proveedor/dist/foca-modal-proveedor.min.js"></script> |
25 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> | 25 | <script src="node_modules/foca-busqueda-cliente/dist/foca-busqueda-cliente.min.js"></script> |
26 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> | 26 | <script src="node_modules/foca-modal-precio-condiciones/dist/foca-modal-precio-condiciones.min.js"></script> |
27 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> | 27 | <script src="node_modules/foca-modal-flete/dist/foca-modal-flete.min.js"></script> |
28 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> | 28 | <script src="node_modules/foca-modal/dist/foca-modal.min.js"></script> |
29 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> | 29 | <script src="node_modules/foca-modal-domicilio/dist/foca-modal-domicilios.min.js"></script> |
30 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> | 30 | <script src="node_modules/foca-modal-moneda/dist/foca-modal-moneda.min.js"></script> |
31 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> | 31 | <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script> |
32 | <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script> | ||
32 | 33 | ||
33 | <script src="src/js/app.js"></script> | 34 | <script src="src/js/app.js"></script> |
34 | <script src="src/js/controller.js"></script> | 35 | <script src="src/js/controller.js"></script> |
35 | <script src="src/js/service.js"></script> | 36 | <script src="src/js/service.js"></script> |
36 | <script src="src/js/route.js"></script> | 37 | <script src="src/js/route.js"></script> |
37 | 38 | ||
38 | <script src="src/etc/develop.js"></script> | 39 | <script src="src/etc/develop.js"></script> |
39 | </head> | 40 | </head> |
40 | <body> | 41 | <body> |
41 | <div ng-view class="container-fluid"></div> | 42 | <div ng-view class="container-fluid"></div> |
42 | </body> | 43 | </body> |
43 | </html> | 44 | </html> |
44 | 45 |
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-ladda ladda@1.0.6 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 git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git" | 11 | "install-dev": "npm install -D jasmine-core pre-commit angular angular-ladda ladda@1.0.6 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 git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.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 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git" | ||
28 | }, | 29 | }, |
29 | "devDependencies": { | 30 | "devDependencies": { |
30 | "angular": "^1.7.5", | 31 | "angular": "^1.7.5", |
31 | "angular-ladda": "^0.4.3", | 32 | "angular-ladda": "^0.4.3", |
32 | "angular-route": "^1.7.5", | 33 | "angular-route": "^1.7.5", |
33 | "bootstrap": "^4.1.3", | 34 | "bootstrap": "^4.1.3", |
34 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", | 35 | "foca-busqueda-cliente": "git+https://debo.suite.repo/modulos-npm/foca-busqueda-cliente.git", |
35 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | 36 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", |
36 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", | 37 | "foca-modal": "git+https://debo.suite.repo/modulos-npm/foca-modal.git", |
37 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", | 38 | "foca-modal-busqueda-productos": "git+https://debo.suite.repo/modulos-npm/foca-modal-busqueda-productos", |
38 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", | 39 | "foca-modal-cotizacion": "git+https://debo.suite.repo/modulos-npm/foca-modal-cotizacion.git", |
39 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", | 40 | "foca-modal-domicilio": "git+https://debo.suite.repo/modulos-npm/foca-modal-domicilio.git", |
40 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", | 41 | "foca-modal-flete": "git+https://debo.suite.repo/modulos-npm/foca-modal-flete", |
41 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", | 42 | "foca-modal-moneda": "git+https://debo.suite.repo/modulos-npm/foca-modal-moneda.git", |
42 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", | 43 | "foca-modal-precio-condiciones": "git+https://debo.suite.repo/modulos-npm/foca-modal-precio-condiciones.git", |
43 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", | 44 | "foca-modal-proveedor": "git+https://debo.suite.repo/modulos-npm/foca-modal-proveedor.git", |
44 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", | 45 | "foca-modal-vendedores": "git+https://debo.suite.repo/modulos-npm/foca-modal-vendedores.git", |
46 | "foca-seguimiento": "git+https://debo.suite.repo/modulos-npm/foca-seguimiento.git", | ||
45 | "font-awesome": "^4.7.0", | 47 | "font-awesome": "^4.7.0", |
46 | "gulp": "^3.9.1", | 48 | "gulp": "^3.9.1", |
47 | "gulp-angular-templatecache": "^2.2.2", | 49 | "gulp-angular-templatecache": "^2.2.2", |
48 | "gulp-clean": "^0.4.0", | 50 | "gulp-clean": "^0.4.0", |
49 | "gulp-concat": "^2.6.1", | 51 | "gulp-concat": "^2.6.1", |
50 | "gulp-connect": "^5.6.1", | 52 | "gulp-connect": "^5.6.1", |
51 | "gulp-htmlmin": "^5.0.1", | 53 | "gulp-htmlmin": "^5.0.1", |
52 | "gulp-jshint": "^2.1.0", | 54 | "gulp-jshint": "^2.1.0", |
53 | "gulp-rename": "^1.4.0", | 55 | "gulp-rename": "^1.4.0", |
54 | "gulp-replace": "^1.0.0", | 56 | "gulp-replace": "^1.0.0", |
55 | "gulp-sequence": "^1.0.0", | 57 | "gulp-sequence": "^1.0.0", |
56 | "gulp-uglify": "^3.0.1", | 58 | "gulp-uglify": "^3.0.1", |
57 | "gulp-uglify-es": "^1.0.4", | 59 | "gulp-uglify-es": "^1.0.4", |
58 | "jasmine-core": "^3.3.0", | 60 | "jasmine-core": "^3.3.0", |
59 | "jquery": "^3.3.1", | 61 | "jquery": "^3.3.1", |
60 | "jshint": "^2.9.6", | 62 | "jshint": "^2.9.6", |
61 | "ladda": "1.0.6", | 63 | "ladda": "1.0.6", |
62 | "pre-commit": "^1.2.2", | 64 | "pre-commit": "^1.2.2", |
63 | "pump": "^3.0.0", | 65 | "pump": "^3.0.0", |
64 | "ui-bootstrap4": "^3.0.5" | 66 | "ui-bootstrap4": "^3.0.5" |
65 | } | 67 | } |
66 | } | 68 | } |
67 | 69 |
src/js/app.js
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 | 'focaModalProveedor', | 6 | 'focaModalProveedor', |
7 | 'focaBusquedaCliente', | 7 | 'focaBusquedaCliente', |
8 | 'focaModalPrecioCondicion', | 8 | 'focaModalPrecioCondicion', |
9 | 'focaModalFlete', | 9 | 'focaModalFlete', |
10 | 'focaDirectivas', | 10 | 'focaDirectivas', |
11 | 'focaModal', | 11 | 'focaModal', |
12 | 'focaModalDomicilio', | 12 | 'focaModalDomicilio', |
13 | 'angular-ladda', | ||
14 | 'focaModalMoneda', | 13 | 'focaModalMoneda', |
15 | 'focaModalCotizacion' | 14 | 'focaModalCotizacion', |
15 | 'focaSeguimiento', | ||
16 | 'angular-ladda' | ||
16 | ]); | 17 | ]); |
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', 'focaSeguimientoService', |
5 | function( | 5 | function( |
6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService | 6 | $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService, |
7 | focaSeguimientoService | ||
7 | ) { | 8 | ) { |
8 | $scope.botonera = [ | 9 | $scope.botonera = [ |
9 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, | 10 | {texto: 'Vendedor', accion: function() {$scope.seleccionarVendedor();}}, |
10 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, | 11 | {texto: 'Cliente', accion: function() {$scope.seleccionarCliente();}}, |
11 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, | 12 | {texto: 'Proveedor', accion: function() {$scope.seleccionarProveedor();}}, |
12 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, | 13 | {texto: 'Moneda', accion: function() {$scope.abrirModalMoneda();}}, |
13 | { | 14 | { |
14 | texto: 'Precios y condiciones', | 15 | texto: 'Precios y condiciones', |
15 | accion: function() {$scope.abrirModalListaPrecio();}}, | 16 | accion: function() {$scope.abrirModalListaPrecio();}}, |
16 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, | 17 | {texto: 'Flete', accion: function() {$scope.abrirModalFlete();}}, |
17 | {texto: '', accion: function() {}}, | 18 | {texto: '', accion: function() {}}, |
18 | {texto: '', accion: function() {}} | 19 | {texto: '', accion: function() {}} |
19 | ]; | 20 | ]; |
20 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
21 | 22 | ||
22 | $scope.show = false; | 23 | $scope.show = false; |
23 | $scope.cargando = true; | 24 | $scope.cargando = true; |
24 | $scope.dateOptions = { | 25 | $scope.dateOptions = { |
25 | maxDate: new Date(), | 26 | maxDate: new Date(), |
26 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) |
27 | }; | 28 | }; |
28 | 29 | ||
29 | $scope.notaPedido = { | 30 | $scope.notaPedido = { |
30 | vendedor: {}, | 31 | vendedor: {}, |
31 | cliente: {}, | 32 | cliente: {}, |
32 | proveedor: {}, | 33 | proveedor: {}, |
33 | domicilio: {dom: ''}, | 34 | domicilio: {dom: ''}, |
34 | moneda: {}, | 35 | moneda: {}, |
35 | cotizacion: {} | 36 | cotizacion: {} |
36 | }; | 37 | }; |
37 | var monedaPorDefecto; | 38 | var monedaPorDefecto; |
38 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | 39 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' |
39 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { | 40 | crearNotaPedidoService.getCotizacionByIdMoneda(1).then(function(res) { |
40 | monedaPorDefecto = { | 41 | monedaPorDefecto = { |
41 | id: res.data[0].ID, | 42 | id: res.data[0].ID, |
42 | detalle: res.data[0].DETALLE, | 43 | detalle: res.data[0].DETALLE, |
43 | simbolo: res.data[0].SIMBOLO, | 44 | simbolo: res.data[0].SIMBOLO, |
44 | cotizaciones: res.data[0].cotizaciones | 45 | cotizaciones: res.data[0].cotizaciones |
45 | }; | 46 | }; |
46 | addCabecera('Moneda:', monedaPorDefecto.detalle); | 47 | addCabecera('Moneda:', monedaPorDefecto.detalle); |
47 | addCabecera('Fecha cotizacion:', | 48 | addCabecera('Fecha cotizacion:', |
48 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | 49 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); |
49 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | 50 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); |
50 | $scope.notaPedido.moneda = monedaPorDefecto; | 51 | $scope.notaPedido.moneda = monedaPorDefecto; |
51 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; | 52 | $scope.notaPedido.cotizacion = monedaPorDefecto.cotizaciones[0]; |
52 | }); | 53 | }); |
53 | 54 | ||
54 | $scope.cabecera = []; | 55 | $scope.cabecera = []; |
55 | $scope.showCabecera = true; | 56 | $scope.showCabecera = true; |
56 | 57 | ||
57 | $scope.now = new Date(); | 58 | $scope.now = new Date(); |
58 | $scope.puntoVenta = Math.round(Math.random() * 10000); | 59 | $scope.puntoVenta = Math.round(Math.random() * 10000); |
59 | $scope.comprobante = Math.round(Math.random() * 1000000); | 60 | $scope.comprobante = Math.round(Math.random() * 1000000); |
60 | 61 | ||
61 | $scope.articulosTabla = []; | 62 | $scope.articulosTabla = []; |
62 | $scope.idLista = undefined; | 63 | $scope.idLista = undefined; |
63 | //La pantalla solo se usa para cargar pedidos | 64 | //La pantalla solo se usa para cargar pedidos |
64 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); | 65 | //var notaPedidoTemp = crearNotaPedidoService.getNotaPedido(); |
65 | 66 | ||
66 | crearNotaPedidoService.getPrecioCondicion().then( | 67 | crearNotaPedidoService.getPrecioCondicion().then( |
67 | function(res) { | 68 | function(res) { |
68 | $scope.precioCondiciones = res.data; | 69 | $scope.precioCondiciones = res.data; |
69 | } | 70 | } |
70 | ); | 71 | ); |
71 | //La pantalla solo se usa para cargar pedidos | 72 | //La pantalla solo se usa para cargar pedidos |
72 | // if (notaPedidoTemp !== undefined) { | 73 | // if (notaPedidoTemp !== undefined) { |
73 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); | 74 | // notaPedidoTemp.fechaCarga = new Date(notaPedidoTemp.fechaCarga); |
74 | // $scope.notaPedido = notaPedidoTemp; | 75 | // $scope.notaPedido = notaPedidoTemp; |
75 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); | 76 | // $scope.notaPedido.flete = ($scope.notaPedido.flete).toString(); |
76 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); | 77 | // $scope.notaPedido.bomba = ($scope.notaPedido.bomba).toString(); |
77 | // $scope.idLista = $scope.notaPedido.precioCondicion; | 78 | // $scope.idLista = $scope.notaPedido.precioCondicion; |
78 | // crearNotaPedidoService | 79 | // crearNotaPedidoService |
79 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( | 80 | // .getArticulosByIdNotaPedido($scope.notaPedido.id).then( |
80 | // function(res) { | 81 | // function(res) { |
81 | // $scope.articulosTabla = res.data; | 82 | // $scope.articulosTabla = res.data; |
82 | // } | 83 | // } |
83 | // ); | 84 | // ); |
84 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | 85 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO |
85 | //(NO REQUERIDO EN ESTA VERSION) | 86 | //(NO REQUERIDO EN ESTA VERSION) |
86 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( | 87 | // crearNotaPedidoService.getDomiciliosByIdNotaPedido($scope.notaPedido.id).then( |
87 | // function(res) { | 88 | // function(res) { |
88 | // $scope.notaPedido.domicilio = res.data; | 89 | // $scope.notaPedido.domicilio = res.data; |
89 | // } | 90 | // } |
90 | // ); | 91 | // ); |
91 | // } else { | 92 | // } else { |
92 | // $scope.notaPedido.fechaCarga = new Date(); | 93 | // $scope.notaPedido.fechaCarga = new Date(); |
93 | // $scope.notaPedido.bomba = '0'; | 94 | // $scope.notaPedido.bomba = '0'; |
94 | // $scope.notaPedido.flete = '0'; | 95 | // $scope.notaPedido.flete = '0'; |
95 | // $scope.idLista = undefined; | 96 | // $scope.idLista = undefined; |
96 | // } | 97 | // } |
97 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | 98 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO |
98 | // $scope.addNewDom = function() { | 99 | // $scope.addNewDom = function() { |
99 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); | 100 | // $scope.notaPedido.domicilio.push({ 'id': 0 }); |
100 | // }; | 101 | // }; |
101 | // $scope.removeNewChoice = function(choice) { | 102 | // $scope.removeNewChoice = function(choice) { |
102 | // if ($scope.notaPedido.domicilio.length > 1) { | 103 | // if ($scope.notaPedido.domicilio.length > 1) { |
103 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( | 104 | // $scope.notaPedido.domicilio.splice($scope.notaPedido.domicilio.findIndex( |
104 | // function(c) { | 105 | // function(c) { |
105 | // return c.$$hashKey === choice.$$hashKey; | 106 | // return c.$$hashKey === choice.$$hashKey; |
106 | // } | 107 | // } |
107 | // ), 1); | 108 | // ), 1); |
108 | // } | 109 | // } |
109 | // }; | 110 | // }; |
110 | 111 | ||
111 | $scope.crearNotaPedido = function() { | 112 | $scope.crearNotaPedido = function() { |
112 | if(!$scope.notaPedido.vendedor.codigo) { | 113 | if(!$scope.notaPedido.vendedor.codigo) { |
113 | focaModalService.alert('Ingrese Vendedor'); | 114 | focaModalService.alert('Ingrese Vendedor'); |
114 | return; | 115 | return; |
115 | } else if(!$scope.notaPedido.cliente.id) { | 116 | } else if(!$scope.notaPedido.cliente.id) { |
116 | focaModalService.alert('Ingrese Cliente'); | 117 | focaModalService.alert('Ingrese Cliente'); |
117 | return; | 118 | return; |
118 | } else if(!$scope.notaPedido.proveedor.codigo) { | 119 | } else if(!$scope.notaPedido.proveedor.codigo) { |
119 | focaModalService.alert('Ingrese Proveedor'); | 120 | focaModalService.alert('Ingrese Proveedor'); |
120 | return; | 121 | return; |
121 | } else if(!$scope.notaPedido.moneda.id) { | 122 | } else if(!$scope.notaPedido.moneda.id) { |
122 | focaModalService.alert('Ingrese Moneda'); | 123 | focaModalService.alert('Ingrese Moneda'); |
123 | return; | 124 | return; |
124 | } else if(!$scope.notaPedido.cotizacion.ID) { | 125 | } else if(!$scope.notaPedido.cotizacion.ID) { |
125 | focaModalService.alert('Ingrese Cotización'); | 126 | focaModalService.alert('Ingrese Cotización'); |
126 | return; | 127 | return; |
127 | } else if(!$scope.plazosPagos) { | 128 | } else if(!$scope.plazosPagos) { |
128 | focaModalService.alert('Ingrese Precios y Condiciones'); | 129 | focaModalService.alert('Ingrese Precios y Condiciones'); |
129 | return; | 130 | return; |
130 | } else if(!$scope.notaPedido.flete) { | 131 | } else if(!$scope.notaPedido.flete) { |
131 | focaModalService.alert('Ingrese Flete'); | 132 | focaModalService.alert('Ingrese Flete'); |
132 | return; | 133 | return; |
133 | } else if(!$scope.notaPedido.domicilio.id) { | 134 | } else if(!$scope.notaPedido.domicilio.id) { |
134 | focaModalService.aler('Ingrese Domicilio'); | 135 | focaModalService.aler('Ingrese Domicilio'); |
135 | return; | 136 | return; |
136 | } else if($scope.articulosTabla.length === 0) { | 137 | } else if($scope.articulosTabla.length === 0) { |
137 | focaModalService.alert('Debe cargar al menos un articulo'); | 138 | focaModalService.alert('Debe cargar al menos un articulo'); |
138 | return; | 139 | return; |
139 | } | 140 | } |
140 | var date = new Date(); | 141 | var date = new Date(); |
141 | var notaPedido = { | 142 | var notaPedido = { |
142 | id: 0, | 143 | id: 0, |
143 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | 144 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) |
144 | .toISOString().slice(0, 19).replace('T', ' '), | 145 | .toISOString().slice(0, 19).replace('T', ' '), |
145 | idVendedor: $scope.notaPedido.vendedor.codigo, | 146 | idVendedor: $scope.notaPedido.vendedor.codigo, |
146 | idCliente: $scope.notaPedido.cliente.id, | 147 | idCliente: $scope.notaPedido.cliente.id, |
147 | idProveedor: $scope.notaPedido.proveedor.codigo, | 148 | idProveedor: $scope.notaPedido.proveedor.codigo, |
148 | idDomicilio: $scope.notaPedido.domicilio.id, | 149 | idDomicilio: $scope.notaPedido.domicilio.id, |
149 | idCotizacion: $scope.notaPedido.cotizacion.ID, | 150 | idCotizacion: $scope.notaPedido.cotizacion.ID, |
150 | flete: $scope.notaPedido.flete, | 151 | flete: $scope.notaPedido.flete, |
151 | fob: $scope.notaPedido.fob, | 152 | fob: $scope.notaPedido.fob, |
152 | bomba: $scope.notaPedido.bomba, | 153 | bomba: $scope.notaPedido.bomba, |
153 | kilometros: $scope.notaPedido.kilometros, | 154 | kilometros: $scope.notaPedido.kilometros, |
154 | total: $scope.getTotal() | 155 | total: $scope.getTotal() |
155 | }; | 156 | }; |
156 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( | 157 | crearNotaPedidoService.crearNotaPedido(notaPedido).then( |
157 | function(data) { | 158 | function(data) { |
158 | 159 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | |
159 | var articulosNotaPedido = $scope.articulosTabla; | 160 | var articulosNotaPedido = $scope.articulosTabla; |
160 | for(var i = 0; i < articulosNotaPedido.length; i++) { | 161 | for(var i = 0; i < articulosNotaPedido.length; i++) { |
161 | delete articulosNotaPedido[i].editCantidad; | 162 | delete articulosNotaPedido[i].editCantidad; |
162 | delete articulosNotaPedido[i].editPrecio; | 163 | delete articulosNotaPedido[i].editPrecio; |
163 | articulosNotaPedido[i].idNotaPedido = data.data.id; | 164 | articulosNotaPedido[i].idNotaPedido = data.data.id; |
164 | crearNotaPedidoService | 165 | crearNotaPedidoService |
165 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); | 166 | .crearArticulosParaNotaPedido(articulosNotaPedido[i]); |
166 | } | 167 | } |
167 | var plazos = $scope.plazosPagos; | 168 | var plazos = $scope.plazosPagos; |
168 | for(var j = 0; j < plazos.length; j++) { | 169 | for(var j = 0; j < plazos.length; j++) { |
169 | var json = { | 170 | var json = { |
170 | idPedido: data.data.id, | 171 | idPedido: data.data.id, |
171 | dias: plazos[j].dias | 172 | dias: plazos[j].dias |
172 | }; | 173 | }; |
173 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); | 174 | crearNotaPedidoService.crearPlazosParaNotaPedido(json); |
174 | } | 175 | } |
175 | focaModalService.alert('Nota pedido creada'); | 176 | focaModalService.alert('Nota pedido creada'); |
176 | $scope.cabecera = []; | 177 | $scope.cabecera = []; |
177 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); | 178 | addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); |
178 | addCabecera( | 179 | addCabecera( |
179 | 'Fecha cotizacion:', | 180 | 'Fecha cotizacion:', |
180 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') | 181 | $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') |
181 | ); | 182 | ); |
182 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); | 183 | addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.cotizacion); |
183 | $scope.notaPedido.vendedor = {}; | 184 | $scope.notaPedido.vendedor = {}; |
184 | $scope.notaPedido.cliente = {}; | 185 | $scope.notaPedido.cliente = {}; |
185 | $scope.notaPedido.proveedor = {}; | 186 | $scope.notaPedido.proveedor = {}; |
186 | $scope.notaPedido.domicilio = {}; | 187 | $scope.notaPedido.domicilio = {}; |
187 | $scope.notaPedido.flete = null; | 188 | $scope.notaPedido.flete = null; |
188 | $scope.notaPedido.fob = null; | 189 | $scope.notaPedido.fob = null; |
189 | $scope.notaPedido.bomba = null; | 190 | $scope.notaPedido.bomba = null; |
190 | $scope.notaPedido.kilometros = null; | 191 | $scope.notaPedido.kilometros = null; |
191 | $scope.articulosTabla = []; | 192 | $scope.articulosTabla = []; |
192 | } | 193 | } |
193 | ); | 194 | ); |
194 | }; | 195 | }; |
195 | 196 | ||
196 | $scope.seleccionarArticulo = function() { | 197 | $scope.seleccionarArticulo = function() { |
197 | if ($scope.idLista === undefined) { | 198 | if ($scope.idLista === undefined) { |
198 | focaModalService.alert( | 199 | focaModalService.alert( |
199 | 'Primero seleccione una lista de precio y condicion'); | 200 | 'Primero seleccione una lista de precio y condicion'); |
200 | return; | 201 | return; |
201 | } | 202 | } |
202 | var modalInstance = $uibModal.open( | 203 | var modalInstance = $uibModal.open( |
203 | { | 204 | { |
204 | ariaLabelledBy: 'Busqueda de Productos', | 205 | ariaLabelledBy: 'Busqueda de Productos', |
205 | templateUrl: 'modal-busqueda-productos.html', | 206 | templateUrl: 'modal-busqueda-productos.html', |
206 | controller: 'modalBusquedaProductosCtrl', | 207 | controller: 'modalBusquedaProductosCtrl', |
207 | resolve: { | 208 | resolve: { |
208 | idLista: function() { return $scope.idLista; }, | 209 | idLista: function() { return $scope.idLista; }, |
209 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION | 210 | cotizacion: $scope.notaPedido.cotizacion.COTIZACION |
210 | }, | 211 | }, |
211 | size: 'lg' | 212 | size: 'lg' |
212 | } | 213 | } |
213 | ); | 214 | ); |
214 | modalInstance.result.then( | 215 | modalInstance.result.then( |
215 | function(producto) { | 216 | function(producto) { |
216 | var newArt = | 217 | var newArt = |
217 | { | 218 | { |
218 | id: 0, | 219 | id: 0, |
219 | codigo: producto.codigo, | 220 | codigo: producto.codigo, |
220 | sector: producto.sector, | 221 | sector: producto.sector, |
221 | sectorCodigo: producto.sector + '-' + producto.codigo, | 222 | sectorCodigo: producto.sector + '-' + producto.codigo, |
222 | descripcion: producto.descripcion, | 223 | descripcion: producto.descripcion, |
223 | item: $scope.articulosTabla.length + 1, | 224 | item: $scope.articulosTabla.length + 1, |
224 | nombre: producto.descripcion, | 225 | nombre: producto.descripcion, |
225 | precio: parseFloat(producto.precio.toFixed(2)), | 226 | precio: parseFloat(producto.precio.toFixed(2)), |
226 | costoUnitario: producto.costo, | 227 | costoUnitario: producto.costo, |
227 | editCantidad: false, | 228 | editCantidad: false, |
228 | editPrecio: false | 229 | editPrecio: false |
229 | }; | 230 | }; |
230 | $scope.articuloACargar = newArt; | 231 | $scope.articuloACargar = newArt; |
231 | $scope.cargando = false; | 232 | $scope.cargando = false; |
232 | }, function() { | 233 | }, function() { |
233 | // funcion ejecutada cuando se cancela el modal | 234 | // funcion ejecutada cuando se cancela el modal |
234 | } | 235 | } |
235 | ); | 236 | ); |
236 | }; | 237 | }; |
237 | 238 | ||
238 | $scope.seleccionarVendedor = function() { | 239 | $scope.seleccionarVendedor = function() { |
239 | var modalInstance = $uibModal.open( | 240 | var modalInstance = $uibModal.open( |
240 | { | 241 | { |
241 | ariaLabelledBy: 'Busqueda de Vendedores', | 242 | ariaLabelledBy: 'Busqueda de Vendedores', |
242 | templateUrl: 'modal-vendedores.html', | 243 | templateUrl: 'modal-vendedores.html', |
243 | controller: 'modalVendedoresCtrl', | 244 | controller: 'modalVendedoresCtrl', |
244 | size: 'lg' | 245 | size: 'lg' |
245 | } | 246 | } |
246 | ); | 247 | ); |
247 | modalInstance.result.then( | 248 | modalInstance.result.then( |
248 | function(vendedor) { | 249 | function(vendedor) { |
249 | addCabecera('Vendedor:', vendedor.NomVen); | 250 | addCabecera('Vendedor:', vendedor.NomVen); |
250 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; | 251 | $scope.notaPedido.vendedor.codigo = vendedor.CodVen; |
251 | }, function() { | 252 | }, function() { |
252 | 253 | ||
253 | } | 254 | } |
254 | ); | 255 | ); |
255 | }; | 256 | }; |
256 | 257 | ||
257 | $scope.seleccionarProveedor = function() { | 258 | $scope.seleccionarProveedor = function() { |
258 | var modalInstance = $uibModal.open( | 259 | var modalInstance = $uibModal.open( |
259 | { | 260 | { |
260 | ariaLabelledBy: 'Busqueda de Proveedor', | 261 | ariaLabelledBy: 'Busqueda de Proveedor', |
261 | templateUrl: 'modal-proveedor.html', | 262 | templateUrl: 'modal-proveedor.html', |
262 | controller: 'focaModalProveedorCtrl', | 263 | controller: 'focaModalProveedorCtrl', |
263 | size: 'lg' | 264 | size: 'lg' |
264 | } | 265 | } |
265 | ); | 266 | ); |
266 | modalInstance.result.then( | 267 | modalInstance.result.then( |
267 | function(proveedor) { | 268 | function(proveedor) { |
268 | $scope.notaPedido.proveedor.codigo = proveedor.COD; | 269 | $scope.notaPedido.proveedor.codigo = proveedor.COD; |
269 | addCabecera('Proveedor:', proveedor.NOM); | 270 | addCabecera('Proveedor:', proveedor.NOM); |
270 | }, function() { | 271 | }, function() { |
271 | 272 | ||
272 | } | 273 | } |
273 | ); | 274 | ); |
274 | }; | 275 | }; |
275 | 276 | ||
276 | $scope.seleccionarCliente = function() { | 277 | $scope.seleccionarCliente = function() { |
277 | 278 | ||
278 | var modalInstance = $uibModal.open( | 279 | var modalInstance = $uibModal.open( |
279 | { | 280 | { |
280 | ariaLabelledBy: 'Busqueda de Cliente', | 281 | ariaLabelledBy: 'Busqueda de Cliente', |
281 | templateUrl: 'foca-busqueda-cliente-modal.html', | 282 | templateUrl: 'foca-busqueda-cliente-modal.html', |
282 | controller: 'focaBusquedaClienteModalController', | 283 | controller: 'focaBusquedaClienteModalController', |
283 | size: 'lg' | 284 | size: 'lg' |
284 | } | 285 | } |
285 | ); | 286 | ); |
286 | modalInstance.result.then( | 287 | modalInstance.result.then( |
287 | function(cliente) { | 288 | function(cliente) { |
288 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( | 289 | crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( |
289 | function(data) { | 290 | function(data) { |
290 | if(data.data.length === 0){ | 291 | if(data.data.length === 0){ |
291 | focaModalService | 292 | focaModalService |
292 | .alert('El cliente no tienen domicilios de entrega') | 293 | .alert('El cliente no tienen domicilios de entrega') |
293 | .then( | 294 | .then( |
294 | function() { | 295 | function() { |
295 | $scope.seleccionarCliente(); | 296 | $scope.seleccionarCliente(); |
296 | } | 297 | } |
297 | ); | 298 | ); |
298 | return; | 299 | return; |
299 | } | 300 | } |
300 | $scope.abrirModalDomicilios(cliente); | 301 | $scope.abrirModalDomicilios(cliente); |
301 | } | 302 | } |
302 | ); | 303 | ); |
303 | }, function() { | 304 | }, function() { |
304 | 305 | ||
305 | } | 306 | } |
306 | ); | 307 | ); |
307 | }; | 308 | }; |
308 | 309 | ||
309 | $scope.abrirModalDomicilios = function(cliente) { | 310 | $scope.abrirModalDomicilios = function(cliente) { |
310 | var modalInstanceDomicilio = $uibModal.open( | 311 | var modalInstanceDomicilio = $uibModal.open( |
311 | { | 312 | { |
312 | ariaLabelledBy: 'Busqueda de Domicilios', | 313 | ariaLabelledBy: 'Busqueda de Domicilios', |
313 | templateUrl: 'modal-domicilio.html', | 314 | templateUrl: 'modal-domicilio.html', |
314 | controller: 'focaModalDomicilioController', | 315 | controller: 'focaModalDomicilioController', |
315 | resolve: { idCliente: function() { return cliente.cod; }}, | 316 | resolve: { idCliente: function() { return cliente.cod; }}, |
316 | size: 'lg', | 317 | size: 'lg', |
317 | } | 318 | } |
318 | ); | 319 | ); |
319 | modalInstanceDomicilio.result.then( | 320 | modalInstanceDomicilio.result.then( |
320 | function(domicilio) { | 321 | function(domicilio) { |
321 | $scope.notaPedido.domicilio.id = domicilio.id; | 322 | $scope.notaPedido.domicilio.id = domicilio.id; |
322 | $scope.notaPedido.cliente.id = cliente.cod; | 323 | $scope.notaPedido.cliente.id = cliente.cod; |
323 | addCabecera('Cliente:', cliente.nom); | 324 | addCabecera('Cliente:', cliente.nom); |
324 | addCabecera('Domicilio:', domicilio.dom); | 325 | addCabecera('Domicilio:', domicilio.dom); |
325 | }, function() { | 326 | }, function() { |
326 | $scope.seleccionarCliente(); | 327 | $scope.seleccionarCliente(); |
327 | return; | 328 | return; |
328 | } | 329 | } |
329 | ); | 330 | ); |
330 | }; | 331 | }; |
331 | 332 | ||
332 | $scope.mostrarFichaCliente = function() { | 333 | $scope.mostrarFichaCliente = function() { |
333 | $uibModal.open( | 334 | $uibModal.open( |
334 | { | 335 | { |
335 | ariaLabelledBy: 'Datos del Cliente', | 336 | ariaLabelledBy: 'Datos del Cliente', |
336 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | 337 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', |
337 | controller: 'focaCrearNotaPedidoFichaClienteController', | 338 | controller: 'focaCrearNotaPedidoFichaClienteController', |
338 | size: 'lg' | 339 | size: 'lg' |
339 | } | 340 | } |
340 | ); | 341 | ); |
341 | }; | 342 | }; |
342 | 343 | ||
343 | $scope.getTotal = function() { | 344 | $scope.getTotal = function() { |
344 | var total = 0; | 345 | var total = 0; |
345 | var arrayTempArticulos = $scope.articulosTabla; | 346 | var arrayTempArticulos = $scope.articulosTabla; |
346 | for (var i = 0; i < arrayTempArticulos.length; i++) { | 347 | for (var i = 0; i < arrayTempArticulos.length; i++) { |
347 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | 348 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; |
348 | } | 349 | } |
349 | return parseFloat(total.toFixed(2)); | 350 | return parseFloat(total.toFixed(2)); |
350 | }; | 351 | }; |
351 | 352 | ||
352 | $scope.getSubTotal = function() { | 353 | $scope.getSubTotal = function() { |
353 | if($scope.articuloACargar) { | 354 | if($scope.articuloACargar) { |
354 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | 355 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; |
355 | } | 356 | } |
356 | }; | 357 | }; |
357 | 358 | ||
358 | $scope.abrirModalListaPrecio = function() { | 359 | $scope.abrirModalListaPrecio = function() { |
359 | var modalInstance = $uibModal.open( | 360 | var modalInstance = $uibModal.open( |
360 | { | 361 | { |
361 | ariaLabelledBy: 'Busqueda de Precio Condición', | 362 | ariaLabelledBy: 'Busqueda de Precio Condición', |
362 | templateUrl: 'modal-precio-condicion.html', | 363 | templateUrl: 'modal-precio-condicion.html', |
363 | controller: 'focaModalPrecioCondicionController', | 364 | controller: 'focaModalPrecioCondicionController', |
364 | size: 'lg' | 365 | size: 'lg' |
365 | } | 366 | } |
366 | ); | 367 | ); |
367 | modalInstance.result.then( | 368 | modalInstance.result.then( |
368 | function(precioCondicion) { | 369 | function(precioCondicion) { |
369 | var cabecera = ''; | 370 | var cabecera = ''; |
370 | var plazosConcat = ''; | 371 | var plazosConcat = ''; |
371 | if(!Array.isArray(precioCondicion)) { | 372 | if(!Array.isArray(precioCondicion)) { |
372 | $scope.plazosPagos = precioCondicion.plazoPago; | 373 | $scope.plazosPagos = precioCondicion.plazoPago; |
373 | $scope.idLista = precioCondicion.idListaPrecio; | 374 | $scope.idLista = precioCondicion.idListaPrecio; |
374 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | 375 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { |
375 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | 376 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; |
376 | } | 377 | } |
377 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | 378 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); |
378 | } else { //Cuando se ingresan los plazos manualmente | 379 | } else { //Cuando se ingresan los plazos manualmente |
379 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | 380 | $scope.idLista = -1; //-1, el modal productos busca todos los productos |
380 | $scope.plazosPagos = precioCondicion; | 381 | $scope.plazosPagos = precioCondicion; |
381 | for(var j = 0; j < precioCondicion.length; j++) { | 382 | for(var j = 0; j < precioCondicion.length; j++) { |
382 | plazosConcat += precioCondicion[j].dias + ' '; | 383 | plazosConcat += precioCondicion[j].dias + ' '; |
383 | } | 384 | } |
384 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | 385 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); |
385 | } | 386 | } |
386 | $scope.articulosTabla = []; | 387 | $scope.articulosTabla = []; |
387 | addCabecera('Precios y condiciones:', cabecera); | 388 | addCabecera('Precios y condiciones:', cabecera); |
388 | }, function() { | 389 | }, function() { |
389 | 390 | ||
390 | } | 391 | } |
391 | ); | 392 | ); |
392 | }; | 393 | }; |
393 | 394 | ||
394 | $scope.abrirModalFlete = function() { | 395 | $scope.abrirModalFlete = function() { |
395 | var modalInstance = $uibModal.open( | 396 | var modalInstance = $uibModal.open( |
396 | { | 397 | { |
397 | ariaLabelledBy: 'Busqueda de Flete', | 398 | ariaLabelledBy: 'Busqueda de Flete', |
398 | templateUrl: 'modal-flete.html', | 399 | templateUrl: 'modal-flete.html', |
399 | controller: 'focaModalFleteController', | 400 | controller: 'focaModalFleteController', |
400 | size: 'lg', | 401 | size: 'lg', |
401 | resolve: { | 402 | resolve: { |
402 | parametrosFlete: | 403 | parametrosFlete: |
403 | function() { | 404 | function() { |
404 | return { | 405 | return { |
405 | flete: $scope.notaPedido.flete ? '1' : | 406 | flete: $scope.notaPedido.flete ? '1' : |
406 | ($scope.notaPedido.fob ? 'FOB' : | 407 | ($scope.notaPedido.fob ? 'FOB' : |
407 | ($scope.notaPedido.flete === undefined ? null : '0')), | 408 | ($scope.notaPedido.flete === undefined ? null : '0')), |
408 | bomba: $scope.notaPedido.bomba ? '1' : | 409 | bomba: $scope.notaPedido.bomba ? '1' : |
409 | ($scope.notaPedido.bomba === undefined ? null : '0'), | 410 | ($scope.notaPedido.bomba === undefined ? null : '0'), |
410 | kilometros: $scope.notaPedido.kilometros | 411 | kilometros: $scope.notaPedido.kilometros |
411 | }; | 412 | }; |
412 | } | 413 | } |
413 | } | 414 | } |
414 | } | 415 | } |
415 | ); | 416 | ); |
416 | modalInstance.result.then( | 417 | modalInstance.result.then( |
417 | function(datos) { | 418 | function(datos) { |
418 | $scope.notaPedido.flete = datos.flete; | 419 | $scope.notaPedido.flete = datos.flete; |
419 | $scope.notaPedido.fob = datos.FOB; | 420 | $scope.notaPedido.fob = datos.FOB; |
420 | $scope.notaPedido.bomba = datos.bomba; | 421 | $scope.notaPedido.bomba = datos.bomba; |
421 | $scope.notaPedido.kilometros = datos.kilometros; | 422 | $scope.notaPedido.kilometros = datos.kilometros; |
422 | 423 | ||
423 | addCabecera('Flete:', datos.flete ? 'Si' : | 424 | addCabecera('Flete:', datos.flete ? 'Si' : |
424 | ($scope.notaPedido.fob ? 'FOB' : 'No')); | 425 | ($scope.notaPedido.fob ? 'FOB' : 'No')); |
425 | if(datos.flete) { | 426 | if(datos.flete) { |
426 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | 427 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); |
427 | addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); | 428 | addCabecera('Kilometros:', datos.kilometros ? 'Si' : 'No'); |
428 | } else { | 429 | } else { |
429 | removeCabecera('Bomba:'); | 430 | removeCabecera('Bomba:'); |
430 | removeCabecera('Kilometros:'); | 431 | removeCabecera('Kilometros:'); |
431 | $scope.notaPedido.fob = false; | 432 | $scope.notaPedido.fob = false; |
432 | $scope.notaPedido.bomba = false; | 433 | $scope.notaPedido.bomba = false; |
433 | $scope.notaPedido.kilometros = null; | 434 | $scope.notaPedido.kilometros = null; |
434 | } | 435 | } |
435 | }, function() { | 436 | }, function() { |
436 | 437 | ||
437 | } | 438 | } |
438 | ); | 439 | ); |
439 | }; | 440 | }; |
440 | 441 | ||
441 | $scope.abrirModalMoneda = function() { | 442 | $scope.abrirModalMoneda = function() { |
442 | var modalInstance = $uibModal.open( | 443 | var modalInstance = $uibModal.open( |
443 | { | 444 | { |
444 | ariaLabelledBy: 'Busqueda de Moneda', | 445 | ariaLabelledBy: 'Busqueda de Moneda', |
445 | templateUrl: 'modal-moneda.html', | 446 | templateUrl: 'modal-moneda.html', |
446 | controller: 'focaModalMonedaController', | 447 | controller: 'focaModalMonedaController', |
447 | size: 'lg' | 448 | size: 'lg' |
448 | } | 449 | } |
449 | ); | 450 | ); |
450 | modalInstance.result.then( | 451 | modalInstance.result.then( |
451 | function(moneda) { | 452 | function(moneda) { |
452 | $scope.abrirModalCotizacion(moneda); | 453 | $scope.abrirModalCotizacion(moneda); |
453 | }, function() { | 454 | }, function() { |
454 | 455 | ||
455 | } | 456 | } |
456 | ); | 457 | ); |
457 | }; | 458 | }; |
458 | 459 | ||
459 | $scope.abrirModalCotizacion = function(moneda) { | 460 | $scope.abrirModalCotizacion = function(moneda) { |
460 | var modalInstance = $uibModal.open( | 461 | var modalInstance = $uibModal.open( |
461 | { | 462 | { |
462 | ariaLabelledBy: 'Busqueda de Cotización', | 463 | ariaLabelledBy: 'Busqueda de Cotización', |
463 | templateUrl: 'modal-cotizacion.html', | 464 | templateUrl: 'modal-cotizacion.html', |
464 | controller: 'focaModalCotizacionController', | 465 | controller: 'focaModalCotizacionController', |
465 | size: 'lg', | 466 | size: 'lg', |
466 | resolve: {idMoneda: function() {return moneda.ID;}} | 467 | resolve: {idMoneda: function() {return moneda.ID;}} |
467 | } | 468 | } |
468 | ); | 469 | ); |
469 | modalInstance.result.then( | 470 | modalInstance.result.then( |
470 | function(cotizacion) { | 471 | function(cotizacion) { |
471 | var articulosTablaTemp = $scope.articulosTabla; | 472 | var articulosTablaTemp = $scope.articulosTabla; |
472 | for(var i = 0; i < articulosTablaTemp.length; i++) { | 473 | for(var i = 0; i < articulosTablaTemp.length; i++) { |
473 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | 474 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * |
474 | $scope.notaPedido.cotizacion.COTIZACION; | 475 | $scope.notaPedido.cotizacion.COTIZACION; |
475 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | 476 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / |
476 | cotizacion.COTIZACION; | 477 | cotizacion.COTIZACION; |
477 | } | 478 | } |
478 | $scope.articulosTabla = articulosTablaTemp; | 479 | $scope.articulosTabla = articulosTablaTemp; |
479 | $scope.notaPedido.moneda = { | 480 | $scope.notaPedido.moneda = { |
480 | id: moneda.ID, | 481 | id: moneda.ID, |
481 | detalle: moneda.DETALLE, | 482 | detalle: moneda.DETALLE, |
482 | simbolo: moneda.SIMBOLO | 483 | simbolo: moneda.SIMBOLO |
483 | }; | 484 | }; |
484 | $scope.notaPedido.cotizacion = { | 485 | $scope.notaPedido.cotizacion = { |
485 | ID: cotizacion.ID, | 486 | ID: cotizacion.ID, |
486 | COTIZACION: cotizacion.COTIZACION, | 487 | COTIZACION: cotizacion.COTIZACION, |
487 | FECHA: cotizacion.fecha | 488 | FECHA: cotizacion.fecha |
488 | }; | 489 | }; |
489 | addCabecera('Moneda:', moneda.DETALLE); | 490 | addCabecera('Moneda:', moneda.DETALLE); |
490 | addCabecera( | 491 | addCabecera( |
491 | 'Fecha cotizacion:', | 492 | 'Fecha cotizacion:', |
492 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | 493 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') |
493 | ); | 494 | ); |
494 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | 495 | addCabecera('Cotizacion:', cotizacion.COTIZACION); |
495 | }, function() { | 496 | }, function() { |
496 | 497 | ||
497 | } | 498 | } |
498 | ); | 499 | ); |
499 | }; | 500 | }; |
500 | 501 | ||
501 | $scope.agregarATabla = function(key) { | 502 | $scope.agregarATabla = function(key) { |
502 | if(key === 13) { | 503 | if(key === 13) { |
503 | if($scope.articuloACargar.cantidad === undefined || | 504 | if($scope.articuloACargar.cantidad === undefined || |
504 | $scope.articuloACargar.cantidad === 0 || | 505 | $scope.articuloACargar.cantidad === 0 || |
505 | $scope.articuloACargar.cantidad === null ){ | 506 | $scope.articuloACargar.cantidad === null ){ |
506 | focaModalService.alert('El valor debe ser al menos 1'); | 507 | focaModalService.alert('El valor debe ser al menos 1'); |
507 | return; | 508 | return; |
508 | } | 509 | } |
509 | delete $scope.articuloACargar.sectorCodigo; | 510 | delete $scope.articuloACargar.sectorCodigo; |
510 | $scope.articulosTabla.push($scope.articuloACargar); | 511 | $scope.articulosTabla.push($scope.articuloACargar); |
511 | $scope.cargando = true; | 512 | $scope.cargando = true; |
512 | } | 513 | } |
513 | }; | 514 | }; |
514 | 515 | ||
515 | $scope.quitarArticulo = function(key) { | 516 | $scope.quitarArticulo = function(key) { |
516 | $scope.articulosTabla.splice(key, 1); | 517 | $scope.articulosTabla.splice(key, 1); |
517 | }; | 518 | }; |
518 | 519 | ||
519 | $scope.editarArticulo = function(key, articulo) { | 520 | $scope.editarArticulo = function(key, articulo) { |
520 | if(key === 13) { | 521 | if(key === 13) { |
521 | if(articulo.cantidad === null || articulo.cantidad === 0 || | 522 | if(articulo.cantidad === null || articulo.cantidad === 0 || |
522 | articulo.cantidad === undefined){ | 523 | articulo.cantidad === undefined){ |
523 | focaModalService.alert('El valor debe ser al menos 1'); | 524 | focaModalService.alert('El valor debe ser al menos 1'); |
524 | return; | 525 | return; |
525 | } | 526 | } |
526 | articulo.editCantidad = false; | 527 | articulo.editCantidad = false; |
527 | articulo.editPrecio = false; | 528 | articulo.editPrecio = false; |
528 | } | 529 | } |
529 | }; | 530 | }; |
530 | 531 | ||
531 | $scope.cambioEdit = function(articulo, propiedad) { | 532 | $scope.cambioEdit = function(articulo, propiedad) { |
532 | if(propiedad === 'cantidad') { | 533 | if(propiedad === 'cantidad') { |
533 | articulo.editCantidad = true; | 534 | articulo.editCantidad = true; |
534 | } else if(propiedad === 'precio') { | 535 | } else if(propiedad === 'precio') { |
535 | articulo.editPrecio = true; | 536 | articulo.editPrecio = true; |
536 | } | 537 | } |
537 | }; | 538 | }; |
538 | 539 | ||
539 | $scope.limpiarFlete = function() { | 540 | $scope.limpiarFlete = function() { |
540 | $scope.notaPedido.fleteNombre = ''; | 541 | $scope.notaPedido.fleteNombre = ''; |
541 | $scope.notaPedido.chofer = ''; | 542 | $scope.notaPedido.chofer = ''; |
542 | $scope.notaPedido.vehiculo = ''; | 543 | $scope.notaPedido.vehiculo = ''; |
543 | $scope.notaPedido.kilometros = ''; | 544 | $scope.notaPedido.kilometros = ''; |
544 | $scope.notaPedido.costoUnitarioKmFlete = ''; | 545 | $scope.notaPedido.costoUnitarioKmFlete = ''; |
545 | $scope.choferes = ''; | 546 | $scope.choferes = ''; |
546 | $scope.vehiculos = ''; | 547 | $scope.vehiculos = ''; |
547 | }; | 548 | }; |
548 | 549 | ||
549 | $scope.limpiarPantalla = function() { | 550 | $scope.limpiarPantalla = function() { |
550 | $scope.limpiarFlete(); | 551 | $scope.limpiarFlete(); |
551 | $scope.notaPedido.flete = '0'; | 552 | $scope.notaPedido.flete = '0'; |
552 | $scope.notaPedido.bomba = '0'; | 553 | $scope.notaPedido.bomba = '0'; |
553 | $scope.notaPedido.precioCondicion = ''; | 554 | $scope.notaPedido.precioCondicion = ''; |
554 | $scope.articulosTabla = []; | 555 | $scope.articulosTabla = []; |
555 | $scope.notaPedido.vendedor.nombre = ''; | 556 | $scope.notaPedido.vendedor.nombre = ''; |
556 | $scope.notaPedido.cliente = {nombre: ''}; | 557 | $scope.notaPedido.cliente = {nombre: ''}; |
557 | $scope.notaPedido.domicilio = {dom: ''}; | 558 | $scope.notaPedido.domicilio = {dom: ''}; |
558 | $scope.domiciliosCliente = []; | 559 | $scope.domiciliosCliente = []; |
559 | }; | 560 | }; |
560 | 561 | ||
561 | $scope.resetFilter = function() { | 562 | $scope.resetFilter = function() { |
562 | $scope.articuloACargar = {}; | 563 | $scope.articuloACargar = {}; |
563 | $scope.cargando = true; | 564 | $scope.cargando = true; |
564 | }; | 565 | }; |
565 | 566 | ||
566 | $scope.selectFocus = function($event) { | 567 | $scope.selectFocus = function($event) { |
567 | $event.target.select(); | 568 | $event.target.select(); |
568 | }; | 569 | }; |
569 | 570 | ||
570 | $scope.salir = function() { | 571 | $scope.salir = function() { |
571 | $location.path('/'); | 572 | $location.path('/'); |
572 | }; | 573 | }; |
573 | 574 | ||
574 | function addCabecera(label, valor) { | 575 | function addCabecera(label, valor) { |
575 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 576 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
576 | if(propiedad.length === 1) { | 577 | if(propiedad.length === 1) { |
577 | propiedad[0].valor = valor; | 578 | propiedad[0].valor = valor; |
578 | } else { | 579 | } else { |
579 | $scope.cabecera.push({label: label, valor: valor}); | 580 | $scope.cabecera.push({label: label, valor: valor}); |
580 | } | 581 | } |
581 | } | 582 | } |
582 | 583 | ||
583 | function removeCabecera(label) { | 584 | function removeCabecera(label) { |
584 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | 585 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); |
585 | if(propiedad.length === 1){ | 586 | if(propiedad.length === 1){ |
586 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | 587 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); |
587 | } | 588 | } |
588 | } | 589 | } |
589 | } | 590 | } |
590 | ] | 591 | ] |
591 | ) | 592 | ) |
592 | .controller('notaPedidoListaCtrl', [ | 593 | .controller('notaPedidoListaCtrl', [ |
593 | '$scope', | 594 | '$scope', |
594 | 'crearNotaPedidoService', | 595 | 'crearNotaPedidoService', |
595 | '$location', | 596 | '$location', |
596 | function($scope, crearNotaPedidoService, $location) { | 597 | function($scope, crearNotaPedidoService, $location) { |
597 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 598 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
598 | $scope.notaPedidos = datos.data; | 599 | $scope.notaPedidos = datos.data; |
599 | }); | 600 | }); |
600 | $scope.editar = function(notaPedido) { | 601 | $scope.editar = function(notaPedido) { |
601 | crearNotaPedidoService.setNotaPedido(notaPedido); | 602 | crearNotaPedidoService.setNotaPedido(notaPedido); |
602 | $location.path('/venta-nota-pedido/abm/'); | 603 | $location.path('/venta-nota-pedido/abm/'); |
603 | }; | 604 | }; |
604 | $scope.crearPedido = function() { | 605 | $scope.crearPedido = function() { |
605 | crearNotaPedidoService.clearNotaPedido(); | 606 | crearNotaPedidoService.clearNotaPedido(); |
606 | $location.path('/venta-nota-pedido/abm/'); | 607 | $location.path('/venta-nota-pedido/abm/'); |
607 | }; | 608 | }; |
608 | } | 609 | } |
609 | ]) | 610 | ]) |
610 | .controller('focaCrearNotaPedidoFichaClienteController', [ | 611 | .controller('focaCrearNotaPedidoFichaClienteController', [ |
611 | '$scope', | 612 | '$scope', |
612 | 'crearNotaPedidoService', | 613 | 'crearNotaPedidoService', |
613 | '$location', | 614 | '$location', |
614 | function($scope, crearNotaPedidoService, $location) { | 615 | function($scope, crearNotaPedidoService, $location) { |
615 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { | 616 | crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { |
616 | $scope.notaPedidos = datos.data; | 617 | $scope.notaPedidos = datos.data; |
617 | }); | 618 | }); |
618 | $scope.editar = function(notaPedido) { | 619 | $scope.editar = function(notaPedido) { |
619 | crearNotaPedidoService.setNotaPedido(notaPedido); | 620 | crearNotaPedidoService.setNotaPedido(notaPedido); |
620 | $location.path('/venta-nota-pedido/abm/'); | 621 | $location.path('/venta-nota-pedido/abm/'); |
621 | }; | 622 | }; |
622 | $scope.crearPedido = function() { | 623 | $scope.crearPedido = function() { |
623 | crearNotaPedidoService.clearNotaPedido(); | 624 | crearNotaPedidoService.clearNotaPedido(); |
624 | $location.path('/venta-nota-pedido/abm/'); | 625 | $location.path('/venta-nota-pedido/abm/'); |
625 | }; | 626 | }; |
626 | } | 627 | } |
627 | ]); | 628 | ]); |
628 | 629 |