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