mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'add/finalizar_envios_logistica' into 'main'
Add/finalizar envios logistica See merge request jjimenez/safekat!731
This commit is contained in:
BIN
httpdocs/assets/img/logistica/albaranes.png
Normal file
BIN
httpdocs/assets/img/logistica/albaranes.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
BIN
httpdocs/assets/img/logistica/envios.jpg
Normal file
BIN
httpdocs/assets/img/logistica/envios.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 507 KiB |
BIN
httpdocs/assets/img/logistica/envios_ferros.png
Normal file
BIN
httpdocs/assets/img/logistica/envios_ferros.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 727 KiB |
BIN
httpdocs/assets/img/logistica/impresionEtiquetas.jpg
Normal file
BIN
httpdocs/assets/img/logistica/impresionEtiquetas.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 140 KiB |
@ -1,33 +1,36 @@
|
||||
import Ajax from '../../components/ajax.js';
|
||||
|
||||
$(()=>{
|
||||
$(() => {
|
||||
|
||||
$('#buscadorPedidos').on('keydown', function(e) {
|
||||
$('#buscadorPedidos').on('keydown', function (e) {
|
||||
if (e.key === 'Enter' || e.keyCode === 13) {
|
||||
e.preventDefault(); // Evita el submit si está dentro de un form
|
||||
let search = $(this).val().trim();
|
||||
new Ajax(
|
||||
'/logistica/buscar/'+search,
|
||||
'/logistica/buscar/' + search,
|
||||
{},
|
||||
{},
|
||||
function(response) {
|
||||
if(!response.status){
|
||||
function (response) {
|
||||
if (!response.status) {
|
||||
popErrorAlert(response.message);
|
||||
}
|
||||
if(response.data){
|
||||
if (response.multienvio) {
|
||||
mostrarSwalDirecciones(response);
|
||||
}
|
||||
else if (response.data) {
|
||||
|
||||
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
function(xhr, status, error) {
|
||||
if(status == 'error' && typeof(error)== 'string')
|
||||
function (xhr, status, error) {
|
||||
if (status == 'error' && typeof (error) == 'string')
|
||||
popErrorAlert(error);
|
||||
else
|
||||
popErrorAlert(error.responseJSON.message);
|
||||
}
|
||||
).get();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@ -55,7 +58,7 @@ $(()=>{
|
||||
{ "data": "cp" },
|
||||
{ "data": "email" },
|
||||
{ "data": "telefono" },
|
||||
{
|
||||
{
|
||||
"data": "finalizado",
|
||||
"className": "text-center",
|
||||
},
|
||||
@ -78,5 +81,52 @@ $(()=>{
|
||||
$(document).on('click', '.btn-edit', function (e) {
|
||||
window.location.href = '/logistica/envio/' + $(this).attr('data-id');
|
||||
});
|
||||
|
||||
|
||||
function mostrarSwalDirecciones(response) {
|
||||
// Crear el select como HTML
|
||||
let options = response.direcciones.map((dir, index) =>
|
||||
`<option value="${index}">${dir}</option>`
|
||||
).join("");
|
||||
|
||||
Swal.fire({
|
||||
title: 'Múltiples direcciones',
|
||||
html: `
|
||||
<p>El pedido tiene múltiples direcciones. Debe seleccionar una dirección:</p>
|
||||
<select id="swal-select-direccion" class="form-select" style="width: 100%; margin-top: 1rem;">
|
||||
${options}
|
||||
</select>
|
||||
`,
|
||||
confirmButtonText: 'Aceptar',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'swal2-confirm btn btn-primary',
|
||||
cancelButton: 'swal2-cancel btn btn-secondary' // Estilo gris
|
||||
},
|
||||
preConfirm: () => {
|
||||
const select = document.getElementById('swal-select-direccion');
|
||||
if (!select.value) {
|
||||
Swal.showValidationMessage('Debe seleccionar una dirección');
|
||||
return false;
|
||||
}
|
||||
return response.direcciones[select.value]; // Devuelve la dirección seleccionada
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const direccionSeleccionada = result.value;
|
||||
$.post('/logistica/generateEnvio', {
|
||||
pedido_id: response.pedido_id,
|
||||
direccion: direccionSeleccionada
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
|
||||
} else {
|
||||
popErrorAlert(response.message);
|
||||
}
|
||||
}).fail(function (xhr, status, error) {
|
||||
popErrorAlert(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@ -28,9 +28,18 @@ class EnvioEdit {
|
||||
this.btnGenerarAlbaran = $("#btnGenerarAlbaran");
|
||||
this.btnbtnSelectAll = $("#btnSelectAll");
|
||||
this.cajas = $("#cajas");
|
||||
this.codigoSeguimiento = $("#codigoSeguimiento");
|
||||
if (!$("#empresaMensajeriaInput").length) {
|
||||
this.proveedor = new ClassSelect($("#empresaMensajeria"), '/compras/proveedores/getProveedores', "", true, { 'tipo_id': 2 });
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
|
||||
if (!$("#empresaMensajeriaInput").length) {
|
||||
this.proveedor.init();
|
||||
}
|
||||
|
||||
this.table = $('#tableLineasEnvio').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
@ -53,14 +62,14 @@ class EnvioEdit {
|
||||
footerCallback: function (row, data, start, end, display) {
|
||||
let totalUnidades = 0;
|
||||
let totalPeso = 0;
|
||||
|
||||
|
||||
data.forEach(row => {
|
||||
const unidades = parseFloat(row.unidadesEnvioRaw) || 0;
|
||||
const pesoUnidad = parseFloat(row.pesoUnidad) || 0;
|
||||
totalUnidades += unidades;
|
||||
totalPeso += unidades * pesoUnidad;
|
||||
});
|
||||
|
||||
|
||||
// Mostrar en spans personalizados del <tfoot>
|
||||
$('#footer-unidades-envio').text(totalUnidades);
|
||||
$('#footer-peso').text(totalPeso.toFixed(2));
|
||||
@ -117,7 +126,7 @@ class EnvioEdit {
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(0);
|
||||
}
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
@ -205,12 +214,240 @@ class EnvioEdit {
|
||||
const checkboxes = this.table.$('input[type="checkbox"]');
|
||||
const allChecked = checkboxes.length === checkboxes.filter(':checked').length;
|
||||
checkboxes.prop('checked', !allChecked);
|
||||
});
|
||||
|
||||
this.codigoSeguimiento.on('change', (e) => {
|
||||
const value = $(e.currentTarget).val();
|
||||
|
||||
$.post('/logistica/updateCodigoSeguimiento', {
|
||||
id: $('#id').val(),
|
||||
codigo_seguimiento: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el código de seguimiento.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
$(e.currentTarget).val(value.substring(0, 100));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (!$("#empresaMensajeriaInput").length) {
|
||||
this.proveedor.onChange((e) => {
|
||||
|
||||
const value = this.proveedor.getVal();
|
||||
$.post('/logistica/updateProveedorEnvio', {
|
||||
id: $('#id').val(),
|
||||
proveedor_id: value
|
||||
}, function (response) {
|
||||
if (!response.status) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo actualizar el proveedor.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
this.proveedor.setVal(0);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$('#finalizarEnvio').on('click', (e) => {
|
||||
|
||||
if (!this._checkDatosFinalizar())
|
||||
return;
|
||||
|
||||
Swal.fire({
|
||||
title: 'Finalizar envío',
|
||||
text: '¿Está seguro de que desea finalizar el envío?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/logistica/finalizarEnvio', {
|
||||
id: $('#id').val()
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
Swal.fire({
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo finalizar el envío.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#finalizarEnvioYOTs').on('click', (e) => {
|
||||
|
||||
if (!this._checkDatosFinalizar())
|
||||
return;
|
||||
|
||||
Swal.fire({
|
||||
title: 'Finalizar envío y las OTs',
|
||||
text: '¿Está seguro de que desea finalizar el envío y las OTs de las líneas de envío?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/logistica/finalizarEnvio', {
|
||||
id: $('#id').val(),
|
||||
finalizar_ots: true
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
|
||||
Swal.fire({
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo finalizar el envío.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this._getAlbaranes();
|
||||
}
|
||||
|
||||
_checkDatosFinalizar() {
|
||||
|
||||
if (this.codigoSeguimiento.val().length <= 0 || this.proveedor.getVal() <= 0) {
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'Debe seleccionar un proveedor y un código de seguimiento antes de finalizar el envío.',
|
||||
icon: 'info',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
_getAlbaranes() {
|
||||
$.get('/albaranes/albaranesEnvio', {
|
||||
envio_id: $('#id').val(),
|
||||
|
||||
26
httpdocs/themes/vuexy/css/logisticaPanel.css
Normal file
26
httpdocs/themes/vuexy/css/logisticaPanel.css
Normal file
@ -0,0 +1,26 @@
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.item img {
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.item p {
|
||||
margin-top: 10px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user