Commit f05145ae33278d69880b3cfabc3f9628dac40f39

Authored by Eric Fernandez
1 parent 60727f1f8d
Exists in master

conflictos de merge

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 '"cordovaGeolocationModule"', ''),
50 gulp.dest(paths.dist) 51 gulp.dest(paths.dist)
51 ] 52 ]
52 ); 53 );
53 }); 54 });
54 55
55 gulp.task('clean', function(){ 56 gulp.task('clean', function(){
56 return gulp.src(['tmp', 'dist'], {read: false}) 57 return gulp.src(['tmp', 'dist'], {read: false})
57 .pipe(clean()); 58 .pipe(clean());
58 }); 59 });
59 60
60 gulp.task('pre-commit', function() { 61 gulp.task('pre-commit', function() {
61 return pump( 62 return pump(
62 [ 63 [
63 gulp.src(paths.srcJS), 64 gulp.src(paths.srcJS),
64 jshint('.jshintrc'), 65 jshint('.jshintrc'),
65 jshint.reporter('default'), 66 jshint.reporter('default'),
66 jshint.reporter('fail') 67 jshint.reporter('fail')
67 ] 68 ]
68 ); 69 );
69 70
70 gulp.start('uglify'); 71 gulp.start('uglify');
71 }); 72 });
72 73
73 gulp.task('webserver', function() { 74 gulp.task('webserver', function() {
74 pump [ 75 pump [
75 connect.server({port: 3300, host: '0.0.0.0'}) 76 connect.server({port: 3300, host: '0.0.0.0'})
76 ] 77 ]
77 }); 78 });
78 79
79 gulp.task('clean-post-install', function() { 80 gulp.task('clean-post-install', function() {
80 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', 81 return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
81 'index.html'], {read: false}) 82 'index.html'], {read: false})
82 .pipe(clean()); 83 .pipe(clean());
83 }); 84 });
84 85
85 gulp.task('default', ['webserver']); 86 gulp.task('default', ['webserver']);
86 87
87 gulp.task('watch', function() { 88 gulp.task('watch', function() {
88 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); 89 gulp.watch([paths.srcJS, paths.srcViews], ['uglify']);
89 }); 90 });
90 91
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 <script src="vendor/cordovaGeolocationModule.min.js"></script>
20 21
21 <script src="node_modules/foca-directivas/dist/foca-directivas.min.js"></script> 22 <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> 23 <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> 24 <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> 25 <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> 26 <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> 27 <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> 28 <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> 29 <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> 30 <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> 31 <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> 32 <script src="node_modules/foca-modal-cotizacion/dist/foca-modal-cotizacion.min.js"></script>
33 <script src="node_modules/foca-seguimiento/dist/foca-seguimiento.min.js"></script>
32 34
33 <script src="src/js/app.js"></script> 35 <script src="src/js/app.js"></script>
34 <script src="src/js/controller.js"></script> 36 <script src="src/js/controller.js"></script>
35 <script src="src/js/service.js"></script> 37 <script src="src/js/service.js"></script>
38 <script src="src/js/businessService.js"></script>
36 <script src="src/js/route.js"></script> 39 <script src="src/js/route.js"></script>
37 40
38 <script src="src/etc/develop.js"></script> 41 <script src="src/etc/develop.js"></script>
39 </head> 42 </head>
40 <body> 43 <body>
41 <div ng-view class="container-fluid"></div> 44 <div ng-view class="container-fluid"></div>
42 </body> 45 </body>
43 </html> 46 </html>
44 47
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
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',
17 'cordovaGeolocationModule'
16 ]); 18 ]);
src/js/businessService.js
File was created 1 angular.module('focaCrearNotaPedido')
2 .service('notaPedidoBusinessService', [
3 'crearNotaPedidoService',
4 function(crearNotaPedidoService) {
5 return {
6 addArticulos: function(articulosNotaPedido, idNotaPedido, cotizacion) {
7 for(var i = 0; i < articulosNotaPedido.length; i++) {
8 delete articulosNotaPedido[i].editCantidad;
9 delete articulosNotaPedido[i].editPrecio;
10 articulosNotaPedido[i].idNotaPedido = idNotaPedido;
11 articulosNotaPedido[i].precio = articulosNotaPedido[i].precio * cotizacion;
12 crearNotaPedidoService.crearArticulosParaNotaPedido(articulosNotaPedido[i]);
13 }
14 }
15 };
16 }]);
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', 'notaPedidoBusinessService',
5 function( 5 function(
6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService 6 $scope, $uibModal, $location, $filter, crearNotaPedidoService, focaModalService,
7 focaSeguimientoService, notaPedidoBusinessService
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 crearNotaPedidoService.addArticulos($scope.articulosTabla, 159 notaPedidoBusinessService.addArticulos($scope.articulosTabla,
159 data.data.id, $scope.notaPedido.cotizacion.COTIZACION); 160 data.data.id, $scope.notaPedido.cotizacion.COTIZACION);
160 161 focaSeguimientoService.guardarPosicion('crear nota pedido', '');
161 var plazos = $scope.plazosPagos; 162 var plazos = $scope.plazosPagos;
162 for(var j = 0; j < plazos.length; j++) { 163 for(var j = 0; j < plazos.length; j++) {
163 var json = { 164 var json = {
164 idPedido: data.data.id, 165 idPedido: data.data.id,
165 dias: plazos[j].dias 166 dias: plazos[j].dias
166 }; 167 };
167 crearNotaPedidoService.crearPlazosParaNotaPedido(json); 168 crearNotaPedidoService.crearPlazosParaNotaPedido(json);
168 } 169 }
169 focaModalService.alert('Nota pedido creada'); 170 focaModalService.alert('Nota pedido creada');
170 $scope.cabecera = []; 171 $scope.cabecera = [];
171 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle); 172 addCabecera('Moneda:', $scope.notaPedido.moneda.detalle);
172 addCabecera( 173 addCabecera(
173 'Fecha cotizacion:', 174 'Fecha cotizacion:',
174 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy') 175 $filter('date')($scope.notaPedido.cotizacion.FECHA, 'dd/MM/yyyy')
175 ); 176 );
176 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION); 177 addCabecera('Cotizacion:', $scope.notaPedido.cotizacion.COTIZACION);
177 $scope.notaPedido.vendedor = {}; 178 $scope.notaPedido.vendedor = {};
178 $scope.notaPedido.cliente = {}; 179 $scope.notaPedido.cliente = {};
179 $scope.notaPedido.proveedor = {}; 180 $scope.notaPedido.proveedor = {};
180 $scope.notaPedido.domicilio = {}; 181 $scope.notaPedido.domicilio = {};
181 $scope.notaPedido.flete = null; 182 $scope.notaPedido.flete = null;
182 $scope.notaPedido.fob = null; 183 $scope.notaPedido.fob = null;
183 $scope.notaPedido.bomba = null; 184 $scope.notaPedido.bomba = null;
184 $scope.notaPedido.kilometros = null; 185 $scope.notaPedido.kilometros = null;
185 $scope.articulosTabla = []; 186 $scope.articulosTabla = [];
186 } 187 }
187 ); 188 );
188 }; 189 };
189 190
190 $scope.seleccionarArticulo = function() { 191 $scope.seleccionarArticulo = function() {
191 if ($scope.idLista === undefined) { 192 if ($scope.idLista === undefined) {
192 focaModalService.alert( 193 focaModalService.alert(
193 'Primero seleccione una lista de precio y condicion'); 194 'Primero seleccione una lista de precio y condicion');
194 return; 195 return;
195 } 196 }
196 var modalInstance = $uibModal.open( 197 var modalInstance = $uibModal.open(
197 { 198 {
198 ariaLabelledBy: 'Busqueda de Productos', 199 ariaLabelledBy: 'Busqueda de Productos',
199 templateUrl: 'modal-busqueda-productos.html', 200 templateUrl: 'modal-busqueda-productos.html',
200 controller: 'modalBusquedaProductosCtrl', 201 controller: 'modalBusquedaProductosCtrl',
201 resolve: { 202 resolve: {
202 parametroProducto: { 203 parametroProducto: {
203 idLista: $scope.idLista, 204 idLista: $scope.idLista,
204 cotizacion: $scope.notaPedido.cotizacion.COTIZACION, 205 cotizacion: $scope.notaPedido.cotizacion.COTIZACION,
205 simbolo: $scope.notaPedido.moneda.simbolo 206 simbolo: $scope.notaPedido.moneda.simbolo
206 } 207 }
207 }, 208 },
208 size: 'lg' 209 size: 'lg'
209 } 210 }
210 ); 211 );
211 modalInstance.result.then( 212 modalInstance.result.then(
212 function(producto) { 213 function(producto) {
213 var newArt = 214 var newArt =
214 { 215 {
215 id: 0, 216 id: 0,
216 codigo: producto.codigo, 217 codigo: producto.codigo,
217 sector: producto.sector, 218 sector: producto.sector,
218 sectorCodigo: producto.sector + '-' + producto.codigo, 219 sectorCodigo: producto.sector + '-' + producto.codigo,
219 descripcion: producto.descripcion, 220 descripcion: producto.descripcion,
220 item: $scope.articulosTabla.length + 1, 221 item: $scope.articulosTabla.length + 1,
221 nombre: producto.descripcion, 222 nombre: producto.descripcion,
222 precio: parseFloat(producto.precio.toFixed(4)), 223 precio: parseFloat(producto.precio.toFixed(4)),
223 costoUnitario: producto.costo, 224 costoUnitario: producto.costo,
224 editCantidad: false, 225 editCantidad: false,
225 editPrecio: false 226 editPrecio: false
226 }; 227 };
227 $scope.articuloACargar = newArt; 228 $scope.articuloACargar = newArt;
228 $scope.cargando = false; 229 $scope.cargando = false;
229 }, function() { 230 }, function() {
230 // funcion ejecutada cuando se cancela el modal 231 // funcion ejecutada cuando se cancela el modal
231 } 232 }
232 ); 233 );
233 }; 234 };
234 235
235 $scope.seleccionarVendedor = function() { 236 $scope.seleccionarVendedor = function() {
236 var modalInstance = $uibModal.open( 237 var modalInstance = $uibModal.open(
237 { 238 {
238 ariaLabelledBy: 'Busqueda de Vendedores', 239 ariaLabelledBy: 'Busqueda de Vendedores',
239 templateUrl: 'modal-vendedores.html', 240 templateUrl: 'modal-vendedores.html',
240 controller: 'modalVendedoresCtrl', 241 controller: 'modalVendedoresCtrl',
241 size: 'lg' 242 size: 'lg'
242 } 243 }
243 ); 244 );
244 modalInstance.result.then( 245 modalInstance.result.then(
245 function(vendedor) { 246 function(vendedor) {
246 addCabecera('Vendedor:', vendedor.NomVen); 247 addCabecera('Vendedor:', vendedor.NomVen);
247 $scope.notaPedido.vendedor.codigo = vendedor.CodVen; 248 $scope.notaPedido.vendedor.codigo = vendedor.CodVen;
248 }, function() { 249 }, function() {
249 250
250 } 251 }
251 ); 252 );
252 }; 253 };
253 254
254 $scope.seleccionarProveedor = function() { 255 $scope.seleccionarProveedor = function() {
255 var modalInstance = $uibModal.open( 256 var modalInstance = $uibModal.open(
256 { 257 {
257 ariaLabelledBy: 'Busqueda de Proveedor', 258 ariaLabelledBy: 'Busqueda de Proveedor',
258 templateUrl: 'modal-proveedor.html', 259 templateUrl: 'modal-proveedor.html',
259 controller: 'focaModalProveedorCtrl', 260 controller: 'focaModalProveedorCtrl',
260 size: 'lg' 261 size: 'lg'
261 } 262 }
262 ); 263 );
263 modalInstance.result.then( 264 modalInstance.result.then(
264 function(proveedor) { 265 function(proveedor) {
265 $scope.notaPedido.proveedor.codigo = proveedor.COD; 266 $scope.notaPedido.proveedor.codigo = proveedor.COD;
266 addCabecera('Proveedor:', proveedor.NOM); 267 addCabecera('Proveedor:', proveedor.NOM);
267 }, function() { 268 }, function() {
268 269
269 } 270 }
270 ); 271 );
271 }; 272 };
272 273
273 $scope.seleccionarCliente = function() { 274 $scope.seleccionarCliente = function() {
274 275
275 var modalInstance = $uibModal.open( 276 var modalInstance = $uibModal.open(
276 { 277 {
277 ariaLabelledBy: 'Busqueda de Cliente', 278 ariaLabelledBy: 'Busqueda de Cliente',
278 templateUrl: 'foca-busqueda-cliente-modal.html', 279 templateUrl: 'foca-busqueda-cliente-modal.html',
279 controller: 'focaBusquedaClienteModalController', 280 controller: 'focaBusquedaClienteModalController',
280 size: 'lg' 281 size: 'lg'
281 } 282 }
282 ); 283 );
283 modalInstance.result.then( 284 modalInstance.result.then(
284 function(cliente) { 285 function(cliente) {
285 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then( 286 crearNotaPedidoService.getDomiciliosByIdCliente(cliente.cod).then(
286 function(data) { 287 function(data) {
287 if(data.data.length === 0){ 288 if(data.data.length === 0){
288 focaModalService 289 focaModalService
289 .alert('El cliente no tienen domicilios de entrega') 290 .alert('El cliente no tienen domicilios de entrega')
290 .then( 291 .then(
291 function() { 292 function() {
292 $scope.seleccionarCliente(); 293 $scope.seleccionarCliente();
293 } 294 }
294 ); 295 );
295 return; 296 return;
296 } 297 }
297 $scope.abrirModalDomicilios(cliente); 298 $scope.abrirModalDomicilios(cliente);
298 } 299 }
299 ); 300 );
300 }, function() { 301 }, function() {
301 302
302 } 303 }
303 ); 304 );
304 }; 305 };
305 306
306 $scope.abrirModalDomicilios = function(cliente) { 307 $scope.abrirModalDomicilios = function(cliente) {
307 var modalInstanceDomicilio = $uibModal.open( 308 var modalInstanceDomicilio = $uibModal.open(
308 { 309 {
309 ariaLabelledBy: 'Busqueda de Domicilios', 310 ariaLabelledBy: 'Busqueda de Domicilios',
310 templateUrl: 'modal-domicilio.html', 311 templateUrl: 'modal-domicilio.html',
311 controller: 'focaModalDomicilioController', 312 controller: 'focaModalDomicilioController',
312 resolve: { idCliente: function() { return cliente.cod; }}, 313 resolve: { idCliente: function() { return cliente.cod; }},
313 size: 'lg', 314 size: 'lg',
314 } 315 }
315 ); 316 );
316 modalInstanceDomicilio.result.then( 317 modalInstanceDomicilio.result.then(
317 function(domicilio) { 318 function(domicilio) {
318 $scope.notaPedido.domicilio.id = domicilio.id; 319 $scope.notaPedido.domicilio.id = domicilio.id;
319 $scope.notaPedido.cliente.id = cliente.cod; 320 $scope.notaPedido.cliente.id = cliente.cod;
320 addCabecera('Cliente:', cliente.nom); 321 addCabecera('Cliente:', cliente.nom);
321 addCabecera('Domicilio:', domicilio.dom); 322 addCabecera('Domicilio:', domicilio.dom);
322 }, function() { 323 }, function() {
323 $scope.seleccionarCliente(); 324 $scope.seleccionarCliente();
324 return; 325 return;
325 } 326 }
326 ); 327 );
327 }; 328 };
328 329
329 $scope.mostrarFichaCliente = function() { 330 $scope.mostrarFichaCliente = function() {
330 $uibModal.open( 331 $uibModal.open(
331 { 332 {
332 ariaLabelledBy: 'Datos del Cliente', 333 ariaLabelledBy: 'Datos del Cliente',
333 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', 334 templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html',
334 controller: 'focaCrearNotaPedidoFichaClienteController', 335 controller: 'focaCrearNotaPedidoFichaClienteController',
335 size: 'lg' 336 size: 'lg'
336 } 337 }
337 ); 338 );
338 }; 339 };
339 340
340 $scope.getTotal = function() { 341 $scope.getTotal = function() {
341 var total = 0; 342 var total = 0;
342 var arrayTempArticulos = $scope.articulosTabla; 343 var arrayTempArticulos = $scope.articulosTabla;
343 for (var i = 0; i < arrayTempArticulos.length; i++) { 344 for (var i = 0; i < arrayTempArticulos.length; i++) {
344 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; 345 total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad;
345 } 346 }
346 return parseFloat(total.toFixed(2)); 347 return parseFloat(total.toFixed(2));
347 }; 348 };
348 349
349 $scope.getSubTotal = function() { 350 $scope.getSubTotal = function() {
350 if($scope.articuloACargar) { 351 if($scope.articuloACargar) {
351 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; 352 return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad;
352 } 353 }
353 }; 354 };
354 355
355 $scope.abrirModalListaPrecio = function() { 356 $scope.abrirModalListaPrecio = function() {
356 var modalInstance = $uibModal.open( 357 var modalInstance = $uibModal.open(
357 { 358 {
358 ariaLabelledBy: 'Busqueda de Precio Condición', 359 ariaLabelledBy: 'Busqueda de Precio Condición',
359 templateUrl: 'modal-precio-condicion.html', 360 templateUrl: 'modal-precio-condicion.html',
360 controller: 'focaModalPrecioCondicionController', 361 controller: 'focaModalPrecioCondicionController',
361 size: 'lg' 362 size: 'lg'
362 } 363 }
363 ); 364 );
364 modalInstance.result.then( 365 modalInstance.result.then(
365 function(precioCondicion) { 366 function(precioCondicion) {
366 var cabecera = ''; 367 var cabecera = '';
367 var plazosConcat = ''; 368 var plazosConcat = '';
368 if(!Array.isArray(precioCondicion)) { 369 if(!Array.isArray(precioCondicion)) {
369 $scope.plazosPagos = precioCondicion.plazoPago; 370 $scope.plazosPagos = precioCondicion.plazoPago;
370 $scope.idLista = precioCondicion.idListaPrecio; 371 $scope.idLista = precioCondicion.idListaPrecio;
371 for(var i = 0; i < precioCondicion.plazoPago.length; i++) { 372 for(var i = 0; i < precioCondicion.plazoPago.length; i++) {
372 plazosConcat += precioCondicion.plazoPago[i].dias + ' '; 373 plazosConcat += precioCondicion.plazoPago[i].dias + ' ';
373 } 374 }
374 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); 375 cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim();
375 } else { //Cuando se ingresan los plazos manualmente 376 } else { //Cuando se ingresan los plazos manualmente
376 $scope.idLista = -1; //-1, el modal productos busca todos los productos 377 $scope.idLista = -1; //-1, el modal productos busca todos los productos
377 $scope.plazosPagos = precioCondicion; 378 $scope.plazosPagos = precioCondicion;
378 for(var j = 0; j < precioCondicion.length; j++) { 379 for(var j = 0; j < precioCondicion.length; j++) {
379 plazosConcat += precioCondicion[j].dias + ' '; 380 plazosConcat += precioCondicion[j].dias + ' ';
380 } 381 }
381 cabecera = 'Ingreso manual ' + plazosConcat.trim(); 382 cabecera = 'Ingreso manual ' + plazosConcat.trim();
382 } 383 }
383 $scope.articulosTabla = []; 384 $scope.articulosTabla = [];
384 addCabecera('Precios y condiciones:', cabecera); 385 addCabecera('Precios y condiciones:', cabecera);
385 }, function() { 386 }, function() {
386 387
387 } 388 }
388 ); 389 );
389 }; 390 };
390 391
391 $scope.abrirModalFlete = function() { 392 $scope.abrirModalFlete = function() {
392 var modalInstance = $uibModal.open( 393 var modalInstance = $uibModal.open(
393 { 394 {
394 ariaLabelledBy: 'Busqueda de Flete', 395 ariaLabelledBy: 'Busqueda de Flete',
395 templateUrl: 'modal-flete.html', 396 templateUrl: 'modal-flete.html',
396 controller: 'focaModalFleteController', 397 controller: 'focaModalFleteController',
397 size: 'lg', 398 size: 'lg',
398 resolve: { 399 resolve: {
399 parametrosFlete: 400 parametrosFlete:
400 function() { 401 function() {
401 return { 402 return {
402 flete: $scope.notaPedido.flete ? '1' : 403 flete: $scope.notaPedido.flete ? '1' :
403 ($scope.notaPedido.fob ? 'FOB' : 404 ($scope.notaPedido.fob ? 'FOB' :
404 ($scope.notaPedido.flete === undefined ? null : '0')), 405 ($scope.notaPedido.flete === undefined ? null : '0')),
405 bomba: $scope.notaPedido.bomba ? '1' : 406 bomba: $scope.notaPedido.bomba ? '1' :
406 ($scope.notaPedido.bomba === undefined ? null : '0'), 407 ($scope.notaPedido.bomba === undefined ? null : '0'),
407 kilometros: $scope.notaPedido.kilometros 408 kilometros: $scope.notaPedido.kilometros
408 }; 409 };
409 } 410 }
410 } 411 }
411 } 412 }
412 ); 413 );
413 modalInstance.result.then( 414 modalInstance.result.then(
414 function(datos) { 415 function(datos) {
415 $scope.notaPedido.flete = datos.flete; 416 $scope.notaPedido.flete = datos.flete;
416 $scope.notaPedido.fob = datos.FOB; 417 $scope.notaPedido.fob = datos.FOB;
417 $scope.notaPedido.bomba = datos.bomba; 418 $scope.notaPedido.bomba = datos.bomba;
418 $scope.notaPedido.kilometros = datos.kilometros; 419 $scope.notaPedido.kilometros = datos.kilometros;
419 420
420 addCabecera('Flete:', datos.flete ? 'Si' : 421 addCabecera('Flete:', datos.flete ? 'Si' :
421 ($scope.notaPedido.fob ? 'FOB' : 'No')); 422 ($scope.notaPedido.fob ? 'FOB' : 'No'));
422 if(datos.flete) { 423 if(datos.flete) {
423 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); 424 addCabecera('Bomba:', datos.bomba ? 'Si' : 'No');
424 addCabecera('Kilometros:', datos.kilometros); 425 addCabecera('Kilometros:', datos.kilometros);
425 } else { 426 } else {
426 removeCabecera('Bomba:'); 427 removeCabecera('Bomba:');
427 removeCabecera('Kilometros:'); 428 removeCabecera('Kilometros:');
428 $scope.notaPedido.fob = false; 429 $scope.notaPedido.fob = false;
429 $scope.notaPedido.bomba = false; 430 $scope.notaPedido.bomba = false;
430 $scope.notaPedido.kilometros = null; 431 $scope.notaPedido.kilometros = null;
431 } 432 }
432 }, function() { 433 }, function() {
433 434
434 } 435 }
435 ); 436 );
436 }; 437 };
437 438
438 $scope.abrirModalMoneda = function() { 439 $scope.abrirModalMoneda = function() {
439 var modalInstance = $uibModal.open( 440 var modalInstance = $uibModal.open(
440 { 441 {
441 ariaLabelledBy: 'Busqueda de Moneda', 442 ariaLabelledBy: 'Busqueda de Moneda',
442 templateUrl: 'modal-moneda.html', 443 templateUrl: 'modal-moneda.html',
443 controller: 'focaModalMonedaController', 444 controller: 'focaModalMonedaController',
444 size: 'lg' 445 size: 'lg'
445 } 446 }
446 ); 447 );
447 modalInstance.result.then( 448 modalInstance.result.then(
448 function(moneda) { 449 function(moneda) {
449 $scope.abrirModalCotizacion(moneda); 450 $scope.abrirModalCotizacion(moneda);
450 }, function() { 451 }, function() {
451 452
452 } 453 }
453 ); 454 );
454 }; 455 };
455 456
456 $scope.abrirModalCotizacion = function(moneda) { 457 $scope.abrirModalCotizacion = function(moneda) {
457 var modalInstance = $uibModal.open( 458 var modalInstance = $uibModal.open(
458 { 459 {
459 ariaLabelledBy: 'Busqueda de Cotización', 460 ariaLabelledBy: 'Busqueda de Cotización',
460 templateUrl: 'modal-cotizacion.html', 461 templateUrl: 'modal-cotizacion.html',
461 controller: 'focaModalCotizacionController', 462 controller: 'focaModalCotizacionController',
462 size: 'lg', 463 size: 'lg',
463 resolve: {idMoneda: function() {return moneda.ID;}} 464 resolve: {idMoneda: function() {return moneda.ID;}}
464 } 465 }
465 ); 466 );
466 modalInstance.result.then( 467 modalInstance.result.then(
467 function(cotizacion) { 468 function(cotizacion) {
468 var articulosTablaTemp = $scope.articulosTabla; 469 var articulosTablaTemp = $scope.articulosTabla;
469 for(var i = 0; i < articulosTablaTemp.length; i++) { 470 for(var i = 0; i < articulosTablaTemp.length; i++) {
470 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * 471 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio *
471 $scope.notaPedido.cotizacion.COTIZACION; 472 $scope.notaPedido.cotizacion.COTIZACION;
472 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / 473 articulosTablaTemp[i].precio = articulosTablaTemp[i].precio /
473 cotizacion.COTIZACION; 474 cotizacion.COTIZACION;
474 } 475 }
475 $scope.articulosTabla = articulosTablaTemp; 476 $scope.articulosTabla = articulosTablaTemp;
476 $scope.notaPedido.moneda = { 477 $scope.notaPedido.moneda = {
477 id: moneda.ID, 478 id: moneda.ID,
478 detalle: moneda.DETALLE, 479 detalle: moneda.DETALLE,
479 simbolo: moneda.SIMBOLO 480 simbolo: moneda.SIMBOLO
480 }; 481 };
481 $scope.notaPedido.cotizacion = { 482 $scope.notaPedido.cotizacion = {
482 ID: cotizacion.ID, 483 ID: cotizacion.ID,
483 COTIZACION: cotizacion.COTIZACION, 484 COTIZACION: cotizacion.COTIZACION,
484 FECHA: cotizacion.FECHA 485 FECHA: cotizacion.FECHA
485 }; 486 };
486 addCabecera('Moneda:', moneda.DETALLE); 487 addCabecera('Moneda:', moneda.DETALLE);
487 addCabecera( 488 addCabecera(
488 'Fecha cotizacion:', 489 'Fecha cotizacion:',
489 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') 490 $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy')
490 ); 491 );
491 addCabecera('Cotizacion:', cotizacion.COTIZACION); 492 addCabecera('Cotizacion:', cotizacion.COTIZACION);
492 }, function() { 493 }, function() {
493 494
494 } 495 }
495 ); 496 );
496 }; 497 };
497 498
498 $scope.agregarATabla = function(key) { 499 $scope.agregarATabla = function(key) {
499 if(key === 13) { 500 if(key === 13) {
500 if($scope.articuloACargar.cantidad === undefined || 501 if($scope.articuloACargar.cantidad === undefined ||
501 $scope.articuloACargar.cantidad === 0 || 502 $scope.articuloACargar.cantidad === 0 ||
502 $scope.articuloACargar.cantidad === null ){ 503 $scope.articuloACargar.cantidad === null ){
503 focaModalService.alert('El valor debe ser al menos 1'); 504 focaModalService.alert('El valor debe ser al menos 1');
504 return; 505 return;
505 } 506 }
506 delete $scope.articuloACargar.sectorCodigo; 507 delete $scope.articuloACargar.sectorCodigo;
507 $scope.articulosTabla.push($scope.articuloACargar); 508 $scope.articulosTabla.push($scope.articuloACargar);
508 $scope.cargando = true; 509 $scope.cargando = true;
509 } 510 }
510 }; 511 };
511 512
512 $scope.quitarArticulo = function(key) { 513 $scope.quitarArticulo = function(key) {
513 $scope.articulosTabla.splice(key, 1); 514 $scope.articulosTabla.splice(key, 1);
514 }; 515 };
515 516
516 $scope.editarArticulo = function(key, articulo) { 517 $scope.editarArticulo = function(key, articulo) {
517 if(key === 13) { 518 if(key === 13) {
518 if(articulo.cantidad === null || articulo.cantidad === 0 || 519 if(articulo.cantidad === null || articulo.cantidad === 0 ||
519 articulo.cantidad === undefined){ 520 articulo.cantidad === undefined){
520 focaModalService.alert('El valor debe ser al menos 1'); 521 focaModalService.alert('El valor debe ser al menos 1');
521 return; 522 return;
522 } 523 }
523 articulo.editCantidad = false; 524 articulo.editCantidad = false;
524 articulo.editPrecio = false; 525 articulo.editPrecio = false;
525 } 526 }
526 }; 527 };
527 528
528 $scope.cambioEdit = function(articulo, propiedad) { 529 $scope.cambioEdit = function(articulo, propiedad) {
529 if(propiedad === 'cantidad') { 530 if(propiedad === 'cantidad') {
530 articulo.editCantidad = true; 531 articulo.editCantidad = true;
531 } else if(propiedad === 'precio') { 532 } else if(propiedad === 'precio') {
532 articulo.editPrecio = true; 533 articulo.editPrecio = true;
533 } 534 }
534 }; 535 };
535 536
536 $scope.limpiarFlete = function() { 537 $scope.limpiarFlete = function() {
537 $scope.notaPedido.fleteNombre = ''; 538 $scope.notaPedido.fleteNombre = '';
538 $scope.notaPedido.chofer = ''; 539 $scope.notaPedido.chofer = '';
539 $scope.notaPedido.vehiculo = ''; 540 $scope.notaPedido.vehiculo = '';
540 $scope.notaPedido.kilometros = ''; 541 $scope.notaPedido.kilometros = '';
541 $scope.notaPedido.costoUnitarioKmFlete = ''; 542 $scope.notaPedido.costoUnitarioKmFlete = '';
542 $scope.choferes = ''; 543 $scope.choferes = '';
543 $scope.vehiculos = ''; 544 $scope.vehiculos = '';
544 }; 545 };
545 546
546 $scope.limpiarPantalla = function() { 547 $scope.limpiarPantalla = function() {
547 $scope.limpiarFlete(); 548 $scope.limpiarFlete();
548 $scope.notaPedido.flete = '0'; 549 $scope.notaPedido.flete = '0';
549 $scope.notaPedido.bomba = '0'; 550 $scope.notaPedido.bomba = '0';
550 $scope.notaPedido.precioCondicion = ''; 551 $scope.notaPedido.precioCondicion = '';
551 $scope.articulosTabla = []; 552 $scope.articulosTabla = [];
552 $scope.notaPedido.vendedor.nombre = ''; 553 $scope.notaPedido.vendedor.nombre = '';
553 $scope.notaPedido.cliente = {nombre: ''}; 554 $scope.notaPedido.cliente = {nombre: ''};
554 $scope.notaPedido.domicilio = {dom: ''}; 555 $scope.notaPedido.domicilio = {dom: ''};
555 $scope.domiciliosCliente = []; 556 $scope.domiciliosCliente = [];
556 }; 557 };
557 558
558 $scope.resetFilter = function() { 559 $scope.resetFilter = function() {
559 $scope.articuloACargar = {}; 560 $scope.articuloACargar = {};
560 $scope.cargando = true; 561 $scope.cargando = true;
561 }; 562 };
562 563
563 $scope.selectFocus = function($event) { 564 $scope.selectFocus = function($event) {
564 $event.target.select(); 565 $event.target.select();
565 }; 566 };
566 567
567 $scope.salir = function() { 568 $scope.salir = function() {
568 $location.path('/'); 569 $location.path('/');
569 }; 570 };
570 571
571 function addCabecera(label, valor) { 572 function addCabecera(label, valor) {
572 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 573 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
573 if(propiedad.length === 1) { 574 if(propiedad.length === 1) {
574 propiedad[0].valor = valor; 575 propiedad[0].valor = valor;
575 } else { 576 } else {
576 $scope.cabecera.push({label: label, valor: valor}); 577 $scope.cabecera.push({label: label, valor: valor});
577 } 578 }
578 } 579 }
579 580
580 function removeCabecera(label) { 581 function removeCabecera(label) {
581 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); 582 var propiedad = $filter('filter')($scope.cabecera, {label: label}, true);
582 if(propiedad.length === 1){ 583 if(propiedad.length === 1){
583 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); 584 $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1);
584 } 585 }
585 } 586 }
586 } 587 }
587 ] 588 ]
588 ) 589 )
589 .controller('notaPedidoListaCtrl', [ 590 .controller('notaPedidoListaCtrl', [
590 '$scope', 591 '$scope',
591 'crearNotaPedidoService', 592 'crearNotaPedidoService',
592 '$location', 593 '$location',
593 function($scope, crearNotaPedidoService, $location) { 594 function($scope, crearNotaPedidoService, $location) {
594 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 595 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
595 $scope.notaPedidos = datos.data; 596 $scope.notaPedidos = datos.data;
596 }); 597 });
597 $scope.editar = function(notaPedido) { 598 $scope.editar = function(notaPedido) {
598 crearNotaPedidoService.setNotaPedido(notaPedido); 599 crearNotaPedidoService.setNotaPedido(notaPedido);
599 $location.path('/venta-nota-pedido/abm/'); 600 $location.path('/venta-nota-pedido/abm/');
600 }; 601 };
601 $scope.crearPedido = function() { 602 $scope.crearPedido = function() {
602 crearNotaPedidoService.clearNotaPedido(); 603 crearNotaPedidoService.clearNotaPedido();
603 $location.path('/venta-nota-pedido/abm/'); 604 $location.path('/venta-nota-pedido/abm/');
604 }; 605 };
605 } 606 }
606 ]) 607 ])
607 .controller('focaCrearNotaPedidoFichaClienteController', [ 608 .controller('focaCrearNotaPedidoFichaClienteController', [
608 '$scope', 609 '$scope',
609 'crearNotaPedidoService', 610 'crearNotaPedidoService',
610 '$location', 611 '$location',
611 function($scope, crearNotaPedidoService, $location) { 612 function($scope, crearNotaPedidoService, $location) {
612 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) { 613 crearNotaPedidoService.obtenerNotaPedido().then(function(datos) {
613 $scope.notaPedidos = datos.data; 614 $scope.notaPedidos = datos.data;
614 }); 615 });
615 $scope.editar = function(notaPedido) { 616 $scope.editar = function(notaPedido) {
616 crearNotaPedidoService.setNotaPedido(notaPedido); 617 crearNotaPedidoService.setNotaPedido(notaPedido);
617 $location.path('/venta-nota-pedido/abm/'); 618 $location.path('/venta-nota-pedido/abm/');
618 }; 619 };
619 $scope.crearPedido = function() { 620 $scope.crearPedido = function() {
620 crearNotaPedidoService.clearNotaPedido(); 621 crearNotaPedidoService.clearNotaPedido();
621 $location.path('/venta-nota-pedido/abm/'); 622 $location.path('/venta-nota-pedido/abm/');
622 }; 623 };
623 } 624 }
624 ]); 625 ]);
625 626
vendor/cordovaGeolocationModule.min.js
File was created 1 var cordovaGeolocationModule=angular.module("cordovaGeolocationModule",[]);cordovaGeolocationModule.constant("cordovaGeolocationConstants",{apiVersion:"1.0.0",cordovaVersion:">=3.4.0"});cordovaGeolocationModule.factory("cordovaGeolocationService",["$rootScope","$log","cordovaGeolocationConstants",function(e,t,n){return{apiVersion:function(){t.debug("cordovaGeolocationService.apiVersion.");return n.apiVersion},cordovaVersion:function(){t.debug("cordovaGeolocationService.cordovaVersion.");return n.cordovaVersion},checkGeolocationAvailability:function(){t.debug("cordovaGeolocationService.checkGeolocationAvailability.");if(!navigator.geolocation){t.warn("Geolocation API is not available.");return false}return true},getCurrentPosition:function(n,r,i){t.debug("cordovaGeolocationService.getCurrentPosition.");if(!this.checkGeolocationAvailability()){return}navigator.geolocation.getCurrentPosition(function(t){e.$apply(n(t))},function(t){e.$apply(r(t))},i)},watchPosition:function(n,r,i){t.debug("cordovaGeolocationService.watchPosition.");if(!this.checkGeolocationAvailability()){return}return navigator.geolocation.watchPosition(function(t){e.$apply(n(t))},function(t){e.$apply(r(t))},i)},clearWatch:function(e){t.debug("cordovaGeolocationService.clearWatch.");if(!this.checkGeolocationAvailability()){return}navigator.geolocation.clearWatch(e)}}}])