mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into mod/presupuesto_cliente
This commit is contained in:
@ -0,0 +1,66 @@
|
||||
$(()=>{
|
||||
var theTable;
|
||||
|
||||
const url = window.location.href;
|
||||
const url_parts = url.split('/');
|
||||
let id = -1;
|
||||
if (url_parts[url_parts.length - 2] == 'edit') {
|
||||
id = url_parts[url_parts.length - 1];
|
||||
}
|
||||
|
||||
$('#papelGenericoId').select2({
|
||||
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '/configuracion/papelesgenericos/menuitems',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
|
||||
data: function (params) {
|
||||
return {
|
||||
id: 'id',
|
||||
text: 'nombre',
|
||||
searchTerm: params.term,
|
||||
|
||||
};
|
||||
},
|
||||
delay: 60,
|
||||
processResults: function (response) {
|
||||
return {
|
||||
results: response.menu
|
||||
};
|
||||
},
|
||||
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Delete row
|
||||
$(document).on('click', '.btn-delete', function (e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
if ($(this).closest('table').attr('id').includes('margenes')) {
|
||||
$(".btn-remove").attr('table', "margenes");
|
||||
}
|
||||
else if ($(this).closest('table').attr('id').includes('tipologias')) {
|
||||
$(".btn-remove").attr('table', "tipologias");
|
||||
}
|
||||
else {
|
||||
$(".btn-remove").attr('table',);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-remove', function (e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
|
||||
if ($(this).attr('table').includes('margenes')) {
|
||||
remove_margenes(dataId, row);
|
||||
}
|
||||
else if ($(this).attr('table').includes('tipologias')) {
|
||||
remove_tipologias(dataId, row);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
@ -0,0 +1,688 @@
|
||||
$(() => {
|
||||
|
||||
|
||||
var theTable;
|
||||
|
||||
const url = window.location.href;
|
||||
const url_parts = url.split('/');
|
||||
let id = -1;
|
||||
if (url_parts[url_parts.length - 2] == 'edit') {
|
||||
id = url_parts[url_parts.length - 1];
|
||||
}
|
||||
|
||||
$('#papelGenericoId').select2({
|
||||
|
||||
allowClear: false,
|
||||
ajax: {
|
||||
url: '/configuracion/papelesgenericos/menuitems',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
|
||||
data: function (params) {
|
||||
return {
|
||||
id: 'id',
|
||||
text: 'nombre',
|
||||
searchTerm: params.term,
|
||||
|
||||
};
|
||||
},
|
||||
delay: 60,
|
||||
processResults: function (response) {
|
||||
return {
|
||||
results: response.menu
|
||||
};
|
||||
},
|
||||
|
||||
cache: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Delete row
|
||||
$(document).on('click', '.btn-delete', function (e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
if ($(this).closest('table').attr('id').includes('margenes')) {
|
||||
$(".btn-remove").attr('table', "margenes");
|
||||
}
|
||||
else if ($(this).closest('table').attr('id').includes('tipologias')) {
|
||||
$(".btn-remove").attr('table', "tipologias");
|
||||
}
|
||||
else {
|
||||
$(".btn-remove").attr('table',);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-remove', function (e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).closest('tr');
|
||||
if ($.isNumeric(dataId)) {
|
||||
|
||||
if ($(this).attr('table').includes('margenes')) {
|
||||
remove_margenes(dataId, row);
|
||||
}
|
||||
else if ($(this).attr('table').includes('tipologias')) {
|
||||
remove_tipologias(dataId, row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/*
|
||||
tabla margenes
|
||||
*/
|
||||
var theTable3;
|
||||
const lastColNr3 = $('#tableOfPapelimpresionmargenes').find("tr:first th").length - 1;
|
||||
const actionBtns3 = function (data) {
|
||||
return `
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit3 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>
|
||||
`;
|
||||
};
|
||||
|
||||
|
||||
// Definición del editor
|
||||
var editor3 = new $.fn.dataTable.Editor({
|
||||
ajax: {
|
||||
url: "/papelesimpresionmargenes/datatable_editor",
|
||||
headers: {
|
||||
},
|
||||
},
|
||||
table: "#tableOfPapelimpresionmargenes",
|
||||
idSrc: 'id',
|
||||
fields: [
|
||||
{
|
||||
name: "paginas_min",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "paginas_min",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "paginas_max",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "paginas_max",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "margen",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "margen",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
"name": "papel_impresion_id",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "deleted_at",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "is_deleted",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
editor3.on('open', (event) => {
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
autoNumericInstance.remove()
|
||||
|
||||
}
|
||||
new AutoNumeric(this, {
|
||||
decimalCharacter: ",",
|
||||
digitGroupSeparator: ".",
|
||||
unformatOnSubmit: true,
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
// Definición de la tabla
|
||||
theTable3 = $('#tableOfPapelimpresionmargenes').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: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
ajax: $.fn.dataTable.pipeline({
|
||||
url: '/papelesimpresionmargenes/datatable',
|
||||
data: {
|
||||
id_PI: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{ 'data': 'paginas_min', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'paginas_max', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'margen', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns3,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr3]
|
||||
}
|
||||
],
|
||||
buttons: [{
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor3,
|
||||
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-edit3', function (e) {
|
||||
editor3.inline(
|
||||
theTable3.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
|
||||
editor3.on('preSubmit', function (e, d, type) {
|
||||
if (d.data) {
|
||||
Object.keys(d.data).forEach(function (key) {
|
||||
// Find all elements with class .autonumeric
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
// Get raw value and update the corresponding field
|
||||
let rawValue = autoNumericInstance.getNumericString();
|
||||
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (type === 'create') {
|
||||
d.data[0]['papel_impresion_id'] = id;
|
||||
}
|
||||
else if (type === 'edit') {
|
||||
for (let v in d.data) {
|
||||
d.data[v]['papel_impresion_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Refrescar tabla
|
||||
editor3.on('submitSuccess', function (e, json, data, action) {
|
||||
|
||||
theTable3.clearPipeline();
|
||||
theTable3.draw();
|
||||
});
|
||||
|
||||
|
||||
// Delete row
|
||||
function remove_margenes(dataId, row) {
|
||||
|
||||
$.ajax({
|
||||
url: `/configuracion/papelimpresionmargenes/delete/${dataId}`,
|
||||
method: 'GET',
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
$('#confirm2delete').modal('toggle');
|
||||
theTable3.clearPipeline();
|
||||
theTable3.row($(row)).invalidate().draw();
|
||||
popSuccessAlert(data.msg ?? jqXHR.statusText);
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
tabla tipologias
|
||||
*/
|
||||
|
||||
var theTable;
|
||||
var editor;
|
||||
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>
|
||||
`;
|
||||
};
|
||||
|
||||
$('#cubierta').on('change', function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#useForTapaDura').prop('disabled', false);
|
||||
$('#useForTapaDura').prop('checked', false);
|
||||
}
|
||||
else {
|
||||
$('#useForTapaDura').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Etiquetas para las tipologias
|
||||
const tipoTypes = [
|
||||
{ label: window.ImpresionTipologias['negro'], value: 'negro' },
|
||||
{ label: window.ImpresionTipologias['color'], value: 'color' },
|
||||
{ label: window.ImpresionTipologias['bicolor'], value: 'bicolor' }
|
||||
];
|
||||
|
||||
|
||||
// Definición del editor
|
||||
editor = new $.fn.dataTable.Editor({
|
||||
ajax: {
|
||||
url: "/papelimpresiontipologias/datatable_editor",
|
||||
headers: {
|
||||
},
|
||||
},
|
||||
table: "#tableOfPapelimpresiontipologias",
|
||||
idSrc: 'id',
|
||||
fields: [
|
||||
{
|
||||
name: "tipo",
|
||||
type: "select",
|
||||
options: tipoTypes
|
||||
}, {
|
||||
name: "negro",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "negro",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "cyan",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "cyan",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "magenta",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "magenta",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "amarillo",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "amarillo",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "cg",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "cg",
|
||||
class: "autonumeric"
|
||||
},
|
||||
def: 0,
|
||||
},
|
||||
{
|
||||
name: "gota_negro",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "gota_negro",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
name: "gota_color",
|
||||
attr: {
|
||||
type: "text",
|
||||
name: "gota_color",
|
||||
class: "autonumeric"
|
||||
}
|
||||
}, {
|
||||
"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: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
ajax: $.fn.dataTable.pipeline({
|
||||
url: '/configuracion/papelesimpresion/datatable',
|
||||
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 window.ImpresionTipologias['negro'];
|
||||
else if (data == 'color')
|
||||
return window.ImpresionTipologias['color'];
|
||||
else if (data == 'bicolor')
|
||||
return window.ImpresionTipologias['bicolor'];
|
||||
}
|
||||
},
|
||||
{ 'data': 'negro', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'cyan', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'magenta', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'amarillo', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'cg', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'gota_negro', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'gota_color', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
visible: false,
|
||||
targets: [5]
|
||||
}
|
||||
],
|
||||
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>'
|
||||
}
|
||||
}],
|
||||
initComplete: function () {
|
||||
if ($('#inkjet').prop('checked')) {
|
||||
theTable.column(5).visible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor.on('open', (event) => {
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
autoNumericInstance.remove()
|
||||
|
||||
}
|
||||
new AutoNumeric(this, {
|
||||
decimalCharacter: ",",
|
||||
digitGroupSeparator: ".",
|
||||
allowDecimalPadding: 'floats',
|
||||
decimalPlaces: 2,
|
||||
unformatOnSubmit: true,
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
// Notificar que no se pueden añadir más tipologías
|
||||
editor.on('initCreate', function () {
|
||||
if ($('#tableOfPapelimpresiontipologias').DataTable().data().count() >= 3) {
|
||||
editor.close();
|
||||
popErrorAlert(window.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 (d.data) {
|
||||
Object.keys(d.data).forEach(function (key) {
|
||||
// Find all elements with class .autonumeric
|
||||
$("input.autonumeric").each(function () {
|
||||
let autoNumericInstance = AutoNumeric.getAutoNumericElement(this)
|
||||
if (autoNumericInstance) {
|
||||
// Get raw value and update the corresponding field
|
||||
let rawValue = autoNumericInstance.getNumericString();
|
||||
d.data[key][this.name] = rawValue; // Ensure the correct name attribute is used
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (type === 'create') {
|
||||
d.data[0]['papel_impresion_id'] = id;
|
||||
}
|
||||
else if (type === 'edit') {
|
||||
for (let v in d.data) {
|
||||
d.data[v]['papel_impresion_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Refrescar tabla
|
||||
editor.on('submitSuccess', function (e, json, data, action) {
|
||||
|
||||
theTable.clearPipeline();
|
||||
theTable.draw();
|
||||
});
|
||||
|
||||
|
||||
// Delete row
|
||||
function remove_tipologias(dataId, row) {
|
||||
|
||||
$.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)
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
tabla maquinas
|
||||
*/
|
||||
|
||||
// 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,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
lengthMenu: [10, 25, 50, 100],
|
||||
order: [[1, "asc"]],
|
||||
pageLength: 50,
|
||||
lengthChange: true,
|
||||
searching: true,
|
||||
paging: true,
|
||||
info: true,
|
||||
dom: "lftp",
|
||||
ajax: $.fn.dataTable.pipeline({
|
||||
url: '/maquinaspapelesimpresion/datatable_2',
|
||||
data: function (d) {
|
||||
d.papel_id = id;
|
||||
d.isRotativa = $('#rotativa').is(':checked') ? 1 : 0;
|
||||
d.webguard_token = '<?= csrf_hash() ?>';
|
||||
},
|
||||
method: 'POST',
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||
async: true,
|
||||
}),
|
||||
columns: [
|
||||
{
|
||||
'data': 'active',
|
||||
render: function (data, type, row) {
|
||||
if (type === 'display') {
|
||||
return '<input type="checkbox" class="editor-active" id="check_' + row.papel_impresion_id + '">';
|
||||
}
|
||||
return data;
|
||||
},
|
||||
className: 'dt-body-center'
|
||||
},
|
||||
{ 'data': 'maquina' },
|
||||
{ 'data': 'ancho', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'alto', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'anchoimpresion', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{ 'data': 'altoimpresion', render: (d) => `<span class="autonumeric">${d}</span>` },
|
||||
{
|
||||
data: actionBtns2,
|
||||
className: 'row-edit dt-center'
|
||||
}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr2]
|
||||
}
|
||||
],
|
||||
rowCallback: function (row, data) {
|
||||
// Set the checked state of the checkbox in the table
|
||||
$('input.editor-active', row).prop('checked', data.active == 1);
|
||||
},
|
||||
language: {
|
||||
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
searchable: false,
|
||||
targets: [0, 2, 3, 4, 5]
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
// Definición del editor
|
||||
var editor2 = new $.fn.dataTable.Editor({
|
||||
ajax: {
|
||||
url: "/maquinaspapelesimpresion/datatable_editor",
|
||||
headers: {},
|
||||
},
|
||||
table: "#tableOfMaquinas",
|
||||
idSrc: 'papel_impresion_id',
|
||||
fields: [
|
||||
{
|
||||
name: "active",
|
||||
type: "checkbox",
|
||||
separator: "|",
|
||||
ipOpts: [
|
||||
{ label: '', value: 1 }
|
||||
]
|
||||
}, {
|
||||
"name": "papel_impresion_id",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "gramaje",
|
||||
"type": "hidden"
|
||||
}, {
|
||||
"name": "maquina_id",
|
||||
"type": "hidden"
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
// Postsubmit del editor
|
||||
editor2.on('postSubmit', function (e, json, data, action) {
|
||||
|
||||
if (json.error) {
|
||||
document.getElementById("check_" + json.data.papel_impresion_id).checked = false;
|
||||
popErrorAlert(json.error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 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
|
||||
.edit($(this).closest('tr'), false)
|
||||
.set('active', $(this).prop('checked') ? 1 : 0)
|
||||
.submit();
|
||||
});
|
||||
|
||||
$('#rotativa').on('change', function () {
|
||||
if ($('#inkjet').prop('checked')) {
|
||||
$('#inkjet').prop('checked', false)
|
||||
}
|
||||
})
|
||||
|
||||
$('#inkjet').on('change', function () {
|
||||
if ($('#rotativa').prop('checked')) {
|
||||
$('#rotativa').prop('checked', false)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user