Commit 85e02bd58eb04e161ffb93970c53c7ad4d641d32
1 parent
2094b28fdb
Exists in
master
orden carga con funcionalidades-excepto hojas de ruta
Showing
6 changed files
with
574 additions
and
112 deletions
 
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 | '$uibModal', | ||
| 5 | '$location', | 4 | '$location', | 
| 6 | '$filter', | 5 | '$filter', | 
| 7 | '$timeout', | 6 | '$timeout', | 
| 8 | 'focaOrdenCargaService', | 7 | 'focaOrdenCargaService', | 
| 9 | 'focaBotoneraLateralService', | 8 | 'focaBotoneraLateralService', | 
| 10 | 'focaModalService', | 9 | 'focaModalService', | 
| 11 | 'notaPedidoBusinessService', | 10 | '$uibModal', | 
| 12 | '$rootScope', | ||
| 13 | 'focaSeguimientoService', | ||
| 14 | 'APP', | ||
| 15 | 'focaLoginService', | ||
| 16 | '$localStorage', | ||
| 17 | function ( | 11 | function ( | 
| 18 | $scope, $uibModal, $location, $filter, $timeout, focaOrdenCargaService, | 12 | $scope, $location, $filter, $timeout, focaOrdenCargaService, | 
| 19 | focaBotoneraLateralService, focaModalService, notaPedidoBusinessService, | 13 | focaBotoneraLateralService, focaModalService, $uibModal) { | 
| 20 | $rootScope, focaSeguimientoService, APP, focaLoginService, $localStorage) { | ||
| 21 | config(); | ||
| 22 | 14 | ||
| 23 | function config() { | 15 | init(); | 
| 16 | |||
| 17 | function init() { | ||
| 24 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 18 | // PARAMETROS INICIALES PARA FUNCIONAMIENTO DEL PROGRAMA | 
| 25 | $scope.tmpCantidad = Number; | 19 | $scope.fecha = new Date(); | 
| 26 | $scope.tmpPrecio = Number; | ||
| 27 | $scope.isNumber = angular.isNumber; | 20 | $scope.isNumber = angular.isNumber; | 
| 28 | $scope.datepickerAbierto = false; | ||
| 29 | $scope.show = false; | 21 | $scope.show = false; | 
| 30 | $scope.cargando = true; | 22 | $scope.cargando = true; | 
| 31 | $scope.cabeceras = []; | 23 | $scope.cabeceras = []; | 
| 32 | $scope.botonera = focaOrdenCargaService.getBotonera(); | 24 | $scope.botonera = focaOrdenCargaService.getBotonera(); | 
| 33 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | ||
| 34 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | ||
| 35 | $scope.dateOptions = { | 25 | $scope.dateOptions = { | 
| 36 | maxDate: new Date(), | 26 | maxDate: new Date(), | 
| 37 | minDate: new Date(2010, 0, 1) | 27 | minDate: new Date(2010, 0, 1) | 
| 38 | }; | 28 | }; | 
| 39 | 29 | ||
| 40 | //SETEO BOTONERA LATERAL | ||
| 41 | $timeout(function () { | ||
| 42 | focaBotoneraLateralService.showSalir(false); | ||
| 43 | focaBotoneraLateralService.showPausar(true); | ||
| 44 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | ||
| 45 | focaBotoneraLateralService.addCustomButton('Salir', salir); | ||
| 46 | }); | ||
| 47 | |||
| 48 | init(); | ||
| 49 | |||
| 50 | } | ||
| 51 | |||
| 52 | function init() { | ||
| 53 | $scope.ordenCarga = { | 30 | $scope.ordenCarga = { | 
| 54 | id: 0, | 31 | id: 0, | 
| 55 | cliente: {}, | 32 | cliente: {}, | 
| 56 | proveedor: {}, | 33 | proveedor: {}, | 
| 57 | domicilio: { dom: '' }, | 34 | domicilio: { dom: '' }, | 
| 58 | vendedor: {}, | 35 | vendedor: {}, | 
| 59 | fechaCarga: new Date(), | 36 | fechaCarga: new Date(), | 
| 60 | cotizacion: {}, | 37 | cotizacion: {}, | 
| 61 | articulosNotaPedido: [], | 38 | articulosNotaPedido: [], | 
| 62 | notaPedidoPlazo: [], | 39 | notaPedidoPlazo: [], | 
| 63 | notaPedidoPuntoDescarga: [] | 40 | notaPedidoPuntoDescarga: [] | 
| 64 | }; | 41 | }; | 
| 42 | $scope.hojaRuta = { | ||
| 43 | fecha: new Date(), | ||
| 44 | litros: 0, | ||
| 45 | chofer: {}, | ||
| 46 | vehiculo: { | ||
| 47 | capacidad: 0, | ||
| 48 | cisternas: [] | ||
| 49 | }, | ||
| 50 | transportista: {}, | ||
| 51 | remitosTabla: [] | ||
| 52 | }; | ||
| 53 | } | ||
| 54 | |||
| 55 | //SETEO BOTONERA LATERAL | ||
| 56 | $timeout(function () { | ||
| 57 | focaBotoneraLateralService.showSalir(false); | ||
| 58 | focaBotoneraLateralService.showPausar(true); | ||
| 59 | focaBotoneraLateralService.showGuardar(true, $scope.crearNotaPedido); | ||
| 60 | focaBotoneraLateralService.addCustomButton('Salir', salir); | ||
| 61 | }); | ||
| 62 | |||
| 63 | function seleccionarTransportista() { | ||
| 64 | var parametrosModal = { | ||
| 65 | titulo: 'Búsqueda de Transportista', | ||
| 66 | query: '/transportista', | ||
| 67 | columnas: [ | ||
| 68 | { | ||
| 69 | nombre: 'Código', | ||
| 70 | propiedad: 'COD' | ||
| 71 | }, | ||
| 72 | { | ||
| 73 | nombre: 'Nombre', | ||
| 74 | propiedad: 'NOM' | ||
| 75 | }, | ||
| 76 | { | ||
| 77 | nombre: 'CUIT', | ||
| 78 | propiedad: 'CUIT' | ||
| 79 | } | ||
| 80 | ] | ||
| 81 | }; | ||
| 82 | return focaModalService.modal(parametrosModal); | ||
| 83 | }; | ||
| 84 | |||
| 85 | $scope.seleccionarVehiculo = function () { | ||
| 86 | |||
| 87 | seleccionarTransportista().then( | ||
| 88 | |||
| 89 | function (transportista) { | ||
| 90 | elegirTransportista(transportista); | ||
| 91 | |||
| 92 | var parametrosModal = { | ||
| 93 | columnas: [ | ||
| 94 | { | ||
| 95 | propiedad: 'codigo', | ||
| 96 | nombre: 'Código' | ||
| 97 | }, | ||
| 98 | { | ||
| 99 | propiedad: 'tractor', | ||
| 100 | nombre: 'tractor' | ||
| 101 | }, | ||
| 102 | { | ||
| 103 | propiedad: 'semi', | ||
| 104 | nombre: 'Semi' | ||
| 105 | }, | ||
| 106 | { | ||
| 107 | propiedad: 'capacidadTotalCisternas', | ||
| 108 | nombre: 'Capacidad' | ||
| 109 | } | ||
| 110 | ], | ||
| 111 | query: '/vehiculo/transportista/' + transportista.COD, | ||
| 112 | titulo: 'Búsqueda de vehiculos', | ||
| 113 | subTitulo: transportista.COD + '-' + transportista.NOM | ||
| 114 | }; | ||
| 115 | |||
| 116 | focaModalService.modal(parametrosModal).then( | ||
| 117 | function (vehiculo) { | ||
| 118 | $scope.$broadcast('addCabecera', { | ||
| 119 | label: 'Vehículo:', | ||
| 120 | valor: vehiculo.codigo | ||
| 121 | }); | ||
| 122 | $scope.hojaRuta.vehiculo = vehiculo; | ||
| 123 | $scope.hojaRuta.transportista = transportista; | ||
| 124 | $scope.hojaRuta.vehiculo.cisternas = vehiculo.cisternas; | ||
| 125 | getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); | ||
| 126 | }, function () { | ||
| 127 | seleccionarTransportista(); | ||
| 128 | }); | ||
| 129 | }); | ||
| 130 | }; | ||
| 131 | |||
| 132 | $scope.seleccionarVerCisternas = function () { | ||
| 133 | if (!$scope.hojaRuta.vehiculo.cisternas.length) { | ||
| 134 | focaModalService.alert('Primero seleccione un vehículo con cisternas'); | ||
| 135 | return; | ||
| 136 | } | ||
| 137 | console.log($scope.hojaRuta.vehiculo); | ||
| 138 | $uibModal.open( | ||
| 139 | { | ||
| 140 | ariaLabelledBy: 'Grafico de cisternas', | ||
| 141 | templateUrl: 'modal-grafico-cisternas.html', | ||
| 142 | controller: 'focaModalGraficoCisternasController', | ||
| 143 | size: 'md', | ||
| 144 | resolve: { | ||
| 145 | filters: { | ||
| 146 | cisternas: $scope.hojaRuta.vehiculo.cisternas | ||
| 147 | } | ||
| 148 | } | ||
| 149 | } | ||
| 150 | ); | ||
| 151 | }; | ||
| 152 | |||
| 153 | $scope.seleccionarFechaDeReparto = function () { | ||
| 154 | focaModalService.modalFecha('Fecha').then(function (fecha) { | ||
| 155 | $scope.$broadcast('addCabecera', { | ||
| 156 | label: 'Fecha:', | ||
| 157 | valor: fecha.toLocaleDateString() | ||
| 158 | }); | ||
| 65 | 159 | ||
| 160 | $scope.fecha = fecha; | ||
| 161 | if ($scope.hojaRuta.vehiculo.cisternas) | ||
| 162 | getEstadosCisternas($scope.hojaRuta.vehiculo.cisternas); | ||
| 163 | }); | ||
| 164 | }; | ||
| 165 | |||
| 166 | $scope.seleccionarRemitoAbierto = function () { | ||
| 167 | if ($scope.hojaRuta.vehiculo.capacidad === 0) { | ||
| 168 | focaModalService.alert('Debe ingresar vehiculo'); | ||
| 169 | return; | ||
| 170 | } else { | ||
| 171 | mostrarDetalle($scope.hojaRuta); | ||
| 172 | } | ||
| 173 | }; | ||
| 174 | |||
| 175 | $scope.seleccionarChofer = function () { | ||
| 176 | var parametrosModal = { | ||
| 177 | titulo: 'Búsqueda de Chofer', | ||
| 178 | query: '/chofer', | ||
| 179 | columnas: [ | ||
| 180 | { | ||
| 181 | propiedad: 'id', | ||
| 182 | nombre: 'Código', | ||
| 183 | filtro: { | ||
| 184 | nombre: 'rellenarDigitos', | ||
| 185 | parametro: 3 | ||
| 186 | } | ||
| 187 | }, | ||
| 188 | { | ||
| 189 | propiedad: 'nombre', | ||
| 190 | nombre: 'Nombre' | ||
| 191 | }, | ||
| 192 | { | ||
| 193 | propiedad: 'dni', | ||
| 194 | nombre: 'DNI' | ||
| 195 | }, | ||
| 196 | { | ||
| 197 | propiedad: 'telefono', | ||
| 198 | nombre: 'Teléfono' | ||
| 199 | } | ||
| 200 | ] | ||
| 201 | }; | ||
| 202 | focaModalService.modal(parametrosModal).then( | ||
| 203 | function (chofer) { | ||
| 204 | $scope.ordenCarga.chofer = chofer; | ||
| 205 | $scope.$broadcast('addCabecera', { | ||
| 206 | label: 'Chofer:', | ||
| 207 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' + chofer.nombre | ||
| 208 | }); | ||
| 209 | |||
| 210 | $filter('filter')($scope.botonera, { | ||
| 211 | label: 'Chofer', | ||
| 212 | })[0].checked = true; | ||
| 213 | }, function () { | ||
| 214 | // funcion ejecutada cuando se cancela el modal | ||
| 215 | } | ||
| 216 | ); | ||
| 217 | }; | ||
| 218 | |||
| 219 | function getEstadosCisternas(cisternas) { | ||
| 220 | cisternas.forEach(function (cisterna) { | ||
| 221 | focaOrdenCargaService | ||
| 222 | .getEstadoCisterna(cisterna.id, $scope.fecha) | ||
| 223 | .then(function (res) { | ||
| 224 | cisterna.estado = res.data; | ||
| 225 | }) | ||
| 226 | .catch(function (err) { console.error(err) }); | ||
| 227 | }); | ||
| 228 | } | ||
| 229 | |||
| 230 | function elegirTransportista(transportista) { | ||
| 231 | var codigo = ('00000' + transportista.COD).slice(-5); | ||
| 232 | $scope.idTransportista = transportista.COD; | ||
| 233 | $scope.filtros = transportista.NOM.trim(); | ||
| 234 | $scope.$broadcast('addCabecera', { | ||
| 235 | label: 'Transportista:', | ||
| 236 | valor: codigo + ' - ' + transportista.NOM | ||
| 237 | }); | ||
| 238 | } | ||
| 239 | |||
| 240 | function mostrarDetalle(hojasRutas) { | ||
| 241 | var modalInstance = $uibModal.open( | ||
| 242 | { | ||
| 243 | ariaLabelledBy: '', | ||
| 244 | templateUrl: 'modal-detalle-carga.html', | ||
| 245 | controller: 'focaModalDetalleController', | ||
| 246 | resolve: { | ||
| 247 | parametrosModal: function () { | ||
| 248 | return { | ||
| 249 | hojasRutas: hojasRutas, | ||
| 250 | orden: $scope.hojaRuta.orden | ||
| 251 | }; | ||
| 252 | } | ||
| 253 | }, | ||
| 254 | size: 'lg', | ||
| 255 | backdrop: false | ||
| 256 | } | ||
| 257 | ); | ||
| 258 | return modalInstance.result | ||
| 259 | .then(function (res) { | ||
| 260 | res.cisternas.forEach(function (cisterna) { | ||
| 261 | $scope.cisternaCargas.push(cisterna.cisternaCarga); | ||
| 262 | }); | ||
| 263 | $scope.cisternaMovimientos = res.movimientos; | ||
| 264 | $scope.articulosRecibidos = res.articulos; | ||
| 265 | $scope.articulos = res.articulos; | ||
| 266 | $filter('filter')($scope.botonera, { | ||
| 267 | label: 'Detalle de Carga', | ||
| 268 | })[0].checked = true; | ||
| 269 | }) | ||
| 270 | .catch(function (e) { console.error(e); }); | ||
| 271 | }; | ||
| 272 | |||
| 273 | function crearOrdenCarga() { | ||
| 274 | |||
| 275 | focaBotoneraLateralService.startGuardar(); | ||
| 276 | $scope.saveLoading = true; | ||
| 66 | } | 277 | } | 
| 67 | 278 | ||
| 68 | $scope.$watch('ordenCarga', function (newValue) { | 279 | $scope.$watch('ordenCarga', function (newValue) { | 
| 69 | focaBotoneraLateralService.setPausarData({ | 280 | focaBotoneraLateralService.setPausarData({ | 
| 70 | label: 'ordenCarga', | 281 | label: 'ordenCarga', | 
| 71 | val: newValue | 282 | val: newValue | 
| 72 | }); | 283 | }); | 
| 73 | }, true); | 284 | }, true); | 
| 74 | 285 | ||
| 75 | $scope.$watch('ordenCarga', function (newValue) { | 286 | $scope.$watch('ordenCarga', function (newValue) { | 
| 76 | focaBotoneraLateralService.setPausarData({ | 287 | focaBotoneraLateralService.setPausarData({ | 
| 77 | label: 'ordenCarga', | 288 | label: 'ordenCarga', | 
| 78 | val: newValue | 289 | val: newValue | 
| 79 | }); | 290 | }); | 
| 80 | focaBotoneraLateralService.setRutasPausadas({ | 291 | focaBotoneraLateralService.setRutasPausadas({ | 
| 81 | label: 'rutas', | 292 | label: 'rutas', | 
| 82 | val: 'orden-carga' | 293 | val: 'orden-carga' | 
| 83 | }); | 294 | }); | 
| 84 | }, true); | 295 | }, true); | 
| 85 | 296 | 
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 | $scope.mostrar = false; | ||
| 9 | $scope.orden = parametrosModal.orden; | ||
| 10 | $scope.articulos = []; | ||
| 11 | $scope.cisternaMovimientos = []; | ||
| 12 | |||
| 13 | init(); | ||
| 14 | |||
| 15 | function init() { | ||
| 16 | |||
| 17 | $scope.hojasRutas = parametrosModal.hojasRutas; | ||
| 18 | $scope.hojasRutas.vehiculo.cisternas = $scope.hojasRutas.vehiculo.cisternas.filter( | ||
| 19 | function (cisterna) { | ||
| 20 | return !cisterna.desactivado; | ||
| 21 | } | ||
| 22 | ); | ||
| 23 | focaCrearHojaRutaService.getArticulos() | ||
| 24 | .then(function (articulos) { | ||
| 25 | $scope.articulos = articulos.data; | ||
| 26 | }); | ||
| 27 | } | ||
| 28 | |||
| 29 | $scope.validarCisternaDisponible = function (cisterna) { | ||
| 30 | if (parseInt(cisterna.disponible) > cisterna.capacidad) { | ||
| 31 | focaModalService.alert('No se puede ingresar una capacidad disponible ' + | ||
| 32 | 'superior a la ' + 'capacidad del vehiculo '); | ||
| 33 | cisterna.disponible = cisterna.capacidad; | ||
| 34 | return; | ||
| 35 | } | ||
| 36 | }; | ||
| 37 | |||
| 38 | $scope.seleccionarProductos = function (key, cisterna) { | ||
| 39 | focaModalService.modal({ | ||
| 40 | titulo: 'Productos', | ||
| 41 | data: $scope.articulos, | ||
| 42 | size: 'md', | ||
| 43 | columnas: [ | ||
| 44 | { | ||
| 45 | propiedad: 'CodRub', | ||
| 46 | nombre: 'Codigo' | ||
| 47 | }, | ||
| 48 | { | ||
| 49 | propiedad: 'descripcion', | ||
| 50 | nombre: 'Nombre' | ||
| 51 | }, | ||
| 52 | ], | ||
| 53 | }).then(function (res) { | ||
| 54 | cisterna.disponible = cisterna.capacidad; | ||
| 55 | var newArt = | ||
| 56 | { | ||
| 57 | id: 0, | ||
| 58 | idRemito: 0, | ||
| 59 | codigo: res.codigo, | ||
| 60 | sector: res.sector, | ||
| 61 | sectorCodigo: res.sector + '-' + res.codigo, | ||
| 62 | descripcion: res.descripcion, | ||
| 63 | item: key + 1, | ||
| 64 | nombre: res.descripcion, | ||
| 65 | precio: parseFloat(res.precio).toFixed(4), | ||
| 66 | costoUnitario: res.costo, | ||
| 67 | editCantidad: false, | ||
| 68 | editPrecio: false, | ||
| 69 | rubro: res.CodRub, | ||
| 70 | ivaUnitario: res.IMPIVA, | ||
| 71 | impuestoInternoUnitario: res.ImpInt, | ||
| 72 | impuestoInterno1Unitario: res.ImpInt2, | ||
| 73 | impuestoInterno2Unitario: res.ImpInt3, | ||
| 74 | precioLista: res.precio, | ||
| 75 | combustible: 1, | ||
| 76 | facturado: 0, | ||
| 77 | idArticulo: res.id, | ||
| 78 | tasaIva: res.tasaIVA | ||
| 79 | }; | ||
| 80 | |||
| 81 | newArt.exentoUnitario = newArt.ivaUnitario ? 0 : res.neto; | ||
| 82 | newArt.netoUnitario = newArt.ivaUnitario ? res.neto : 0; | ||
| 83 | |||
| 84 | cisterna.articuloSeleccionado = newArt; | ||
| 85 | cisterna.nombreArticulo = res.descripcion; | ||
| 86 | }).catch(function (e) { | ||
| 87 | console.log(e); | ||
| 88 | }); | ||
| 89 | }; | ||
| 90 | |||
| 91 | $scope.guardar = function () { | ||
| 92 | |||
| 93 | var cisternasFilter = validarArticulos(); | ||
| 94 | |||
| 95 | var articulos = []; | ||
| 96 | if (cisternasFilter === undefined) { | ||
| 97 | return; | ||
| 98 | } | ||
| 99 | cisternasFilter.forEach(function (cisterna) { | ||
| 100 | |||
| 101 | var fechaReparto = $scope.hojasRutas.fechaReparto; | ||
| 102 | |||
| 103 | // var filtroCisternaCarga = cisterna.cisternasCarga.filter(function(carga) { | ||
| 104 | // return carga.fechaReparto === fechaReparto; | ||
| 105 | // }); | ||
| 106 | |||
| 107 | // if (filtroCisternaCarga.length) { | ||
| 108 | // cisterna.cisternaCarga = filtroCisternaCarga[0]; | ||
| 109 | // } else { | ||
| 110 | cisterna.cisternaCarga = { | ||
| 111 | confirmado: null, | ||
| 112 | fechaReparto: fechaReparto, | ||
| 113 | idCisterna: cisterna.id, | ||
| 114 | orden: $scope.orden | ||
| 115 | }; | ||
| 116 | // } | ||
| 117 | |||
| 118 | //cargar | ||
| 119 | if (cisterna.cisternaCarga.cantidad) { | ||
| 120 | cisterna.cisternaCarga.cantidad += cisterna.disponible; | ||
| 121 | } else { | ||
| 122 | cisterna.cisternaCarga.cantidad = cisterna.disponible; | ||
| 123 | cisterna.cisternaCarga.idProducto = | ||
| 124 | cisterna.articuloSeleccionado.idArticulo; | ||
| 125 | } | ||
| 126 | |||
| 127 | //Guardar | ||
| 128 | var now = new Date(); | ||
| 129 | var cisternaMovimiento = { | ||
| 130 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
| 131 | cantidad: cisterna.disponible, | ||
| 132 | metodo: 'carga', | ||
| 133 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
| 134 | }; | ||
| 135 | |||
| 136 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
| 137 | cisterna.articuloSeleccionado.cantidad = cisterna.disponible; | ||
| 138 | articulos.push(cisterna.articuloSeleccionado); | ||
| 139 | $scope.cisternaMovimientos.push(cisternaMovimiento); | ||
| 140 | }); | ||
| 141 | |||
| 142 | $uibModalInstance.close({ | ||
| 143 | cisternas: cisternasFilter, | ||
| 144 | movimientos: $scope.cisternaMovimientos, | ||
| 145 | articulos: articulos | ||
| 146 | }); | ||
| 147 | }; | ||
| 148 | |||
| 149 | $scope.cancel = function () { | ||
| 150 | $uibModalInstance.dismiss(null); | ||
| 151 | }; | ||
| 152 | |||
| 153 | function validarArticulos() { | ||
| 154 | var cisternasFilter = $scope.hojasRutas.vehiculo.cisternas | ||
| 155 | .filter(function (cisterna) { | ||
| 156 | return parseInt(cisterna.disponible) > 0 || cisterna.articuloSeleccionado; | ||
| 157 | }); | ||
| 158 | |||
| 159 | var cisternasIncompletas = cisternasFilter.filter(function (cisterna) { | ||
| 160 | return (cisterna.articuloSeleccionado && !cisterna.disponible) || | ||
| 161 | (!cisterna.articuloSeleccionado && cisterna.disponible); | ||
| 162 | }); | ||
| 163 | |||
| 164 | if (cisternasIncompletas.length > 0 && cisternasFilter.length > 0) { | ||
| 165 | focaModalService.alert('Ingrese todos los campos para completar el remito'); | ||
| 166 | cisternasFilter = undefined; | ||
| 167 | } | ||
| 168 | return cisternasFilter; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | ]); | ||
| 172 | 
src/js/service.js
| 1 | angular.module('focaOrdenCarga') | 1 | angular.module('focaOrdenCarga') | 
| 2 | .factory('focaOrdenCargaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | 2 | .factory('focaOrdenCargaService', ['$http', 'API_ENDPOINT', function ($http, API_ENDPOINT) { | 
| 3 | var route = API_ENDPOINT.URL; | ||
| 4 | return { | 3 | return { | 
| 5 | getBotonera: function() { | 4 | getVehiculos: function () { | 
| 6 | var result = [ | 5 | return $http.get(API_ENDPOINT.URL + '/vehiculo'); | 
| 7 | { | 6 | }, | 
| 8 | label: 'Vehiculo', | 7 | getTransportistas: function () { | 
| 9 | image: 'vehiculo_secundario.png' | 8 | return $http.get(API_ENDPOINT.URL + '/transportista'); | 
| 10 | }, | 9 | }, | 
| 11 | { | 10 | getCisternadoPorVehiculo: function (idVehiculo) { | 
| 12 | label: 'Fecha de Reparto', | 11 | return $http.get(API_ENDPOINT.URL + '/cisterna/listar/' + idVehiculo); | 
| 13 | image: 'fechaDeEntrega.png' | 12 | }, | 
| 14 | }, | 13 | getCisterna: function (id) { | 
| 15 | { | 14 | return $http.get(API_ENDPOINT.URL + '/cisterna/obtener/' + id); | 
| 16 | label: 'Hojas de Ruta', | 15 | }, | 
| 17 | image: 'hojaDeRuta.png' | 16 | guardarCisterna: function (cisterna) { | 
| 18 | }, | 17 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar', { cisterna: cisterna }); | 
| 19 | { | 18 | }, | 
| 20 | label: 'Remito Abierto', | 19 | deleteCisterna: function (id) { | 
| 21 | image: 'remito_abierto.png' | 20 | return $http.delete(API_ENDPOINT.URL + '/cisterna/borrar/' + id); | 
| 22 | }, | 21 | }, | 
| 23 | { | 22 | getVehiculosPorTransportista: function (id) { | 
| 24 | label: 'Chofer', | 23 | return $http.get(API_ENDPOINT.URL + '/vehiculo/transportista/' + id); | 
| 25 | image: 'chofer_secundario.png' | 24 | }, | 
| 26 | }, | 25 | getEstadoCisterna: function (id, fecha) { | 
| 27 | { | 26 | console.log(id, " ", fecha); | 
| 28 | label: 'Ver Cisternas', | 27 | return $http.post(API_ENDPOINT.URL + '/cisterna/stock', | 
| 29 | image: 'verCisterna.png' | 28 | { idCisterna: id, fecha: fecha }); | 
| 30 | } | 29 | }, | 
| 31 | ]; | 30 | getBotonera: function () { | 
| 32 | return result; | 31 | var result = [ | 
| 33 | }, | 32 | { | 
| 34 | }; | 33 | label: 'Vehiculo', | 
| 35 | }]); | 34 | image: 'vehiculo_secundario.png' | 
| 35 | }, | ||
| 36 | { | ||
| 37 | label: 'Fecha de Reparto', | ||
| 38 | image: 'fechaDeEntrega.png' | ||
| 39 | }, | ||
| 40 | { | ||
| 41 | label: 'Hojas de Ruta', | ||
| 42 | image: 'hojaDeRuta.png' | ||
| 43 | }, | ||
| 44 | { | ||
| 45 | label: 'Remito Abierto', | ||
| 46 | image: 'remito_abierto.png' | ||
| 47 | }, | ||
| 48 | { | ||
| 49 | label: 'Chofer', | ||
| 50 | image: 'chofer_secundario.png' | ||
| 51 | }, | ||
| 52 | { | ||
| 53 | label: 'Ver Cisternas', | ||
| 54 | image: 'verCisterna.png' | ||
| 55 | } | ||
| 56 | ]; | ||
| 57 | return result; | ||
| 58 | }, | ||
| 59 | }; | ||
| 60 | }]); | 
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 | </div> | 
src/views/orden-carga.html
| 1 | <div class="row"> | 1 | <div class="row"> | 
| 2 | <foca-cabecera-facturador | 2 | <foca-cabecera-facturador titulo="'Orden de Carga'" numero="puntoVenta + '-' + comprobante" | 
| 3 | titulo="'Orden de Carga'" | 3 | fecha="ordenCarga.fechaCarga" class="mb-0 col-lg-12"></foca-cabecera-facturador> | 
| 4 | numero="puntoVenta + '-' + comprobante" | ||
| 5 | fecha="ordenCarga.fechaCarga" | ||
| 6 | class="mb-0 col-lg-12" | ||
| 7 | ></foca-cabecera-facturador> | ||
| 8 | </div> | 4 | </div> | 
| 9 | <div class="row"> | 5 | <div class="row"> | 
| 10 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 6 | <div class="col-12 col-md-10 p-0 mt-4 border border-white rounded"> | 
| 11 | <div class="row px-5 py-2 botonera-secundaria"> | 7 | <div class="row px-5 py-2 botonera-secundaria"> | 
| 12 | <div class="col-12"> | 8 | <div class="col-12"> | 
| 13 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 9 | <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> | 
| 14 | </div> | 10 | </div> | 
| 15 | </div> | 11 | </div> | 
| 16 | 12 | ||
| 17 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 13 | <table class="table table-default table-hover table-sm table-abm table-striped mb-0"> | 
| 18 | <thead> | 14 | <thead> | 
| 19 | <tr> | 15 | <tr> | 
| 20 | <th>Cisterna</th> | 16 | <th>Cisterna</th> | 
| 21 | <th>Producto</th> | 17 | <th>Producto</th> | 
| 22 | <th>Capacidad Total</th> | 18 | <th>Capacidad Total</th> | 
| 23 | <th>Carga</th> | 19 | <th>Carga</th> | 
| 24 | <th>Disponible</th> | 20 | <th>Disponible</th> | 
| 25 | <th class="text-center"> | 21 | <th class="text-center"> | 
| 26 | </th> | 22 | </th> | 
| 27 | </tr> | 23 | </tr> | 
| 28 | </thead> | 24 | </thead> | 
| 29 | <tbody> | 25 | <tbody> | 
| 30 | <tr ng-repeat="hojaRuta in hojasRuta | filter:filtros"> | 26 | <tr> | 
| 31 | <td> | 27 | <th scope="row">-</th> | 
| 32 | <b ng-show="hojaRuta.abierta !== null">RA </b> | 28 | <td>-</td> | 
| 33 | <b ng-show="hojaRuta.abierta === null">  </b> | 29 | <td>-</td> | 
| 34 | <span ng-bind="[hojaRuta.sucursal, hojaRuta.numeroHojaRuta] | comprobante"></span> | 30 | <td>-</td> | 
| 35 | </td> | 31 | <td>-</td> | 
| 36 | <td ng-bind="hojaRuta.fechaReparto | date:'yyyy-MM-dd':'-0300'"></td> | 32 | </tr> | 
| 37 | <td> | 33 | </tr> | 
| 38 | <div ng-bind="hojaRuta.remitos.length" class="d-inline-block"></div> | 34 | <tr> | 
| 39 | <button class="btn btn-outline-dark boton-accion" ng-click="mostrarRemitos(hojaRuta)"> | 35 | <th scope="row">-</th> | 
| 40 | <i class="fa fa-eye"></i> | 36 | <td>-</td> | 
| 41 | </button> | 37 | <td>-</td> | 
| 42 | </td> | 38 | <td>-</td> | 
| 43 | <td | 39 | <td>-</td> | 
| 44 | ng-bind="setearEstado(hojaRuta.estado)" | ||
| 45 | ng-class="{'text-white':hojaRuta.estado == 0, | ||
| 46 | 'text-danger':hojaRuta.estado == 1, | ||
| 47 | 'text-dark': hojaRuta.estado == 2 | ||
| 48 | }" | ||
| 49 | ></td> | ||
| 50 | <td></td> | ||
| 51 | <td class="text-center"> | ||
| 52 | <button | ||
| 53 | class="btn btn-outline-dark boton-accion" | ||
| 54 | title="Activar" | ||
| 55 | ng-click="activarHojaRuta(hojaRuta)" | ||
| 56 | > | ||
| 57 | <i | ||
| 58 | ng-class="{'fa-check': hojaRuta.estado == 0,'fa-times': hojaRuta.estado == 1}" | ||
| 59 | class="fa"> | ||
| 60 | </i> | ||
| 61 | </button> | ||
| 62 | </td> | ||
| 63 | </tr> | 40 | </tr> | 
| 64 | </body> | 41 | <tr> | 
| 42 | <th scope="row">-</th> | ||
| 43 | <td>-</td> | ||
| 44 | <td>-</td> | ||
| 45 | <td>-</td> |