añadido botón duplicar presupuesto en cliente

This commit is contained in:
2025-02-08 22:34:31 +01:00
parent a138330e24
commit 5ad2fcd566
4 changed files with 44 additions and 5 deletions

View File

@ -638,6 +638,7 @@ $routes->group('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos
$routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion'); $routes->get('papelimpresion', 'Presupuestoadmin::getPapelImpresion');
$routes->get('maquinas', 'Presupuestoadmin::getMaquinas'); $routes->get('maquinas', 'Presupuestoadmin::getMaquinas');
$routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto'); $routes->post('getlinea', 'Presupuestoadmin::getLineaPresupuesto');
$routes->post('clone', 'Presupuestoadmin::datatable_2');
}); });
$routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']); $routes->resource('presupuestoadmin', ['namespace' => 'App\Controllers\Presupuestos', 'controller' => 'Presupuestoadmin', 'except' => 'show,new,create,update']);

View File

@ -24,7 +24,7 @@ return [
"global_disable" => "Desactivar", "global_disable" => "Desactivar",
"global_active" => "Activo", "global_active" => "Activo",
"global_inactive" => "Inactivo", "global_inactive" => "Inactivo",
"global_copy" => "Dupdo", "global_copy" => "Duplicar",
"global_print" => "Impresión", "global_print" => "Impresión",
"global_print2" => "Imprimir", "global_print2" => "Imprimir",
"global_confirm" => "Confirmar", "global_confirm" => "Confirmar",

View File

@ -18,8 +18,14 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="ms-auto"> <div class="ms-auto">
<div id="cloneForm" class="btn mt-3 btn-info waves-effect waves-light ml-2 d-none">
<span class="align-middle d-sm-inline-block d-none me-sm-1"></i><?= lang('App.global_copy') ?></span>
</div>
<?php if ($state != 2): ?> <?php if ($state != 2): ?>
<div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none"> <div id="btnConfirm" class="btn mt-3 btn-success waves-effect waves-light ml-2 d-none">

View File

@ -22,6 +22,7 @@ class PresupuestoCliente {
this.btnPrev = $('#btnPrev'); this.btnPrev = $('#btnPrev');
this.btnPrint = $('#btnPrint'); this.btnPrint = $('#btnPrint');
this.btnSave = $('#btnSave'); this.btnSave = $('#btnSave');
this.btnDuplicate = $('#cloneForm');
this.btnConfirm = $('#btnConfirm'); this.btnConfirm = $('#btnConfirm');
this.btnUploadFile = $('#btnUploadFile') this.btnUploadFile = $('#btnUploadFile')
@ -90,6 +91,7 @@ class PresupuestoCliente {
this.btnNext.on('click', this.#nextStep.bind(this)); this.btnNext.on('click', this.#nextStep.bind(this));
this.btnPrev.on('click', this.#prevtStep.bind(this)); this.btnPrev.on('click', this.#prevtStep.bind(this));
this.btnSave.on('click', this.#savePresupuesto.bind(this)); this.btnSave.on('click', this.#savePresupuesto.bind(this));
this.btnDuplicate.on('click', this.#clonePresupuesto.bind(this));
this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this)); this.btnConfirm.on('click', this.#confirmPresupuesto.bind(this));
this.btnPrint.on('click', this.#printPresupuesto.bind(this)); this.btnPrint.on('click', this.#printPresupuesto.bind(this));
this.btnUploadFile.on('click', () => { this.btnUploadFile.on('click', () => {
@ -417,6 +419,7 @@ class PresupuestoCliente {
this.btnPrev.addClass('d-none'); this.btnPrev.addClass('d-none');
this.btnNext.removeClass('d-none'); this.btnNext.removeClass('d-none');
this.btnSave.addClass('d-none'); this.btnSave.addClass('d-none');
this.btnDuplicate.addClass('d-none');
this.btnPrint.addClass('d-none'); this.btnPrint.addClass('d-none');
this.btnConfirm.addClass('d-none'); this.btnConfirm.addClass('d-none');
break; break;
@ -427,6 +430,7 @@ class PresupuestoCliente {
this.btnPrev.removeClass('d-none'); this.btnPrev.removeClass('d-none');
this.btnNext.removeClass('d-none'); this.btnNext.removeClass('d-none');
this.btnSave.removeClass('d-none'); this.btnSave.removeClass('d-none');
this.btnDuplicate.addClass('d-none');
this.btnPrint.addClass('d-none'); this.btnPrint.addClass('d-none');
this.btnConfirm.addClass('d-none'); this.btnConfirm.addClass('d-none');
break; break;
@ -434,6 +438,7 @@ class PresupuestoCliente {
case 'resumen-libro': case 'resumen-libro':
this.btnPrev.removeClass('d-none'); this.btnPrev.removeClass('d-none');
this.btnNext.addClass('d-none'); this.btnNext.addClass('d-none');
this.btnDuplicate.removeClass('d-none');
this.btnSave.removeClass('d-none'); this.btnSave.removeClass('d-none');
this.btnPrint.removeClass('d-none'); this.btnPrint.removeClass('d-none');
this.btnConfirm.removeClass('d-none'); this.btnConfirm.removeClass('d-none');
@ -469,6 +474,33 @@ class PresupuestoCliente {
this.#solicitudGuardarPresupuesto(true); this.#solicitudGuardarPresupuesto(true);
} }
#clonePresupuesto() {
const id = window.location.href.split("/").pop();
new Ajax('/presupuestoadmin/clone',
{
tipo: 'duplicar',
presupuesto_id: id
},
{},
(response) => {
// check if response object has a property named 'id'
if (response.id) {
const new_location = window.location.href.replace(id, response.id);
window.location.href = new_location;
}
else {
popErrorAlert("No se ha podido duplicar el presupuesto");
}
},
(error) => {
console.error('Error al duplicar el presupuesto:', error);
}
).post();
}
#savePresupuesto() { #savePresupuesto() {
@ -573,7 +605,7 @@ class PresupuestoCliente {
popAlert2Hide(); popAlert2Hide();
for (let i = 0; i < response.tiradas.length; i++) { for (let i = 0; i < response.tiradas.length; i++) {
if(i==0){ if (i == 0) {
$('#eb').val(response.eb[i]); $('#eb').val(response.eb[i]);
} }
new tarjetaTiradasPrecio( new tarjetaTiradasPrecio(
@ -586,7 +618,7 @@ class PresupuestoCliente {
if (this.actualizarTiradasEnvio) { if (this.actualizarTiradasEnvio) {
this.direcciones.insertTirada(response.tiradas[i]); this.direcciones.insertTirada(response.tiradas[i]);
if(i==0){ if (i == 0) {
$('#tiradaEnvios-' + response.tiradas[i]).trigger('click'); $('#tiradaEnvios-' + response.tiradas[i]).trigger('click');
} }
} }
@ -687,7 +719,7 @@ class PresupuestoCliente {
}, },
} }
if(this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0){ if (this.direcciones.getSelectedTirada() != null && this.direcciones.getSelectedTirada() != undefined && this.direcciones.getSelectedTirada() > 0) {
this.datos.selectedTirada = this.direcciones.getSelectedTirada(); this.datos.selectedTirada = this.direcciones.getSelectedTirada();
} }
@ -717,7 +749,7 @@ class PresupuestoCliente {
carasImpresion: this.disenioCubierta.carasCubierta.val(), carasImpresion: this.disenioCubierta.carasCubierta.val(),
}; };
this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta(); this.datos.sobrecubierta = this.disenioCubierta.getSobrecubierta();
this.datos.faja = this.disenioCubierta.getFaja(); this.datos.faja = this.disenioCubierta.getFaja();