-
-
-
-
-
">
-
-
+
+
+
+
+
+
+
+
+
">
+
-
+
+
= $this->endSection() ?>
+ = $this->section("additionalInlineJs") ?>
+ window.ImpresionTipologias = [];
+ window.ImpresionTipologias['negro'] = '= lang('ImpresionTipologias.negro') ?>';
+ window.ImpresionTipologias['color'] = '= lang('ImpresionTipologias.color') ?>';
+ window.ImpresionTipologias['bicolor'] = '= lang('ImpresionTipologias.bicolor') ?>';
+ window.maxRowsReached = '= lang('Basic.global.sweet.maxRowsReached') ?>';
+ = $this->endSection() ?>
+
= $this->section('additionalExternalJs') ?>
-
- = $this->endSection() ?>
-
-
-
- = $this->section("additionalInlineJs") ?>
-
- 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: '= route_to("menuItemsOfPapelesGenericos") ?>',
- type: 'post',
- dataType: 'json',
-
- data: function (params) {
- return {
- id: 'id',
- text: 'nombre',
- searchTerm: params.term,
- = csrf_token() ?? "token" ?> : = csrf_token() ?>v
- };
- },
- delay: 60,
- processResults: function (response) {
-
- yeniden(response.= csrf_token() ?>);
-
- 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);
- }
- }
- });
- = $this->endSection() ?>
-
-
-
+
-
-
-
-
-
- = $this->section("additionalInlineJs") ?>
-
- var theTable3;
- const lastColNr3 = $('#tableOfPapelimpresionmargenes').find("tr:first th").length - 1;
- const actionBtns3 = function(data) {
- return `
-
-
-
- `;
- };
-
-
- // Definición del editor
- var editor3 = new $.fn.dataTable.Editor( {
- ajax: {
- url: "= route_to('editorOfPapelImpresionMargenes') ?>",
- headers: {
- = csrf_token() ?? "token" ?> : = csrf_token() ?>v,
- },
- },
- 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>
<"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: '= route_to('dataTableOfPapelImpresionMargen') ?>',
- data: {
- id_PI: id,
- },
- method: 'POST',
- headers: {'X-Requested-With': 'XMLHttpRequest'},
- async: true,
- }),
- columns : [
- { 'data': 'paginas_min' , render : (d) => `${d}` },
- { 'data': 'paginas_max' , render : (d) => `${d}`},
- { 'data': 'margen', render : (d) => `${d}`},
- { 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: ''
- }
- } ]
- });
-
-
- // 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: '',
- cancelTrigger: 'span.cancel',
- submitHtml: '',
- 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 (v in d.data){
- d.data[v]['papel_impresion_id'] = id;
- }
- }
- });
-
- // Refrescar token
- editor3.on( 'postSubmit', function ( e, json, data, action ) {
-
- yeniden(json.= csrf_token() ?>);
- });
-
- // 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)
- });
- }
-
-
- = $this->endSection() ?>
-
-
-
-
- = $this->section("additionalInlineJs") ?>
-
- var theTable;
- const lastColNr = $('#tableOfPapelimpresiontipologias').find("tr:first th").length - 1;
- const actionBtns = function(data) {
- return `
-
-
-
- `;
- };
-
- $('#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:'= 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: "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><"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: '= 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',render : (d) => `${d}` },
- { 'data': 'cyan',render : (d) => `${d}` },
- { 'data': 'magenta',render : (d) => `${d}` },
- { 'data': 'amarillo',render : (d) => `${d}` },
- { 'data': 'cg',render : (d) => `${d}` },
- { 'data': 'gota_negro',render : (d) => `${d}` },
- { 'data': 'gota_color',render : (d) => `${d}` },
- { 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: ''
- }
- } ],
- initComplete: function () {
- inkjet) { ?>
- 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('= 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: '',
- cancelTrigger: 'span.cancel',
- submitHtml: '',
- 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 (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();
- });
-
-
- // 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)
- });
- }
-
- = $this->endSection() ?>
-
-
-
-
-
- = $this->section("additionalInlineJs") ?>
-
- // Botones última columna
- const lastColNr2 = $('#tableOfMaquinas').find("tr:first th").length - 1;
- const actionBtns2 = function(data) {
- return `
-
- `;
- };
-
-
- // Definicion de la tabla
- var theTable2 = $('#tableOfMaquinas').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: true,
- dom: "lftp",
- ajax : $.fn.dataTable.pipeline( {
- url: '= route_to('dataTableOfPapelesImpresionMaquinas') ?>',
- 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 '';
- }
- return data;
- },
- className: 'dt-body-center'
- },
- { 'data': 'maquina'},
- { 'data': 'ancho',render : (d) => `${d}`},
- { 'data': 'alto',render : (d) => `${d}`},
- { 'data': 'anchoimpresion',render : (d) => `${d}`},
- { 'data': 'altoimpresion',render : (d) => `${d}`},
- { 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
- editor2 = new $.fn.dataTable.Editor( {
- ajax: {
- url: "= route_to('editorOfMaquinasPapelImpresion') ?>",
- headers: {
- = csrf_token() ?? "token" ?> : = csrf_token() ?>v,
- },
- },
- 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 ) {
- yeniden(json.= csrf_token() ?>);
- 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)
- }
- })
-
- = $this->endSection() ?>
-
-
-
-
- = $this->section('css') ?>
-
- ">
- = $this->endSection() ?>
-
- = $this->section('additionalExternalJs') ?>
-
-
-
-
-
-
-
-
-
- = $this->endSection() ?>
\ No newline at end of file
+
+
+
+
+
+ = $this->endSection() ?>
+
+
+
+ = $this->section('css') ?>
+
+ ">
+ = $this->endSection() ?>
+
+ = $this->section('additionalExternalJs') ?>
+
+
+
+
+
+
+
+
+
+ = $this->endSection() ?>
\ No newline at end of file
diff --git a/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionAdd.js b/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionAdd.js
new file mode 100644
index 00000000..f35e93b6
--- /dev/null
+++ b/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionAdd.js
@@ -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);
+ }
+ }
+ });
+})
\ No newline at end of file
diff --git a/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionEdit.js b/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionEdit.js
new file mode 100644
index 00000000..1d1ecc06
--- /dev/null
+++ b/httpdocs/assets/js/safekat/pages/configuracion/papel_impresion/papelesImpresionEdit.js
@@ -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 `
+
+
+
+ `;
+ };
+
+
+ // 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><"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) => `${d}` },
+ { 'data': 'paginas_max', render: (d) => `${d}` },
+ { 'data': 'margen', render: (d) => `${d}` },
+ {
+ 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: ''
+ }
+ }]
+ });
+
+
+ // 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: '',
+ cancelTrigger: 'span.cancel',
+ submitHtml: '',
+ 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 `
+
+
+
+ `;
+ };
+
+ $('#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><"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) => `${d}` },
+ { 'data': 'cyan', render: (d) => `${d}` },
+ { 'data': 'magenta', render: (d) => `${d}` },
+ { 'data': 'amarillo', render: (d) => `${d}` },
+ { 'data': 'cg', render: (d) => `${d}` },
+ { 'data': 'gota_negro', render: (d) => `${d}` },
+ { 'data': 'gota_color', render: (d) => `${d}` },
+ {
+ 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: ''
+ }
+ }],
+ 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: '',
+ cancelTrigger: 'span.cancel',
+ submitHtml: '',
+ 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 `
+
+ `;
+ };
+
+
+ // 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 '';
+ }
+ return data;
+ },
+ className: 'dt-body-center'
+ },
+ { 'data': 'maquina' },
+ { 'data': 'ancho', render: (d) => `${d}` },
+ { 'data': 'alto', render: (d) => `${d}` },
+ { 'data': 'anchoimpresion', render: (d) => `${d}` },
+ { 'data': 'altoimpresion', render: (d) => `${d}` },
+ {
+ 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)
+ }
+ })
+
+})
\ No newline at end of file