Commit 8a4b631e3bfeb300b9bac8831ba1fea50deba0b6
Exists in
master
Merge branch 'master' into 'develop'
Master(benjamin) See merge request !2
Showing
8 changed files
 
Show diff stats
src/js/app.js
| 1 | angular.module('focaOrdenCarga', [ | 1 | angular.module('focaOrdenCarga', [ | 
| 2 | 'ui.bootstrap', | 2 | 'ui.bootstrap', | 
| 3 | 'focaDirectivas', | 3 | 'focaDirectivas', | 
| 4 | 'angular-ladda' | 4 | 'angular-ladda', | 
| 5 | 'chart.js' | ||
| 5 | ]); | 6 | ]); | 
| 6 | 7 | 
src/js/controller.js
| 1 | angular.module('focaOrdenCarga') | 1 | angular.module('focaOrdenCarga') | 
| 2 | .controller('focaOrdenCargaController', [ | 2 | .controller('focaOrdenCargaController', [ | 
| 3 | '$scope', | 3 | '$scope', | 
| 4 | function ($scope) { | 4 | '$location', | 
| 5 | '$filter', | ||
| 6 | '$timeout', | ||
| 7 | 'focaOrdenCargaService', | ||
| 8 | 'focaBotoneraLateralService', | ||
| 9 | 'focaModalService', | ||
| 10 | '$uibModal', | ||
| 11 | function ( | ||
| 12 | $scope, $location, $filter, $timeout, focaOrdenCargaService, | ||
| 13 | focaBotoneraLateralService, focaModalService, $uibModal) { | ||
| 5 | 14 | ||
| 6 | //#region VARIABLES | ||
| 7 | |||
| 8 | //#endregion | ||
| 9 | |||
| 10 | //#region METODOS | ||
| 11 | init(); | 15 | init(); | 
| 12 | 16 | ||
| 13 | function init() { | 17 | function init() { | 
| 18 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | ||
| 19 | $scope.fecha = new Date(); | ||
| 20 | $scope.isNumber = angular.isNumber; | ||
| 21 | $scope.show = false; | ||
| 22 | $scope.cargando = true; | ||
| 23 | $scope.cabeceras = []; | ||
| 24 | $scope.botonera = focaOrdenCargaService.getBotonera(); | ||
| 25 | $scope.dateOptions = { | ||
| 26 | maxDate: new Date(), | ||
| 27 | minDate: new Date(2010, 0, 1) | ||
| 28 | }; | ||
| 29 | $scope.ordenCarga = { | ||
| 30 | id: 0, | ||
| 31 | cliente: {}, | ||
| 32 | proveedor: {}, | ||
| 33 | domicilio: { dom: '' }, | ||
| 34 | vendedor: {}, | ||
| 35 | fechaCarga: new Date(), | ||
| 36 | cotizacion: {}, | ||
| 37 | articulosNotaPedido: [], | ||
| 38 | notaPedidoPlazo: [], | ||
| 39 | notaPedidoPuntoDescarga: [] | ||
| 40 | }; | ||
| 41 | $scope.hojaRuta = { | ||
| 42 | fecha: new Date(), | ||
| 43 | litros: 0, | ||
| 44 | chofer: {}, | ||
| 45 | vehiculo: { | ||
| 46 | capacidad: 0, | ||
| 47 | cisternas: [] | ||
| 48 | }, | ||
| 49 | transportista: {}, | ||
| 50 | remitosTabla: [] | ||
| 51 | }; | ||
| 52 | } | ||
| 53 | |||
| 54 | //SETEO BOTONERA LATERAL | ||
| 55 | $timeout(function () { | ||
| 56 | focaBotoneraLateralService.showSalir(false); | ||
| 57 | focaBotoneraLateralService.showPausar(true); | ||
| 58 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | ||
| 59 | focaBotoneraLateralService.addCustomButton('Salir', salir); | ||
| 60 | }); | ||
| 61 | |||
| 62 | $scope.seleccionarVehiculo = function () { | ||
| 63 | |||
| 64 | seleccionarTransportista().then( | ||
| 65 | |||
| 66 | function (transportista) { | ||
| 67 | elegirTransportista(transportista); | ||
| 68 | |||
| 69 | var parametrosModal = { | ||
| 70 | columnas: [ | ||
| 71 | { | ||
| 72 | propiedad: 'codigo', | ||
| 73 | nombre: 'Código' | ||
| 74 | }, | ||
| 75 | { | ||
| 76 | propiedad: 'tractor', | ||
| 77 | nombre: 'tractor' | ||
| 78 | }, | ||
| 79 | { | ||
| 80 | propiedad: 'semi', | ||
| 81 | nombre: 'Semi' | ||
| 82 | }, | ||
| 83 | { | ||
| 84 | propiedad: 'capacidadTotalCisternas', | ||
| 85 | nombre: 'Capacidad' | ||
| 86 | } | ||
| 87 | ], | ||
| 88 | query: '/vehiculo/transportista/' + transportista.COD, | ||
| 89 | titulo: 'Búsqueda de vehiculos', | ||
| 90 | subTitulo: transportista.COD + '-' + transportista.NOM | ||
| 91 | }; | ||
| 92 | |||
| 93 | focaModalService.modal(parametrosModal).then( | ||
| 94 | function (vehiculo) { | ||
| 95 | $scope.$broadcast('addCabecera', { | ||
| 96 | label: 'Vehículo:', | ||
| 97 | valor: vehiculo.codigo | ||
| 98 | }); | ||
| 99 | $scope.hojaRuta.vehiculo = vehiculo; | ||
| 100 | $scope.hojaRuta.transportista = transportista; | ||
| 101 | $scope.hojaRuta.vehiculo.cisternas = vehiculo.cisternas; | ||
| 102 | getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); | ||
| 103 | }, function () { | ||
| 104 | seleccionarTransportista(); | ||
| 105 | }); | ||
| 106 | }); | ||
| 107 | }; | ||
| 108 | |||
| 109 | function seleccionarTransportista() { | ||
| 110 | var parametrosModal = { | ||
| 111 | titulo: 'Búsqueda de Transportista', | ||
| 112 | query: '/transportista', | ||
| 113 | columnas: [ | ||
| 114 | { | ||
| 115 | nombre: 'Código', | ||
| 116 | propiedad: 'COD' | ||
| 117 | }, | ||
| 118 | { | ||
| 119 | nombre: 'Nombre', | ||
| 120 | propiedad: 'NOM' | ||
| 121 | }, | ||
| 122 | { | ||
| 123 | nombre: 'CUIT', | ||
| 124 | propiedad: 'CUIT' | ||
| 125 | } | ||
| 126 | ] | ||
| 127 | }; | ||
| 128 | return focaModalService.modal(parametrosModal); | ||
| 129 | }; | ||
| 130 | |||
| 131 | $scope.seleccionarFechaDeReparto = function () { | ||
| 132 | focaModalService.modalFecha('Fecha').then(function (fecha) { | ||
| 133 | $scope.$broadcast('addCabecera', { | ||
| 134 | label: 'Fecha:', | ||
| 135 | valor: fecha.toLocaleDateString() | ||
| 136 | }); | ||
| 137 | |||
| 138 | $scope.fecha = fecha; | ||
| 139 | if ($scope.hojaRuta.vehiculo.cisternas) | ||
| 140 | getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); | ||
| 141 | }); | ||
| 142 | }; | ||
| 143 | |||
| 144 | $scope.seleccionarHojasDeRuta = function () { | ||
| 145 | if (!$scope.hojaRuta.vehiculo.cisternas.length) { | ||
| 146 | focaModalService.alert('Primero seleccione un vehículo con cisternas'); | ||
| 147 | return; | ||
| 148 | } | ||
| 149 | $uibModal.open( | ||
| 150 | { | ||
| 151 | ariaLabelledBy: 'Hojas de Ruta', | ||
| 152 | templateUrl: 'modal-hojas-ruta.html', | ||
| 153 | controller: 'focaOrdenCargaController', | ||
| 154 | size: 'md', | ||
| 155 | resolve: { | ||
| 156 | filters: { | ||
| 157 | cisternas: $scope.hojaRuta.vehiculo.id | ||
| 158 | } | ||
| 159 | } | ||
| 160 | } | ||
| 161 | ); | ||
| 162 | var idVehiculo = $scope.hojaRuta.vehiculo.id | ||
| 163 | focaOrdenCargaService.getHojasRuta(idVehiculo) | ||
| 164 | .then(function (res) { | ||
| 165 | console.log(res); | ||
| 166 | }) | ||
| 167 | .catch(function (err) { | ||
| 168 | console.error(err) | ||
| 169 | }) | ||
| 170 | } | ||
| 171 | |||
| 172 | $scope.seleccionarRemitoAbierto = function () { | ||
| 173 | if ($scope.hojaRuta.vehiculo.capacidad === 0) { | ||
| 174 | focaModalService.alert('Debe ingresar vehiculo'); | ||
| 175 | return; | ||
| 176 | } else { | ||
| 177 | mostrarDetalle($scope.hojaRuta); | ||
| 178 | } | ||
| 179 | }; | ||
| 180 | |||
| 181 | $scope.seleccionarChofer = function () { | ||
| 182 | var parametrosModal = { | ||
| 183 | titulo: 'Búsqueda de Chofer', | ||
| 184 | query: '/chofer', | ||
| 185 | columnas: [ | ||
| 186 | { | ||
| 187 | propiedad: 'id', | ||
| 188 | nombre: 'Código', | ||
| 189 | filtro: { | ||
| 190 | nombre: 'rellenarDigitos', | ||
| 191 | parametro: 3 | ||
| 192 | } | ||
| 193 | }, | ||
| 194 | { | ||
| 195 | propiedad: 'nombre', | ||
| 196 | nombre: 'Nombre' | ||
| 197 | }, | ||
| 198 | { | ||
| 199 | propiedad: 'dni', | ||
| 200 | nombre: 'DNI' | ||
| 201 | }, | ||
| 202 | { | ||
| 203 | propiedad: 'telefono', | ||
| 204 | nombre: 'Teléfono' | ||
| 205 | } | ||
| 206 | ] | ||
| 207 | }; | ||
| 208 | focaModalService.modal(parametrosModal).then( | ||
| 209 | function (chofer) { | ||
| 210 | $scope.ordenCarga.chofer = chofer; | ||
| 211 | $scope.$broadcast('addCabecera', { | ||
| 212 | label: 'Chofer:', | ||
| 213 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre | ||
| 214 | }); | ||
| 215 | |||
| 216 | $filter('filter')($scope.botonera, { | ||
| 217 | label: 'Chofer', | ||
| 218 | })[0].checked = true; | ||
| 219 | }, function () { | ||
| 220 | // funcion ejecutada cuando se cancela el modal | ||
| 221 | } | ||
| 222 | ); | ||
| 223 | }; | ||
| 224 | |||
| 225 | $scope.seleccionarGraficar = function () { | ||
| 226 | if (!$scope.hojaRuta.vehiculo.cisternas.length) { | ||
| 227 | focaModalService.alert('Primero seleccione un vehículo con cisternas'); | ||
| 228 | return; | ||
| 229 | } | ||
| 230 | $uibModal.open( | ||
| 231 | { | ||
| 232 | ariaLabelledBy: 'Grafico de cisternas', | ||
| 233 | templateUrl: 'modal-grafico-cisternas.html', | ||
| 234 | controller: 'focaModalGraficoCisternasController', | ||
| 235 | size: 'md', | ||
| 236 | resolve: { | ||
| 237 | filters: { | ||
| 238 | cisternas: $scope.hojaRuta.vehiculo.cisternas | ||
| 239 | } | ||
| 240 | } | ||
| 241 | } | ||
| 242 | ); | ||
| 243 | }; | ||
| 244 | |||
| 245 | function elegirTransportista(transportista) { | ||
| 246 | var codigo = ('00000' + transportista.COD).slice(-5); | ||
| 247 | $scope.idTransportista = transportista.COD; | ||
| 248 | $scope.filtros = transportista.NOM.trim(); | ||
| 249 | $scope.$broadcast('addCabecera', { | ||
| 250 | label: 'Transportista:', | ||
| 251 | valor: codigo + ' - ' + transportista.NOM | ||
| 252 | }); | ||
| 253 | } | ||
| 254 | |||
| 255 | function getEstadosCisternas(cisternas) { | ||
| 256 | cisternas.forEach(function (cisterna) { | ||
| 257 | focaOrdenCargaService | ||
| 258 | .getEstadoCisterna(cisterna.id, $scope.fecha) | ||
| 259 | .then(function (res) { | ||
| 260 | cisterna.estado = res.data; | ||
| 261 | }) | ||
| 262 | .catch(function (err) { console.error(err) }); | ||
| 263 | }); | ||
| 264 | } | ||
| 265 | |||
| 266 | function mostrarDetalle(hojasRutas) { | ||
| 267 | var modalInstance = $uibModal.open( | ||
| 268 | { | ||
| 269 | ariaLabelledBy: '', | ||
| 270 | templateUrl: 'modal-detalle-carga.html', | ||
| 271 | controller: 'focaModalDetalleController', | ||
| 272 | resolve: { | ||
| 273 | parametrosModal: function () { | ||
| 274 | return { | ||
| 275 | hojasRutas: hojasRutas, | ||
| 276 | orden: $scope.hojaRuta.orden | ||
| 277 | }; | ||
| 278 | } | ||
| 279 | }, | ||
| 280 | size: 'lg', | ||
| 281 | backdrop: false | ||
| 282 | } | ||
| 283 | ); | ||
| 284 | return modalInstance.result | ||
| 285 | .then(function (res) { | ||
| 286 | res.cisternas.forEach(function (cisterna) { | ||
| 287 | $scope.cisternaCargas.push(cisterna.cisternaCarga); | ||
| 288 | }); | ||
| 289 | $scope.cisternaMovimientos = res.movimientos; | ||
| 290 | $scope.articulosRecibidos = res.articulos; | ||
| 291 | $scope.articulos = res.articulos; | ||
| 292 | $filter('filter')($scope.botonera, { | ||
| 293 | label: 'Detalle de Carga', | ||
| 294 | })[0].checked = true; | ||
| 295 | }) | ||
| 296 | .catch(function (e) { console.error(e); }); | ||
| 297 | }; | ||
| 298 | |||
| 299 | function crearOrdenCarga() { | ||
| 300 | if (!$scope.hojaRuta.vehiculo) { | ||
| 301 | focaModalService.alert('Ingrese Vehículo'); | ||
| 302 | return; | ||
| 303 | } else if (!$scope.hojaRuta.chofer) { | ||
| 304 | focaBotoneraLateralService.alert('Ingrese Chofer'); | ||
| 305 | return; | ||
| 306 | } | ||
| 307 | |||
| 308 | focaBotoneraLateralService.startGuardar(); | ||
| 309 | $scope.saveLoading = true; | ||
| 310 | |||
| 311 | } | ||
| 312 | |||
| 313 | $scope.$watch('ordenCarga', function (newValue) { | ||
| 314 | focaBotoneraLateralService.setPausarData({ | ||
| 315 | label: 'ordenCarga', | ||
| 316 | val: newValue | ||
| 317 | }); | ||
| 318 | }, true); | ||
| 319 | |||
| 320 | $scope.$watch('ordenCarga', function (newValue) { | ||
| 321 | focaBotoneraLateralService.setPausarData({ | ||
| 322 | label: 'ordenCarga', | ||
| 323 | val: newValue | ||
| 324 | }); | ||
| 325 | focaBotoneraLateralService.setRutasPausadas({ | ||
| 326 | label: 'rutas', | ||
| 327 | val: 'orden-carga' | ||
| 328 | }); | ||
| 329 | }, true); | ||
| 330 | |||
| 331 | $scope.salir = function () { | ||
| 332 | $location.path('/'); | ||
| 333 | }; | ||
| 334 | |||
| 335 | function salir() { | ||
| 336 | var confirmacion = false; | ||
| 337 | |||
| 338 | if (!angular.equals($scope.ordenCarga, $scope.inicial)) { | ||
| 339 | confirmacion = true; | ||
| 340 | } | ||
| 341 | |||
| 342 | if (confirmacion) { | ||
| 343 | focaModalService.confirm( | ||
| 344 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | ||
| 345 | ).then(function (data) { | ||
| 346 | if (data) { | ||
| 347 | $location.path('/'); | ||
| 348 | } | ||
| 349 | }); | ||
| 350 | } else { | 
src/js/controllerDetalle.js
| File was created | 1 | angular.module('focaOrdenCarga') | |
| 2 | .controller('focaModalDetalleController', [ | ||
| 3 | '$scope', '$timeout', '$uibModalInstance', 'focaModalService', | ||
| 4 | 'focaCrearHojaRutaService', 'parametrosModal', | ||
| 5 | function ($scope, $timeout, $uibModalInstance, focaModalService, | ||
| 6 | focaCrearHojaRutaService, parametrosModal) { | ||
| 7 | |||
| 8 | init(); | ||
| 9 | |||
| 10 | function init() { | ||
| 11 | $scope.mostrar = false; | ||
| 12 | $scope.orden = parametrosModal.orden; | ||
| 13 | $scope.articulos = []; | ||
| 14 | $scope.cisternaMovimientos = []; | ||
| 15 | $scope.hojasRutas = parametrosModal.hojasRutas; | ||
| 16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | ||
| 17 | function (cisterna) { | ||
| 18 | return !cisterna.desactivado; | ||
| 19 | } | ||
| 20 | ); | ||
| 21 | focaCrearHojaRutaService.getArticulos() | ||
| 22 | .then(function (articulos) { | ||
| 23 | $scope.articulos = articulos.data; | ||
| 24 | }); | ||
| 25 | } | ||
| 26 | |||
| 27 | $scope.validarCisternaDisponible = function (cisterna) { | ||
| 28 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { | ||
| 29 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + | ||
| 30 | 'superior a la ' + 'capacidad del vehiculo '); | ||
| 31 | cisterna.disponible = cisterna.capacidad; | ||
| 32 | return; | ||
| 33 | } | ||
| 34 | }; | ||
| 35 | |||
| 36 | $scope.seleccionarProductos = function (key, cisterna) { | ||
| 37 | focaModalService.modal({ | ||
| 38 | titulo: 'Productos', | ||
| 39 | data: $scope.articulos, | ||
| 40 | size: 'md', | ||
| 41 | columnas: [ | ||
| 42 | { | ||
| 43 | propiedad: 'CodRub', | ||
| 44 | nombre: 'Codigo' | ||
| 45 | }, | ||
| 46 | { | ||
| 47 | propiedad: 'descripcion', | ||
| 48 | nombre: 'Nombre' | ||
| 49 | }, | ||
| 50 | ], | ||
| 51 | }).then(function (res) { | ||
| 52 | cisterna.disponible = cisterna.capacidad; | ||
| 53 | var newArt = | ||
| 54 | { | ||
| 55 | id: 0, | ||
| 56 | idRemito: 0, | ||
| 57 | codigo: res.codigo, | ||
| 58 | sector: res.sector, | ||
| 59 | sectorCodigo: res.sector + '-' + res.codigo, | ||
| 60 | descripcion: res.descripcion, | ||
| 61 | item: key + 1, | ||
| 62 | nombre: res.descripcion, | ||
| 63 | precio: parseFloat(res.precio).toFixed(4), | ||
| 64 | costoUnitario: res.costo, | ||
| 65 | editCantidad: false, | ||
| 66 | editPrecio: false, | ||
| 67 | rubro: res.CodRub, | ||
| 68 | ivaUnitario: res.IMPIVA, | ||
| 69 | impuestoInternoUnitario: res.ImpInt, | ||
| 70 | impuestoInterno1Unitario: res.ImpInt2, | ||
| 71 | impuestoInterno2Unitario: res.ImpInt3, | ||
| 72 | precioLista: res.precio, | ||
| 73 | combustible: 1, | ||
| 74 | facturado: 0, | ||
| 75 | idArticulo: res.id, | ||
| 76 | tasaIva: res.tasaIVA | ||
| 77 | }; | ||
| 78 | |||
| 79 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | ||
| 80 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | ||
| 81 | |||
| 82 | cisterna.articuloSeleccionado = newArt; | ||
| 83 | cisterna.nombreArticulo = res.descripcion; | ||
| 84 | }).catch(function (e) { | ||
| 85 | console.error(e); | ||
| 86 | }); | ||
| 87 | }; | ||
| 88 | |||
| 89 | $scope.guardar = function () { | ||
| 90 | |||
| 91 | var cisternasFilter = validarArticulos(); | ||
| 92 | |||
| 93 | var articulos = []; | ||
| 94 | if (cisternasFilter === undefined) { | ||
| 95 | return; | ||
| 96 | } | ||
| 97 | cisternasFilter.forEach(function (cisterna) { | ||
| 98 | |||
| 99 | var fechaReparto = $scope.hojasRutas.fechaReparto; | ||
| 100 | cisterna.cisternaCarga = { | ||
| 101 | confirmado: null, | ||
| 102 | fechaReparto: fechaReparto, | ||
| 103 | idCisterna: cisterna.id, | ||
| 104 | orden: $scope.orden | ||
| 105 | }; | ||
| 106 | |||
| 107 | //cargar | ||
| 108 | if (cisterna.cisternaCarga.cantidad) { | ||
| 109 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | ||
| 110 | } else { | ||
| 111 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | ||
| 112 | cisterna.cisternaCarga.idProducto = | ||
| 113 | cisterna.articuloSeleccionado.idArticulo; | ||
| 114 | } | ||
| 115 | |||
| 116 | //Guardar | ||
| 117 | var now = new Date(); | ||
| 118 | var cisternaMovimiento = { | ||
| 119 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
| 120 | cantidad: cisterna.disponible, | ||
| 121 | metodo: 'carga', | ||
| 122 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
| 123 | }; | ||
| 124 | |||
| 125 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
| 126 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | ||
| 127 | articulos.push(cisterna.articuloSeleccionado); | ||
| 128 | $scope.cisternaMovimientos.push(cisternaMovimiento); | ||
| 129 | }); | ||
| 130 | |||
| 131 | $uibModalInstance.close({ | ||
| 132 | cisternas: cisternasFilter, | ||
| 133 | movimientos: $scope.cisternaMovimientos, | ||
| 134 | articulos: articulos | ||
| 135 | }); | ||
| 136 | }; | ||
| 137 | |||
| 138 | $scope.cancel = function () { | ||
| 139 | $uibModalInstance.dismiss(null); | ||
| 140 | }; | ||
| 141 | |||
| 142 | function validarArticulos() { | ||
| 143 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas | ||
| 144 | .filter(function (cisterna) { | ||
| 145 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | ||
| 146 | }); | ||
| 147 | |||
| 148 | var cisternasIncompletas = cisternasFilter.filter(function (cisterna) { | ||
| 149 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || | ||
| 150 | (!cisterna.articuloSeleccionado && cisterna.disponible); | ||
| 151 | }); | ||
| 152 | |||
| 153 | if (cisternasIncompletas.length > 0 && cisternasFilter.length > 0) { | ||
| 154 | focaModalService.alert('Ingrese todos los campos para completar el remito'); | ||
| 155 | cisternasFilter = undefined; | ||
| 156 | } | ||
| 157 | return cisternasFilter; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | ]); | ||
| 161 | 
src/js/controllerHojasRuta.js
| File was created | 1 | angular.module('focaOrdenCarga') | |
| 2 | .controller('focaModalHojasRutaController', [ | ||
| 3 | '$scope', '$uibModalInstance', 'focaModalService', | ||
| 4 | 'focaCrearHojaRutaService', 'parametrosModal', | ||
| 5 | function ($scope, $uibModalInstance, focaModalService, | ||
| 6 | focaCrearHojaRutaService, parametrosModal) { | ||
| 7 | |||
| 8 | init(); | ||
| 9 | |||
| 10 | function init() { | ||
| 11 | $scope.mostrar = false; | ||
| 12 | $scope.orden = parametrosModal.orden; | ||
| 13 | $scope.articulos = []; | ||
| 14 | $scope.cisternaMovimientos = []; | ||
| 15 | $scope.hojasRutas = parametrosModal.hojasRutas; | ||
| 16 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | ||
| 17 | function (cisterna) { | ||
| 18 | return !cisterna.desactivado; | ||
| 19 | } | ||
| 20 | ); | ||
| 21 | focaCrearHojaRutaService.getArticulos() | ||
| 22 | .then(function (articulos) { | ||
| 23 | $scope.articulos = articulos.data; | ||
| 24 | }); | ||
| 25 | }; | ||
| 26 | |||
| 27 | $scope.guardar = function () { | ||
| 28 | |||
| 29 | var cisternasFilter = validarArticulos(); | ||
| 30 | |||
| 31 | var articulos = []; | ||
| 32 | if (cisternasFilter === undefined) { | ||
| 33 | return; | ||
| 34 | } | ||
| 35 | cisternasFilter.forEach(function (cisterna) { | ||
| 36 | |||
| 37 | var fechaReparto = $scope.hojasRutas.fechaReparto; | ||
| 38 | cisterna.cisternaCarga = { | ||
| 39 | confirmado: null, | ||
| 40 | fechaReparto: fechaReparto, | ||
| 41 | idCisterna: cisterna.id, | ||
| 42 | orden: $scope.orden | ||
| 43 | }; | ||
| 44 | |||
| 45 | //cargar | ||
| 46 | if (cisterna.cisternaCarga.cantidad) { | ||
| 47 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | ||
| 48 | } else { | ||
| 49 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | ||
| 50 | cisterna.cisternaCarga.idProducto = | ||
| 51 | cisterna.articuloSeleccionado.idArticulo; | ||
| 52 | } | ||
| 53 | |||
| 54 | //Guardar | ||
| 55 | var now = new Date(); | ||
| 56 | var cisternaMovimiento = { | ||
| 57 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
| 58 | cantidad: cisterna.disponible, | ||
| 59 | metodo: 'carga', | ||
| 60 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
| 61 | }; | ||
| 62 | |||
| 63 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
| 64 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | ||
| 65 | articulos.push(cisterna.articuloSeleccionado); | ||
| 66 | $scope.cisternaMovimientos.push(cisternaMovimiento); | ||
| 67 | }); | ||
| 68 | |||
| 69 | $uibModalInstance.close({ | ||
| 70 | cisternas: cisternasFilter, | ||
| 71 | movimientos: $scope.cisternaMovimientos, | ||
| 72 | articulos: articulos | ||
| 73 | }); | ||
| 74 | }; | ||
| 75 | |||
| 76 | $scope.cancel = function () { | ||
| 77 | $uibModalInstance.dismiss(null); | ||
| 78 | }; | ||
| 79 | |||
| 80 | function validarArticulos() { | ||
| 81 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas | ||
| 82 | .filter(function (cisterna) { | ||
| 83 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | ||
| 84 | }); | ||
| 85 | |||
| 86 | var cisternasIncompletas = cisternasFilter.filter(function (cisterna) { | ||
| 87 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || | ||
| 88 | (!cisterna.articuloSeleccionado && cisterna.disponible); | ||
| 89 | }); | ||
| 90 | |||
| 91 | if (cisternasIncompletas.length > 0 && cisternasFilter.length > 0) { | ||
| 92 | focaModalService.alert('Ingrese todos los campos para completar el remito'); | ||
| 93 | cisternasFilter = undefined; | ||
| 94 | } | ||
| 95 | return cisternasFilter; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | ]); | ||
| 99 | 
src/js/service.js
| 1 | angular.module('focaOrdenCarga') | 1 | angular.module('focaOrdenCarga') | 
| 2 | .factory('focaOrdenCargaService', ['$http', 'API_ENDPOINT', | 2 | .factory('focaOrdenCargaService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 
| 3 | function ($http, API_ENDPOINT) { | 3 | return { | 
| 4 | return { | 4 | getVehiculos: function () { | 
| 5 | }; | 5 | return $http.get(API_ENDPOINT.URL + '/vehiculo'); | 
| 6 | }]); | 6 | }, | 
| 7 | getTransportistas: function () { | ||
| 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | ||
| 9 | }, | ||
| 10 | getCisternadoPorVehiculo: function (idVehiculo) { | ||
| 11 | return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); | ||
| 12 | }, | ||
| 13 | getCisterna: function (id) { | ||
| 14 | return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); | ||
| 15 | }, | ||
| 16 | guardarCisterna: function (cisterna) { | ||
| 17 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', { cisterna: cisterna }); | ||
| 18 | }, | ||
| 19 | deleteCisterna: function (id) { | ||
| 20 | return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); | ||
| 21 | }, | ||
| 22 | getVehiculosPorTransportista: function (id) { | ||
| 23 | return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); | ||
| 24 | }, | ||
| 25 | getEstadoCisterna: function (id, fecha) { | ||
| 26 | console.log(id, " ", fecha); | ||
| 27 | return $http.post(API_ENDPOINT.URL + '/cisterna/stock', | ||
| 28 | { idCisterna: id, fecha: fecha }); | ||
| 29 | }, | ||
| 30 | getHojasRuta: function (idVehiculo) { | ||
| 31 | return $http.get(API_ENDPOINT.URL + '/orden-carga/hoja-ruta/' + idVehiculo); | ||
| 32 | }, | ||
| 33 | getBotonera: function () { | ||
| 34 | var result = [ | ||
| 35 | { | ||
| 36 | label: 'Vehiculo', | ||
| 37 | image: 'vehiculo_secundario.png' | ||
| 38 | }, | ||
| 39 | { | ||
| 40 | label: 'Fecha de Reparto', | ||
| 41 | image: 'fechaDeEntrega.png' | ||
| 42 | }, | ||
| 43 | { | ||
| 44 | label: 'Hojas de Ruta', | ||
| 45 | image: 'hojaDeRuta.png' | ||
| 46 | }, | ||
| 47 | { | ||
| 48 | label: 'Remito Abierto', | ||
| 49 | image: 'remito_abierto.png' | ||
| 50 | }, | ||
| 51 | { | ||
| 52 | label: 'Chofer', | ||
| 53 | image: 'chofer_secundario.png' | ||
| 54 | }, | ||
| 55 | { | ||
| 56 | label: 'Graficar', | ||
| 57 | image: 'graficar.png' | ||
| 58 | } | ||
| 59 | ]; | ||
| 60 | return result; | ||
| 61 | }, | ||
| 62 | |||
| 63 | }; | ||
| 64 | }]); | ||
| 7 | 65 | 
src/views/modal-detalle-carga.html
| File was created | 1 | <div class="modal-header py-1"> | |
| 2 | <div class="row w-100"> | ||
| 3 | <div class="col-lg-6"> | ||
| 4 | <h5 class="modal-title my-1">Detalle de Carga</h5> | ||
| 5 | </div> | ||
| 6 | </div> | ||
| 7 | </div> | ||
| 8 | <div class="row"> | ||
| 9 | <div class="col ml-3 mt-2"> | ||
| 10 | <span class=" text-left"> | ||
| 11 | Transportista <b>{{hojasRutas.idTransportista}} {{hojasRutas.transportista.NOM}}</b> | ||
| 12 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | ||
| 13 | </span> | ||
| 14 | |||
| 15 | </div> | ||
| 16 | </div> | ||
| 17 | <div class="row"> | ||
| 18 | <div class="col ml-3"> | ||
| 19 | <span class=" text-left">Fecha <b>{{hojasRutas.fecha | date:'yyyy-MM-dd':'-0300'}}</b></span> | ||
| 20 | </div> | ||
| 21 | </div> | ||
| 22 | <div class="modal-body" id="modal-body"> | ||
| 23 | <table class="table table-hover table-sm table-striped"> | ||
| 24 | <thead> | ||
| 25 | <tr> | ||
| 26 | <th>Cisterna</th> | ||
| 27 | <th>Capacidad</th> | ||
| 28 | <th>Disponibles</th> | ||
| 29 | <th>Articulo Cargado</th> | ||
| 30 | </tr> | ||
| 31 | </thead> | ||
| 32 | <tbody> | ||
| 33 | <tr | ||
| 34 | ng-repeat="(key, cisterna) in hojasRutas.vehiculo.cisternas" | ||
| 35 | > | ||
| 36 | <td ng-bind="cisterna.id"></td> | ||
| 37 | <td ng-bind="cisterna.capacidad"></td> | ||
| 38 | <td class="w-50"> | ||
| 39 | <input | ||
| 40 | ng-focus="$event.target.select();" | ||
| 41 | ng-model="cisterna.disponible" | ||
| 42 | ng-keyup="validarCisternaDisponible(cisterna)" | ||
| 43 | class="form-control" | ||
| 44 | solo-positivos | ||
| 45 | foca-tipo-input | ||
| 46 | /> | ||
| 47 | </td> | ||
| 48 | <td class="w-25"> | ||
| 49 | <div class="input-group "> | ||
| 50 | <input | ||
| 51 | ng-model="cisterna.nombreArticulo" | ||
| 52 | class="form-control" | ||
| 53 | ng-click="seleccionarProductos(key, cisterna)" | ||
| 54 | readonly | ||
| 55 | /> | ||
| 56 | <div class="input-group-append"> | ||
| 57 | <button | ||
| 58 | ladda="searchLoading" | ||
| 59 | class="btn btn-outline-secondary form-control" | ||
| 60 | type="button" | ||
| 61 | ng-click="seleccionarProductos(key, cisterna)" | ||
| 62 | > | ||
| 63 | <i class="fa fa-search" aria-hidden="true"></i> | ||
| 64 | </button> | ||
| 65 | </div> | ||
| 66 | </div> | ||
| 67 | </td> | ||
| 68 | </tr> | ||
| 69 | </tbody> | ||
| 70 | </table> | ||
| 71 | </div> | ||
| 72 | <div class="modal-footer py-1"> | ||
| 73 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 74 | <button class="btn btn-sm btn-primary" type="button" ng-click="guardar()">Guardar</button> | ||
| 75 | </div> | ||
| 76 | 
src/views/modal-hojas-ruta.html
| File was created | 1 | <div class="modal-header py-1"> | |
| 2 | <div class="row w-100"> | ||
| 3 | <div class="col-lg-6"> | ||
| 4 | <h5 class="modal-title my-1">Hojas de Ruta</h5> | ||
| 5 | </div> | ||
| 6 | </div> | ||
| 7 | </div> | ||
| 8 | <!-- <div class="row"> | ||
| 9 | <div class="col ml-3 mt-2"> | ||
| 10 | <span class=" text-left"> | ||
| 11 | Unidad <b>{{hojasRutas.vehiculo.codigo}}</b> Tractor <b>{{hojasRutas.vehiculo.tractor}}</b> | ||
| 12 | </span> | ||
| 13 | </div> | ||
| 14 | </div> --> | ||
| 15 | <div class="modal-body" id="modal-body"> | ||
| 16 | <table class="table table-hover table-sm table-striped"> | ||
| 17 | <thead> | ||
| 18 | <tr> | ||
| 19 | <th>Fecha</th> | ||
| 20 | <th>N°</th> | ||
| 21 | <th>Ver</th> | ||
| 22 | <th></th> | ||
| 23 | </tr> | ||
| 24 | </thead> | ||
| 25 | <tbody> | ||
| 26 | <tr ng-repeat="remito in hojasRutas.remitos"> | ||
| 27 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | ||
| 28 | <td ng-bind="remito.nombreCliente"></td> | ||
| 29 | <td ng-bind="remito.domicilioStamp"></td> | ||
| 30 | <td> | ||
| 31 | <button | ||
| 32 | type="button" | ||
| 33 | class="btn btn-xs p-1 float-right" | ||
| 34 | ng-class="{ | ||
| 35 | 'btn-secondary': selectedCobranza != key, | ||
| 36 | 'btn-primary': selectedCobranza == key | ||
| 37 | }" | ||
| 38 | foca-focus="selectedCobranza == {{key}}" | ||
| 39 | ng-keydown="itemCobranza($event.keyCode)" | ||
| 40 | > | ||
| 41 | <i class="fa fa-circle-thin" aria-hidden="true"></i> | ||
| 42 | </button> | ||
| 43 | </td>> | ||
| 44 | </tr> | ||
| 45 | </tbody> | ||
| 46 | </table> | ||
| 47 | </div> | ||
| 48 | <div class="modal-footer py-1"> | ||
| 49 | <button class="btn btn-sm btn-secondary" type="button" ng-click="cancel()">Cancelar</button> | ||
| 50 | </div> | ||
| 51 | 
src/views/orden-carga.html
| 1 | <div class="row"> | ||
| 2 | <foca-cabecera-facturador titulo="'Orden de Carga'" numero="puntoVenta + '-' + comprobante" | ||
| 3 | fecha="ordenCarga.fechaCarga" class="mb-0 col-lg-12"></foca-cabecera-facturador> | ||
| 4 | </div> | ||
| 5 | <div class="row"> | ||
| 6 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | ||
| 7 | <div class="row px-5 py-2 botonera-secundaria"> | ||
| 8 | <div class="col-12"> | ||
| 9 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | ||
| 10 | </div> | ||
| 11 | </div> | ||
| 12 | |||
| 13 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | ||
| 14 | <thead> | ||
| 15 | <tr> | ||
| 16 | <th>Cisterna</th> | ||
| 17 | <th>Producto</th> | ||
| 18 | <th>Capacidad Total</th> | ||
| 19 | <th>Carga</th> | ||
| 20 | <th>Disponible</th> | ||
| 21 | <th class="text-center"> | ||
| 22 | </th> | ||
| 23 | </tr> | ||
| 24 | </thead> | ||
| 25 | <tbody> | ||
| 26 | <tr ng-repeat="cisterna in hojaRuta.vehiculo.cisternas"> | ||
| 27 | <td ng-bind="cisterna.codigo"></td> | ||
| 28 | <td>producto</td> | ||
| 29 | <td ng-bind="cisterna.capacidad"></td> | ||
| 30 | <td ng-bind="cisterna.cantidadDescargada"></td> | ||
| 31 | <td>{{cisterna.capacidad - cisterna.cantidadDescargada}}</td> | ||
| 32 | </tr> | ||
| 33 | </tbody> | ||
| 34 | </table> | ||
| 35 | </div> | ||
| 36 | </div> | ||
| 37 |