Merge branch 'main' into feat/view-maquinista

This commit is contained in:
amazuecos
2025-04-25 07:41:25 +02:00
52 changed files with 5300 additions and 469 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

View File

@ -0,0 +1,418 @@
import ClassSelect from '../../components/select2.js';
import Ajax from '../../components/ajax.js';
class Catalogo {
constructor() {
/* Definiciones */
this.tirada_no_pod = 100;
this.tirada_pod = 1;
/* Mapeado de elementos */
this.tipo_impresion = $("#tipo_impresion");
this.paginas_cubierta = $("#cubierta_paginas");
this.sobrecubiertaItems = $('.sobrecubierta_items').add('.sobrecubierta_pod_items');
this.paginasSobrecubierta = $('#sobrecubierta_paginas');
this.negro = $('#negro_paginas');
this.color = $('#color_paginas');
this.total = $('#paginas');
/* Select2 para clientes */
this.cliente = new ClassSelect($("#cliente_id"), '/catalogo/libros/clientlist', "Seleccione un cliente");
/* Select2 para tipos de encuadernacion */
this.encuadernacion = new ClassSelect($("#encuadernacion_id"), '/importador/getencuadernacion', "Seleccione una encuadernación");
/* Select2 para impresion en Negro */
this.selectPapelNegro = new ClassSelect($("#negro_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
this.selectPapelNegroPod = new ClassSelect($("#negro_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
this.selectGramajeNegro = new ClassSelect($('#negro_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelNegro.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
this.selectGramajeNegroPod = new ClassSelect($('#negro_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelNegroPod.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'negrohq' : 'negro',
});
/* Select2 para impresion en Color */
this.selectPapelColor = new ClassSelect($("#color_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
this.selectPapelColorPod = new ClassSelect($("#color_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
this.selectGramajeColor = new ClassSelect($('#color_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelColor.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
this.selectGramajeColorPod = new ClassSelect($('#color_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelColorPod.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: 0,
lomo: 0,
tipo: () => this.tipo_impresion.val().includes('hq') ? 'colorhq' : 'color',
});
/* Select2 para impresion de cubiertas */
this.selectPapelCubierta = new ClassSelect($("#cubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#cubierta_ancho_solapas').val(),
lomo: () => 0,
tipo: 'colorhq',
uso: 'cubierta',
});
this.selectPapelCubiertaPod = new ClassSelect($("#cubierta_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#cubierta_ancho_solapas').val(),
lomo: () => 0,
tipo: 'colorhq',
uso: 'cubierta',
});
this.selectGramajeCubierta = new ClassSelect($('#cubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelCubierta.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#cubierta_ancho_solapas').val(),
lomo: 0,
tipo: 'colorhq',
});
this.selectGramajeCubiertaPod = new ClassSelect($('#cubierta_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelCubiertaPod.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#cubierta_ancho_solapas').val(),
lomo: 0,
tipo: 'colorhq',
});
this.acabadoCubierta = new ClassSelect($("#cubierta_acabado_id"),
'/serviciosacabados/getacabados',
'Seleccione acabado',
false,
{
"cubierta": 1
}
);
/* Select2 para impresion de sobrecubierta */
this.selectPapelSobrecubierta = new ClassSelect($("#sobrecubierta_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
lomo: () => 0,
tipo: 'colorhq',
uso: 'sobrecubierta',
});
this.selectPapelSobrecubiertaPod = new ClassSelect($("#sobrecubierta_pod_papel_id"), '/presupuestoadmin/papelgenerico', "Seleccione un papel", false,
{
tipo_impresion: this.encuadernacion.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
lomo: () => 0,
tipo: 'colorhq',
uso: 'sobrecubierta',
});
this.selectGramajeSobrecubierta = new ClassSelect($('#sobrecubierta_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelSobrecubierta.getVal(),
tirada: () => this.tirada_no_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
lomo: 0,
tipo: 'colorhq',
});
this.selectGramajeSobrecubiertaPod = new ClassSelect($('#sobrecubierta_pod_gramaje'), '/presupuestoadmin/papelgramaje', 'Seleccione un gramaje', false,
{
tipo_impresion: () => this.encuadernacion.getVal(),
papel_generico: () => this.selectPapelSobrecubiertaPod.getVal(),
tirada: () => this.tirada_pod,
ancho: () => this.getDimensionLibro().ancho,
alto: () => this.getDimensionLibro().alto,
sopalas: () => $('#sobrecubierta_ancho_solapas').val(),
lomo: 0,
tipo: 'colorhq',
});
this.acabadosSobrecubierta = new ClassSelect($("#sobrecubierta_acabado_id"),
'/serviciosacabados/getacabados',
'Seleccione acabado',
false,
{
"sobrecubierta": 1
}
);
}
init() {
const self = this;
// Eliminar elementos que no se usan
$('[id*="_pod_paginas"]').remove();
$('[id*="_pod_ancho_solapas"]').remove();
$('[id*="_pod_acabado_id"]').remove();
// Fuerza el foco en el campo de búsqueda de select2
$(document).on('select2:open', () => {
document.querySelector('.select2-search__field').focus();
});
this.cliente.init();
this.tipo_impresion.select2();
this.paginas_cubierta.select2();
this.paginasSobrecubierta.select2();
this.encuadernacion.init();
this.selectPapelNegro.init();
this.selectPapelNegroPod.init();
this.selectGramajeNegro.init();
this.selectGramajeNegroPod.init();
this.selectPapelColor.init();
this.selectPapelColorPod.init();
this.selectGramajeColor.init();
this.selectGramajeColorPod.init();
this.selectPapelCubierta.init();
this.selectPapelCubiertaPod.init();
this.selectGramajeCubierta.init();
this.selectGramajeCubiertaPod.init();
this.acabadoCubierta.init();
this.selectPapelSobrecubierta.init();
this.selectPapelSobrecubiertaPod.init();
this.selectGramajeSobrecubierta.init();
this.selectGramajeSobrecubiertaPod.init();
this.acabadosSobrecubierta.init();
// Al cargar la página
this.toggleSobrecubiertaFields();
// Inicializacino de eventos
this.selectPapelNegro.item.on('select2:select', function () {
self.selectGramajeNegro.empty();
});
this.total.on('input change', () => {
this.validarMultiploDe4([this.total, this.color, this.negro]);
});
this.color.on('input change', this.actualizarDesdeColor.bind(this));
this.negro.on('input change', this.actualizarDesdeNegro.bind(this));
this.tipo_impresion.on("change", this.updateOpcionesImpresion.bind(this));
// Al cambiar el selector de paginas de sobrecubierta
this.paginasSobrecubierta.on('change', this.toggleSobrecubiertaFields.bind(this));
// Al cambiar el tipo de encuadernacion
this.encuadernacion.onChange(this.enableSobrecubiertaLines.bind(this));
this.updateOpcionesImpresion();
$(document).on('change', '.warning-change', function () {
$(this).addClass('bg-warning');
let select2Container = $(this).next('.select2').find('.select2-selection');
select2Container.addClass('bg-warning');
});
}
actualizarDesdeColor() {
const total = parseInt(this.total.val(), 10) || 0;
const color = parseInt(this.color.val(), 10) || 0;
const negro = Math.max(total - color, 0);
this.negro.val(negro);
this.validarMultiploDe4([this.total, this.color, this.negro]);
}
actualizarDesdeNegro() {
const total = parseInt(this.total.val(), 10) || 0;
const negro = parseInt(this.negro.val(), 10) || 0;
const color = Math.max(total - negro, 0);
this.color.val(color);
this.validarMultiploDe4([this.total, this.color, this.negro]);
}
validarMultiploDe4(campos) {
campos.forEach($el => {
const val = parseInt($el.val(), 10) || 0;
if (val % 4 !== 0) {
$el.css('color', 'red');
} else {
$el.css('color', '');
}
});
}
updateOpcionesImpresion() {
$('.negro_items').off('change');
$('.color_items').off('change');
const selValue = this.tipo_impresion.val();
// Buscar elementos por clase dinámica (negro-*-line y color-*-line)
const elements_negro = $('*').filter(function () {
return [...this.classList].some(cls => /^negro.*line$/.test(cls));
});
const elements_color = $('*').filter(function () {
return [...this.classList].some(cls => /^color.*line$/.test(cls));
});
if (selValue.includes('color')) {
elements_color.removeClass('d-none');
} else {
elements_color.addClass('d-none');
}
elements_negro.removeClass('d-none');
}
getDimensionLibro() {
let ancho = $('#ancho').val();
let alto = $('#alto').val();;
return { ancho, alto };
}
toggleSobrecubiertaFields() {
if (this.paginasSobrecubierta.val() === '1') {
this.sobrecubiertaItems.prop('disabled', false).trigger('change.select2');
} else {
this.sobrecubiertaItems.prop('disabled', true).trigger('change.select2');
}
}
enableSobrecubiertaLines() {
// Buscar elementos por clase dinámica (sobrecubierta-*-line)
const elements_sobrecubierta = $('*').filter(function () {
return [...this.classList].some(cls => /^sobrecubierta.*line$/.test(cls));
});
switch (parseInt(this.encuadernacion.getVal(), 10)) {
case 5:
case 6:
case 7:
case 8:
case 21:
console.log("Desactivar sobrecubierta:" + this.encuadernacion.getVal());
elements_sobrecubierta.addClass('d-none');
break;
default:
console.log("Activar sobrecubierta:" + this.encuadernacion.getVal());
elements_sobrecubierta.removeClass('d-none');
break;
}
}
}
document.addEventListener('DOMContentLoaded', function () {
let catalogo = new Catalogo();
catalogo.init();
});
export default Catalogo;

View File

@ -0,0 +1,114 @@
import Ajax from '../../components/ajax.js';
document.addEventListener('DOMContentLoaded', function () {
const lastColNr = $('#tableOfCatalogoLibros').find("tr:first th").length - 1;
const theTable = $('#tableOfCatalogoLibros').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
orderCellsTop: true,
responsive: true,
scrollX: true,
lengthMenu: [5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500],
pageLength: 10,
lengthChange: true,
dom: 'lfBrtip',
buttons: [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
order: [[1, 'asc']],
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
ajax: {
url: '/catalogo/libros/datatable',
method: 'GET'
},
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns: [
{ data: 'portada' },
{ data: 'id' },
{ data: 'titulo' },
{ data: 'cliente' },
{
data: 'edicion',
className: "text-center"
},
{ data: 'autor' },
{ data: 'isbn' },
{ data: 'ean' },
{
data: 'paginas',
className: "text-center"
},
{ data: 'actionBtns' }
]
});
$(document).on('click', '.btn-edit', function (e) {
window.location.href = '/catalogo/libros/edit/' + $(this).attr('data-id');
});
$(document).on('click', '.btn-delete', function (e) {
e.preventDefault();
const row = $(this).closest('tr')[0]._DT_RowIndex;
const dataId = $(this).attr('data-id');
Swal.fire({
title: '¿Estás seguro?',
text: 'Esta acción no se puede deshacer.',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Sí',
cancelButtonText: 'No',
reverseButtons: false,
buttonsStyling: true,
customClass: {
confirmButton: 'btn btn-danger', // rojo para "Sí"
cancelButton: 'btn btn-secondary' // gris para "No"
}
}).then((result) => {
if (result.isConfirmed) {
new Ajax(
'/catalogo/libros/delete/' + dataId,
{},
{},
(data, textStatus, jqXHR) => {
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
},
(error) => {
console.error(error);
Swal.fire('Error', 'No se pudo eliminar el libro.', 'error');
}
).get();
}
});
});
$(document).on("keyup", ".filtro_catalogo", (event) => {
let columnName = $(event.currentTarget).attr("name");
let columnIndex = $('#tableOfCatalogoLibros').DataTable().columns().eq(0).filter(function (index) {
return $('#tableOfCatalogoLibros').DataTable().column(index).dataSrc() === columnName;
})[0];
$('#tableOfCatalogoLibros').DataTable().column(columnIndex).search($(event.currentTarget).val()).draw()
})
});

View File

@ -1,35 +1,55 @@
import Ajax from '../../components/ajax.js';
import ClassSelect from '../../components/select2.js';
$(()=>{
$(() => {
$('#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,
{},
{},
function(response) {
if(!response.status){
popErrorAlert(response.message);
}
if(response.data){
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
}
},
function(xhr, status, error) {
if(status == 'error' && typeof(error)== 'string')
popErrorAlert(error);
else
popErrorAlert(error.responseJSON.message);
}
).get();
}
const selectPedidos = new ClassSelect($('#buscadorPedidos'), '/logistica/selectPedidosForEnvio', "");
selectPedidos.init();
const selectDirecciones = new ClassSelect($('#selectDirecciones'), '/logistica/selectDireccionForEnvio', "", true, {
pedido_id: () => selectPedidos.getVal()
});
selectDirecciones.init();
selectPedidos.item.on('select2:open', () => {
$('.select-direcciones').addClass('d-none');
$('.add-envio').addClass('d-none');
})
selectPedidos.item.on('change', () => {
selectDirecciones.empty();
$('.select-direcciones').removeClass('d-none');
})
selectDirecciones.item.on('select2:open', () => {
$('.add-envio').addClass('d-none');
})
selectDirecciones.item.on('change', () => {
$('.add-envio').removeClass('d-none');
})
$('#btnAddEnvio').on('click', () => {
const pedido_id = selectPedidos.getVal();
const direccionSeleccionada = selectDirecciones.getText();
$.post('/logistica/generateEnvio', {
pedido_id: pedido_id,
direccion: direccionSeleccionada
}, function (response) {
if (response.status) {
window.open(`${window.location.origin}/logistica/envio/${response.data.id_envio}`);
selectDirecciones.empty();
selectPedidos.empty();
$('.select-direcciones').addClass('d-none');
$('.add-envio').addClass('d-none');
} else {
popErrorAlert(response.message);
}
}).fail(function (xhr, status, error) {
popErrorAlert(error);
});
})
const tableEnvios = $('#tableOfEnvios').DataTable({
processing: true,
@ -55,7 +75,7 @@ $(()=>{
{ "data": "cp" },
{ "data": "email" },
{ "data": "telefono" },
{
{
"data": "finalizado",
"className": "text-center",
},
@ -78,5 +98,7 @@ $(()=>{
$(document).on('click', '.btn-edit', function (e) {
window.location.href = '/logistica/envio/' + $(this).attr('data-id');
});
});

View File

@ -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(),

View File

@ -11,13 +11,18 @@ class Resumen {
const self = this;
this.toastPresupuestoTotal = null
$(".update-totales").on("change", function () {
self.updateTotales(null, { updateLP: true, updateServicios: true, updateEnvio: true });
self.updateTotales({ updateLP: true, updateServicios: true, updateEnvio: true });
});
$(document).on('update-totales', async function () {
await self.updateTotales();
$(document).trigger('update-totales-completed');
});
$('#total_descuentoPercent').on('change', function () {
this.updateTotales({ updateLP: false, updateServicios: false, updateEnvio: false }, false);
}.bind(this));
$("#totalDespuesDecuento").on('change', this.updateToastSummary.bind(this))
}

View 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;
}
}