terminando la consulta get resource del modelo maquinaspapelimpresion

This commit is contained in:
Jaime Jimenez
2023-06-30 11:34:30 +02:00
parent 38dd7cdadf
commit d356974178
11 changed files with 269 additions and 110 deletions

View File

@ -49,7 +49,6 @@
<th><?= lang('MaquinasTarifasImpresions.uso') ?></th>
<th><?= lang('MaquinasTarifasImpresions.tipo') ?></th>
<th><?= lang('MaquinasTarifasImpresions.precio') ?></th>
<th><?= lang('MaquinasTarifasImpresions.predeterminado') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -68,22 +67,26 @@
<div class="accordion mt-3" id="accordianPapelesImpresion">
<div class="card accordion-item active">
<h2 class="accordion-header" id="headingOne">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip1" aria-expanded="false" aria-controls="accordionTip1">
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip2" aria-expanded="false" aria-controls="accordionTip2">
<p><?= lang("MaquinasTarifasImpresions.moduleTitle") ?></p>
</button>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordianPapelesImpresion">
<div id="accordionTip2" class="accordion-collapse collapse show" data-bs-parent="#accordianPapelesImpresion">
<div class="accordion-body">
<table id="tableOfPapelesImpresion" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('MaquinasTarifasImpresions.uso') ?></th>
<th><?= lang('MaquinasTarifasImpresions.tipo') ?></th>
<th><?= lang('MaquinasTarifasImpresions.precio') ?></th>
<th><?= lang('MaquinasTarifasImpresions.predeterminado') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
<th><?= lang('MaquinasPapelImpresion.activo') ?></th>
<th><?= lang('PapelGenerico.papelGenerico') ?></th>
<th><?= lang('PapelImpresion.nombre') ?></th>
<th><?= lang('PapelImpresion.gramaje') ?></th>
<th><?= lang('PapelImpresion.bn') ?></th>
<th><?= lang('PapelImpresion.color') ?></th>
<th><?= lang('PapelImpresion.cubierta') ?></th>
<th><?= lang('PapelImpresion.sobrecubierta') ?></th>
<th><?= lang('PapelImpresion.rotativa') ?></th>
</tr>
</thead>
<tbody>
@ -102,6 +105,21 @@
<?= $this->section("additionalInlineJs") ?>
function watch(j) {
return new Proxy(JSON.parse ('{"watch":' + j + '}'), {
set: function(target, property, value) {
target[property] = value;
$('#tableOfPapelesImpresion').DataTable().ajax.reload(null,false);
theTable2.clearPipeline();
theTable2.draw();
}
});
}
isRotativa = watch(0);
$(document).ready(function () {
if($(this).is(':checked')){
@ -113,6 +131,8 @@
if($(this).is(':checked')){
$("#datosRotativa").show();
isRotativa.watch = 1;
}else{
document.getElementById("precioTintaNegro").value = null;
document.getElementById("precioTintaColor").value = null;
@ -120,6 +140,7 @@
document.getElementById("precioHoraCorte").value = null;
document.getElementById("metrosxminuto").value = null;
$("#datosRotativa").hide();
isRotativa.watch = 0;
}
});
@ -183,6 +204,19 @@
};
usoTypes = [
{label:'<?= lang('MaquinasTarifasImpresions.interior') ?>', value:'interior'},
{label:'<?= lang('MaquinasTarifasImpresions.cubierta') ?>', value: 'cubierta'},
{label:'<?= lang('MaquinasTarifasImpresions.sobrecubierta') ?>', value: 'sobrecubierta'}
];
tipoTypes = [
{label:'<?= lang('MaquinasTarifasImpresions.negro') ?>', value:'negro'},
{label:'<?= lang('MaquinasTarifasImpresions.negrohq') ?>', value: 'negrohq'},
{label:'<?= lang('MaquinasTarifasImpresions.bicolor') ?>', value: 'bicolor'},
{label:'<?= lang('MaquinasTarifasImpresions.color') ?>', value: 'color'}
];
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfMaquinasTarifaImpresion') ?>",
@ -195,26 +229,16 @@
fields: [ {
name: "uso",
type: "select",
options: ['<?= lang('MaquinasTarifasImpresions.interior') ?>', '<?= lang('MaquinasTarifasImpresions.portada') ?>']
options: usoTypes
}, {
name: "tipo",
type: "select",
options: ['<?= lang('MaquinasTarifasImpresions.negro') ?>', '<?= lang('MaquinasTarifasImpresions.color') ?>',
'<?= lang('MaquinasTarifasImpresions.negrohq') ?>', '<?= lang('MaquinasTarifasImpresions.bicolor') ?>']
options: tipoTypes
}, {
name: "precio",
attr: {
type: "number"
}
}, {
name: "predeterminado",
type: "checkbox",
separator: "",
options: [
{ label: "", value: 1 }
],
unselectedValue: 0
}, {
"name": "maquina_id",
"type": "hidden"
@ -228,6 +252,7 @@
]
} );
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['maquina_id'] = id;
@ -257,11 +282,11 @@
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 0, "asc" ]],
lengthMenu: [ 5, 10, 25, 50],
order: [[ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: false,
searching: true,
paging: true,
info: false,
dom: "Bltp",
@ -275,14 +300,32 @@
async: true,
}),
columns: [
{ 'data': 'uso' },
{ 'data': 'tipo' },
{ 'data': 'uso', "render": function ( data, type, row, meta ) {
if(data=='interior')
return '<?= lang('MaquinasTarifasImpresions.interior') ?>';
else if (data=='cubierta')
return '<?= lang('MaquinasTarifasImpresions.cubierta') ?>';
else if (data=='sobrecubierta')
return '<?= lang('MaquinasTarifasImpresions.sobrecubierta') ?>';
}
},
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('MaquinasTarifasImpresions.negro') ?>';
else if (data=='negrohq')
return '<?= lang('MaquinasTarifasImpresions.negrohq') ?>';
else if (data=='bicolor')
return '<?= lang('MaquinasTarifasImpresions.bicolor') ?>';
else if (data=='color')
return '<?= lang('MaquinasTarifasImpresions.color') ?>';
}
},
{ 'data': 'precio' },
{ 'data': 'predeterminado' },
{
data: actionBtns,
className: 'row-edit dt-center'
}
],
columnDefs: [
{
@ -307,6 +350,49 @@
} ]
} );
var theTable2 = $('#tableOfPapelesImpresion').DataTable( {
serverSide: true,
processing: true,
autoWidth: true,
responsive: true,
lengthMenu: [ 5, 10, 25],
order: [[ 1, "asc" ]],
pageLength: 10,
lengthChange: true,
searching: true,
paging: true,
info: false,
dom: "lftp",
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfMaquinasPapelesImpresion') ?>',
data: function (d) {
d.id_maquina = id;
d.isRotativa = isRotativa.watch;
},
/*{
id_maquina: id,
//tarifas: [{'uso':'interior', 'tipo':'negro'}],
isRotativa: isRotativa.watch,
},*/
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns: [
{ 'data': 'active'},
{ 'data': 'papel_generico'},
{ 'data': 'papel_impresion'},
{ 'data': 'gramaje'},
{ 'data': 'bn'},
{ 'data': 'color'},
{ 'data': 'cubierta'},
{ 'data': 'sobrecubierta'},
{ 'data': 'rotativa'}
],
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
}
} );
// Activate an inline edit on click of a table cell
@ -323,6 +409,14 @@
);
} );
theTable2.on( 'draw.dt', function () {
const boolCols = [4, 5, 6, 7, 8];
for (let coln of boolCols) {
theTable2.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
});
// Delete row
$('#tableOfMaquinastarifasimpresion').on( 'click', 'tbody span.remove', function (e) {
@ -352,15 +446,6 @@
});
});
theTable.on( 'draw.dt', function () {
const boolCols = [3];
for (let coln of boolCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="ti ti-check"></i>' : '';
});
}
});