Commit e9d59a290007f83a57079f059cb525a4bc48bad5
Exists in
master
and in
1 other branch
Merge remote-tracking branch 'upstream/master'
Showing
8 changed files
Show diff stats
gulpfile.js
| 1 | const templateCache = require('gulp-angular-templatecache'); | 1 | const templateCache = require('gulp-angular-templatecache'); |
| 2 | const clean = require('gulp-clean'); | 2 | const clean = require('gulp-clean'); |
| 3 | const concat = require('gulp-concat'); | 3 | const concat = require('gulp-concat'); |
| 4 | const htmlmin = require('gulp-htmlmin'); | 4 | const htmlmin = require('gulp-htmlmin'); |
| 5 | const rename = require('gulp-rename'); | 5 | const rename = require('gulp-rename'); |
| 6 | const uglify = require('gulp-uglify'); | 6 | const uglify = require('gulp-uglify'); |
| 7 | const gulp = require('gulp'); | 7 | const gulp = require('gulp'); |
| 8 | const pump = require('pump'); | 8 | const pump = require('pump'); |
| 9 | const jshint = require('gulp-jshint'); | 9 | const jshint = require('gulp-jshint'); |
| 10 | const replace = require('gulp-replace'); | 10 | const replace = require('gulp-replace'); |
| 11 | const connect = require('gulp-connect'); | 11 | const connect = require('gulp-connect'); |
| 12 | 12 | ||
| 13 | var paths = { | 13 | var paths = { |
| 14 | srcJS: 'src/js/*.js', | 14 | srcJS: 'src/js/*.js', |
| 15 | srcViews: 'src/views/*.html', | 15 | srcViews: 'src/views/*.html', |
| 16 | tmp: 'tmp', | 16 | tmp: 'tmp', |
| 17 | dist: 'dist/' | 17 | dist: 'dist/' |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | gulp.task('templates', ['clean'], function() { | 20 | gulp.task('templates', ['clean'], function() { |
| 21 | return pump( | 21 | return pump( |
| 22 | [ | 22 | [ |
| 23 | gulp.src(paths.srcViews), | 23 | gulp.src(paths.srcViews), |
| 24 | htmlmin(), | 24 | htmlmin(), |
| 25 | templateCache('views.js', { | 25 | templateCache('views.js', { |
| 26 | module: 'focaLogisticaPedidoRuta', | 26 | module: 'focaLogisticaPedidoRuta', |
| 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-logistica-pedido-ruta.js'), | 41 | concat('foca-logistica-pedido-ruta.js'), |
| 42 | replace('src/views/', ''), | 42 | replace('src/views/', ''), |
| 43 | gulp.dest(paths.tmp), | 43 | gulp.dest(paths.tmp), |
| 44 | rename('foca-logistica-pedido-ruta.min.js'), | 44 | rename('foca-logistica-pedido-ruta.min.js'), |
| 45 | uglify(), | 45 | uglify(), |
| 46 | replace('"ngRoute","ui.bootstrap"', ''), | ||
| 47 | gulp.dest(paths.dist) | 46 | gulp.dest(paths.dist) |
| 48 | ] | 47 | ] |
| 49 | ); | 48 | ); |
| 50 | }); | 49 | }); |
| 51 | 50 | ||
| 52 | gulp.task('clean', function(){ | 51 | gulp.task('clean', function(){ |
| 53 | return gulp.src(['tmp', 'dist'], {read: false}) | 52 | return gulp.src(['tmp', 'dist'], {read: false}) |
| 54 | .pipe(clean()); | 53 | .pipe(clean()); |
| 55 | }); | 54 | }); |
| 56 | 55 | ||
| 57 | gulp.task('pre-commit', function() { | 56 | gulp.task('pre-commit', function() { |
| 58 | return pump( | 57 | return pump( |
| 59 | [ | 58 | [ |
| 60 | gulp.src(paths.srcJS), | 59 | gulp.src(paths.srcJS), |
| 61 | jshint('.jshintrc'), | 60 | jshint('.jshintrc'), |
| 62 | jshint.reporter('default'), | 61 | jshint.reporter('default'), |
| 63 | jshint.reporter('fail') | 62 | jshint.reporter('fail') |
| 64 | ] | 63 | ] |
| 65 | ); | 64 | ); |
| 66 | 65 | ||
| 67 | gulp.start('uglify'); | 66 | gulp.start('uglify'); |
| 68 | }); | 67 | }); |
| 69 | 68 | ||
| 70 | gulp.task('webserver', function() { | 69 | gulp.task('webserver', function() { |
| 71 | pump [ | 70 | pump [ |
| 72 | connect.server({port: 3300, host: '0.0.0.0'}) | 71 | connect.server({port: 3300, host: '0.0.0.0'}) |
| 73 | ] | 72 | ] |
| 74 | }); | 73 | }); |
| 75 | 74 | ||
| 76 | gulp.task('clean-post-install', function() { | 75 | gulp.task('clean-post-install', function() { |
| 77 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', | 76 | return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', |
| 78 | 'index.html'], {read: false}) | 77 | 'index.html'], {read: false}) |
| 79 | .pipe(clean()); | 78 | .pipe(clean()); |
| 80 | }); | 79 | }); |
| 81 | 80 | ||
| 82 | gulp.task('default', ['webserver']); | 81 | gulp.task('default', ['webserver']); |
| 83 | 82 | ||
| 84 | gulp.task('watch', function() { | 83 | gulp.task('watch', function() { |
| 85 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); | 84 | gulp.watch([paths.srcJS, paths.srcViews], ['uglify']); |
| 86 | }); | 85 | }); |
| 87 | 86 |
src/js/app.js
| 1 | angular.module('focaLogisticaPedidoRuta', [ | 1 | angular.module('focaLogisticaPedidoRuta', []); |
| 2 | 'ngRoute', | ||
| 3 | 'ui.bootstrap' | ||
| 4 | ]); | ||
| 5 | 2 |
src/js/controller.js
| 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ |
| 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
| 3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', | 3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', |
| 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
| 5 | focaModalService, focaBotoneraLateralService, $interval | 5 | focaModalService, focaBotoneraLateralService, $interval |
| 6 | ) { | 6 | ) { |
| 7 | $scope.actividad = 'Logistica'; | 7 | $scope.actividad = 'Logistica'; |
| 8 | 8 | ||
| 9 | //Datos Pantalla | 9 | //Datos Pantalla |
| 10 | $scope.titulo = 'Logistica de Pedidos'; | 10 | $scope.titulo = 'Logistica de Pedidos'; |
| 11 | var transportista = { | 11 | var transportista = { |
| 12 | label: 'Vehículo', | 12 | label: 'Vehículo', |
| 13 | image: 'abmChofer.png' | 13 | image: 'abmChofer.png' |
| 14 | }; | 14 | }; |
| 15 | var fecha = { | 15 | var fecha = { |
| 16 | label: 'Fecha Reparto', | 16 | label: 'Fecha Reparto', |
| 17 | image: 'fechaDeReparto.png' | 17 | image: 'fechaDeReparto.png' |
| 18 | }; | 18 | }; |
| 19 | $scope.botonera = [fecha, transportista]; | 19 | $scope.botonera = [fecha, transportista]; |
| 20 | var cabecera = ''; | 20 | var cabecera = ''; |
| 21 | $scope.now = new Date(); | 21 | $scope.now = new Date(); |
| 22 | $scope.idVendedor = 0; | 22 | $scope.idVendedor = 0; |
| 23 | $scope.marcadores = []; | 23 | $scope.marcadores = []; |
| 24 | $scope.vehiculos = []; | 24 | $scope.vehiculos = []; |
| 25 | getSeguimiento(); | 25 | getSeguimiento(); |
| 26 | $scope.arrastrando = false; | 26 | $scope.arrastrando = false; |
| 27 | $scope.general = function() { | 27 | $scope.general = function() { |
| 28 | $scope.idVendedor = 0; | 28 | $scope.idVendedor = 0; |
| 29 | getSeguimiento(); | 29 | getSeguimiento(); |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | //SETEO BOTONERA LATERAL | 32 | //SETEO BOTONERA LATERAL |
| 33 | focaBotoneraLateralService.showSalir(true); | 33 | focaBotoneraLateralService.showSalir(true); |
| 34 | focaBotoneraLateralService.showPausar(false); | 34 | focaBotoneraLateralService.showPausar(false); |
| 35 | focaBotoneraLateralService.showGuardar(false); | 35 | focaBotoneraLateralService.showGuardar(false); |
| 36 | 36 | ||
| 37 | $scope.general = function() { | 37 | $scope.general = function() { |
| 38 | $scope.idVendedor = 0; | 38 | $scope.idVendedor = 0; |
| 39 | getSeguimiento(); | 39 | getSeguimiento(); |
| 40 | $scope.$broadcast('removeCabecera', cabecera); | 40 | $scope.$broadcast('removeCabecera', cabecera); |
| 41 | $scope.$broadcast('addCabecera', { | 41 | $scope.$broadcast('addCabecera', { |
| 42 | label: 'General', | 42 | label: 'General', |
| 43 | valor: '' | 43 | valor: '' |
| 44 | }); | 44 | }); |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | $scope.cargar = function(idVehiculo, punto) { | 47 | $scope.cargar = function(idVehiculo, punto) { |
| 48 | if(!eligioFecha()) return; | 48 | if(!eligioFecha()) return; |
| 49 | var idRemito; | 49 | var idRemito; |
| 50 | if(punto === -1) { | 50 | if(punto === -1) { |
| 51 | idRemito = -1; | 51 | idRemito = -1; |
| 52 | }else { | 52 | }else { |
| 53 | idRemito = JSON.parse(punto).notaPedido.remito.id; | 53 | idRemito = JSON.parse(punto).notaPedido.remito.id; |
| 54 | } | 54 | } |
| 55 | var modalInstance = $uibModal.open( | 55 | var modalInstance = $uibModal.open( |
| 56 | { | 56 | { |
| 57 | ariaLabelledBy: 'Busqueda de Vehiculo', | 57 | ariaLabelledBy: 'Busqueda de Vehiculo', |
| 58 | templateUrl: 'foca-detalle-vehiculo.html', | 58 | templateUrl: 'foca-detalle-vehiculo.html', |
| 59 | controller: 'focaDetalleVehiculo', | 59 | controller: 'focaDetalleVehiculo', |
| 60 | size: 'lg', | 60 | size: 'lg', |
| 61 | resolve: { | 61 | resolve: { |
| 62 | idVehiculo: function() {return idVehiculo;}, | 62 | idVehiculo: function() {return idVehiculo;}, |
| 63 | idRemito: function() {return idRemito;}, | 63 | idRemito: function() {return idRemito;}, |
| 64 | fechaReparto: function() {return $scope.fechaReparto;} | 64 | fechaReparto: function() {return $scope.fechaReparto;} |
| 65 | } | 65 | } |
| 66 | } | 66 | } |
| 67 | ); | 67 | ); |
| 68 | modalInstance.result.then(function() { | 68 | modalInstance.result.then(function() { |
| 69 | }, function() { | 69 | }, function() { |
| 70 | }); | 70 | }); |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | $scope.quitarVehiculo = function(vehiculo) { | 73 | $scope.quitarVehiculo = function(vehiculo) { |
| 74 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 74 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
| 75 | 75 | ||
| 76 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 76 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
| 77 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { | 77 | vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { |
| 78 | eliminarVehiculo(vehiculo); | 78 | eliminarVehiculo(vehiculo); |
| 79 | }); | 79 | }); |
| 80 | }; | 80 | }; |
| 81 | 81 | ||
| 82 | $scope.hacerHojaRuta = function(vehiculo, cerrar) { | 82 | $scope.hacerHojaRuta = function(vehiculo, cerrar) { |
| 83 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; | 83 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
| 84 | var modalInstance = $uibModal.open( | 84 | var modalInstance = $uibModal.open( |
| 85 | { | 85 | { |
| 86 | ariaLabelledBy: 'Creación hoja ruta', | 86 | ariaLabelledBy: 'Creación hoja ruta', |
| 87 | templateUrl: 'foca-modal-cerrar-vehiculo.html', | 87 | templateUrl: 'foca-modal-cerrar-vehiculo.html', |
| 88 | controller: 'focaModalCerrarVehiculo', | 88 | controller: 'focaModalCerrarVehiculo', |
| 89 | size: 'lg', | 89 | size: 'lg', |
| 90 | resolve: { | 90 | resolve: { |
| 91 | idVehiculo: function() {return vehiculo.id;}, | 91 | idVehiculo: function() {return vehiculo.id;}, |
| 92 | fechaReparto: function() {return $scope.fechaReparto;}, | 92 | fechaReparto: function() {return $scope.fechaReparto;}, |
| 93 | cerrar: function() {return cerrar;} | 93 | cerrar: function() {return cerrar;} |
| 94 | } | 94 | } |
| 95 | } | 95 | } |
| 96 | ); | 96 | ); |
| 97 | modalInstance.result.then(function() { | 97 | modalInstance.result.then(function() { |
| 98 | 98 | ||
| 99 | }, function() { | 99 | }, function() { |
| 100 | //usar cuando se cancela el modal | 100 | //usar cuando se cancela el modal |
| 101 | }); | 101 | }); |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | $scope.arrastra = function() { | 104 | $scope.arrastra = function() { |
| 105 | $scope.arrastrando = true; | 105 | $scope.arrastrando = true; |
| 106 | $scope.$digest(); | 106 | $scope.$digest(); |
| 107 | }; | 107 | }; |
| 108 | 108 | ||
| 109 | $scope.noArrastra = function() { | 109 | $scope.noArrastra = function() { |
| 110 | $scope.arrastrando = false; | 110 | $scope.arrastrando = false; |
| 111 | $scope.$digest(); | 111 | $scope.$digest(); |
| 112 | }; | 112 | }; |
| 113 | 113 | ||
| 114 | $scope.individual = function() { | 114 | $scope.individual = function() { |
| 115 | $scope.idVendedor = -1; | 115 | $scope.idVendedor = -1; |
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | $scope.mostrarDetalle = function() { | 118 | $scope.mostrarDetalle = function() { |
| 119 | $scope.detalle = true; | 119 | $scope.detalle = true; |
| 120 | }; | 120 | }; |
| 121 | 121 | ||
| 122 | $scope.salir = function() { | 122 | $scope.salir = function() { |
| 123 | $location.path('/'); | 123 | $location.path('/'); |
| 124 | }; | 124 | }; |
| 125 | 125 | ||
| 126 | $scope.search = function() { | 126 | $scope.search = function() { |
| 127 | getSeguimiento(); | 127 | getSeguimiento(); |
| 128 | }; | 128 | }; |
| 129 | 129 | ||
| 130 | $scope.fecha = function() { | 130 | $scope.fecha = function() { |
| 131 | getSeguimiento(); | 131 | getSeguimiento(); |
| 132 | }; | 132 | }; |
| 133 | 133 | ||
| 134 | $scope.seleccionarVehículo = function() { | 134 | $scope.seleccionarVehículo = function() { |
| 135 | var modalInstance = $uibModal.open( | 135 | var modalInstance = $uibModal.open( |
| 136 | { | 136 | { |
| 137 | ariaLabelledBy: 'Busqueda de Transportista', | 137 | ariaLabelledBy: 'Busqueda de Transportista', |
| 138 | templateUrl: 'modal-proveedor.html', | 138 | templateUrl: 'modal-proveedor.html', |
| 139 | controller: 'focaModalProveedorCtrl', | 139 | controller: 'focaModalProveedorCtrl', |
| 140 | size: 'lg', | 140 | size: 'lg', |
| 141 | resolve: { | 141 | resolve: { |
| 142 | transportista: function() { | 142 | transportista: function() { |
| 143 | return true; | 143 | return true; |
| 144 | } | 144 | } |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | ); | 147 | ); |
| 148 | modalInstance.result.then(function(transportista) { | 148 | modalInstance.result.then(function(transportista) { |
| 149 | $scope.selectVehiculo(transportista.COD); | 149 | $scope.selectVehiculo(transportista.COD, transportista.NOM); |
| 150 | }); | 150 | }); |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | $scope.selectVehiculo = function(idTransportista) { | 153 | $scope.selectVehiculo = function(idTransportista, nombreTransportista) { |
| 154 | var query = '/vehiculo/transportista/' + idTransportista; | 154 | var parametrosModal = { |
| 155 | var columnas = { | 155 | columnas: { |
| 156 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | 156 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
| 157 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | 157 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
| 158 | }, | ||
| 159 | query: '/vehiculo/transportista/' + idTransportista, | ||
| 160 | titulo: 'Búsqueda de vehiculos', | ||
| 161 | subTitulo: idTransportista + '-' + nombreTransportista | ||
| 158 | }; | 162 | }; |
| 159 | var titulo = 'Búsqueda de vehiculos'; | 163 | focaModalService.modal(parametrosModal).then( |
| 160 | focaModalService.modal(columnas, query, titulo).then( | ||
| 161 | function(vehiculo) { | 164 | function(vehiculo) { |
| 162 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 165 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
| 163 | if(existe.length) { | 166 | if(existe.length) { |
| 164 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 167 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
| 165 | return; | 168 | return; |
| 166 | } | 169 | } |
| 167 | if(!vehiculo.cisternas.length) { | 170 | if(!vehiculo.cisternas.length) { |
| 168 | focaModalService.alert('El vehiculo no tiene cisternas'); | 171 | focaModalService.alert('El vehiculo no tiene cisternas'); |
| 169 | return; | 172 | return; |
| 170 | } | 173 | } |
| 171 | $scope.vehiculos.push(vehiculo); | 174 | $scope.vehiculos.push(vehiculo); |
| 172 | }, function() { | 175 | }, function() { |
| 173 | // funcion ejecutada cuando se cancela el modal | 176 | // funcion ejecutada cuando se cancela el modal |
| 174 | }); | 177 | }); |
| 175 | }; | 178 | }; |
| 176 | 179 | ||
| 177 | $scope.seleccionarFechaReparto = function() { | 180 | $scope.seleccionarFechaReparto = function() { |
| 178 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | 181 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { |
| 179 | $scope.$broadcast('addCabecera',{ | 182 | $scope.$broadcast('addCabecera',{ |
| 180 | label: 'Fecha:', | 183 | label: 'Fecha:', |
| 181 | valor: fecha.toLocaleDateString() | 184 | valor: fecha.toLocaleDateString() |
| 182 | }); | 185 | }); |
| 183 | $scope.fechaReparto = fecha; | 186 | $scope.fechaReparto = fecha; |
| 184 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 187 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
| 185 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { | 188 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { |
| 186 | $scope.vehiculos = res.data; | 189 | $scope.vehiculos = res.data; |
| 187 | }); | 190 | }); |
| 188 | }); | 191 | }); |
| 189 | }; | 192 | }; |
| 190 | 193 | ||
| 191 | function getSeguimiento() { | 194 | function getSeguimiento() { |
| 192 | var desde = new Date('1900/01/01'); | 195 | var desde = new Date('1900/01/01'); |
| 193 | var hasta = new Date('2099/01/01'); | 196 | var hasta = new Date('2099/01/01'); |
| 194 | if($scope.fechaDesde) { | 197 | if($scope.fechaDesde) { |
| 195 | var fechaDesde = $scope.fechaDesde; | 198 | var fechaDesde = $scope.fechaDesde; |
| 196 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 199 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
| 197 | desde = new Date(desde); | 200 | desde = new Date(desde); |
| 198 | } | 201 | } |
| 199 | if($scope.fechaHasta) { | 202 | if($scope.fechaHasta) { |
| 200 | var fechaHasta = $scope.fechaHasta; | 203 | var fechaHasta = $scope.fechaHasta; |
| 201 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 204 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
| 202 | hasta = hasta.setDate(hasta.getDate() + 1); | 205 | hasta = hasta.setDate(hasta.getDate() + 1); |
| 203 | hasta = new Date(hasta); | 206 | hasta = new Date(hasta); |
| 204 | } | 207 | } |
| 205 | var datos = { | 208 | var datos = { |
| 206 | actividad: $scope.actividad, | 209 | actividad: $scope.actividad, |
| 207 | idUsuario: $scope.idVendedor, | 210 | idUsuario: $scope.idVendedor, |
| 208 | fechaDesde: desde, | 211 | fechaDesde: desde, |
| 209 | fechaHasta: hasta, | 212 | fechaHasta: hasta, |
| 210 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 213 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
| 211 | false : undefined) | 214 | false : undefined) |
| 212 | }; | 215 | }; |
| 213 | 216 | ||
| 214 | $scope.datosBuscados = { | 217 | $scope.datosBuscados = { |
| 215 | actividad: $scope.actividad, | 218 | actividad: $scope.actividad, |
| 216 | individual: $scope.idVendedor ? true : false | 219 | individual: $scope.idVendedor ? true : false |
| 217 | }; | 220 | }; |
| 218 | 221 | ||
| 219 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 222 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
| 220 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | 223 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { |
| 221 | $scope.marcadores = datos.data; | 224 | $scope.marcadores = datos.data; |
| 222 | } | 225 | } |
| 223 | }); | 226 | }); |
| 224 | } | 227 | } |
| 225 | 228 | ||
| 226 | function eliminarVehiculo(vehiculo) { | 229 | function eliminarVehiculo(vehiculo) { |
| 227 | focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { | 230 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { |
| 228 | if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { | 231 | if(!res.data.length) { |
| 229 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 232 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
| 230 | }else { | 233 | }else { |
| 231 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 234 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
| 232 | 'tiene remitos asociados').then(function() { | 235 | 'tiene remitos asociados').then(function() { |
| 233 | $scope.hacerHojaRuta(vehiculo, true); | 236 | $scope.hacerHojaRuta(vehiculo, true); |
| 234 | }); | 237 | }); |
| 235 | } | 238 | } |
| 236 | }); | 239 | }); |
| 237 | } | 240 | } |
| 238 | 241 | ||
| 239 | function eligioFecha() { | 242 | function eligioFecha() { |
| 240 | if(!$scope.fechaReparto) { | 243 | if(!$scope.fechaReparto) { |
| 241 | focaModalService.alert('Primero seleccione fecha de reparto'); | 244 | focaModalService.alert('Primero seleccione fecha de reparto'); |
| 242 | return false; | 245 | return false; |
| 243 | } | 246 | } |
| 244 | return true; | 247 | return true; |
| 245 | } | 248 | } |
| 246 | 249 | ||
| 247 | function vehiculoEnUso(vehiculo) { | 250 | function vehiculoEnUso(vehiculo) { |
| 248 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | 251 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; |
| 249 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 252 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
| 250 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 253 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
| 251 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 254 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
| 252 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | 255 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto |
| 253 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | 256 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && |
| 254 | cisternaCarga.idUsuarioProceso !== idUsuario) | 257 | cisternaCarga.idUsuarioProceso !== idUsuario) |
| 255 | { | 258 | { |
| 256 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | 259 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); |
| 257 | return true; | 260 | return true; |
| 258 | } | 261 | } |
| 259 | } | 262 | } |
| 260 | } | 263 | } |
| 261 | return false; | 264 | return false; |
| 262 | } | 265 | } |
| 263 | // TODO: descomentar en produccion | 266 | $interval(function() { |
| 264 | // $interval(function() { | 267 | getSeguimiento(); |
| 265 | // getSeguimiento(); | 268 | }, 5000); |
| 266 | // }, 5000); | ||
| 267 | } | 269 | } |
src/js/controllerCerrarVehiculo.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .controller('focaModalCerrarVehiculo', [ | 2 | .controller('focaModalCerrarVehiculo', [ |
| 3 | '$scope', | 3 | '$scope', |
| 4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
| 5 | '$uibModal', | 5 | '$uibModal', |
| 6 | 'focaLogisticaPedidoRutaService', | 6 | 'focaLogisticaPedidoRutaService', |
| 7 | 'idVehiculo', | 7 | 'idVehiculo', |
| 8 | 'focaModalService', | 8 | 'focaModalService', |
| 9 | '$filter', | 9 | '$filter', |
| 10 | 'fechaReparto', | 10 | 'fechaReparto', |
| 11 | 'cerrar', | 11 | 'cerrar', |
| 12 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 12 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
| 13 | idVehiculo, focaModalService, $filter, fechaReparto, cerrar) { | 13 | idVehiculo, focaModalService, $filter, fechaReparto, cerrar) { |
| 14 | $scope.cerrar = cerrar; | 14 | $scope.cerrar = cerrar; |
| 15 | $scope.vehiculo = {}; | 15 | $scope.vehiculo = {}; |
| 16 | $scope.remitos = []; | 16 | $scope.remitos = []; |
| 17 | $scope.now = fechaReparto; | 17 | $scope.now = fechaReparto; |
| 18 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 18 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
| 19 | $scope.vehiculo = res.data; | 19 | $scope.vehiculo = res.data; |
| 20 | }); | 20 | }); |
| 21 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { | 21 | focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(idVehiculo, 1, 1).then( |
| 22 | function(res) { | ||
| 22 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); | 23 | $scope.remitos = res.data; |
| 23 | }); | 24 | }); |
| 24 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 25 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
| 25 | $scope.sucursal = res.data.sucursal; | 26 | $scope.sucursal = res.data.sucursal; |
| 26 | $scope.numero = res.data.numeroHojaRuta; | 27 | $scope.numero = res.data.numeroHojaRuta; |
| 27 | }); | 28 | }); |
| 28 | $scope.cancelar = function() { | 29 | $scope.cancelar = function() { |
| 29 | $uibModalInstance.close(); | 30 | $uibModalInstance.close(); |
| 30 | }; | 31 | }; |
| 31 | $scope.aceptar = function() { | 32 | $scope.aceptar = function() { |
| 32 | var idsRemito = []; | 33 | var idsRemito = []; |
| 33 | $scope.remitos.forEach(function(remito) { | 34 | $scope.remitos.forEach(function(remito) { |
| 34 | idsRemito.push(remito.id); | 35 | idsRemito.push(remito.id); |
| 35 | }); | 36 | }); |
| 36 | var cierreDistribuicion = { | 37 | var cierreDistribuicion = { |
| 37 | idsRemito: idsRemito, | 38 | idsRemito: idsRemito, |
| 38 | fechaReparto: focaLogisticaPedidoRutaService.fecha | 39 | fechaReparto: focaLogisticaPedidoRutaService.fecha |
| 39 | }; | 40 | }; |
| 40 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) | 41 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) |
| 41 | .then(function() { | 42 | .then(function() { |
| 42 | focaModalService.alert('Vehículo cerrado con éxito'); | 43 | focaModalService.alert('Vehículo cerrado con éxito'); |
| 43 | } | 44 | } |
| 44 | ); | 45 | ); |
| 45 | }; | 46 | }; |
| 46 | $scope.seleccionarChofer = function() { | 47 | $scope.seleccionarChofer = function() { |
| 47 | var modalInstance = $uibModal.open( | 48 | var modalInstance = $uibModal.open( |
| 48 | { | 49 | { |
| 49 | ariaLabelledBy: 'Busqueda de Chofer', | 50 | ariaLabelledBy: 'Busqueda de Chofer', |
| 50 | templateUrl: 'modal-chofer.html', | 51 | templateUrl: 'modal-chofer.html', |
| 51 | controller: 'focaModalChoferController', | 52 | controller: 'focaModalChoferController', |
| 52 | size: 'lg' | 53 | size: 'lg' |
| 53 | } | 54 | } |
| 54 | ); | 55 | ); |
| 55 | 56 | ||
| 56 | modalInstance.result.then( | 57 | modalInstance.result.then( |
| 57 | function(chofer) { | 58 | function(chofer) { |
| 58 | $scope.chofer = chofer; | 59 | $scope.chofer = chofer; |
| 59 | }, function() { | 60 | }, function() { |
| 60 | // funcion ejecutada cuando se cancela el modal | 61 | // funcion ejecutada cuando se cancela el modal |
| 61 | } | 62 | } |
| 62 | ); | 63 | ); |
| 63 | }; | 64 | }; |
| 64 | $scope.eliminarRemitos = function() { | 65 | $scope.eliminarRemitos = function() { |
| 65 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); | 66 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); |
| 66 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') | 67 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') |
| 67 | .then(function() { | 68 | .then(function() { |
| 68 | eliminarRemitos(remitosDel); | 69 | eliminarRemitos(remitosDel); |
| 69 | } | 70 | } |
| 70 | ); | 71 | ); |
| 71 | }; | 72 | }; |
| 72 | $scope.minimoUnoChecked = function() { | 73 | $scope.minimoUnoChecked = function() { |
| 73 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); | 74 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); |
| 74 | return !remitosChequeados.length; | 75 | return !remitosChequeados.length; |
| 75 | }; | 76 | }; |
| 76 | function eliminarRemitos(remitosDel) { | 77 | function eliminarRemitos(remitosDel) { |
| 77 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); | 78 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); |
| 78 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, | 79 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, |
| 79 | nuevosRemitos ? true : false).then(function() { | 80 | nuevosRemitos ? true : false).then(function() { |
| 80 | $scope.remitos = nuevosRemitos; | 81 | $scope.remitos = nuevosRemitos; |
| 81 | }); | 82 | }); |
| 82 | } | 83 | } |
| 83 | }]); | 84 | }]); |
| 84 | 85 |
src/js/osm-directive.js
| 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { | 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { |
| 2 | return { | 2 | return { |
| 3 | restrict: 'E', | 3 | restrict: 'E', |
| 4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
| 5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
| 6 | contenedor.className = 'border border-light rounded'; | 6 | contenedor.className = 'border border-light rounded'; |
| 7 | el.append(contenedor); | 7 | el.append(contenedor); |
| 8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
| 9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
| 10 | }, | 10 | }, |
| 11 | controller: ['$scope', '$filter', function($scope, $filter) { | 11 | controller: ['$scope', '$filter', function($scope, $filter) { |
| 12 | $scope.markers = []; | 12 | $scope.markers = []; |
| 13 | $scope.$watch('marcadores', function() { | 13 | $scope.$watch('marcadores', function() { |
| 14 | for(var i in $scope.markers) { | 14 | for(var i in $scope.markers) { |
| 15 | $scope.map.removeLayer($scope.markers[i]); | 15 | $scope.map.removeLayer($scope.markers[i]); |
| 16 | } | 16 | } |
| 17 | $scope.markers = []; | 17 | $scope.markers = []; |
| 18 | 18 | ||
| 19 | angular.forEach($scope.marcadores, function(marcador) { | 19 | angular.forEach($scope.marcadores, function(marcador) { |
| 20 | var observacion = | 20 | var observacion = |
| 21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
| 22 | ( | 22 | ( |
| 23 | marcador.notaPedido.vendedor ? | 23 | marcador.notaPedido.vendedor ? |
| 24 | marcador.notaPedido.vendedor.NomVen : | 24 | marcador.notaPedido.vendedor.NomVen : |
| 25 | '' | 25 | '' |
| 26 | ) + '<br/>'; | 26 | ) + '<br/>'; |
| 27 | observacion += 'Fecha: ' + | 27 | observacion += 'Fecha: ' + |
| 28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
| 29 | marcador.fecha.slice(11,19) + '<br/>'; | 29 | marcador.fecha.slice(11,19) + '<br/>'; |
| 30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ | 30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
| 31 | marcador.notaPedido.remito.sucursal, | 31 | marcador.notaPedido.remito.sucursal, |
| 32 | marcador.notaPedido.remito.numeroRemito | 32 | marcador.notaPedido.remito.numeroRemito |
| 33 | ]) + '<br/>'; | 33 | ]) + '<br/>'; |
| 34 | observacion += 'Cliente: ' + | 34 | observacion += 'Cliente: ' + |
| 35 | marcador.notaPedido.cliente.NOM + '<br/>'; | 35 | marcador.notaPedido.cliente.NOM + '<br/>'; |
| 36 | 36 | ||
| 37 | // if($scope.parametros.individual) { | 37 | // if($scope.parametros.individual) { |
| 38 | observacion += | 38 | observacion += |
| 39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); | 39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); |
| 40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
| 41 | 41 | ||
| 42 | if(marcador.distancia) { | 42 | if(marcador.distancia) { |
| 43 | observacion += '<br/>Distancia a casa central: ' + | 43 | observacion += '<br/>Distancia a casa central: ' + |
| 44 | marcador.distancia + 'km'; | 44 | marcador.distancia + 'km'; |
| 45 | } | 45 | } |
| 46 | observacion += '<br/>'; | ||
| 47 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | ||
| 48 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | ||
| 49 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | ||
| 50 | var icon; | 46 | var icon; |
| 51 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 47 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
| 48 | observacion += '<br/>'; | ||
| 49 | observacion += '<strong>'; | ||
| 50 | observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito | ||
| 51 | .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); | ||
| 52 | observacion += '<br/>'; | ||
| 53 | observacion += 'Vehículo: ' + marcador.notaPedido.remito | ||
| 54 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.tractor; | ||
| 55 | observacion += '<br/>'; | ||
| 56 | observacion += 'Transportista: ' + marcador.notaPedido.remito | ||
| 57 | .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista | ||
| 58 | .NOM; | ||
| 59 | observacion += '</strong>'; | ||
| 52 | //Asignado ROJO | 60 | //Asignado ROJO |
| 53 | icon = new L.Icon({ | 61 | icon = new L.Icon({ |
| 54 | iconUrl: 'img/marker-icon-2x-red.png', | 62 | iconUrl: 'img/marker-icon-2x-red.png', |
| 55 | shadowUrl: 'img/marker-shadow.png', | 63 | shadowUrl: 'img/marker-shadow.png', |
| 56 | iconSize: [25, 41], | 64 | iconSize: [25, 41], |
| 57 | iconAnchor: [12, 41], | 65 | iconAnchor: [12, 41], |
| 58 | popupAnchor: [1, -34], | 66 | popupAnchor: [1, -34], |
| 59 | shadowSize: [41, 41] | 67 | shadowSize: [41, 41] |
| 60 | }); | 68 | }); |
| 61 | }else { | 69 | }else { |
| 70 | observacion += '<br/>'; | ||
| 71 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | ||
| 72 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | ||
| 73 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | ||
| 74 | |||
| 62 | //Sin asignar VERDE | 75 | //Sin asignar VERDE |
| 63 | icon = new L.Icon({ | 76 | icon = new L.Icon({ |
| 64 | iconUrl: 'img/marker-icon-2x-green.png', | 77 | iconUrl: 'img/marker-icon-2x-green.png', |
| 65 | shadowUrl: 'img/marker-shadow.png', | 78 | shadowUrl: 'img/marker-shadow.png', |
| 66 | iconSize: [25, 41], | 79 | iconSize: [25, 41], |
| 67 | iconAnchor: [12, 41], | 80 | iconAnchor: [12, 41], |
| 68 | popupAnchor: [1, -34], | 81 | popupAnchor: [1, -34], |
| 69 | shadowSize: [41, 41] | 82 | shadowSize: [41, 41] |
| 70 | }); | 83 | }); |
| 71 | } | 84 | } |
| 72 | $scope.markers.push( | 85 | $scope.markers.push( |
| 73 | L.marker( | 86 | L.marker( |
| 74 | [marcador.latitud, marcador.longitud], | 87 | [marcador.latitud, marcador.longitud], {icon: icon}) |
| 75 | {icon: icon, draggable: true}) | ||
| 76 | .addTo($scope.map) | 88 | .addTo($scope.map) |
| 77 | .bindPopup(observacion) | 89 | .bindPopup(observacion) |
| 90 | .bindTooltip('Haga click para seleccionar') | ||
| 78 | ); | 91 | ); |
| 79 | //abre marcador del primer punto | 92 | //abre marcador del primer punto |
| 80 | //$scope.markers[0].openPopup(); | 93 | //$scope.markers[0].openPopup(); |
| 81 | }); | 94 | }); |
| 82 | }); | 95 | }); |
| 83 | }], | 96 | }], |
| 84 | scope: { | 97 | scope: { |
| 85 | latitud: '=', | 98 | latitud: '=', |
| 86 | longitud: '=', | 99 | longitud: '=', |
| 87 | zoom: '=', | 100 | zoom: '=', |
| 88 | marcadores: '=', | 101 | marcadores: '=', |
src/js/service.js
| 1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
| 2 | .factory( | 2 | .factory( |
| 3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
| 4 | '$http', | 4 | '$http', |
| 5 | '$cookies', | 5 | '$cookies', |
| 6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
| 7 | '$filter', | 7 | '$filter', |
| 8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
| 9 | var url = API_ENDPOINT.URL; | 9 | var url = API_ENDPOINT.URL; |
| 10 | return { | 10 | return { |
| 11 | idUsuario: $cookies.get('vendedorCobrador'), | 11 | idUsuario: $cookies.get('vendedorCobrador'), |
| 12 | obtenerActividad: function(parametros) { | 12 | obtenerActividad: function(parametros) { |
| 13 | return $http.post(url + '/seguimiento/filtros', parametros); | 13 | return $http.post(url + '/seguimiento/filtros', parametros); |
| 14 | }, | 14 | }, |
| 15 | numeroHojaRuta: function() { | 15 | numeroHojaRuta: function() { |
| 16 | return $http.get(url + '/hoja-ruta/numero-siguiente'); | 16 | return $http.get(url + '/hoja-ruta/numero-siguiente'); |
| 17 | }, | 17 | }, |
| 18 | getRemitos: function(idVehiculo) { | 18 | getRemitos: function(idVehiculo) { |
| 19 | return $http.get(url + '/remito/sin-hoja-ruta/' + idVehiculo); | 19 | return $http.get(url + '/remito/sin-hoja-ruta/' + idVehiculo); |
| 20 | }, | 20 | }, |
| 21 | cerrarDistribuicion: function(remitos) { | 21 | cerrarDistribuicion: function(remitos) { |
| 22 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); | 22 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); |
| 23 | }, | 23 | }, |
| 24 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 24 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
| 25 | var idsRemitos = []; | 25 | var idsRemitos = []; |
| 26 | for (var i = 0; i < remitos.length; i++) { | 26 | for (var i = 0; i < remitos.length; i++) { |
| 27 | idsRemitos.push(remitos[i].id); | 27 | idsRemitos.push(remitos[i].id); |
| 28 | } | 28 | } |
| 29 | return $http.post(url + '/vehiculo/desasociar-remitos', | 29 | return $http.post(url + '/vehiculo/desasociar-remitos', |
| 30 | { | 30 | { |
| 31 | idsRemitos: idsRemitos, | 31 | idsRemitos: idsRemitos, |
| 32 | idVehiculo: idVehiculo, | 32 | idVehiculo: idVehiculo, |
| 33 | vehiculoSinRemitos: sinRemitos | 33 | vehiculoSinRemitos: sinRemitos |
| 34 | }); | 34 | }); |
| 35 | }, | 35 | }, |
| 36 | obtenerRemitosDeCarga: function(remitos) { | 36 | getRemitosByIdVehiculo: function(idVehiculo, sinConfirmar, sinHojaRuta) { |
| 37 | var remitosRes = []; | 37 | var sinHoja = sinHojaRuta ? '/sinHojaRuta' : ''; |
| 38 | for(var i = 0; i < remitos.cisternas.length; i++) { | 38 | return $http.get(url + '/vehiculo/obtener/remitos/' + |
| 39 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); | 39 | idVehiculo + '/' + this.fecha.toISOString().substring(0, 10) + |
| 40 | } | 40 | '/' + sinConfirmar + sinHoja); |
| 41 | function procesoCistena(cisterna, fecha) { | ||
| 42 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { | ||
| 43 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos | ||
| 44 | .length; k++) | ||
| 45 | { | ||
| 46 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === | ||
| 47 | fecha.substring(0, 10)) | ||
| 48 | { | ||
| 49 | procesoMovimiento(cisterna.cisternasCarga[j] | ||
| 50 | .cisternaMovimientos[k]); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | function procesoMovimiento(movimiento) { | ||
| 56 | if(!movimiento.anulado && movimiento.remito && | ||
| 57 | !movimiento.remito.idHojaRuta) { | ||
| 58 | var remito = movimiento.remito; | ||
| 59 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | ||
| 60 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | ||
| 61 | remitosRes.push(remito); | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 65 | return remitosRes; | ||
| 66 | }, | 41 | }, |
| 67 | getVehiculosByIdUsuario: function() { | 42 | getVehiculosByIdUsuario: function() { |
| 68 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); | 43 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); |
| 69 | }, | 44 | }, |
| 70 | getUnidadesByFecha: function() { | 45 | getUnidadesByFecha: function() { |
| 71 | return $http.post(url + '/vehiculo/listar/fecha', | 46 | return $http.post(url + '/vehiculo/listar/fecha', |
| 72 | {fecha: this.fecha}); | 47 | {fecha: this.fecha}); |
| 73 | }, | 48 | }, |
| 74 | setFechaReparto: function(fechaReparto) { | 49 | setFechaReparto: function(fechaReparto) { |
| 75 | this.fecha = fechaReparto; | 50 | this.fecha = fechaReparto; |
| 76 | }, | 51 | }, |
| 77 | obtenerVehiculoById: function(idVehiculo) { | 52 | obtenerVehiculoById: function(idVehiculo) { |
| 78 | return $http.get(url + '/vehiculo/' + idVehiculo); | 53 | return $http.get(url + '/vehiculo/' + idVehiculo); |
| 79 | } | 54 | } |
| 80 | }; | 55 | }; |
| 81 | }]); | 56 | }]); |
| 82 | 57 |
src/views/foca-logistica-pedido-ruta.html
| 1 | <div class="foca-logistica-pedido-ruta" id="scope"> | 1 | <div class="foca-logistica-pedido-ruta" id="scope"> |
| 2 | <div class="row"> | 2 | <div class="row"> |
| 3 | <foca-cabecera-facturador | 3 | <foca-cabecera-facturador |
| 4 | titulo="titulo" | 4 | titulo="titulo" |
| 5 | fecha="now" | 5 | fecha="now" |
| 6 | class="mb-0 col-lg-12" | 6 | class="mb-0 col-lg-12" |
| 7 | ></foca-cabecera-facturador> | 7 | ></foca-cabecera-facturador> |
| 8 | </div> | 8 | </div> |
| 9 | <div class="row px-5 py-2 botonera-secundaria position-relative"> | 9 | <div class="row px-5 py-2 botonera-secundaria position-relative"> |
| 10 | <div class="col-10"> | 10 | <div class="col-10"> |
| 11 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 11 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> |
| 12 | </div> | 12 | </div> |
| 13 | <div class="col-2 pl-0 position-absolute right-0"> | 13 | <div class="col-2 pl-0 position-absolute right-0"> |
| 14 | <strong>Filtros: </strong> | 14 | <strong>Filtros: </strong> |
| 15 | <br> | 15 | <br> |
| 16 | <span>Fecha Desde</span> | 16 | <span>Fecha Desde</span> |
| 17 | <input | 17 | <input |
| 18 | type="text" | 18 | type="text" |
| 19 | readonly | 19 | readonly |
| 20 | ng-model="fechaDesde" | 20 | ng-model="fechaDesde" |
| 21 | class="form-control form-control-sm" | 21 | class="form-control form-control-sm" |
| 22 | uib-datepicker-popup="dd/MM/yyyy" | 22 | uib-datepicker-popup="dd/MM/yyyy" |
| 23 | show-button-bar="false" | 23 | show-button-bar="false" |
| 24 | is-open="fechaDesdeOpen" | 24 | is-open="fechaDesdeOpen" |
| 25 | on-open-focus="false" | 25 | on-open-focus="false" |
| 26 | ng-focus="fechaDesdeOpen = true" | 26 | ng-focus="fechaDesdeOpen = true" |
| 27 | ng-change="search()" | 27 | ng-change="search()" |
| 28 | /> | 28 | /> |
| 29 | <span>Fecha Hasta</span> | 29 | <span>Fecha Hasta</span> |
| 30 | <input | 30 | <input |
| 31 | type="text" | 31 | type="text" |
| 32 | readonly | 32 | readonly |
| 33 | ng-model="fechaHasta" | 33 | ng-model="fechaHasta" |
| 34 | class="form-control form-control-sm" | 34 | class="form-control form-control-sm" |
| 35 | uib-datepicker-popup="dd/MM/yyyy" | 35 | uib-datepicker-popup="dd/MM/yyyy" |
| 36 | show-button-bar="false" | 36 | show-button-bar="false" |
| 37 | is-open="fechaHastaOpen" | 37 | is-open="fechaHastaOpen" |
| 38 | on-open-focus="false" | 38 | on-open-focus="false" |
| 39 | ng-focus="fechaHastaOpen = true" | 39 | ng-focus="fechaHastaOpen = true" |
| 40 | ng-change="search()" | 40 | ng-change="search()" |
| 41 | /> | 41 | /> |
| 42 | <div class="custom-control custom-radio"> | 42 | <div class="custom-control custom-radio"> |
| 43 | <input | 43 | <input |
| 44 | type="radio" | 44 | type="radio" |
| 45 | class="custom-control-input" | 45 | class="custom-control-input" |
| 46 | id="idTodos" | 46 | id="idTodos" |
| 47 | name="filtro" | 47 | name="filtro" |
| 48 | ng-model="filtroEstado" | 48 | ng-model="filtroEstado" |
| 49 | ng-change="search()" | 49 | ng-change="search()" |
| 50 | checked> | 50 | checked> |
| 51 | <label class="custom-control-label pb-3" for="idTodos"></label> | 51 | <label class="custom-control-label pb-3" for="idTodos"></label> |
| 52 | <img src="img/marker-icon-grey.png"> | 52 | <img src="img/marker-icon-grey.png"> |
| 53 | <strong>Todos</strong> | 53 | <strong>Todos</strong> |
| 54 | </div> | 54 | </div> |
| 55 | <div class="custom-control custom-radio"> | 55 | <div class="custom-control custom-radio"> |
| 56 | <input | 56 | <input |
| 57 | type="radio" | 57 | type="radio" |
| 58 | class="custom-control-input" | 58 | class="custom-control-input" |
| 59 | id="idSinAsignar" | 59 | id="idSinAsignar" |
| 60 | name="filtro" | 60 | name="filtro" |
| 61 | ng-model="filtroEstado" | 61 | ng-model="filtroEstado" |
| 62 | ng-change="search()" | 62 | ng-change="search()" |
| 63 | ng-value="false"> | 63 | ng-value="false"> |
| 64 | <label class="custom-control-label pb-3" for="idSinAsignar"></label> | 64 | <label class="custom-control-label pb-3" for="idSinAsignar"></label> |
| 65 | <img src="img/marker-icon-green.png"> | 65 | <img src="img/marker-icon-green.png"> |
| 66 | <strong>Sin asignar</strong> | 66 | <strong>Sin asignar</strong> |
| 67 | </div> | 67 | </div> |
| 68 | <div class="custom-control custom-radio"> | 68 | <div class="custom-control custom-radio"> |
| 69 | <input | 69 | <input |
| 70 | type="radio" | 70 | type="radio" |
| 71 | class="custom-control-input" | 71 | class="custom-control-input" |
| 72 | id="idAsignado" | 72 | id="idAsignado" |
| 73 | name="filtro" | 73 | name="filtro" |
| 74 | ng-model="filtroEstado" | 74 | ng-model="filtroEstado" |
| 75 | ng-change="search()" | 75 | ng-change="search()" |
| 76 | ng-value="true"> | 76 | ng-value="true"> |
| 77 | <label class="custom-control-label pb-3" for="idAsignado"></label> | 77 | <label class="custom-control-label pb-3" for="idAsignado"></label> |
| 78 | <img src="img/marker-icon-red.png"> | 78 | <img src="img/marker-icon-red.png"> |
| 79 | <strong>Asignado</strong> | 79 | <strong>Asignado</strong> |
| 80 | </div> | 80 | </div> |
| 81 | </div> | 81 | </div> |
| 82 | </div> | 82 | </div> |
| 83 | <div class="row px-5"> | 83 | <div class="row px-5"> |
| 84 | <div class="col-10"> | 84 | <div class="col-10"> |
| 85 | <foca-logistica | 85 | <foca-logistica |
| 86 | latitud="-32.89214159952345" | 86 | latitud="-34.7152975" |
| 87 | longitud="-68.84572999101856" | 87 | longitud="-65.9053867" |
| 88 | zoom="14" | 88 | zoom="5" |
| 89 | marcadores="marcadores" | 89 | marcadores="marcadores" |
| 90 | parametros= "datosBuscados" | 90 | parametros= "datosBuscados" |
| 91 | /> | 91 | /> |
| 92 | </div> | 92 | </div> |
| 93 | <div class="row"> | 93 | <div class="row"> |
| 94 | <div | 94 | <div |
| 95 | class="container col-auto" | 95 | class="container col-auto" |
| 96 | ng-repeat="vehiculo in vehiculos" | 96 | ng-repeat="vehiculo in vehiculos" |
| 97 | ng-click="mostrarDetalleVehiculo(vehiculo)" | 97 | ng-click="mostrarDetalleVehiculo(vehiculo)" |
| 98 | > | 98 | > |
| 99 | <div> | 99 | <div> |
| 100 | <div class="col-md-3 col-sm-6"> | 100 | <div class="col-md-3 col-sm-6"> |
| 101 | <div class="progress-circle" ng-class="{'arrastrando': arrastrando}"> | 101 | <div class="progress-circle" ng-class="{'arrastrando': arrastrando}"> |
| 102 | <span class="progress-left"> | 102 | <span class="progress-left"> |
| 103 | <span class="progress-bar"></span> | 103 | <span class="progress-bar"></span> |
| 104 | </span> | 104 | </span> |
| 105 | <span class="progress-right"> | 105 | <span class="progress-right"> |
| 106 | <span class="progress-bar"></span> | 106 | <span class="progress-bar"></span> |
| 107 | </span> | 107 | </span> |
| 108 | <div class="progress-value">{{vehiculo.codigo}}</div> | 108 | <div class="progress-value py-4 px-3 d-flex align-content-between flex-wrap"> |
| 109 | <small class="w-100"> | ||
| 110 | <small> | ||
| 111 | <small> | ||
| 112 | {{vehiculo.transportista.NOM.trim()}} | ||
| 113 | </small> | ||
| 114 | </small> | ||
| 115 | </small> | ||
| 116 | <small class="w-100"> | ||
| 117 | {{vehiculo.codigo}} | ||
| 118 | </small> | ||
| 119 | </div> | ||
| 109 | </div> | 120 | </div> |
| 110 | </div> | 121 | </div> |
| 111 | <div class="row ml-2"> | 122 | <div class="row ml-2"> |
| 112 | <div class="col-3 position-absolute"> | 123 | <div class="col-3 position-absolute"> |
| 113 | <img | 124 | <img |
| 114 | src="img/hojaRutaVolante.png" | 125 | src="img/hojaRutaVolante.png" |
| 115 | width="100%"> | 126 | width="100%"> |
| 116 | </div> | 127 | </div> |
| 117 | <div class="col-3" | 128 | <div class="col-3" |
| 118 | uib-tooltip="Cerrar distribuición" | 129 | uib-tooltip="Confirmar distribuición" |
| 119 | ng-click="hacerHojaRuta(vehiculo, false)"></div> | 130 | ng-click="hacerHojaRuta(vehiculo)"></div> |
| 120 | <div class="col-3"> | 131 | <div class="col-3"> |
| 121 | <i | 132 | <i |
| 122 | class="fa fa-eye fa-2x" | 133 | class="fa fa-eye fa-2x" |
| 123 | uib-tooltip="Ver cisternas" | 134 | uib-tooltip="Ver cisternas" |
| 124 | ng-click="cargar(vehiculo.id, -1)"> | 135 | ng-click="cargar(vehiculo.id, -1)"> |
| 125 | </i> | 136 | </i> |
| 126 | </div> | 137 | </div> |
| 127 | <div class="col-3 ml-2"> | 138 | <div class="col-3 ml-2"> |
| 128 | <i | 139 | <i |
| 129 | class="fa fa-trash fa-2x" | 140 | class="fa fa-trash fa-2x" |
| 130 | uib-tooltip="Eliminar vehiculo" | 141 | uib-tooltip="Eliminar vehiculo" |
| 131 | ng-click="quitarVehiculo(vehiculo)"></i> | 142 | ng-click="quitarVehiculo(vehiculo)"></i> |
| 132 | </div> | 143 | </div> |
| 133 | </div> | 144 | </div> |
| 134 | <div | 145 | <div |
| 135 | class="ml-1 border border-dark text-center" | 146 | class="ml-1 border border-dark text-center w-100" |
| 136 | ng-show="arrastrando" | 147 | ng-show="arrastrando" |
| 137 | id="{{vehiculo.id}}" | 148 | id="{{vehiculo.id}}" |
| 138 | ondrop="drop(event)" | 149 | ondrop="drop(event)" |
| 139 | ondragover="allowDrop(event)" | 150 | ondragover="allowDrop(event)" |
| 140 | >Soltar acá</div> | 151 | >Soltar acá</div> |
| 141 | </div> | 152 | </div> |
| 142 | </div> | 153 | </div> |
| 143 | </div> | 154 | </div> |
| 144 | </div> | 155 | </div> |
| 145 | </div> | 156 | </div> |
| 146 | 157 |
src/views/foca-modal-cerrar-vehiculo.html
| 1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
| 2 | <h4>Cerrar distribución vehículo</h4> | 2 | <h4>Confirmar distribución vehículo</h4> |
| 3 | <div class="row"> | 3 | <div class="row"> |
| 4 | <div class="col-6 row"> | 4 | <div class="col-6 row"> |
| 5 | <label class="col-3 mt-2">Fecha:</label> | 5 | <label class="col-3 mt-2">Fecha:</label> |
| 6 | <input | 6 | <input |
| 7 | type="text" | 7 | type="text" |
| 8 | readonly | 8 | readonly |
| 9 | ng-model="now" | 9 | ng-model="now" |
| 10 | uib-datepicker-popup="dd/MM/yyyy" | 10 | uib-datepicker-popup="dd/MM/yyyy" |
| 11 | show-button-bar="false" | 11 | show-button-bar="false" |
| 12 | is-open="datepickerOpen" | 12 | is-open="datepickerOpen" |
| 13 | on-open-focus="false" | 13 | on-open-focus="false" |
| 14 | class="form-control col-8"/> | 14 | class="form-control col-8"/> |
| 15 | </div> | 15 | </div> |
| 16 | </div> | 16 | </div> |
| 17 | </div> | 17 | </div> |
| 18 | <div class="modal-body"> | 18 | <div class="modal-body"> |
| 19 | <form class="row" name="formHojaRuta"> | 19 | <form class="row" name="formHojaRuta"> |
| 20 | 20 | ||
| 21 | <div class="col-2"> | 21 | <div class="col-2"> |
| 22 | <label>Transportista</label> | 22 | <label>Transportista</label> |
| 23 | </div> | 23 | </div> |
| 24 | <div class="col-4"> | 24 | <div class="col-4"> |
| 25 | <input | 25 | <input |
| 26 | class="form-control" | 26 | class="form-control" |
| 27 | readonly | 27 | readonly |
| 28 | ng-value="vehiculo.transportista.COD + ' ' + vehiculo.transportista.NOM" | 28 | ng-value="vehiculo.transportista.COD + ' ' + vehiculo.transportista.NOM" |
| 29 | > | 29 | > |
| 30 | </div> | 30 | </div> |
| 31 | <div class="col-2 form-group"> | 31 | <div class="col-2 form-group"> |
| 32 | <label>Unidad</label> | 32 | <label>Unidad</label> |
| 33 | </div> | 33 | </div> |
| 34 | <div class="col-4"> | 34 | <div class="col-4"> |
| 35 | <input | 35 | <input |
| 36 | class="form-control" | 36 | class="form-control" |
| 37 | readonly | 37 | readonly |
| 38 | ng-model="vehiculo.codigo" | 38 | ng-model="vehiculo.codigo" |
| 39 | > | 39 | > |
| 40 | </div> | 40 | </div> |
| 41 | </form> | 41 | </form> |
| 42 | <strong>Remitos:</strong> | 42 | <strong>Remitos:</strong> |
| 43 | <table class="table"> | 43 | <table class="table"> |
| 44 | <thead> | 44 | <thead> |
| 45 | <tr> | 45 | <tr> |
| 46 | <th>Remito Nº</th> | 46 | <th>Remito Nº</th> |
| 47 | <th>Cliente</th> | 47 | <th>Cliente</th> |
| 48 | <th>Domicilio de entrega</th> | 48 | <th>Domicilio de entrega</th> |
| 49 | <th ng-if="cerrar">Eliminar</th> | 49 | <th ng-if="cerrar">Eliminar |
| 50 | <i | ||
| 51 | class="fa fa-info" | ||
| 52 | uib-tooltip="Los remitos que no se pueden eliminar tienen asignada una hoja de ruta"> | ||
| 53 | </i> | ||
| 54 | </th> | ||
| 50 | </tr> | 55 | </tr> |
| 51 | </thead> | 56 | </thead> |
| 52 | <tbody> | 57 | <tbody> |
| 53 | <tr ng-show="!remitos.length"> | 58 | <tr ng-show="!remitos.length"> |
| 54 | <td colspan="3"> | 59 | <td colspan="3"> |
| 55 | No se han encontrado remitos. | 60 | No se han encontrado remitos. |
| 56 | </td> | 61 | </td> |
| 57 | </tr> | 62 | </tr> |
| 58 | <tr ng-repeat="remito in remitos"> | 63 | <tr ng-repeat="remito in remitos"> |
| 59 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | 64 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> |
| 60 | <td ng-bind="remito.nombreCliente"></td> | 65 | <td ng-bind="remito.nombreCliente"></td> |
| 61 | <td ng-bind="remito.domicilioStamp"></td> | 66 | <td ng-bind="remito.domicilioStamp"></td> |
| 62 | <td ng-if="cerrar"> | 67 | <td ng-if="cerrar"> |
| 63 | <div class="custom-control custom-checkbox"> | 68 | <div class="custom-control custom-checkbox"> |
| 64 | <input | 69 | <input |
| 65 | type="checkbox" | 70 | type="checkbox" |
| 66 | ng-model="remito.checked" | 71 | ng-model="remito.checked" |
| 67 | class="custom-control-input" | 72 | class="custom-control-input" |
| 68 | id="{{remito.id}}"> | 73 | id="{{remito.id}}" |
| 74 | ng-disabled="remito.idHojaRuta"> | ||
| 69 | <label class="custom-control-label" for="{{remito.id}}"></label> | 75 | <label class="custom-control-label" for="{{remito.id}}"></label> |
| 70 | </div> | 76 | </div> |
| 71 | </td> | 77 | </td> |
| 72 | </tr> | 78 | </tr> |
| 73 | </tbody> | 79 | </tbody> |
| 74 | </table> | 80 | </table> |
| 75 | </div> | 81 | </div> |
| 76 | <div class="modal-footer py-1"> | 82 | <div class="modal-footer py-1"> |
| 77 | <button | 83 | <button |
| 78 | class="btn btn-sm btn-secondary" | 84 | class="btn btn-sm btn-secondary" |
| 79 | ladda="cargando" | 85 | ladda="cargando" |
| 80 | type="button" | 86 | type="button" |
| 81 | ng-click="cancelar()" | 87 | ng-click="cancelar()" |
| 82 | >Cancelar</button> | 88 | >Cancelar</button> |
| 83 | <button | 89 | <button |
| 84 | class="btn btn-sm btn-danger" | 90 | class="btn btn-sm btn-danger" |
| 85 | type="button" | 91 | type="button" |
| 86 | ng-click="eliminarRemitos()" | 92 | ng-click="eliminarRemitos()" |
| 87 | ng-disabled="minimoUnoChecked()" | 93 | ng-disabled="minimoUnoChecked()" |
| 88 | ng-if="cerrar" | 94 | ng-if="cerrar" |
| 89 | >Eliminar</button> | 95 | >Eliminar</button> |
| 90 | <button | 96 | <button |
| 91 | class="btn btn-sm btn-primary" | 97 | class="btn btn-sm btn-primary" |
| 92 | ladda="cargando" | 98 | ladda="cargando" |
| 93 | type="button" | 99 | type="button" |
| 94 | ng-disabled="!formHojaRuta.$valid || !remitos.length" | 100 | ng-disabled="!formHojaRuta.$valid || !remitos.length" |
| 95 | ng-click="aceptar()" | 101 | ng-click="aceptar()" |
| 96 | ng-if="!cerrar" | 102 | ng-if="!cerrar" |
| 97 | >Cerrar distribución</button> | 103 | >Cerrar distribución</button> |
| 98 | </div> | 104 | </div> |
| 99 | 105 |