añadidos los ficheros de papel impresion margenes. Faltan rutas y js del formulario

This commit is contained in:
Jaime Jimenez
2023-08-21 18:36:56 +02:00
parent aab3b89cfc
commit 71044d1e14
9 changed files with 800 additions and 502 deletions

View File

@ -15,13 +15,6 @@
<input type="text" id="referencia" name="referencia" maxLength="13" class="form-control" value="<?= old('referencia', $papelImpresion->referencia) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="ancho" class="form-label">
<?= lang('PapelImpresion.ancho') ?>*
</label>
<input type="number" id="ancho" name="ancho" required maxLength="8" step="0.01" class="form-control" value="<?= old('ancho', $papelImpresion->ancho) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="mano" class="form-label">
<?= lang('PapelImpresion.mano') ?>*
@ -34,25 +27,56 @@
<?= lang('PapelImpresion.precioTonelada') ?>*
</label>
<input type="number" id="precioTonelada" name="precio_tonelada" required maxLength="31" step="0.01" class="form-control" value="<?= old('precio_tonelada', $papelImpresion->precio_tonelada) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="pesoPorPliego" class="form-label">
<?= lang('PapelImpresion.pesoPorPliego') ?>
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="papelGenericoId" class="form-label">
<?= lang('PapelImpresion.papelGenericoId') ?>*
</label>
<input readonly style="background-color:#d6d6d6;" id="pesoPorPliego" name="peso_por_pliego" required maxLength="31" class="form-control" value="<?= old('peso_por_pliego', $papelImpresion->peso_por_pliego) ?>">
<select id="papelGenericoId" name="papel_generico_id" required class="form-control select2" style="width: 100%;">
<?php if (isset($papelGenericoList) && is_array($papelGenericoList) && !empty($papelGenericoList)) :
foreach ($papelGenericoList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $papelImpresion->papel_generico_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="gramaje" class="form-label">
<?= lang('PapelImpresion.gramaje') ?>*
</label>
<input type="number" id="gramaje" name="gramaje" required maxLength="31" step="0.01" class="form-control" value="<?= old('gramaje', $papelImpresion->gramaje) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="espesor" class="form-label">
<?= lang('PapelImpresion.espesor') ?>*
</label>
<input type="number" id="espesor" name="espesor" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?= old('espesor', $papelImpresion->espesor) ?>">
</div><!--//.mb-3 -->
<label for="bn" class="form-check-label">
<input type="checkbox" id="bn" name="bn" value="1" class="form-check-input" <?= $papelImpresion->bn == true ? 'checked' : ''; ?>>
<?= lang('PapelImpresion.bn') ?>
</label>
</div><!--//.col -->
</div><!-- //.row -->
<div class="row">
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<div class="form-check">
<label for="bn" class="form-check-label">
<input type="checkbox" id="bn" name="bn" value="1" class="form-check-input" <?= $papelImpresion->bn == true ? 'checked' : ''; ?>>
<?= lang('PapelImpresion.bn') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
@ -85,71 +109,10 @@
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="papelGenericoId" class="form-label">
<?= lang('PapelImpresion.papelGenericoId') ?>*
</label>
<select id="papelGenericoId" name="papel_generico_id" required class="form-control select2" style="width: 100%;">
<?php if (isset($papelGenericoList) && is_array($papelGenericoList) && !empty($papelGenericoList)) :
foreach ($papelGenericoList as $k => $v) : ?>
<option value="<?= $k ?>" <?= $k == $papelImpresion->papel_generico_id ? ' selected' : '' ?>>
<?= $v ?>
</option>
<?php endforeach;
endif; ?>
</select>
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="gramaje" class="form-label">
<?= lang('PapelImpresion.gramaje') ?>*
</label>
<input type="number" id="gramaje" name="gramaje" required maxLength="31" step="0.01" class="form-control" value="<?= old('gramaje', $papelImpresion->gramaje) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label id="labelAlto" for="alto" class="form-label">
<?= lang('PapelImpresion.alto') ?>*
</label>
<input type="number" id="alto" name="alto" required maxLength="8" step="0.01" class="form-control" value="<?= old('alto', $papelImpresion->alto) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="espesor" class="form-label">
<?= lang('PapelImpresion.espesor') ?>*
</label>
<input type="number" id="espesor" name="espesor" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?= old('espesor', $papelImpresion->espesor) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="margen" class="form-label">
<?= lang('PapelImpresion.margen') ?>*
</label>
<input type="number" id="margen" name="margen" required placeholder="0" maxLength="31" step="0.01" class="form-control" value="<?= old('margen', $papelImpresion->margen) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label id="labelPrecioPliego" for="precioPliego" class="form-label">
<?= lang('PapelImpresion.precioPliego') ?>
</label>
<input readonly style="background-color:#d6d6d6;" id="precioPliego" name="precio_pliego" required maxLength="31" class="form-control" value="<?= old('precio_pliego', $papelImpresion->precio_pliego) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="color" class="form-check-label">
@ -178,8 +141,5 @@
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -27,32 +27,100 @@
</form>
</div><!-- //.card -->
<?php if(str_contains($formAction,'edit')): ?>
<div class="accordion mt-3" id="accordionMargenes">
<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="#accordionTip3" aria-expanded="false" aria-controls="accordionTip3">
<p><?= lang("PapelImpresionMargenes.accordion") ?></p>
</button>
</h2>
<div id="accordionTip3" class="accordion-collapse collapse show" data-bs-parent="#accordionMargenes">
<div class="accordion-body">
<table id="tableOfPapelimpresionmargenes" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('PapelImpresionMargenes.paginasMin') ?></th>
<th><?= lang('PapelImpresionMargenes.paginasMax') ?></th>
<th><?= lang('PapelImpresionMargenes.margen') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php endif; ?>
<?php if(str_contains($formAction,'edit') && $papelImpresion->rotativa == true): ?>
<div class="accordion mt-3" id="accordionTipologias">
<?php else: ?>
<div class="accordion mt-3" id="accordionTipologias" style="display:none">
<?php endif; ?>
<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">
<p><?= lang("PapelImpresion.consumo_tintas_rotativas") ?></p>
</button>
</h2>
<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">
<p><?= lang("PapelImpresion.consumo_tintas_rotativas") ?></p>
</button>
</h2>
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionTipologias">
<div id="accordionTip1" class="accordion-collapse collapse show" data-bs-parent="#accordionTipologias">
<div class="accordion-body">
<table id="tableOfPapelimpresiontipologias" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ImpresionTipologias.tipo') ?></th>
<th><?= lang('ImpresionTipologias.negro') ?></th>
<th><?= lang('ImpresionTipologias.cyan') ?></th>
<th><?= lang('ImpresionTipologias.magenta') ?></th>
<th><?= lang('ImpresionTipologias.amarillo') ?></th>
<th><?= lang('ImpresionTipologias.gotaNegro') ?></th>
<th><?= lang('ImpresionTipologias.gotaColor') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php endif; ?>
<?php if(str_contains($formAction,'edit')): ?>
<div class="accordion mt-3" id="accordionMaquinas">
<div class="card accordion-item">
<h2 class="accordion-header" id="headingTwo">
<button
type="button"
class="accordion-button collapsed"
data-bs-toggle="collapse"
data-bs-target="#accordionMaq"
aria-expanded="false"
aria-controls="accordionMaq"
>
<p><?= lang("PapelImpresion.maquinas_papel") ?></p>
</button>
</h2>
<div id="accordionMaq" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionMaquinas">
<div class="accordion-body">
<table id="tableOfPapelimpresiontipologias" class="table table-striped table-hover" style="width: 100%;">
<table id="tableOfMaquinas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('ImpresionTipologias.tipo') ?></th>
<th><?= lang('ImpresionTipologias.negro') ?></th>
<th><?= lang('ImpresionTipologias.cyan') ?></th>
<th><?= lang('ImpresionTipologias.magenta') ?></th>
<th><?= lang('ImpresionTipologias.amarillo') ?></th>
<th><?= lang('ImpresionTipologias.gotaNegro') ?></th>
<th><?= lang('ImpresionTipologias.gotaColor') ?></th>
<th><?= lang('MaquinasPapelImpresion.activo') ?></th>
<th><?= lang('Maquinas.nombre') ?></th>
<th><?= lang('Maquinas.ancho') ?></th>
<th><?= lang('Maquinas.alto') ?></th>
<th><?= lang('Maquinas.anchoImpresion') ?></th>
<th><?= lang('Maquinas.altoImpresion') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
@ -63,55 +131,16 @@
</div>
</div>
</div>
</div> <!-- //.accordion -->
<?php if(str_contains($formAction,'edit')): ?>
<div class="accordion mt-3" id="accordionMaquinas">
<?php else: ?>
<div class="accordion mt-3" id="accordionMaquinas" style="display:none">
<?php endif; ?>
<div class="card accordion-item">
<h2 class="accordion-header" id="headingTwo">
<button
type="button"
class="accordion-button collapsed"
data-bs-toggle="collapse"
data-bs-target="#accordionMaq"
aria-expanded="false"
aria-controls="accordionMaq"
>
<p><?= lang("PapelImpresion.maquinas_papel") ?></p>
</button>
</h2>
<div id="accordionMaq" class="accordion-collapse collapse" aria-labelledby="headingTwo" data-bs-parent="#accordionMaquinas">
<div class="accordion-body">
<table id="tableOfMaquinas" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?= lang('MaquinasPapelImpresion.activo') ?></th>
<th><?= lang('Maquinas.nombre') ?></th>
<th><?= lang('Maquinas.ancho') ?></th>
<th><?= lang('Maquinas.alto') ?></th>
<th><?= lang('Maquinas.anchoImpresion') ?></th>
<th><?= lang('Maquinas.altoImpresion') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<!------------------------------------------->
<!-- Código JS para general -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
var theTable;
@ -125,239 +154,6 @@
id = -1;
}
$(document).on('click', '#rotativa', function(e) {
updateForRotativa();
});
$(document).ready(function() {
updateForRotativa();
});
function updateForRotativa(){
let label = document.getElementById('labelAlto');
let field = document.getElementById('alto');
let labelPrecio = document.getElementById('labelPrecioPliego');
if($("#rotativa").is(":checked")) {
labelPrecio.innerHTML = '<?= lang('PapelImpresion.precioMetro') ?>';
label.innerHTML = '<?= lang('PapelImpresion.alto') ?>';
field.readOnly = true;
field.style.backgroundColor = "#d6d6d6";
field.value = '0';
updateValue();
}
else{
labelPrecio.innerHTML = '<?= lang('PapelImpresion.precioPliego') ?>';
label.innerHTML = '<?= lang('PapelImpresion.alto') ?>*';
field.readOnly = false;
field.style.backgroundColor = "white";
updateValue();
}
};
const lastColNr = $('#tableOfPapelimpresiontipologias').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<span class="cancel"></span>
`;
};
const lastColNr2 = $('#tableOfMaquinas').find("tr:first th").length - 1;
const actionBtns2 = function(data) {
return `
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit2 mx-2" data-id="${data.maquina_id}"></i></a>
`;
};
if(url_parts[url_parts.length-2] == 'edit'){
tipoTypes = [
{label:'<?= lang('ImpresionTipologias.negro') ?>', value:'negro'},
{label:'<?= lang('ImpresionTipologias.color') ?>', value: 'color'},
{label:'<?= lang('ImpresionTipologias.bicolor') ?>', value: 'bicolor'}
];
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfConsumoTintas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfPapelimpresiontipologias",
idSrc: 'id',
fields: [ {
name: "tipo",
type: "select",
options: tipoTypes
}, {
name: "negro",
attr: {
type: "number"
}
},{
name: "cyan",
attr: {
type: "number"
}
},{
name: "magenta",
attr: {
type: "number"
}
},{
name: "amarillo",
attr: {
type: "number"
}
},{
name: "gota_negro",
attr: {
type: "number"
}
},{
name: "gota_color",
attr: {
type: "number"
}
}, {
"name": "papel_impresion_id",
"type": "hidden"
}
]
} );
editor.on( 'initCreate', function () {
if ($('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3){
popErrorAlert(<?= lang('Basic.global.sweet.maxRowsReached') ?>);
}
} );
theTable = $('#tableOfPapelimpresiontipologias').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5],
pageLength: 5,
lengthChange: false,
searching: false,
info: false,
"dom": '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
stateSave: true,
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresion') ?>',
data: {
id_PI: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns : [
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('ImpresionTipologias.negro') ?>';
else if (data=='color')
return '<?= lang('ImpresionTipologias.color') ?>';
else if (data=='bicolor')
return '<?= lang('ImpresionTipologias.bicolor') ?>';
}
},
{ 'data': 'negro' },
{ 'data': 'cyan' },
{ 'data': 'magenta' },
{ 'data': 'amarillo' },
{ 'data': 'gota_negro' },
{ 'data': 'gota_color' },
{ data: actionBtns,
className: 'row-edit dt-center'}
],
buttons: [ {
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
});
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit', function(e) {
editor.inline(
theTable.cells(this.parentNode.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['papel_impresion_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['papel_impresion_id'] = id;
}
}
});
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
}
$(document).on('click', '.btn-edit2', function(e) {
window.open(`/configuracion/maquinas/edit/${$(this).attr('data-id')}`);
});
$('#papelGenericoId').select2({
allowClear: false,
@ -387,7 +183,234 @@
cache: true
}
});
<?= $this->endSection() ?>
<?php if(str_contains($formAction,'edit')): ?>
<!------------------------------------------->
<!-- Código JS para tabla tipologias -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
var theTable;
const lastColNr = $('#tableOfPapelimpresiontipologias').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
<span class="cancel"></span>
`;
};
// Etiquetas para las tipologias
const tipoTypes = [
{label:'<?= lang('ImpresionTipologias.negro') ?>', value:'negro'},
{label:'<?= lang('ImpresionTipologias.color') ?>', value: 'color'},
{label:'<?= lang('ImpresionTipologias.bicolor') ?>', value: 'bicolor'}
];
// Definición del editor
editor = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfConsumoTintas') ?>",
headers: {
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
},
},
table : "#tableOfPapelimpresiontipologias",
idSrc: 'id',
fields: [
{
name: "tipo",
type: "select",
options: tipoTypes
}, {
name: "negro",
attr: {
type: "number"
}
},{
name: "cyan",
attr: {
type: "number"
}
},{
name: "magenta",
attr: {
type: "number"
}
},{
name: "amarillo",
attr: {
type: "number"
}
},{
name: "gota_negro",
attr: {
type: "number"
}
},{
name: "gota_color",
attr: {
type: "number"
}
}, {
"name": "papel_impresion_id",
"type": "hidden"
}
]
} );
// Definición de la tabla
theTable = $('#tableOfPapelimpresiontipologias').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5],
pageLength: 5,
lengthChange: false,
searching: false,
info: false,
"dom": '<"mt-4"><"float-end"B><"float-start"l><t><"mt-4 mb-3"p>',
stateSave: true,
language: {
url: "//cdn.datatables.net/plug-ins/1.13.4/i18n/<?= config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesImpresion') ?>',
data: {
id_PI: id,
},
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columns : [
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
if(data=='negro')
return '<?= lang('ImpresionTipologias.negro') ?>';
else if (data=='color')
return '<?= lang('ImpresionTipologias.color') ?>';
else if (data=='bicolor')
return '<?= lang('ImpresionTipologias.bicolor') ?>';
}
},
{ 'data': 'negro' },
{ 'data': 'cyan' },
{ 'data': 'magenta' },
{ 'data': 'amarillo' },
{ 'data': 'gota_negro' },
{ 'data': 'gota_color' },
{ data: actionBtns,
className: 'row-edit dt-center'}
],
buttons: [ {
className: 'btn btn-primary float-end me-sm-3 me-1',
extend: "createInline",
editor: editor,
formOptions: {
submitTrigger: -1,
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
}
} ]
});
// Notificar que no se pueden añadir más tipologías
editor.on( 'initCreate', function () {
if ( $('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3 ){
popErrorAlert('<?= lang('Basic.global.sweet.maxRowsReached') ?>');
}
});
// Activate an inline edit on click of a table cell
$(document).on('click', '.btn-edit', function(e) {
editor.inline(
theTable.cells(this.parentNode.parentNode.parentNode, '*').nodes(),
{
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
cancelTrigger: 'span.cancel',
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
submitTrigger: 'span.edit',
submit: 'allIfChanged'
}
);
} );
// Obtención del id para editar
editor.on( 'preSubmit', function ( e, d, type ) {
if ( type === 'create'){
d.data[0]['papel_impresion_id'] = id;
}
else if(type === 'edit' ) {
for (v in d.data){
d.data[v]['papel_impresion_id'] = id;
}
}
});
// Refrescar token
editor.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
});
// Refrescar tabla
editor.on( 'submitSuccess', function ( e, json, data, action ) {
theTable.clearPipeline();
theTable.draw();
});
// Borrar registro
$(document).on('click', '.btn-delete', function(e) {
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
});
$(document).on('click', '.btn-remove', function(e) {
const dataId = $(this).attr('data-id');
const row = $(this).closest('tr');
if ($.isNumeric(dataId)) {
$.ajax({
url: `/configuracion/papelimpresiontipologias/delete/${dataId}`,
method: 'GET',
}).done((data, textStatus, jqXHR) => {
$('#confirm2delete').modal('toggle');
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
popSuccessAlert(data.msg ?? jqXHR.statusText);
}).fail((jqXHR, textStatus, errorThrown) => {
popErrorAlert(jqXHR.responseJSON.messages.error)
})
}
});
<?= $this->endSection() ?>
<!------------------------------------------->
<!-- Código JS para tabla maquinas -->
<!------------------------------------------->
<?= $this->section("additionalInlineJs") ?>
// Botones última columna
const lastColNr2 = $('#tableOfMaquinas').find("tr:first th").length - 1;
const actionBtns2 = function(data) {
return `
<a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit2 mx-2" data-id="${data.maquina_id}"></i></a>
`;
};
// Definicion de la tabla
var theTable2 = $('#tableOfMaquinas').DataTable( {
serverSide: true,
processing: true,
@ -406,8 +429,6 @@
data: function (d) {
d.papel_id = id;
d.isRotativa = $('#rotativa').is(':checked')?1:0;
d.ancho = document.getElementById("ancho").value;
d.alto = document.getElementById("alto").value;
d.webguard_token = '<?= csrf_hash() ?>';
},
method: 'POST',
@ -454,6 +475,8 @@
],
} );
// Definición del editor
editor2 = new $.fn.dataTable.Editor( {
ajax: {
url: "<?= route_to('editorOfMaquinasPapelImpresion') ?>",
@ -484,6 +507,8 @@
]
} );
// Postsubmit del editor
editor2.on( 'postSubmit', function ( e, json, data, action ) {
yeniden(json.<?= csrf_token() ?>);
if(json.error){
@ -492,6 +517,13 @@
}
});
// Click sobre el botón editar máquina
$(document).on('click', '.btn-edit2', function(e) {
window.open(`/configuracion/maquinas/edit/${$(this).attr('data-id')}`);
});
// Cuando se clica en un checkbox hacer submit en el editor
theTable2.on( 'change', 'input.editor-active', function () {
editor2
@ -500,42 +532,12 @@
.submit();
} );
// Calculos del precio
$("#ancho").on('input', function () {
updateValue();
});
$("#alto").on('input', function () {
if(!$('#rotativa').is(':checked')){
updateValue();
}
});
$("#gramaje").on('input', function () {
updateValue();
});
$("#precioTonelada").on('input', function () {
updateValue();
});
function updateValue() {
let value;
if($("#rotativa").is(":checked")) {
value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*1000/1E6;
}
else{
value = parseFloat($("#gramaje").val()) * parseFloat($("#ancho").val())*parseFloat($("#alto").val())/1E6;
}
value = value.toFixed(2);
$('#pesoPorPliego').val(value);
let value2 = parseFloat($("#precioTonelada").val()) *value/1E6;
value2 = value2.toFixed(6);
$('#precioPliego').val(value2);
}
<?= $this->endSection() ?>
<?php endif; ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">