diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php
index 52415fbe..63ea31b4 100644
--- a/ci4/app/Config/Routes.php
+++ b/ci4/app/Config/Routes.php
@@ -198,6 +198,14 @@ $routes->group('papelimpresiontipologias', ['namespace' => 'App\Controllers\Conf
$routes->get('delete/(:num)', 'Papelimpresiontipologias::delete/$1', ['as' => 'deletePapelImpresionTipologia']);
});
+
+$routes->group('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
+ $routes->post('datatable', 'Papelimpresionmargenes::datatable', ['as' => 'dataTableOfPapelImpresionMargen']);
+ $routes->post('datatable_editor', 'Papelimpresionmargenes::datatable_editor', ['as' => 'editorOfPapelImpresionMargenes']);
+});
+$routes->resource('papelesimpresionmargenes', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Papelimpresionmargenes', 'except' => 'show,new,create,update']);
+
+
$routes->group('tarifaacabadolineas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) {
$routes->get('', 'Tarifaacabadolineas::index', ['as' => 'tarifaAcabadoLineaList']);
$routes->get('add', 'Tarifaacabadolineas::add', ['as' => 'newTarifaAcabadoLinea']);
diff --git a/ci4/app/Controllers/Configuracion/Papelimpresionmargenes.php b/ci4/app/Controllers/Configuracion/Papelimpresionmargenes.php
index 9b59bed1..0feadbc4 100644
--- a/ci4/app/Controllers/Configuracion/Papelimpresionmargenes.php
+++ b/ci4/app/Controllers/Configuracion/Papelimpresionmargenes.php
@@ -80,7 +80,7 @@ class Papelimpresionmargenes extends \App\Controllers\GoBaseResourceController
->validator('Validate::notEmpty', array(
'message' => lang('PapelImpresionMargenesvalidation.margen.required'))
),
- Field::inst('papel_impresion:id'),
+ Field::inst('papel_impresion_id'),
Field::inst('user_created_id'),
Field::inst('created_at'),
Field::inst('user_updated_id'),
@@ -154,7 +154,7 @@ class Papelimpresionmargenes extends \App\Controllers\GoBaseResourceController
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
- $order = TarifaEncuadernacionLineaModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
+ $order = PapelImpresionMargenModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$id_PI = $reqData['papel_impresion_id'] ?? -1;
diff --git a/ci4/app/Models/Configuracion/PapelImpresionMargenModel.php b/ci4/app/Models/Configuracion/PapelImpresionMargenModel.php
index 29e7af9b..1c320067 100644
--- a/ci4/app/Models/Configuracion/PapelImpresionMargenModel.php
+++ b/ci4/app/Models/Configuracion/PapelImpresionMargenModel.php
@@ -83,15 +83,12 @@ class PapelImpresionMargenModel extends \App\Models\GoBaseModel
->table($this->table . " t1")
->select(
"t1.id AS id, t1.papel_impresion_id AS papel_impresion_id, t1.paginas_min AS paginas_min,
- t1.paginas_max AS paginas_max, t1.margen AS margen, t2.id AS papel_impresion"
+ t1.paginas_max AS paginas_max, t1.margen AS margen"
);
//JJO
$builder->where('papel_impresion_id', $papel_impresion_id);
$builder->where("t1.is_deleted", 0);
- $builder->join("lg_papel_impresion t2", "t1.papel_impresion_id = t2.id", "left");
-
-
return empty($search)
? $builder
: $builder
diff --git a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php
index 95de667b..8e3b26bc 100644
--- a/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php
+++ b/ci4/app/Views/themes/backend/vuexy/form/configuracion/papel/viewPapelImpresionForm.php
@@ -186,7 +186,189 @@
= $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: "number"
+ }
+ },{
+ name: "paginas_max",
+ attr: {
+ type: "number"
+ }
+ },{
+ name: "margen",
+ attr: {
+ type: "number"
+ }
+ }, {
+ "name": "papel_impresion_id",
+ "type": "hidden"
+ }, {
+ "name": "deleted_at",
+ "type": "hidden"
+ }, {
+ "name": "is_deleted",
+ "type": "hidden"
+ },
+ ]
+ } );
+
+
+
+ // 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: "//cdn.datatables.net/plug-ins/1.13.4/i18n/= config('Basics')->i18n ?>.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' },
+ { 'data': 'paginas_max' },
+ { 'data': 'margen' },
+ { 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-edit2', function(e) {
+ editor.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 ( 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();
+ });
+
+
+ /*
+
+ // 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() ?>
+