finalizado el controlador máquinas

This commit is contained in:
Jaime Jimenez
2023-07-10 00:12:45 +02:00
parent 370b0deb62
commit 411c3f3f9c
12 changed files with 187 additions and 170 deletions

View File

@ -128,20 +128,38 @@
});
$('#isRotativa').on("click",function(el){
if($(this).is(':checked')){
$("#datosRotativa").show();
isRotativa.watch = 1;
}else{
document.getElementById("precioTintaNegro").value = null;
document.getElementById("precioTintaColor").value = null;
document.getElementById("velocidadCorte").value = null;
document.getElementById("precioHoraCorte").value = null;
document.getElementById("metrosxminuto").value = null;
$("#datosRotativa").hide();
isRotativa.watch = 0;
}
Swal.fire({
title: '<?= lang('MaquinasPapelImpresion.sureToChangeRotativaTitle') ?>',
text: '<?= lang('MaquinasPapelImpresion.sureToChangeRotativaText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.yes') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
if (result.value) {
if($(this).is(':checked')){
isRotativa.watch = 1;
$("#datosRotativa").show();
}else{
document.getElementById("precioTintaNegro").value = null;
document.getElementById("precioTintaColor").value = null;
document.getElementById("velocidadCorte").value = null;
document.getElementById("precioHoraCorte").value = null;
document.getElementById("metrosxminuto").value = null;
$("#datosRotativa").hide();
isRotativa.watch = 0;
}
theTable2.clearPipeline();
theTable2.draw();
yeniden(response.<?= csrf_token() ?>);
}
});
});
$('#isPadre').on("click",function(el){
@ -268,24 +286,27 @@
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
setTimeout(() => {
console.log("1 Segundo esperado")
}, 1000);
$.ajax({
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
data: function (d) {
d.id_maquina= id;
d.isRotativa = isRotativa.watch;
d.<?= csrf_token() ?? "token" ?> = <?= csrf_token() ?>v;
data: {
maquina_id: id,
isRotativa: isRotativa.watch,
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
success:function(response){
yeniden(response.<?= csrf_token() ?>);
token=JSON.parse(response).<?= csrf_token() ?>;
yeniden(token);
theTable.clearPipeline();
theTable.draw();
theTable2.clearPipeline();
theTable2.draw();
}
@ -301,6 +322,7 @@
},
},
table : "#tableOfPapelesImpresion",
idSrc: 'papel_impresion_id',
fields: [
{
name: "active",
@ -310,21 +332,11 @@
{ label: '', value: 1 }
]
},{
"name": "papel_generico"
"name": "papel_impresion_id",
"type": "hidden"
},{
"name": "papel_impresion",
},{
"name": "gramaje"
},{
"name": "bn"
},{
"name": "color"
},{
"name": "cubierta"
},{
"name": "sobrecubierta"
},{
"name": "rotativa"
"name": "gramaje",
"type": "hidden"
},{
"name": "maquina_id",
"type": "hidden"
@ -332,36 +344,31 @@
]
} );
/*editor2.on( 'preSubmit', function ( e, d, type ) {
if(type === 'edit' ) {
for (v in d.data){
d.data[v]['maquina_id'] = id;
//d.data[v]['papel_impresion_id'] = papel_impresion_id;
}
}
});*/
editor2.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
if(json.error){
document.getElementById("check_" + json.data.papel_impresion_id).checked = false;
Swal.fire({
icon: 'error',
title: '<?= lang('Basic.global.sweet.error_tittle') ?>',
text: json.error,
});
}
});
var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25, 50],
order: [[ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: true,
pageLength: 5,
lengthChange: false,
searching: false,
paging: true,
info: false,
dom: "Bltp",
dom: "Blt",
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfMaquinasTarifasImpresion') ?>',
data: {
@ -441,6 +448,7 @@
data: function (d) {
d.maquina_id = id;
d.isRotativa = isRotativa.watch;
d.webguard_token = '<?= csrf_hash() ?>';
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
@ -450,7 +458,7 @@
{ 'data': 'active',
render: function (data, type, row) {
if (type === 'display') {
return '<input type="checkbox" class="editor-active">';
return '<input type="checkbox" class="editor-active" id="check_' + row.papel_impresion_id + '">';
}
return data;
},
@ -480,9 +488,9 @@
],
} );
// Cuando se clica en un checkbox hacer submit en el editor
theTable2.on( 'change', 'input.editor-active', function () {
console.log($(this).closest('tr')[0]));
editor2
.edit( $(this).closest('tr'), false )
.set( 'active', $(this).prop( 'checked' ) ? 1 : 0 )