terminando el editor2 de los papeles

This commit is contained in:
Jaime Jimenez
2023-07-05 11:46:00 +02:00
parent 14b69b52ae
commit 370b0deb62
5 changed files with 279 additions and 57 deletions

View File

@ -274,6 +274,22 @@
theTable.clearPipeline();
theTable.draw();
$.ajax({
url: '<?= route_to('updateMaquinaPapelOnTarifasChange') ?>',
data: function (d) {
d.id_maquina= id;
d.isRotativa = isRotativa.watch;
d.<?= csrf_token() ?? "token" ?> = <?= csrf_token() ?>v;
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
success:function(response){
yeniden(response.<?= csrf_token() ?>);
theTable2.clearPipeline();
theTable2.draw();
}
});
});
@ -284,31 +300,47 @@
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfMaquinaspapelesimpresion",
table : "#tableOfPapelesImpresion",
fields: [
{
{
name: "active",
type: "checkbox",
separator: "|",
ipOpts: [
{ label: '', value: 1 }
]
},{
"name": "papel_generico"
},{
"name": "papel_impresion",
},{
"name": "gramaje"
},{
"name": "bn"
},{
"name": "color"
},{
"name": "cubierta"
},{
"name": "sobrecubierta"
},{
"name": "rotativa"
},{
"name": "maquina_id",
"type": "hidden"
},{
"name": "papel_generico_id",
"type": "hidden"
},{
"name": "active",
},
}
]
} );
editor2.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['maquina_id'] = id;
}
else if(type === 'edit' ) {
/*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 ) {
@ -316,12 +348,6 @@
yeniden(json.<?= csrf_token() ?>);
});
/*editor2.on( 'submitSuccess', function ( e, json, data, action ) {
theTable2.clearPipeline();
theTable2.draw();
});*/
var theTable = $('#tableOfMaquinastarifasimpresion').DataTable( {
serverSide: true,
@ -396,6 +422,7 @@
} ]
} );
var theTable2 = $('#tableOfPapelesImpresion').DataTable( {
serverSide: true,
processing: true,
@ -412,7 +439,7 @@
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfMaquinasPapelesImpresion') ?>',
data: function (d) {
d.id_maquina = id;
d.maquina_id = id;
d.isRotativa = isRotativa.watch;
},
method: 'POST',
@ -452,6 +479,15 @@
}
],
} );
// 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 )
.submit();
} );
// Activate an inline edit on click of a table cell
@ -500,7 +536,6 @@
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
.set( 'is_deleted', 1 )
.submit();
}
});
});
@ -528,6 +563,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.js') ?>"></script>
<?=$this->endSection() ?>