Commit 9b9585d7197beab83a50d029e343c4abc02bcfc0
1 parent
79de91ab16
Exists in
master
and in
2 other branches
init commit
Showing
11 changed files
with
1460 additions
and
0 deletions
Show diff stats
.gitignore
File was created | 1 | /node_modules | |
2 | /dist | ||
3 | package-lock\.json | ||
4 | /src/etc/develop.js | ||
5 | |||
6 | tmp/ | ||
7 |
.jshintrc
File was created | 1 | { | |
2 | /* | ||
3 | * ENVIRONMENTS | ||
4 | * ================= | ||
5 | */ | ||
6 | |||
7 | // Define globals exposed by modern browsers. | ||
8 | "browser": true, | ||
9 | |||
10 | // Define globals exposed by jQuery. | ||
11 | "jquery": true, | ||
12 | |||
13 | // Define globals exposed by Node.js. | ||
14 | "node": true, | ||
15 | |||
16 | // Allow ES6. | ||
17 | "esversion": 6, | ||
18 | |||
19 | /* | ||
20 | * ENFORCING OPTIONS | ||
21 | * ================= | ||
22 | */ | ||
23 | |||
24 | // Force all variable names to use either camelCase style or UPPER_CASE | ||
25 | // with underscores. | ||
26 | "camelcase": true, | ||
27 | |||
28 | // Prohibit use of == and != in favor of === and !==. | ||
29 | "eqeqeq": true, | ||
30 | |||
31 | // Enforce tab width of 2 spaces. | ||
32 | "indent": 4, | ||
33 | |||
34 | // Prohibit use of a variable before it is defined. | ||
35 | "latedef": false, | ||
36 | |||
37 | // Enforce line length to 100 characters | ||
38 | "maxlen": 100, | ||
39 | |||
40 | // Require capitalized names for constructor functions. | ||
41 | "newcap": true, | ||
42 | |||
43 | // Enforce use of single quotation marks for strings. | ||
44 | "quotmark": "single", | ||
45 | |||
46 | // Enforce placing 'use strict' at the top function scope | ||
47 | "strict": false, | ||
48 | |||
49 | // Prohibit use of explicitly undeclared variables. | ||
50 | "undef": true, | ||
51 | |||
52 | // Warn when variables are defined but never used. | ||
53 | "unused": true, | ||
54 | |||
55 | // Para que funcione en angular | ||
56 | "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe"], | ||
57 | /* | ||
58 | * RELAXING OPTIONS | ||
59 | * ================= | ||
60 | */ | ||
61 | |||
62 | // Suppress warnings about == null comparisons. | ||
63 | "eqnull": true | ||
64 | } | ||
65 |
gulpfile.js
File was created | 1 | const templateCache = require('gulp-angular-templatecache'); | |
2 | const clean = require('gulp-clean'); | ||
3 | const concat = require('gulp-concat'); | ||
4 | const htmlmin = require('gulp-htmlmin'); | ||
5 | const rename = require('gulp-rename'); | ||
6 | const uglify = require('gulp-uglify'); | ||
7 | const gulp = require('gulp'); | ||
8 | const pump = require('pump'); | ||
9 | const jshint = require('gulp-jshint'); | ||
10 | const replace = require('gulp-replace'); | ||
11 | const connect = require('gulp-connect'); | ||
12 | |||
13 | var paths = { | ||
14 | srcJS: 'src/js/*.js', | ||
15 | srcViews: 'src/views/*.html', | ||
16 | tmp: 'tmp', | ||
17 | dist: 'dist/' | ||
18 | }; | ||
19 | |||
20 | gulp.task('templates', ['clean'], function() { | ||
21 | return pump( | ||
22 | [ | ||
23 | gulp.src(paths.srcViews), | ||
24 | htmlmin(), | ||
25 | templateCache('views.js', { | ||
26 | module: 'focaCrearHojaRuta', | ||
27 | root: '' | ||
28 | }), | ||
29 | gulp.dest(paths.tmp) | ||
30 | ] | ||
31 | ); | ||
32 | }); | ||
33 | |||
34 | gulp.task('uglify', ['templates'], function() { | ||
35 | return pump( | ||
36 | [ | ||
37 | gulp.src([ | ||
38 | paths.srcJS, | ||
39 | 'tmp/views.js' | ||
40 | ]), | ||
41 | concat('foca-crear-hoja-ruta.js'), | ||
42 | replace('src/views/', ''), | ||
43 | gulp.dest(paths.tmp), | ||
44 | rename('foca-crear-hoja-ruta.min.js'), | ||
45 | uglify(), | ||
46 | /*replace('"ngRoute","ui.bootstrap","focaModalVendedores","focaBusquedaProductos",'+ | ||
47 | '"focaModalProveedor","focaBusquedaCliente","focaModalPrecioCondicion",'+ | ||
48 | '"focaModalFlete","focaDirectivas","focaModal","focaModalDomicilio",'+ | ||
49 | '"focaModalMoneda","focaModalCotizacion","focaSeguimiento","angular-ladda",'+ | ||
50 | '"cordovaGeolocationModule"', ''),*/ | ||
51 | gulp.dest(paths.dist) | ||
52 | ] | ||
53 | ); | ||
54 | }); | ||
55 | |||
56 | gulp.task('clean', function(){ | ||
57 | return gulp.src(['tmp', 'dist'], {read: false}) | ||
58 | .pipe(clean()); | ||
59 | }); | ||
60 | |||
61 | gulp.task('pre-commit', function() { | ||
62 | return pump( | ||
63 | [ | ||
64 | gulp.src(paths.srcJS), | ||
65 | jshint('.jshintrc'), | ||
66 | jshint.reporter('default'), | ||
67 | jshint.reporter('fail') | ||
68 | ] | ||
69 | ); | ||
70 | |||
71 | gulp.start('uglify'); | ||
72 | }); | ||
73 | |||
74 | gulp.task('webserver', function() { | ||
75 | pump [ | ||
76 | connect.server({port: 3300, host: '0.0.0.0'}) | ||
77 | ] | ||
78 | }); | ||
79 | |||
80 | gulp.task('clean-post-install', function() { | ||
81 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | ||
82 | 'index.html'], {read: false}) | ||
83 | .pipe(clean()); | ||
84 | }); | ||
85 | |||
86 | gulp.task('default', ['webserver']); | ||
87 | |||
88 | gulp.task('watch', function() { | ||
89 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | ||
90 | }); | ||
91 |
package.json
File was created | 1 | { | |
2 | "name": "foca-crear-hoja-ruta", | ||
3 | "version": "0.0.1", | ||
4 | "description": "foca-crear-hoja-ruta", | ||
5 | "main": "index.js", | ||
6 | "scripts": { | ||
7 | "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | }, | ||
9 | "repository": { | ||
10 | "type": "git", | ||
11 | "url": "https://debo.suite.repo/modulos-npm/foca-crear-hoja-ruta.git" | ||
12 | }, | ||
13 | "author": "Nicolás Guarnieri", | ||
14 | "license": "ISC", | ||
15 | "devDependencies": { | ||
16 | "angular": "^1.7.5", | ||
17 | "angular-route": "^1.7.5", | ||
18 | "bootstrap": "^4.1.3", | ||
19 | "foca-directivas": "git+https://debo.suite.repo/modulos-npm/foca-directivas.git", | ||
20 | "font-awesome": "^4.7.0", | ||
21 | "gulp": "^3.9.1", | ||
22 | "gulp-angular-templatecache": "^2.2.5", | ||
23 | "gulp-clean": "^0.4.0", | ||
24 | "gulp-concat": "^2.6.1", | ||
25 | "gulp-connect": "^5.6.1", | ||
26 | "gulp-htmlmin": "^5.0.1", | ||
27 | "gulp-jshint": "^2.1.0", | ||
28 | "gulp-rename": "^1.4.0", | ||
29 | "gulp-replace": "^1.0.0", | ||
30 | "gulp-sequence": "^1.0.0", | ||
31 | "gulp-uglify": "^3.0.1", | ||
32 | "jasmine-core": "^3.3.0", | ||
33 | "jquery": "^3.3.1", | ||
34 | "jshint": "^2.9.6", | ||
35 | "ladda": "^2.0.1", | ||
36 | "pre-commit": "^1.2.2", | ||
37 | "pump": "^3.0.0", | ||
38 | "ui-bootstrap4": "^3.0.5" | ||
39 | } | ||
40 | } | ||
41 |
src/etc/develop.js.ejemplo
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .constant("API_ENDPOINT", { | ||
3 | 'URL': '//127.0.0.1:9000' | ||
4 | }); | ||
5 |
src/js/app.js
File was created | 1 | angular.module('focaCrearHojaRuta', [ | |
2 | 'ngRoute', | ||
3 | 'ui.bootstrap'/*, | ||
4 | 'focaModalVendedores', | ||
5 | 'focaBusquedaProductos', | ||
6 | 'focaModalProveedor', | ||
7 | 'focaBusquedaCliente', | ||
8 | 'focaModalPrecioCondicion', | ||
9 | 'focaModalFlete', | ||
10 | 'focaDirectivas', | ||
11 | 'focaModal', | ||
12 | 'focaModalDomicilio', | ||
13 | 'focaModalMoneda', | ||
14 | 'focaModalCotizacion', | ||
15 | 'focaSeguimiento', | ||
16 | 'angular-ladda', | ||
17 | 'cordovaGeolocationModule'*/ | ||
18 | ]); | ||
19 |
src/js/businessService.js
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .factory('hojaRutaBusinessService', [ | ||
3 | 'crearHojaRutaService', | ||
4 | function(crearHojaRutaService) { | ||
5 | return { | ||
6 | addArticulos: function(articulosHojaRuta, idHojaRuta, cotizacion) { | ||
7 | for(var i = 0; i < articulosHojaRuta.length; i++) { | ||
8 | delete articulosHojaRuta[i].editCantidad; | ||
9 | delete articulosHojaRuta[i].editPrecio; | ||
10 | articulosHojaRuta[i].idHojaRuta = idHojaRuta; | ||
11 | articulosHojaRuta[i].precio = articulosHojaRuta[i].precio * cotizacion; | ||
12 | crearHojaRutaService.crearArticulosParaHojaRuta(articulosHojaRuta[i]); | ||
13 | } | ||
14 | }, | ||
15 | addEstado: function(idHojaRuta, idVendedor) { | ||
16 | var date = new Date(); | ||
17 | var estado = { | ||
18 | idHojaRuta: idHojaRuta, | ||
19 | fecha: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | ||
20 | .toISOString().slice(0, 19).replace('T', ' '), | ||
21 | estado: 0, | ||
22 | idVendedor: idVendedor | ||
23 | }; | ||
24 | crearHojaRutaService.crearEstadoParaHojaRuta(estado); | ||
25 | } | ||
26 | }; | ||
27 | }]); | ||
28 |
src/js/controller.js
File was created | 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | |
2 | [ | ||
3 | '$scope', '$uibModal', '$location', '$filter', 'crearHojaRutaService', | ||
4 | 'focaModalService', 'focaSeguimientoService', 'hojaRutaBusinessService', | ||
5 | function( | ||
6 | $scope, $uibModal, $location, $filter, crearHojaRutaService, focaModalService, | ||
7 | focaSeguimientoService, hojaRutaBusinessService | ||
8 | ) { | ||
9 | $scope.botonera = [ | ||
10 | {texto: 'Transportista', accion: function() {$scope.seleccionarProveedor();}}, | ||
11 | {texto: 'Chofer', accion: function() {$scope.seleccionarChofer();}}, | ||
12 | {texto: 'Vehiculo', accion: function() {$scope.seleccionarVehiculo();}}, | ||
13 | {texto: 'Tarifario', accion: function() {$scope.seleccionarTarifario();}}, | ||
14 | {texto: 'Remitos', accion: function() {$scope.seleccionarRemito();}}, | ||
15 | {texto: '', accion: function() {}}, | ||
16 | {texto: '', accion: function() {}}, | ||
17 | {texto: '', accion: function() {}} | ||
18 | ]; | ||
19 | $scope.datepickerAbierto = false; | ||
20 | |||
21 | $scope.show = false; | ||
22 | $scope.cargando = true; | ||
23 | $scope.dateOptions = { | ||
24 | maxDate: new Date(), | ||
25 | minDate: new Date(2010, 0, 1) | ||
26 | }; | ||
27 | |||
28 | $scope.hojaRuta = { | ||
29 | vendedor: {}, | ||
30 | cliente: {}, | ||
31 | proveedor: {}, | ||
32 | domicilio: {dom: ''}, | ||
33 | moneda: {}, | ||
34 | cotizacion: {} | ||
35 | }; | ||
36 | var monedaPorDefecto; | ||
37 | //Trabajo con la cotización más reciente, por eso uso siempre la primera '[0]' | ||
38 | crearHojaRutaService.getCotizacionByIdMoneda(1).then(function(res) { | ||
39 | monedaPorDefecto = { | ||
40 | id: res.data[0].ID, | ||
41 | detalle: res.data[0].DETALLE, | ||
42 | simbolo: res.data[0].SIMBOLO, | ||
43 | cotizaciones: res.data[0].cotizaciones | ||
44 | }; | ||
45 | addCabecera('Moneda:', monedaPorDefecto.detalle); | ||
46 | addCabecera('Fecha cotizacion:', | ||
47 | new Date(monedaPorDefecto.cotizaciones[0].FECHA).toLocaleDateString()); | ||
48 | addCabecera('Cotizacion:', monedaPorDefecto.cotizaciones[0].COTIZACION); | ||
49 | $scope.hojaRuta.moneda = monedaPorDefecto; | ||
50 | $scope.hojaRuta.cotizacion = monedaPorDefecto.cotizaciones[0]; | ||
51 | }); | ||
52 | |||
53 | $scope.cabecera = []; | ||
54 | $scope.showCabecera = true; | ||
55 | |||
56 | $scope.now = new Date(); | ||
57 | $scope.puntoVenta = '0000'; | ||
58 | $scope.comprobante = '00000000'; | ||
59 | $scope.articulosTabla = []; | ||
60 | $scope.idLista = undefined; | ||
61 | //La pantalla solo se usa para cargar pedidos | ||
62 | //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); | ||
63 | |||
64 | crearHojaRutaService.getPrecioCondicion().then( | ||
65 | function(res) { | ||
66 | $scope.precioCondiciones = res.data; | ||
67 | } | ||
68 | ); | ||
69 | |||
70 | crearHojaRutaService.getNumeroHojaRuta().then( | ||
71 | function(res) { | ||
72 | $scope.puntoVenta = rellenar(res.data.sucursal, 4); | ||
73 | $scope.comprobante = rellenar(res.data.numeroHojaRuta, 8); | ||
74 | }, | ||
75 | function(err) { | ||
76 | focaModalService.alert('La terminal no esta configurada correctamente'); | ||
77 | console.info(err); | ||
78 | } | ||
79 | ); | ||
80 | //La pantalla solo se usa para cargar pedidos | ||
81 | // if (hojaRutaTemp !== undefined) { | ||
82 | // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); | ||
83 | // $scope.hojaRuta = hojaRutaTemp; | ||
84 | // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); | ||
85 | // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); | ||
86 | // $scope.idLista = $scope.hojaRuta.precioCondicion; | ||
87 | // crearHojaRutaService | ||
88 | // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( | ||
89 | // function(res) { | ||
90 | // $scope.articulosTabla = res.data; | ||
91 | // } | ||
92 | // ); | ||
93 | //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | ||
94 | //(NO REQUERIDO EN ESTA VERSION) | ||
95 | // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( | ||
96 | // function(res) { | ||
97 | // $scope.hojaRuta.domicilio = res.data; | ||
98 | // } | ||
99 | // ); | ||
100 | // } else { | ||
101 | // $scope.hojaRuta.fechaCarga = new Date(); | ||
102 | // $scope.hojaRuta.bomba = '0'; | ||
103 | // $scope.hojaRuta.flete = '0'; | ||
104 | // $scope.idLista = undefined; | ||
105 | // } | ||
106 | //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | ||
107 | // $scope.addNewDom = function() { | ||
108 | // $scope.hojaRuta.domicilio.push({ 'id': 0 }); | ||
109 | // }; | ||
110 | // $scope.removeNewChoice = function(choice) { | ||
111 | // if ($scope.hojaRuta.domicilio.length > 1) { | ||
112 | // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( | ||
113 | // function(c) { | ||
114 | // return c.$$hashKey === choice.$$hashKey; | ||
115 | // } | ||
116 | // ), 1); | ||
117 | // } | ||
118 | // }; | ||
119 | |||
120 | $scope.crearHojaRuta = function() { | ||
121 | if(!$scope.hojaRuta.vendedor.codigo) { | ||
122 | focaModalService.alert('Ingrese Vendedor'); | ||
123 | return; | ||
124 | } else if(!$scope.hojaRuta.cliente.cod) { | ||
125 | focaModalService.alert('Ingrese Cliente'); | ||
126 | return; | ||
127 | } else if(!$scope.hojaRuta.proveedor.codigo) { | ||
128 | focaModalService.alert('Ingrese Proveedor'); | ||
129 | return; | ||
130 | } else if(!$scope.hojaRuta.moneda.id) { | ||
131 | focaModalService.alert('Ingrese Moneda'); | ||
132 | return; | ||
133 | } else if(!$scope.hojaRuta.cotizacion.ID) { | ||
134 | focaModalService.alert('Ingrese Cotización'); | ||
135 | return; | ||
136 | } else if(!$scope.plazosPagos) { | ||
137 | focaModalService.alert('Ingrese Precios y Condiciones'); | ||
138 | return; | ||
139 | } else if( | ||
140 | $scope.hojaRuta.flete === undefined || $scope.hojaRuta.flete === null) | ||
141 | { | ||
142 | focaModalService.alert('Ingrese Flete'); | ||
143 | return; | ||
144 | } else if(!$scope.hojaRuta.domicilio.id) { | ||
145 | focaModalService.alert('Ingrese Domicilio'); | ||
146 | return; | ||
147 | } else if($scope.articulosTabla.length === 0) { | ||
148 | focaModalService.alert('Debe cargar al menos un articulo'); | ||
149 | return; | ||
150 | } | ||
151 | var date = new Date(); | ||
152 | var hojaRuta = { | ||
153 | id: 0, | ||
154 | fechaCarga: new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | ||
155 | .toISOString().slice(0, 19).replace('T', ' '), | ||
156 | idVendedor: $scope.hojaRuta.vendedor.codigo, | ||
157 | idCliente: $scope.hojaRuta.cliente.cod, | ||
158 | nombreCliente: $scope.hojaRuta.cliente.nom, | ||
159 | cuitCliente: $scope.hojaRuta.cliente.cuit, | ||
160 | idProveedor: $scope.hojaRuta.proveedor.codigo, | ||
161 | idDomicilio: $scope.hojaRuta.domicilio.id, | ||
162 | idCotizacion: $scope.hojaRuta.cotizacion.ID, | ||
163 | cotizacion: $scope.hojaRuta.cotizacion.COTIZACION, | ||
164 | flete: $scope.hojaRuta.flete, | ||
165 | fob: $scope.hojaRuta.fob, | ||
166 | bomba: $scope.hojaRuta.bomba, | ||
167 | kilometros: $scope.hojaRuta.kilometros, | ||
168 | estado: 0, | ||
169 | total: $scope.getTotal() | ||
170 | }; | ||
171 | crearHojaRutaService.crearHojaRuta(hojaRuta).then( | ||
172 | function(data) { | ||
173 | hojaRutaBusinessService.addArticulos($scope.articulosTabla, | ||
174 | data.data.id, $scope.hojaRuta.cotizacion.COTIZACION); | ||
175 | focaSeguimientoService.guardarPosicion('crear nota pedido', ''); | ||
176 | var plazos = $scope.plazosPagos; | ||
177 | |||
178 | for(var j = 0; j < plazos.length; j++) { | ||
179 | var json = { | ||
180 | idPedido: data.data.id, | ||
181 | dias: plazos[j].dias | ||
182 | }; | ||
183 | crearHojaRutaService.crearPlazosParaHojaRuta(json); | ||
184 | } | ||
185 | hojaRutaBusinessService.addEstado(data.data.id, | ||
186 | $scope.hojaRuta.vendedor.codigo); | ||
187 | |||
188 | focaModalService.alert('Nota pedido creada'); | ||
189 | $scope.cabecera = []; | ||
190 | addCabecera('Moneda:', $scope.hojaRuta.moneda.detalle); | ||
191 | addCabecera( | ||
192 | 'Fecha cotizacion:', | ||
193 | $filter('date')($scope.hojaRuta.cotizacion.FECHA, 'dd/MM/yyyy') | ||
194 | ); | ||
195 | addCabecera('Cotizacion:', $scope.hojaRuta.cotizacion.COTIZACION); | ||
196 | $scope.hojaRuta.vendedor = {}; | ||
197 | $scope.hojaRuta.cliente = {}; | ||
198 | $scope.hojaRuta.proveedor = {}; | ||
199 | $scope.hojaRuta.domicilio = {}; | ||
200 | $scope.hojaRuta.flete = null; | ||
201 | $scope.hojaRuta.fob = null; | ||
202 | $scope.hojaRuta.bomba = null; | ||
203 | $scope.hojaRuta.kilometros = null; | ||
204 | $scope.articulosTabla = []; | ||
205 | }, | ||
206 | function(error) { | ||
207 | focaModalService.alert('Hubo un error al crear la nota de pedido'); | ||
208 | console.info(error); | ||
209 | } | ||
210 | ); | ||
211 | }; | ||
212 | |||
213 | $scope.seleccionarArticulo = function() { | ||
214 | if ($scope.idLista === undefined) { | ||
215 | focaModalService.alert( | ||
216 | 'Primero seleccione una lista de precio y condicion'); | ||
217 | return; | ||
218 | } | ||
219 | var modalInstance = $uibModal.open( | ||
220 | { | ||
221 | ariaLabelledBy: 'Busqueda de Productos', | ||
222 | templateUrl: 'modal-busqueda-productos.html', | ||
223 | controller: 'modalBusquedaProductosCtrl', | ||
224 | resolve: { | ||
225 | parametroProducto: { | ||
226 | idLista: $scope.idLista, | ||
227 | cotizacion: $scope.hojaRuta.cotizacion.COTIZACION, | ||
228 | simbolo: $scope.hojaRuta.moneda.simbolo | ||
229 | } | ||
230 | }, | ||
231 | size: 'lg' | ||
232 | } | ||
233 | ); | ||
234 | modalInstance.result.then( | ||
235 | function(producto) { | ||
236 | var newArt = | ||
237 | { | ||
238 | id: 0, | ||
239 | codigo: producto.codigo, | ||
240 | sector: producto.sector, | ||
241 | sectorCodigo: producto.sector + '-' + producto.codigo, | ||
242 | descripcion: producto.descripcion, | ||
243 | item: $scope.articulosTabla.length + 1, | ||
244 | nombre: producto.descripcion, | ||
245 | precio: parseFloat(producto.precio.toFixed(4)), | ||
246 | costoUnitario: producto.costo, | ||
247 | editCantidad: false, | ||
248 | editPrecio: false | ||
249 | }; | ||
250 | $scope.articuloACargar = newArt; | ||
251 | $scope.cargando = false; | ||
252 | }, function() { | ||
253 | // funcion ejecutada cuando se cancela el modal | ||
254 | } | ||
255 | ); | ||
256 | }; | ||
257 | |||
258 | $scope.seleccionarVendedor = function() { | ||
259 | var modalInstance = $uibModal.open( | ||
260 | { | ||
261 | ariaLabelledBy: 'Busqueda de Vendedores', | ||
262 | templateUrl: 'modal-vendedores.html', | ||
263 | controller: 'modalVendedoresCtrl', | ||
264 | size: 'lg' | ||
265 | } | ||
266 | ); | ||
267 | modalInstance.result.then( | ||
268 | function(vendedor) { | ||
269 | addCabecera('Vendedor:', vendedor.NomVen); | ||
270 | $scope.hojaRuta.vendedor.codigo = vendedor.CodVen; | ||
271 | }, function() { | ||
272 | |||
273 | } | ||
274 | ); | ||
275 | }; | ||
276 | |||
277 | $scope.seleccionarProveedor = function() { | ||
278 | var modalInstance = $uibModal.open( | ||
279 | { | ||
280 | ariaLabelledBy: 'Busqueda de Proveedor', | ||
281 | templateUrl: 'modal-proveedor.html', | ||
282 | controller: 'focaModalProveedorCtrl', | ||
283 | size: 'lg', | ||
284 | resolve: { | ||
285 | transportista: function() { | ||
286 | return true; | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | ); | ||
291 | modalInstance.result.then( | ||
292 | function(proveedor) { | ||
293 | $scope.hojaRuta.proveedor.codigo = proveedor.COD; | ||
294 | addCabecera('Proveedor:', proveedor.NOM); | ||
295 | }, function() { | ||
296 | |||
297 | } | ||
298 | ); | ||
299 | }; | ||
300 | |||
301 | $scope.seleccionarCliente = function() { | ||
302 | |||
303 | var modalInstance = $uibModal.open( | ||
304 | { | ||
305 | ariaLabelledBy: 'Busqueda de Cliente', | ||
306 | templateUrl: 'foca-busqueda-cliente-modal.html', | ||
307 | controller: 'focaBusquedaClienteModalController', | ||
308 | size: 'lg' | ||
309 | } | ||
310 | ); | ||
311 | modalInstance.result.then( | ||
312 | function(cliente) { | ||
313 | $scope.abrirModalDomicilios(cliente); | ||
314 | }, function() { | ||
315 | |||
316 | } | ||
317 | ); | ||
318 | }; | ||
319 | |||
320 | $scope.abrirModalDomicilios = function(cliente) { | ||
321 | var modalInstanceDomicilio = $uibModal.open( | ||
322 | { | ||
323 | ariaLabelledBy: 'Busqueda de Domicilios', | ||
324 | templateUrl: 'modal-domicilio.html', | ||
325 | controller: 'focaModalDomicilioController', | ||
326 | resolve: { idCliente: function() { return cliente.cod; }}, | ||
327 | size: 'lg', | ||
328 | } | ||
329 | ); | ||
330 | modalInstanceDomicilio.result.then( | ||
331 | function(domicilio) { | ||
332 | $scope.hojaRuta.domicilio.id = domicilio.nivel2; | ||
333 | $scope.hojaRuta.cliente = cliente; | ||
334 | |||
335 | addCabecera('Cliente:', cliente.nom); | ||
336 | addCabecera('Domicilio:', domicilio.Calle + ' ' + domicilio.Numero); | ||
337 | }, function() { | ||
338 | $scope.seleccionarCliente(); | ||
339 | return; | ||
340 | } | ||
341 | ); | ||
342 | }; | ||
343 | |||
344 | $scope.mostrarFichaCliente = function() { | ||
345 | $uibModal.open( | ||
346 | { | ||
347 | ariaLabelledBy: 'Datos del Cliente', | ||
348 | templateUrl: 'foca-crear-nota-pedido-ficha-cliente.html', | ||
349 | controller: 'focaCrearHojaRutaFichaClienteController', | ||
350 | size: 'lg' | ||
351 | } | ||
352 | ); | ||
353 | }; | ||
354 | |||
355 | $scope.getTotal = function() { | ||
356 | var total = 0; | ||
357 | var arrayTempArticulos = $scope.articulosTabla; | ||
358 | for (var i = 0; i < arrayTempArticulos.length; i++) { | ||
359 | total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | ||
360 | } | ||
361 | return parseFloat(total.toFixed(2)); | ||
362 | }; | ||
363 | |||
364 | $scope.getSubTotal = function() { | ||
365 | if($scope.articuloACargar) { | ||
366 | return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | ||
367 | } | ||
368 | }; | ||
369 | |||
370 | $scope.abrirModalListaPrecio = function() { | ||
371 | var modalInstance = $uibModal.open( | ||
372 | { | ||
373 | ariaLabelledBy: 'Busqueda de Precio Condición', | ||
374 | templateUrl: 'modal-precio-condicion.html', | ||
375 | controller: 'focaModalPrecioCondicionController', | ||
376 | size: 'lg' | ||
377 | } | ||
378 | ); | ||
379 | modalInstance.result.then( | ||
380 | function(precioCondicion) { | ||
381 | var cabecera = ''; | ||
382 | var plazosConcat = ''; | ||
383 | if(!Array.isArray(precioCondicion)) { | ||
384 | $scope.plazosPagos = precioCondicion.plazoPago; | ||
385 | $scope.idLista = precioCondicion.idListaPrecio; | ||
386 | for(var i = 0; i < precioCondicion.plazoPago.length; i++) { | ||
387 | plazosConcat += precioCondicion.plazoPago[i].dias + ' '; | ||
388 | } | ||
389 | cabecera = precioCondicion.nombre + ' ' + plazosConcat.trim(); | ||
390 | } else { //Cuando se ingresan los plazos manualmente | ||
391 | $scope.idLista = -1; //-1, el modal productos busca todos los productos | ||
392 | $scope.plazosPagos = precioCondicion; | ||
393 | for(var j = 0; j < precioCondicion.length; j++) { | ||
394 | plazosConcat += precioCondicion[j].dias + ' '; | ||
395 | } | ||
396 | cabecera = 'Ingreso manual ' + plazosConcat.trim(); | ||
397 | } | ||
398 | $scope.articulosTabla = []; | ||
399 | addCabecera('Precios y condiciones:', cabecera); | ||
400 | }, function() { | ||
401 | |||
402 | } | ||
403 | ); | ||
404 | }; | ||
405 | |||
406 | $scope.abrirModalFlete = function() { | ||
407 | var modalInstance = $uibModal.open( | ||
408 | { | ||
409 | ariaLabelledBy: 'Busqueda de Flete', | ||
410 | templateUrl: 'modal-flete.html', | ||
411 | controller: 'focaModalFleteController', | ||
412 | size: 'lg', | ||
413 | resolve: { | ||
414 | parametrosFlete: | ||
415 | function() { | ||
416 | return { | ||
417 | flete: $scope.hojaRuta.flete ? '1' : | ||
418 | ($scope.hojaRuta.fob ? 'FOB' : | ||
419 | ($scope.hojaRuta.flete === undefined ? null : '0')), | ||
420 | bomba: $scope.hojaRuta.bomba ? '1' : | ||
421 | ($scope.hojaRuta.bomba === undefined ? null : '0'), | ||
422 | kilometros: $scope.hojaRuta.kilometros | ||
423 | }; | ||
424 | } | ||
425 | } | ||
426 | } | ||
427 | ); | ||
428 | modalInstance.result.then( | ||
429 | function(datos) { | ||
430 | $scope.hojaRuta.flete = datos.flete; | ||
431 | $scope.hojaRuta.fob = datos.FOB; | ||
432 | $scope.hojaRuta.bomba = datos.bomba; | ||
433 | $scope.hojaRuta.kilometros = datos.kilometros; | ||
434 | |||
435 | addCabecera('Flete:', datos.flete ? 'Si' : | ||
436 | ($scope.hojaRuta.fob ? 'FOB' : 'No')); | ||
437 | if(datos.flete) { | ||
438 | addCabecera('Bomba:', datos.bomba ? 'Si' : 'No'); | ||
439 | addCabecera('Kilometros:', datos.kilometros); | ||
440 | } else { | ||
441 | removeCabecera('Bomba:'); | ||
442 | removeCabecera('Kilometros:'); | ||
443 | $scope.hojaRuta.fob = false; | ||
444 | $scope.hojaRuta.bomba = false; | ||
445 | $scope.hojaRuta.kilometros = null; | ||
446 | } | ||
447 | }, function() { | ||
448 | |||
449 | } | ||
450 | ); | ||
451 | }; | ||
452 | |||
453 | $scope.abrirModalMoneda = function() { | ||
454 | var modalInstance = $uibModal.open( | ||
455 | { | ||
456 | ariaLabelledBy: 'Busqueda de Moneda', | ||
457 | templateUrl: 'modal-moneda.html', | ||
458 | controller: 'focaModalMonedaController', | ||
459 | size: 'lg' | ||
460 | } | ||
461 | ); | ||
462 | modalInstance.result.then( | ||
463 | function(moneda) { | ||
464 | $scope.abrirModalCotizacion(moneda); | ||
465 | }, function() { | ||
466 | |||
467 | } | ||
468 | ); | ||
469 | }; | ||
470 | |||
471 | $scope.abrirModalCotizacion = function(moneda) { | ||
472 | var modalInstance = $uibModal.open( | ||
473 | { | ||
474 | ariaLabelledBy: 'Busqueda de Cotización', | ||
475 | templateUrl: 'modal-cotizacion.html', | ||
476 | controller: 'focaModalCotizacionController', | ||
477 | size: 'lg', | ||
478 | resolve: {idMoneda: function() {return moneda.ID;}} | ||
479 | } | ||
480 | ); | ||
481 | modalInstance.result.then( | ||
482 | function(cotizacion) { | ||
483 | var articulosTablaTemp = $scope.articulosTabla; | ||
484 | for(var i = 0; i < articulosTablaTemp.length; i++) { | ||
485 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio * | ||
486 | $scope.hojaRuta.cotizacion.COTIZACION; | ||
487 | articulosTablaTemp[i].precio = articulosTablaTemp[i].precio / | ||
488 | cotizacion.COTIZACION; | ||
489 | } | ||
490 | $scope.articulosTabla = articulosTablaTemp; | ||
491 | $scope.hojaRuta.moneda = { | ||
492 | id: moneda.ID, | ||
493 | detalle: moneda.DETALLE, | ||
494 | simbolo: moneda.SIMBOLO | ||
495 | }; | ||
496 | $scope.hojaRuta.cotizacion = { | ||
497 | ID: cotizacion.ID, | ||
498 | COTIZACION: cotizacion.COTIZACION, | ||
499 | FECHA: cotizacion.FECHA | ||
500 | }; | ||
501 | addCabecera('Moneda:', moneda.DETALLE); | ||
502 | addCabecera( | ||
503 | 'Fecha cotizacion:', | ||
504 | $filter('date')(cotizacion.FECHA, 'dd/MM/yyyy') | ||
505 | ); | ||
506 | addCabecera('Cotizacion:', cotizacion.COTIZACION); | ||
507 | }, function() { | ||
508 | |||
509 | } | ||
510 | ); | ||
511 | }; | ||
512 | |||
513 | $scope.agregarATabla = function(key) { | ||
514 | if(key === 13) { | ||
515 | if($scope.articuloACargar.cantidad === undefined || | ||
516 | $scope.articuloACargar.cantidad === 0 || | ||
517 | $scope.articuloACargar.cantidad === null ){ | ||
518 | focaModalService.alert('El valor debe ser al menos 1'); | ||
519 | return; | ||
520 | } | ||
521 | delete $scope.articuloACargar.sectorCodigo; | ||
522 | console.info($scope.articuloACargar); | ||
523 | $scope.articulosTabla.push($scope.articuloACargar); | ||
524 | $scope.cargando = true; | ||
525 | } | ||
526 | }; | ||
527 | |||
528 | $scope.quitarArticulo = function(key) { | ||
529 | $scope.articulosTabla.splice(key, 1); | ||
530 | }; | ||
531 | |||
532 | $scope.editarArticulo = function(key, articulo) { | ||
533 | if(key === 13) { | ||
534 | if(articulo.cantidad === null || articulo.cantidad === 0 || | ||
535 | articulo.cantidad === undefined){ | ||
536 | focaModalService.alert('El valor debe ser al menos 1'); | ||
537 | return; | ||
538 | } | ||
539 | articulo.editCantidad = false; | ||
540 | articulo.editPrecio = false; | ||
541 | } | ||
542 | }; | ||
543 | |||
544 | $scope.cambioEdit = function(articulo, propiedad) { | ||
545 | if(propiedad === 'cantidad') { | ||
546 | articulo.editCantidad = true; | ||
547 | } else if(propiedad === 'precio') { | ||
548 | articulo.editPrecio = true; | ||
549 | } | ||
550 | }; | ||
551 | |||
552 | $scope.limpiarFlete = function() { | ||
553 | $scope.hojaRuta.fleteNombre = ''; | ||
554 | $scope.hojaRuta.chofer = ''; | ||
555 | $scope.hojaRuta.vehiculo = ''; | ||
556 | $scope.hojaRuta.kilometros = ''; | ||
557 | $scope.hojaRuta.costoUnitarioKmFlete = ''; | ||
558 | $scope.choferes = ''; | ||
559 | $scope.vehiculos = ''; | ||
560 | }; | ||
561 | |||
562 | $scope.limpiarPantalla = function() { | ||
563 | $scope.limpiarFlete(); | ||
564 | $scope.hojaRuta.flete = '0'; | ||
565 | $scope.hojaRuta.bomba = '0'; | ||
566 | $scope.hojaRuta.precioCondicion = ''; | ||
567 | $scope.articulosTabla = []; | ||
568 | $scope.hojaRuta.vendedor.nombre = ''; | ||
569 | $scope.hojaRuta.cliente = {nombre: ''}; | ||
570 | $scope.hojaRuta.domicilio = {dom: ''}; | ||
571 | $scope.domiciliosCliente = []; | ||
572 | }; | ||
573 | |||
574 | $scope.resetFilter = function() { | ||
575 | $scope.articuloACargar = {}; | ||
576 | $scope.cargando = true; | ||
577 | }; | ||
578 | //Recibe aviso si el teclado está en uso | ||
579 | // $rootScope.$on('usarTeclado', function(event, data) { | ||
580 | // if(data) { | ||
581 | // $scope.mostrarTeclado = true; | ||
582 | // return; | ||
583 | // } | ||
584 | // $scope.mostrarTeclado = false; | ||
585 | // }) | ||
586 | $scope.selectFocus = function($event) { | ||
587 | //Si el teclado esta en uso no selecciona el valor | ||
588 | // if($scope.mostrarTeclado) { | ||
589 | // return; | ||
590 | // } | ||
591 | $event.target.select(); | ||
592 | }; | ||
593 | |||
594 | $scope.salir = function() { | ||
595 | $location.path('/'); | ||
596 | }; | ||
597 | |||
598 | $scope.parsearATexto = function(articulo) { | ||
599 | articulo.cantidad = parseFloat(articulo.cantidad); | ||
600 | articulo.precio = parseFloat(articulo.precio); | ||
601 | }; | ||
602 | |||
603 | function addCabecera(label, valor) { | ||
604 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | ||
605 | if(propiedad.length === 1) { | ||
606 | propiedad[0].valor = valor; | ||
607 | } else { | ||
608 | $scope.cabecera.push({label: label, valor: valor}); | ||
609 | } | ||
610 | } | ||
611 | |||
612 | function removeCabecera(label) { | ||
613 | var propiedad = $filter('filter')($scope.cabecera, {label: label}, true); | ||
614 | if(propiedad.length === 1){ | ||
615 | $scope.cabecera.splice($scope.cabecera.indexOf(propiedad[0]), 1); | ||
616 | } | ||
617 | } | ||
618 | |||
619 | function rellenar(relleno, longitud) { | ||
620 | relleno = '' + relleno; | ||
621 | while (relleno.length < longitud) { | ||
622 | relleno = '0' + relleno; | ||
623 | } | ||
624 | |||
625 | return relleno; | ||
626 | } | ||
627 | } | ||
628 | ] | ||
629 | ) | ||
630 | .controller('hojaRutaListaCtrl', [ | ||
631 | '$scope', | ||
632 | 'crearHojaRutaService', | ||
633 | '$location', | ||
634 | function($scope, crearHojaRutaService, $location) { | ||
635 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | ||
636 | $scope.hojaRutas = datos.data; | ||
637 | }); | ||
638 | $scope.editar = function(hojaRuta) { | ||
639 | crearHojaRutaService.setHojaRuta(hojaRuta); | ||
640 | $location.path('/venta-nota-pedido/abm/'); | ||
641 | }; | ||
642 | $scope.crearPedido = function() { | ||
643 | crearHojaRutaService.clearHojaRuta(); | ||
644 | $location.path('/venta-nota-pedido/abm/'); | ||
645 | }; | ||
646 | } | ||
647 | ]) | ||
648 | .controller('focaCrearHojaRutaFichaClienteController', [ | ||
649 | '$scope', | ||
650 | 'crearHojaRutaService', | ||
651 | '$location', | ||
652 | function($scope, crearHojaRutaService, $location) { | ||
653 | crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | ||
654 | $scope.hojaRutas = datos.data; | ||
655 | }); | ||
656 | $scope.editar = function(hojaRuta) { | ||
657 | crearHojaRutaService.setHojaRuta(hojaRuta); | ||
658 | $location.path('/venta-nota-pedido/abm/'); | ||
659 | }; | ||
660 | $scope.crearPedido = function() { | ||
661 | crearHojaRutaService.clearHojaRuta(); | ||
662 | $location.path('/venta-nota-pedido/abm/'); | ||
663 | }; | ||
664 | } | ||
665 | ]); | ||
666 |
src/js/route.js
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .config(['$routeProvider', function($routeProvider) { | ||
3 | $routeProvider.when('/venta-hoja-ruta/crear', { | ||
4 | controller: 'hojaRutaCtrl', | ||
5 | templateUrl: 'src/views/hoja-ruta.html' | ||
6 | }); | ||
7 | }]); | ||
8 |
src/js/service.js
File was created | 1 | angular.module('focaCrearHojaRuta') | |
2 | .service('crearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | ||
3 | var route = API_ENDPOINT.URL; | ||
4 | return { | ||
5 | crearHojaRuta: function(hojaRuta) { | ||
6 | return $http.post(route + '/nota-pedido', {hojaRuta: hojaRuta}); | ||
7 | }, | ||
8 | obtenerHojaRuta: function() { | ||
9 | return $http.get(route +'/nota-pedido'); | ||
10 | }, | ||
11 | setHojaRuta: function(hojaRuta) { | ||
12 | this.hojaRuta = hojaRuta; | ||
13 | }, | ||
14 | clearHojaRuta: function() { | ||
15 | this.hojaRuta = undefined; | ||
16 | }, | ||
17 | getHojaRuta: function() { | ||
18 | return this.hojaRuta; | ||
19 | }, | ||
20 | getArticulosByIdHojaRuta: function(id) { | ||
21 | return $http.get(route+'/articulos/nota-pedido/'+id); | ||
22 | }, | ||
23 | crearArticulosParaHojaRuta: function(articuloHojaRuta) { | ||
24 | return $http.post(route + '/articulos/nota-pedido', | ||
25 | {articuloHojaRuta: articuloHojaRuta}); | ||
26 | }, | ||
27 | getDomiciliosByIdHojaRuta: function(id) { | ||
28 | return $http.get(route +'/nota-pedido/'+id+'/domicilios'); | ||
29 | }, | ||
30 | getDomiciliosByIdCliente: function(id) { | ||
31 | var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) | ||
32 | return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); | ||
33 | }, | ||
34 | getPrecioCondicion: function() { | ||
35 | return $http.get(route + '/precio-condicion'); | ||
36 | }, | ||
37 | getPrecioCondicionById: function(id) { | ||
38 | return $http.get(route + '/precio-condicion/' + id); | ||
39 | }, | ||
40 | getPlazoPagoByPrecioCondicion: function(id) { | ||
41 | return $http.get(route + '/plazo-pago/precio-condicion/'+ id); | ||
42 | }, | ||
43 | crearFlete: function(flete) { | ||
44 | return $http.post(route + '/flete', {flete : flete}); | ||
45 | }, | ||
46 | crearPlazosParaHojaRuta: function(plazos) { | ||
47 | return $http.post(route + '/plazo-pago/nota-pedido', plazos); | ||
48 | }, | ||
49 | getCotizacionByIdMoneda: function(id) { | ||
50 | return $http.get(route + '/moneda/' + id); | ||
51 | }, | ||
52 | crearEstadoParaHojaRuta: function(estado) { | ||
53 | return $http.post(route + '/estado', {estado: estado}); | ||
54 | }, | ||
55 | getNumeroHojaRuta: function() { | ||
56 | return $http.get(route + '/nota-pedido/numero-siguiente'); | ||
57 | } | ||
58 | }; | ||
59 | }]); | ||
60 |
src/views/hoja-ruta.html
File was created | 1 | <div class="crear-nota-pedido"> | |
2 | <form name="formCrearNota" ng-submit="crearNotaPedido()" class="mb-0"> | ||
3 | <div class="row"> | ||
4 | <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2"> | ||
5 | <div class="row p-1 panel-informativo"> | ||
6 | <div class="col-12"> | ||
7 | <div class="row"> | ||
8 | <div class="col-12 col-sm-4 nota-pedido"> | ||
9 | <h5>HOJA RUTA</h5> | ||
10 | </div> | ||
11 | <div class="col-5 col-sm-4 numero-pedido" | ||
12 | >Nº {{puntoVenta}}-{{comprobante}} | ||
13 | </div> | ||
14 | <div class="col-7 col-sm-4 text-right"> | ||
15 | Fecha: | ||
16 | <span | ||
17 | ng-show="!datepickerAbierto" | ||
18 | ng-bind="now | date:'dd/MM/yyyy HH:mm'" | ||
19 | ng-click="datepickerAbierto = true" | ||
20 | > | ||
21 | </span> | ||
22 | <input | ||
23 | ng-show="datepickerAbierto" | ||
24 | type="date" | ||
25 | ng-model="now" | ||
26 | ng-change="datepickerAbierto = false" | ||
27 | ng-blur="datepickerAbierto = false" | ||
28 | class="form-control form-control-sm col-8 float-right" | ||
29 | foca-focus="datepickerAbierto" | ||
30 | hasta-hoy | ||
31 | /> | ||
32 | </div> | ||
33 | </div> | ||
34 | <div class="row"> | ||
35 | <div class="col-auto" ng-repeat="cab in cabecera" ng-show="showCabecera"> | ||
36 | <span class="label" ng-bind="cab.label"></span> | ||
37 | <span class="valor" ng-bind="cab.valor"></span> | ||
38 | </div> | ||
39 | <a | ||
40 | class="btn col-12 btn-secondary d-sm-none" | ||
41 | ng-show="cabecera.length > 0" | ||
42 | ng-click="showCabecera = !showCabecera" | ||
43 | > | ||
44 | <i | ||
45 | class="fa fa-chevron-down" | ||
46 | ng-hide="showCabecera" | ||
47 | aria-hidden="true" | ||
48 | > | ||
49 | </i> | ||
50 | <i | ||
51 | class="fa fa-chevron-up" | ||
52 | ng-show="showCabecera" | ||
53 | aria-hidden="true"> | ||
54 | </i> | ||
55 | </a> | ||
56 | </div> | ||
57 | </div> | ||
58 | </div> | ||
59 | <div class="row p-1 botonera-secundaria"> | ||
60 | <div class="col-12"> | ||
61 | <div class="row"> | ||
62 | <div class="col-6 col-sm-3 px-0 py-0" ng-repeat="boton in botonera"> | ||
63 | <button | ||
64 | type="button" | ||
65 | class="btn btn-default btn-block btn-xs text-left py-2" | ||
66 | ng-click="boton.accion()" | ||
67 | ng-class="{'d-none d-sm-block': boton.texto == ''}" | ||
68 | > | ||
69 | <i | ||
70 | class="fa fa-arrow-circle-right" | ||
71 | ng-show="boton.texto != ''" | ||
72 | ></i> | ||
73 | | ||
74 | {{boton.texto}} | ||
75 | </button> | ||
76 | </div> | ||
77 | </div> | ||
78 | </div> | ||
79 | </div> | ||
80 | </div> | ||
81 | </div> | ||
82 | </form> | ||
83 | <div class="row"> | ||
84 | <div class="col-12 col-md-10 col-lg-8 offset-md-1 offset-lg-2"> | ||
85 | <!-- PC --> | ||
86 | <div class="row grilla-articulo align-items-end d-none d-sm-flex"> | ||
87 | <table class="table tabla-articulo table-striped table-sm table-dark"> | ||
88 | <thead> | ||
89 | <tr class="d-flex"> | ||
90 | <th class="">#</th> | ||
91 | <th class="col">Código</th> | ||
92 | <th class="col-4">Descripción</th> | ||
93 | <th class="col text-right">Cantidad</th> | ||
94 | <th class="col text-right">Precio Unitario</th> | ||
95 | <th class="col text-right">SubTotal</th> | ||
96 | <th class="text-right"> | ||
97 | <button | ||
98 | class="btn btn-outline-secondary selectable" | ||
99 | ng-click="show = !show; masMenos()" | ||
100 | > | ||
101 | <i | ||
102 | class="fa fa-chevron-down" | ||
103 | ng-show="show" | ||
104 | aria-hidden="true" | ||
105 | > | ||
106 | </i> | ||
107 | <i | ||
108 | class="fa fa-chevron-up" | ||
109 | ng-hide="show" | ||
110 | aria-hidden="true"> | ||
111 | </i> | ||
112 | </button> | ||
113 | </th> | ||
114 | </tr> | ||
115 | </thead> | ||
116 | <tbody class="tabla-articulo-body"> | ||
117 | <tr | ||
118 | ng-repeat="(key, articulo) in articulosTabla" | ||
119 | ng-show="show || key == (articulosTabla.length - 1)" | ||
120 | class="d-flex" | ||
121 | > | ||
122 | <td ng-bind="key + 1"></td> | ||
123 | <td | ||
124 | class="col" | ||
125 | ng-bind="articulo.sector + '-' + articulo.codigo" | ||
126 | ></td> | ||
127 | <td | ||
128 | class="col-4" | ||
129 | ng-bind="articulo.descripcion" | ||
130 | ></td> | ||
131 | <td class="col text-right"> | ||
132 | <input | ||
133 | ng-show="articulo.editCantidad" | ||
134 | ng-model="articulo.cantidad" | ||
135 | class="form-control" | ||
136 | type="number" | ||
137 | min="1" | ||
138 | foca-focus="articulo.editCantidad" | ||
139 | ng-keypress="editarArticulo($event.keyCode, articulo)" | ||
140 | ng-focus="selectFocus($event)" | ||
141 | teclado-virtual | ||
142 | > | ||
143 | <i | ||
144 | class="selectable" | ||
145 | ng-click="cambioEdit(articulo, 'cantidad')" | ||
146 | ng-hide="articulo.editCantidad" | ||
147 | ng-bind="articulo.cantidad"> | ||
148 | </i> | ||
149 | </td> | ||
150 | <td class="col text-right"> | ||
151 | <input | ||
152 | ng-show="articulo.editPrecio" | ||
153 | ng-model="articulo.precio" | ||
154 | class="form-control" | ||
155 | type="number" | ||
156 | min="0" | ||
157 | step="0.0001" | ||
158 | foca-focus="articulo.editPrecio" | ||
159 | ng-keypress="editarArticulo($event.keyCode, articulo)" | ||
160 | ng-focus="selectFocus($event)" | ||
161 | teclado-virtual | ||
162 | > | ||
163 | <i | ||
164 | class="selectable" | ||
165 | ng-click="idLista == -1 && cambioEdit(articulo, 'precio')" | ||
166 | ng-hide="articulo.editPrecio" | ||
167 | ng-bind="articulo.precio | currency: hojaRuta.moneda.simbolo : 4"> | ||
168 | </i> | ||
169 | </td> | ||
170 | <td | ||
171 | class="col text-right" | ||
172 | ng-bind="(articulo.precio * articulo.cantidad) | currency: hojaRuta.moneda.simbolo"> | ||
173 | </td> | ||
174 | <td class="text-center"> | ||
175 | <button | ||
176 | class="btn btn-outline-secondary" | ||
177 | ng-click="quitarArticulo(key)" | ||
178 | > | ||
179 | <i class="fa fa-trash"></i> | ||
180 | </button> | ||
181 | </td> | ||
182 | </tr> | ||
183 | </tbody> | ||
184 | <tfoot> | ||
185 | <tr ng-show="!cargando" class="d-flex"> | ||
186 | <td | ||
187 | class="align-middle" | ||
188 | ng-bind="articulosTabla.length + 1" | ||
189 | ></td> | ||
190 | <td class="col"> | ||
191 | <input | ||
192 | class="form-control" | ||
193 | ng-model="articuloACargar.sectorCodigo" | ||
194 | readonly | ||
195 | > | ||
196 | </td> | ||
197 | <td class="col-4 tabla-articulo-descripcion"> | ||
198 | <input | ||
199 | class="form-control" | ||
200 | ng-model="articuloACargar.descripcion" | ||
201 | readonly | ||
202 | > | ||
203 | </td> | ||
204 | <td class="col text-right"> | ||
205 | <input | ||
206 | class="form-control" | ||
207 | type="number" | ||
208 | min="1" | ||
209 | ng-model="articuloACargar.cantidad" | ||
210 | foca-focus="!cargando" | ||
211 | esc-key="resetFilter()" | ||
212 | ng-keypress="agregarATabla($event.keyCode)" | ||
213 | ng-blur="parsearATexto(articuloACargar)" | ||
214 | teclado-virtual | ||
215 | > | ||
216 | </td> | ||
217 | <td class="col text-right"> | ||
218 | <input | ||
219 | class="form-control" | ||
220 | ng-value="articuloACargar.precio | currency: hojaRuta.moneda.simbolo : 4" | ||
221 | ng-show="idLista != -1" | ||
222 | readonly | ||
223 | > | ||
224 | <input | ||
225 | class="form-control" | ||
226 | type="number" | ||
227 | min="0" | ||
228 | step="0.0001" | ||
229 | ng-model="articuloACargar.precio" | ||
230 | esc-key="resetFilter()" | ||
231 | ng-keypress="agregarATabla($event.keyCode)" | ||
232 | ng-show="idLista == -1" | ||
233 | teclado-virtual | ||
234 | > | ||
235 | </td> | ||
236 | <td class="col text-right"> | ||
237 | <input | ||
238 | class="form-control" | ||
239 | ng-value="getSubTotal() | currency: hojaRuta.moneda.simbolo" | ||
240 | readonly | ||
241 | ></td> | ||
242 | <td class="text-center align-middle"> | ||
243 | <button | ||
244 | class="btn btn-outline-secondary" | ||
245 | ng-click="agregarATabla(13)" | ||
246 | > | ||
247 | <i class="fa fa-save"></i> | ||
248 | </button> | ||
249 | </td> | ||
250 | </tr> | ||
251 | <tr ng-show="cargando" class="d-flex"> | ||
252 | <td colspan="7" class="col-12"> | ||
253 | <input | ||
254 | placeholder="Seleccione Articulo" | ||
255 | class="form-control form-control-sm" | ||
256 | readonly | ||
257 | ng-click="seleccionarArticulo()" | ||
258 | /> | ||
259 | </td> | ||
260 | </tr> | ||
261 | <tr class="d-flex"> | ||
262 | <td colspan="4" class="no-border-top"> | ||
263 | <strong>Items:</strong> | ||
264 | <a ng-bind="articulosTabla.length"></a> | ||
265 | </td> | ||
266 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
267 | <h3>Total:</h3> | ||
268 | </td> | ||
269 | <td class="table-celda-total text-right no-border-top" colspan="1"> | ||
270 | <h3>{{getTotal() | currency: hojaRuta.moneda.simbolo}}</h3> | ||
271 | </td> | ||
272 | <td class="text-right no-border-top"> | ||
273 | <button | ||
274 | type="button" | ||
275 | class="btn btn-default btn-sm" | ||
276 | > | ||
277 | Totales | ||
278 | </button> | ||
279 | </td> | ||
280 | </tr> | ||
281 | </tfoot> | ||
282 | </table> | ||
283 | </div> | ||
284 | |||
285 | <!-- MOBILE --> | ||
286 | <div class="row d-sm-none"> | ||
287 | <table class="table table-sm table-striped table-dark margin-bottom-mobile"> | ||
288 | <thead> | ||
289 | <tr class="d-flex"> | ||
290 | <th class="">#</th> | ||
291 | <th class="col px-0"> | ||
292 | <div class="d-flex"> | ||
293 | <div class="col-4 px-1">Código</div> | ||
294 | <div class="col-8 px-1">Descripción</div> | ||
295 | </div> | ||
296 | <div class="d-flex"> | ||
297 | <div class="col-3 px-1">Cantidad</div> | ||
298 | <div class="col px-1 text-right">P. Uni.</div> | ||
299 | <div class="col px-1 text-right">Subtotal</div> | ||
300 | </div> | ||
301 | </th> | ||
302 | <th class="text-center tamaño-boton"> | ||
303 | | ||
304 | </th> | ||
305 | </tr> | ||
306 | </thead> | ||
307 | <tbody> | ||
308 | <tr | ||
309 | ng-repeat="(key, articulo) in articulosTabla" | ||
310 | ng-show="show || key == articulosTabla.length - 1" | ||
311 | > | ||
312 | <td class="w-100 align-middle d-flex p-0"> | ||
313 | <div class="align-middle p-1"> | ||
314 | <span ng-bind="key+1" class="align-middle"></span> | ||
315 | </div> | ||
316 | <div class="col px-0"> | ||
317 | <div class="d-flex"> | ||
318 | <div class="col-4 px-1"> | ||
319 | <span | ||
320 | ng-bind="articulo.sector + '-' + articulo.codigo" | ||
321 | ></span> | ||
322 | </div> | ||
323 | <div class="col-8 px-1"> | ||
324 | <span ng-bind="articulo.descripcion"></span> | ||
325 | </div> | ||
326 | </div> | ||
327 | <div class="d-flex"> | ||
328 | <div class="col-3 px-1"> | ||
329 | <span ng-bind="'x' + articulo.cantidad"></span> | ||
330 | </div> | ||
331 | <div class="col-3 px-1 text-right"> | ||
332 | <span ng-bind="articulo.precio | currency: hojaRuta.moneda.simbolo : 4"></span> | ||
333 | </div> | ||
334 | <div class="col px-1 text-right"> | ||
335 | <span | ||
336 | ng-bind="(articulo.precio * articulo.cantidad) | currency: hojaRuta.moneda.simbolo" | ||
337 | > | ||
338 | </span> | ||
339 | </div> | ||
340 | </div> | ||
341 | </div> | ||
342 | <div class="align-middle p-1"> | ||
343 | <button | ||
344 | class="btn btn-outline-secondary" | ||
345 | ng-click="quitarArticulo(key)" | ||
346 | > | ||
347 | <i class="fa fa-trash"></i> | ||
348 | </button> | ||
349 | </div> | ||
350 | </td> | ||
351 | </tr> | ||
352 | </tbody> | ||
353 | <tfoot> | ||
354 | <!-- CARGANDO ITEM --> | ||
355 | <tr ng-show="!cargando" class="d-flex"> | ||
356 | <td | ||
357 | class="align-middle p-1" | ||
358 | ng-bind="articulosTabla.length + 1" | ||
359 | ></td> | ||
360 | <td class="col p-0"> | ||
361 | <div class="d-flex"> | ||
362 | <div class="col-4 px-1"> | ||
363 | <span | ||
364 | ng-bind="articuloACargar.sectorCodigo" | ||
365 | ></span> | ||
366 | </div> | ||
367 | <div class="col-8 px-1"> | ||
368 | <span ng-bind="articuloACargar.descripcion"></span> | ||
369 | </div> | ||
370 | </div> | ||
371 | <div class="d-flex"> | ||
372 | <div class="col-3 px-1 m-1"> | ||
373 | <input | ||
374 | class="form-control p-1" | ||
375 | type="number" | ||
376 | min="1" | ||
377 | ng-model="articuloACargar.cantidad" | ||
378 | foca-focus="!cargando" | ||
379 | ng-keypress="agregarATabla($event.keyCode)" | ||
380 | style="height: auto; line-height: 1.1em" | ||
381 | > | ||
382 | </div> | ||
383 | <div class="col-3 px-1 text-right"> | ||
384 | <span ng-bind="articuloACargar.precio | currency: hojaRuta.moneda.simbolo : 4"></span> | ||
385 | </div> | ||
386 | <div class="col px-1 text-right"> | ||
387 | <span | ||
388 | ng-bind="getSubTotal() | currency: hojaRuta.moneda.simbolo" | ||
389 | > | ||
390 | </span> | ||
391 | </div> | ||
392 | </div> | ||
393 | </td> | ||
394 | <td class="text-center align-middle"> | ||
395 | <button | ||
396 | class="btn btn-outline-secondary" | ||
397 | ng-click="agregarATabla(13)" | ||
398 | > | ||
399 | <i class="fa fa-save"></i> | ||
400 | </button> | ||
401 | </td> | ||
402 | </tr> | ||
403 | <!-- SELECCIONAR PRODUCTO --> | ||
404 | <tr ng-show="cargando" class="d-flex"> | ||
405 | <td class="col-12"> | ||
406 | <input | ||
407 | placeholder="Seleccione Articulo" | ||
408 | class="form-control form-control-sm" | ||
409 | readonly | ||
410 | ng-click="seleccionarArticulo()" | ||
411 | /> | ||
412 | </td> | ||
413 | </tr> | ||
414 | <!-- TOOGLE EXPANDIR --> | ||
415 | <tr> | ||
416 | <td class="col"> | ||
417 | <button | ||
418 | class="btn btn-outline-secondary selectable w-100" | ||
419 | ng-click="show = !show; masMenos()" | ||
420 | ng-show="articulosTabla.length > 0" | ||
421 | > | ||
422 | <i | ||
423 | class="fa fa-chevron-down" | ||
424 | ng-hide="show" | ||
425 | aria-hidden="true" | ||
426 | > | ||
427 | </i> | ||
428 | <i | ||
429 | class="fa fa-chevron-up" | ||
430 | ng-show="show" | ||
431 | aria-hidden="true"> | ||
432 | </i> | ||
433 | </button> | ||
434 | </td> | ||
435 | </tr> | ||
436 | <!-- FOOTER --> | ||
437 | <tr class="d-flex"> | ||
438 | <td class="align-middle no-border-top" colspan="2"> | ||
439 | <strong>Cantidad Items:</strong> | ||
440 | <a ng-bind="articulosTabla.length"></a> | ||
441 | </td> | ||
442 | <td class="text-right ml-auto table-celda-total no-border-top"> | ||
443 | <h3>Total:</h3> | ||
444 | </td> | ||
445 | <td class="table-celda-total text-right no-border-top"> | ||
446 | <h3>{{getTotal() | currency: hojaRuta.moneda.simbolo}}</h3> | ||
447 | </td> | ||
448 | </tr> | ||
449 | </tfoot> | ||
450 | </table> | ||
451 | </div> | ||
452 | </div> | ||
453 | <div class="col-auto my-2 col-lg-2 botonera-lateral d-none d-md-block"> | ||
454 | <div class="row align-items-end"> | ||
455 | <div class="col-12"> | ||
456 | <button | ||
457 | ng-click="crearNotaPedido()" | ||
458 | type="submit" | ||
459 | title="Crear nota pedido" | ||
460 | class="btn btn-default btn-block mb-2"> | ||
461 | Guardar | ||
462 | </button> | ||
463 | <button | ||
464 | ng-click="salir()" | ||
465 | type="button" | ||
466 | title="Salir" | ||
467 | class="btn btn-default btn-block"> | ||
468 | Salir | ||
469 | </button> | ||
470 | </div> | ||
471 | </div> | ||
472 | </div> | ||
473 | </div> | ||
474 | <div class="row d-md-none fixed-bottom"> | ||
475 | <div class="w-100 bg-dark d-flex px-3 acciones-mobile"> | ||
476 | <span class="ml-3 text-muted" ng-click="salir()">Salir</span> | ||
477 | <span class="mr-3 ml-auto" ng-click="crearNotaPedido()">Guardar</span> | ||
478 | </div> | ||
479 | </div> | ||
480 | </div> | ||
481 |