Merge branch 'dev/duplicar_presupuesto' into 'main'

Dev/duplicar presupuesto

See merge request jjimenez/safekat!184
This commit is contained in:
2024-03-09 18:01:14 +00:00
14 changed files with 290 additions and 69 deletions

View File

@ -0,0 +1,36 @@
<div id="modalMessage" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 id="labelTitleMessageDialog" class="modal-title"></h4>
</div>
<div class="modal-body">
<p id="labelMsgMessageDialog"></p>
</div>
<div class="modal-footer">
<button id="okButton"
type="button"
class="btn btn-primary"
><?= lang('Basic.global.ok') ?></button>
</div>
</div>
</div>
</div>
<?= $this->section('additionalInlineJs') ?>
function asyncMessageDialog(title, msg, callback) {
var $messageDialog = $("#modalMessage");
$messageDialog.modal('show');
$("#labelTitleMessageDialog").html(title);
$("#labelMsgMessageDialog").html(msg);
$("#okButton").off('click').click(function () {
callback();
$confirmDialog.modal("hide");
});
}
<?= $this->endSection() ?>

View File

@ -33,7 +33,6 @@
</div>
<!-- /Logo -->
<h3 class="mb-1 fw-bold"><?= lang("App.login_title") ?> 👋</h3>
<p class="mb-4"><?= lang("App.login_subtitle") ?></p>
<form id="formAuthentication" class="mb-3" action="<?= site_url('login/authenticate'); ?>" method="POST">
<?= csrf_field() ?>

View File

@ -382,7 +382,7 @@ function load_datos_envios(){
})
.draw();
checkInsertar()
updateTotales(false, false, true)
});
$('#tableOfDireccionesEnvio').bind('draw.dt', update_tiradas_alternativas);
})

View File

@ -1254,12 +1254,7 @@ $('#btn_addLinea').on("click", function (e) {
})
// Funcion para actualizar el total de coste de la linea dependiendo
// de los checkboxes que esten seleccionados
function update_total_linea(e){
}
<?= $this->endSection() ?>
@ -1443,7 +1438,7 @@ function calcularPresupuesto_bn(input_data={}, updatedTipologias = false){
datos.a_favor_fibra = $('#lp_bn_aFavorFibra').prop('checked')
}
if(updatedTipologias){
if(updatedTipologias && $('#lp_bn_gotaNegro').length){
datos.gota_negro= $('#lp_bn_gotaNegro').val()
datos.gota_color= $('#lp_bn_gotaColor').val()
datos.negro= $('#lp_bn_cobNegro').val()
@ -1591,9 +1586,6 @@ function eventos_lp_bn(isInkjet = false){
$('#lp_bn_defecto').bind("click", por_defecto_lp_bn);
$('#lp_bn_aFavorFibra').bind("change", change_lp_bn_aFavorFibra);
}
$('#lp_bn_checkPapel').bind("change", {id_linea: 'lp_bn'}, update_total_linea);
$('#lp_bn_checkClicks').bind("change", {id_linea: 'lp_bn'}, update_total_linea);
}
<?= $this->endSection() ?>
@ -1798,7 +1790,7 @@ function calcularPresupuesto_color(input_data={}, updatedTipologias = false){
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
if(updatedTipologias){
if(updatedTipologias && $('#lp_color_gotaNegro').length){
datos.gota_negro= $('#lp_color_gotaNegro').val()
datos.gota_color= $('#lp_color_gotaColor').val()
datos.negro= $('#lp_color_cobNegro').val()
@ -1922,9 +1914,6 @@ function eventos_lp_color(isInkjet = false){
$('#lp_color_defecto').bind("click", por_defecto_lp_color);
$('#lp_color_aFavorFibra').bind("change", change_lp_color_aFavorFibra);
}
$('#lp_color_checkPapel').bind("change", {id_linea: 'lp_color'}, update_total_linea);
$('#lp_color_checkClicks').bind("change", {id_linea: 'lp_color'}, update_total_linea);
}
<?= $this->endSection() ?>
@ -2126,7 +2115,7 @@ function calcularPresupuesto_bnhq(input_data={}, updatedTipologias = false){
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
if(updatedTipologias){
if(updatedTipologias && $('#lp_bnhq_gotaNegro').length){
datos.gota_negro= $('#lp_bnhq_gotaNegro').val()
datos.gota_color= $('#lp_bnhq_gotaColor').val()
datos.negro= $('#lp_bnhq_cobNegro').val()
@ -2250,9 +2239,6 @@ function eventos_lp_bnhq(isInkjet = false){
$('#lp_bnhq_defecto').bind("click", por_defecto_lp_bnhq);
$('#lp_bnhq_aFavorFibra').bind("change", change_lp_bnhq_aFavorFibra);
}
$('#lp_bnhq_checkPapel').bind("change", {id_linea: 'lp_bnhq'}, update_total_linea);
$('#lp_bnhq_checkClicks').bind("change", {id_linea: 'lp_bnhq'}, update_total_linea);
}
<?= $this->endSection() ?>
@ -2462,7 +2448,7 @@ function calcularPresupuesto_colorhq(input_data={}, updatedTipologias = false){
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
};
if(updatedTipologias){
if(updatedTipologias && $('#lp_colorhq_gotaNegro').length){
datos.gota_negro= $('#lp_colorhq_gotaNegro').val()
datos.gota_color= $('#lp_colorhq_gotaColor').val()
datos.negro= $('#lp_colorhq_cobNegro').val()
@ -2587,11 +2573,7 @@ function eventos_lp_colorhq(isInkjet = false){
$('.lp-colorhq-tipologia').bind("change", change_lp_colorhq_tipologia);
$('#lp_colorhq_defecto').bind("click", por_defecto_lp_colorhq);
$('#lp_colorhq_aFavorFibra').bind("change", change_lp_colorhq_aFavorFibra);
}
$('#lp_colorhq_checkPapel').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea);
$('#lp_colorhq_checkClicks').bind("change", {id_linea: 'lp_colorhq'}, update_total_linea);
}
}
<?= $this->endSection() ?>
@ -2740,7 +2722,7 @@ function change_lp_rot_bn_aFavorFibra(){
}
function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){
async function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=false, input_data={}){
const dimension = getDimensionLibro();
@ -2786,7 +2768,7 @@ function calcularPresupuesto_rot_bn(fromComparador=false, updatedTipologias=fals
datos.amarillo= $('#lp_rot_bn_cobAmarillo').val()
}
$.ajax({
await $.ajax({
type: "POST",
url: "/cosidotapablanda/datatable",
data: datos,
@ -2844,11 +2826,12 @@ function change_lp_rot_bn_tipologia(){
){
calcularPresupuesto_rot_bn(false,true);
}
}
function por_defecto_lp_rot_bn(){
function por_defecto_lp_rot_bn(wait_result = false){
if( parseInt($('#lp_rot_bn_paginas').val())>0 &&
parseInt($('#lp_rot_bn_papel option:selected').val())>0 &&
@ -2856,7 +2839,7 @@ function por_defecto_lp_rot_bn(){
parseInt($('#lp_rot_bn_papelImpresion option:selected').val())>0
){
calcularPresupuesto_rot_bn(false);
calcularPresupuesto_rot_bn(false);
}
}
@ -2927,8 +2910,6 @@ function eventos_lp_rot_bn(){
$('#lp_rot_bn_aFavorFibra').bind("change", change_lp_rot_bn_aFavorFibra);
$('.lp-rot-bn-tipologia').bind("change", change_lp_rot_bn_tipologia);
$('#lp_rot_bn_defecto').bind("click", por_defecto_lp_rot_bn);
$('#lp_rot_bn_checkPapel').bind("change", {id_linea: 'lp_rot_bn'}, update_total_linea);
$('#lp_rot_bn_checkClicks').bind("change", {id_linea: 'lp_rot_bn'}, update_total_linea);
}
<?= $this->endSection() ?>
@ -3272,8 +3253,6 @@ function eventos_lp_rot_color(){
$('#lp_rot_color_aFavorFibra').bind("change", change_lp_rot_color_aFavorFibra);
$('.lp-rot-color-tipologia').bind("change", change_lp_rot_color_tipologia);
$('#lp_rot_color_defecto').bind("click", por_defecto_lp_rot_color);
$('#lp_rot_color_checkPapel').bind("change", {id_linea: 'lp_rot_color'}, update_total_linea);
$('#lp_rot_color_checkClicks').bind("change", {id_linea: 'lp_rot_color'}, update_total_linea);
}
<?= $this->endSection() ?>
@ -3542,8 +3521,6 @@ function eventos_lp_cubierta(){
$('#lp_cubierta_maquina').bind("change", change_lp_cubierta_maquina);
$('#lp_cubierta_paginas').bind("change", change_lp_cubierta_paginas);
$('#lp_cubierta_vercalculos').bind("click", {rowId: 'lp_cubierta'}, verCalculosInkjet);
$('#lp_cubierta_checkPapel').bind("change", {id_linea: 'lp_cubierta'}, update_total_linea);
$('#lp_cubierta_checkClicks').bind("change", {id_linea: 'lp_cubierta'}, update_total_linea);
}
@ -3805,8 +3782,6 @@ function eventos_lp_sobrecubierta(){
$('#lp_sobrecubierta_maquina').bind("focus", set_lp_sobrecubierta_maquina);
$('#lp_sobrecubierta_maquina').bind("change", change_lp_sobrecubierta_maquina);
$('#lp_sobrecubierta_vercalculos').bind("click", {rowId: 'lp_sobrecubierta'}, verCalculosInkjet);
$('#lp_sobrecubierta_checkPapel').bind("change", {id_linea: 'lp_sobrecubierta'}, update_total_linea);
$('#lp_sobrecubierta_checkClicks').bind("change", {id_linea: 'lp_sobrecubierta'}, update_total_linea);
}
@ -4005,8 +3980,6 @@ function eventos_lp_guardas(isInkjet = false){
$('#lp_guardas_maquina').bind("focus", set_lp_guardas_maquina);
$('#lp_guardas_maquina').bind("change", calcularPresupuesto_guardas);
$('#lp_guardas_paginas').bind("change", change_lp_guardas_paginas);
$('#lp_guardas_checkPapel').bind("change", {id_linea: 'lp_guardas'}, update_total_linea);
$('#lp_guardas_checkClicks').bind("change", {id_linea: 'lp_guardas'}, update_total_linea);
if(isInkjet){
$('#lp_guardas_vercalculos').bind("click", {rowId: 'lp_guardas'}, verCalculosInkjet);
@ -4414,7 +4387,7 @@ async function fill_bbdd_from_lp(presupuesto_id){
// Handle error here
console.log(jqXHR)
});
}
function updateLineasPresupuesto(){
@ -4422,27 +4395,29 @@ function updateLineasPresupuesto(){
$('#tableLineasPresupuesto tbody tr:visible ').each(function(){
if(this.id.endsWith('lp_bn')){
checkComparadorInt(false, false, true, false);
calcularPresupuesto_bn({}, true);
}
else if(this.id.endsWith('lp_bnhq')){
checkComparadorInt(false, true, true, false);
calcularPresupuesto_bnhq({}, true);
}
else if(this.id.endsWith('lp_color')){
checkComparadorInt(true, false, true, false);
calcularPresupuesto_color({}, true);
}
else if(this.id.endsWith('lp_colorhq')){
checkComparadorInt(true, true, true, false);
calcularPresupuesto_colorhq({}, true);
}
else if(this.id.endsWith('lp_rot_bn')){
checkComparadorInt(false, false, false, true)
calcularPresupuesto_rot_bn(false, true, {})
}
else if(this.id.endsWith('lp_rot_color')){
checkComparadorInt(true,false, false, true);
calcularPresupuesto_rot_color(false, true, {})
}
else if(this.id.endsWith('_cubierta')){
checkComparadorCubierta(true)
calcularPresupuesto_cubierta(false, {})
}
else if(this.id.endsWith('_guardas')){
calcularPresupuesto_guardas(false, {})
}
})
}

View File

@ -250,6 +250,7 @@ $('#saveDireccionEnvio').on('click', function(){
})
}
checkInsertar()
updateTotales(false, false, true)
$('#addressForm').modal("hide");
}

View File

@ -43,7 +43,12 @@
/>
<?php if (str_contains($formAction, 'edit')): ?>
<?= anchor(route_to("presupuestoToPdf", $presupuestoId), lang("Basic.global.Print"), ["class" => "btn btn-dark float-start me-sm-3 me-1",'target' => '_blank']) ?>
<?= anchor(route_to("#"), lang("Basic.global.Clone"), ["class" => "btn btn-info float-start me-sm-3 me-1",]) ?>
<input type="button"
class="btn btn-info float-start me-sm-3 me-1"
name="clone"
id="cloneForm"
value="<?= lang("Basic.global.Clone") ?>"
/>
<?php endif; ?>
<?= anchor(route_to("cosidotapablandaList", $tipo_impresion_id), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start",]) ?>
</div>
@ -52,9 +57,58 @@
</div><!--//.col -->
</div><!--//.row -->
<?= view("themes/_commonPartialsBs/_modalConfirmDialog") ?>
<?= view("themes/_commonPartialsBs/_modalMessageDialog") ?>
<?= $this->endSection() ?>
<!------------------------------------------->
<!-- Código JS para el boton de duplicar -->
<!------------------------------------------->
<?php if (str_contains($formAction, 'edit')): ?>
<?= $this->section("additionalInlineJs") ?>
$('#cloneForm').on('click', async function(e) {
// se comprueba que no haya lineas de presupuesto en el que exista la variable gotaNegro
var gotaNegro = false
$("#tableLineasPresupuesto").DataTable().rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var rowData = this.data();
if(rowData.hasOwnProperty('gotaNegro')){
gotaNegro = true
return;
}
})
if(gotaNegro){
asyncMessageDialog('<?= lang("Basic.global.Warning") ?>', '<?= lang("Presupuestos.duplicarConTipologias") ?>', function() {
$.ajax({
type: 'post',
url: '<?= route_to("updateDataOfCosidotapablanda") ?>',
data: {
tipo: 'duplicar',
presupuesto_id: id,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v
},
dataType: 'json',
success:function(response){
token=response.<?= csrf_token() ?>;
yeniden(token);
// redirect
new_location = '<?= site_url("presupuestos/cosidotapablanda/edit/") ?>' + response.id
window.location.href = new_location;
}
}).fail(function (jqXHR, textStatus, error) {
// Handle error here
console.log(jqXHR)
});
})
}
});
<?= $this->endSection() ?>
<?php endif; ?>
<!------------------------------------------->
<!-- Código JS para los selects -->