trabajando en papel generico. Problema al generar el datatable

This commit is contained in:
Jaime Jimenez
2023-05-18 20:28:07 +02:00
parent 2c69b6e69c
commit 10a057493f
15 changed files with 782 additions and 37 deletions

View File

@ -123,6 +123,18 @@ $routes->group('', [], function($routes) {
$routes->post('menuitems', 'Tipologias::menuItems', ['as' => 'menuItemsOfTipologiasLibros']);
});
$routes->group('papel-generico', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'PapelGenerico::index', ['as' => 'papelGenericoList']);
$routes->get('add', 'PapelGenerico::add', ['as' => 'newPapelGenerico']);
$routes->post('add', 'PapelGenerico::add', ['as' => 'createPapelGenerico']);
$routes->post('create', 'PapelGenerico::create', ['as' => 'ajaxCreatePapelGenerico']);
$routes->put('(:num)/update', 'PapelGenerico::update/$1', ['as' => 'ajaxUpdatePapelGenerico']);
$routes->post('(:num)/edit', 'PapelGenerico::edit/$1', ['as' => 'updatePapelGenerico']);
$routes->post('datatable', 'PapelGenerico::datatable', ['as' => 'dataTableOfPapelesGenericos']);
$routes->post('allmenuitems', 'PapelGenerico::allItemsSelect', ['as' => 'select2ItemsOfPapelesGenericos']);
$routes->post('menuitems', 'PapelGenerico::menuItems', ['as' => 'menuItemsOfPapelesGenericos']);
});
$routes->resource('papel-generico', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'PapelGenerico', 'except' => 'show,new,create,update']);
});

View File

@ -1,35 +1,274 @@
<?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseController;
<?php namespace App\Controllers\Configuracion;
class Papelgenerico extends BaseController
{
function __construct()
{
}
use App\Controllers\GoBaseResourceController;
public function index()
{
echo 'Papel genérico';
}
use App\Models\Collection;
public function edit()
{
use App\Entities\Configuracion\PapelGenericoEntity;
}
use App\Models\Configuracion\PapelGenericoModel;
public function add()
{
}
class PapelGenerico extends \App\Controllers\GoBaseResourceController {
protected $modelName = PapelGenericoModel::class;
protected $format = 'json';
protected static $singularObjectName = 'Papel Generico';
protected static $singularObjectNameCc = 'papelGenerico';
protected static $pluralObjectName = 'Papeles Genericos';
protected static $pluralObjectNameCc = 'papelesGenericos';
protected static $controllerSlug = 'papel-generico';
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/papel/';
protected $indexRoute = 'papelGenericoList';
public function delete()
{
}
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
$this->viewData['pageTitle'] = lang('PapelGenerico.moduleTitle');
$this->viewData['usingSweetAlert'] = true;
parent::initController($request, $response, $logger);
}
public function index() {
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('PapelGenerico.papelGenerico')]),
'papelGenericoEntity' => new PapelGenericoEntity(),
'usingServerSideDataTable' => true,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath.'viewPapelGenericoList', $viewData);
}
public function add() {
$requestMethod = $this->request->getMethod();
if ($requestMethod === 'post') :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->save($sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['errorMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$thenRedirect = true; // Change this to false if you want your user to stay on the form after submission
endif;
if ($noException && $successfulResult) :
$id = $this->model->db->insertID();
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.';
$message .= anchor( "admin/papel-generico/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['papelGenericoEntity'] = isset($sanitizedData) ? new PapelGenericoEntity($sanitizedData) : new PapelGenericoEntity();
$this->viewData['formAction'] = route_to('createPapelGenerico');
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('PapelGenerico.moduleTitle').' '.lang('Basic.global.addNewSuffix');
return $this->displayForm(__METHOD__);
} // end function add()
public function edit($requestedId = null) {
if ($requestedId == null) :
return $this->redirect2listView();
endif;
$id = filter_var($requestedId, FILTER_SANITIZE_URL);
$papelGenericoEntity = $this->model->find($id);
if ($papelGenericoEntity == false) :
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('PapelGenerico.papelGenerico')), $id]);
return $this->redirect2listView('sweet-error', $message);
endif;
$requestMethod = $this->request->getMethod();
if ($requestMethod === 'post') :
$nullIfEmpty = true; // !(phpversion() >= '8.1');
$postData = $this->request->getPost();
$sanitizedData = $this->sanitized($postData, $nullIfEmpty);
if ($this->request->getPost('show_in_client') == null ) {
$sanitizedData['show_in_client'] = false;
}
$noException = true;
if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) :
if ($this->canValidate()) :
try {
$successfulResult = $this->model->skipValidation(true)->update($id, $sanitizedData);
} catch (\Exception $e) {
$noException = false;
$this->dealWithException($e);
}
else:
$this->viewData['warningMessage'] = lang('Basic.global.formErr1', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]);
$this->session->setFlashdata('formErrors', $this->model->errors());
endif;
$papelGenericoEntity->fill($sanitizedData);
$thenRedirect = true;
endif;
if ($noException && $successfulResult) :
$id = $papelGenericoEntity->id ?? $id;
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.';
$message .= anchor( "admin/papel-generico/{$id}/edit" , lang('Basic.global.continueEditing').'?');
$message = ucfirst(str_replace("'", "\'", $message));
if ($thenRedirect) :
if (!empty($this->indexRoute)) :
return redirect()->to(route_to( $this->indexRoute ) )->with('sweet-success', $message);
else:
return $this->redirect2listView('sweet-success', $message);
endif;
else:
$this->session->setFlashData('sweet-success', $message);
endif;
endif; // $noException && $successfulResult
endif; // ($requestMethod === 'post')
$this->viewData['papelGenericoEntity'] = $papelGenericoEntity;
$this->viewData['formAction'] = route_to('updatePapelGenerico', $id);
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('PapelGenerico.moduleTitle').' '.lang('Basic.global.edit3');
return $this->displayForm(__METHOD__, $id);
} // end function edit(...)
public function datatable() {
if ($this->request->isAJAX()) {
$reqData = $this->request->getPost();
if (!isset($reqData['draw']) || !isset($reqData['columns']) ) {
$errstr = 'No data available in response to this specific request.';
$response = $this->respond(Collection::datatable( [], 0, 0, $errstr ), 400, $errstr);
return $response;
}
$start = $reqData['start'] ?? 0;
$length = $reqData['length'] ?? 5;
$search = $reqData['search']['value'];
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
$order = PapelGenericoModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$this->model->getResource()->countAllResults(),
$this->model->getResource($search)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function allItemsSelect() {
if ($this->request->isAJAX()) {
$onlyActiveOnes = true;
$reqVal = $this->request->getPost('val') ?? 'id';
$menu = $this->model->getAllForMenu($reqVal.', nombre', 'nombre', $onlyActiveOnes, false);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->nombre = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
public function menuItems() {
if ($this->request->isAJAX()) {
$searchStr = goSanitize($this->request->getPost('searchTerm'))[0];
$reqId = goSanitize($this->request->getPost('id'))[0];
$reqText = goSanitize($this->request->getPost('text'))[0];
$onlyActiveOnes = false;
$columns2select = [$reqId ?? 'id', $reqText ?? 'nombre'];
$onlyActiveOnes = false;
$menu = $this->model->getSelect2MenuItems($columns2select, $columns2select[1], $onlyActiveOnes, $searchStr);
$nonItem = new \stdClass;
$nonItem->id = '';
$nonItem->text = '- '.lang('Basic.global.None').' -';
array_unshift($menu , $nonItem);
$newTokenHash = csrf_hash();
$csrfTokenName = csrf_token();
$data = [
'menu' => $menu,
$csrfTokenName => $newTokenHash
];
return $this->respond($data);
} else {
return $this->failUnauthorized('Invalid request', 403);
}
}
}

View File

@ -57,7 +57,7 @@ abstract class GoBaseResourceController extends \CodeIgniter\RESTful\ResourceCon
*
* @var array
*/
protected $helpers = ['session', 'go_common', 'form', 'text'];
protected $helpers = ['session', 'go_common', 'form', 'text', 'general','jwt']; //JJO
/**
* Initializer method.

View File

@ -2,8 +2,7 @@
namespace App\Controllers;
use App\Models\Usuarios\GroupUserModel;
use App\Controllers\Configuracion\PapelGenerico;
class Test extends BaseController
{
@ -16,8 +15,8 @@ class Test extends BaseController
public function index()
{
$model = new GroupUserModel();
var_dump($model->getUsersWithRol('115b5ad39b853084209caf6824224f6b'));
$papel = new PapelGenerico();
var_dump($papel->datatable());
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Entities\Configuracion;
use CodeIgniter\Entity;
class PapelGenericoEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"nombre" => null,
"code" => null,
"code_ot" => null,
"show_in_client" => true,
"is_deleted" => 0,
"created_at" => null,
"updated_at" => null,
];
protected $casts = [
"show_in_client" => "boolean",
"is_deleted" => "int",
];
}

View File

@ -0,0 +1,41 @@
<?php
return [
'code' => 'Code',
'codeOt' => 'Code Ot',
'createdAt' => 'Created At',
'deletedAt' => 'Deleted At',
'id' => 'ID',
'isDeleted' => 'Is Deleted',
'moduleTitle' => 'Generic Paper',
'nombre' => 'Name',
'papel-generico' => 'Generic Papers',
'papelGenerico' => 'Generic Paper',
'papelGenericoList' => 'Generic Papers List',
'papelesGenericos' => 'Generic Paper',
'showInClient' => 'Show in Client',
'updatedAt' => 'Updated At',
'validation' => [
'code' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
],
'code_ot' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
],
'nombre' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'required' => 'The {field} field is required.',
],
],
];

View File

@ -0,0 +1,32 @@
<?php
return [
'code' => 'Code',
'id' => 'ID',
'moduleTitle' => 'Tipologias Libros',
'nombre' => 'Nombre',
'tipologiaLibros' => 'Tipologia Libros',
'tipologiaLibrosList' => 'Tipologia Libros List',
'tipologiasLibros' => 'Tipologias Libros',
'tipologiaslibros' => 'Tipologias Libros',
'validation' => [
'nombre' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'required' => 'The {field} field is required.',
],
'code' => [
'is_unique' => 'The {field} field must contain a unique value',
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'required' => 'The {field} field is required.',
],
],
];

View File

@ -0,0 +1,41 @@
<?php
return [
'code' => 'Código',
'codeOt' => 'Código Ot',
'createdAt' => 'Created At',
'deletedAt' => 'Deleted At',
'id' => 'ID',
'isDeleted' => 'Is Deleted',
'moduleTitle' => 'Papel Genérico',
'nombre' => 'Nombre',
'papel-generico' => 'Papeles Genéricos',
'papelGenerico' => 'Papel Genérico',
'papelGenericoList' => 'Lista Papeles Genéricos',
'papelesGenericos' => 'Papeles Genéricos',
'showInClient' => 'Mostrar en cliente',
'updatedAt' => 'Updated At',
'validation' => [
'code' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
],
'code_ot' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
],
'nombre' => [
'max_length' => 'El campo {field} no puede exceder {param} caracteres en longitud.',
'required' => 'El campo {field} es obligatorio.',
],
],
];

View File

@ -0,0 +1,32 @@
<?php
return [
'code' => 'Code',
'id' => 'ID',
'moduleTitle' => 'Tipologias Libros',
'nombre' => 'Nombre',
'tipologiaLibros' => 'Tipologia Libros',
'tipologiaLibrosList' => 'Tipologia Libros List',
'tipologiasLibros' => 'Tipologias Libros',
'tipologiaslibros' => 'Tipologias Libros',
'validation' => [
'nombre' => [
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'required' => 'The {field} field is required.',
],
'code' => [
'is_unique' => 'The {field} field must contain a unique value',
'max_length' => 'The {field} field cannot exceed {param} characters in length.',
'required' => 'The {field} field is required.',
],
],
];

View File

@ -0,0 +1,92 @@
<?php
namespace App\Models\Configuracion;
class PapelGenericoModel extends \App\Models\GoBaseModel
{
protected $table = "lg_papel_generico";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
const SORTABLE = [
1 => "t1.id",
2 => "t1.nombre",
3 => "t1.code",
4 => "t1.code_ot",
5 => "t1.show_in_client",
];
protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client"];
protected $returnType = "App\Entities\Configuracion\PapelGenericoEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $createdField = "created_at";
protected $updatedField = "updated_at";
public static $labelField = "nombre";
protected $validationRules = [
"code" => [
"label" => "PapelGenericoes.code",
"rules" => "trim|max_length[5]",
],
"code_ot" => [
"label" => "PapelGenericoes.codeOt",
"rules" => "trim|max_length[5]",
],
"nombre" => [
"label" => "PapelGenericoes.nombre",
"rules" => "trim|required|max_length[255]",
],
];
protected $validationMessages = [
"code" => [
"max_length" => "PapelGenericoes.validation.code.max_length",
],
"code_ot" => [
"max_length" => "PapelGenericoes.validation.code_ot.max_length",
],
"nombre" => [
"max_length" => "PapelGenericoes.validation.nombre.max_length",
"required" => "PapelGenericoes.validation.nombre.required",
],
];
/**
* Get resource data.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "")
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.nombre AS nombre, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client"
);
return empty($search)
? $builder
: $builder
->groupStart()
->like("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->orLike("t1.id", $search)
->orLike("t1.nombre", $search)
->orLike("t1.code", $search)
->orLike("t1.code_ot", $search)
->groupEnd();
}
}

View File

@ -0,0 +1,36 @@
<div class="row">
<div class="col-md-12 col-lg-12 px-4">
<div class="mb-3">
<label for="nombre" class="form-label">
<?=lang('PapelGenerico.nombre') ?>*
</label>
<input type="text" id="nombre" name="nombre" required maxLength="255" class="form-control" value="<?=old('nombre', $papelGenericoEntity->nombre) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="code" class="form-label">
<?=lang('PapelGenerico.code') ?>
</label>
<input type="text" id="code" name="code" maxLength="5" class="form-control" value="<?=old('code', $papelGenericoEntity->code) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="codeOt" class="form-label">
<?=lang('PapelGenerico.codeOt') ?>
</label>
<input type="text" id="codeOt" name="code_ot" maxLength="5" class="form-control" value="<?=old('code_ot', $papelGenericoEntity->code_ot) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<div class="form-check">
<label for="showInClient" class="form-check-label">
<input type="checkbox" id="showInClient" name="show_in_client" value="1" class="form-check-input"<?=$papelGenericoEntity->show_in_client== true ? 'checked' : ''; ?>>
<?=lang('PapelGenerico.showInClient') ?>
</label>
</div><!--//.form-check -->
</div><!--//.mb-3 -->
</div><!--//.col -->
</div><!-- //.row -->

View File

@ -0,0 +1,26 @@
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?= $this->include("themes/_commonPartialsBs/sweetalert") ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?= $boxTitle ?? $pageTitle ?></h3>
</div><!--//.card-header -->
<form id="papelGenericoForm" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/configuracion/papel/_papelGenericoFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer">
<?= anchor(route_to("papelGenericoList"), lang("Basic.global.Cancel"), ["class" => "btn btn-secondary float-start"]) ?>
<input type="submit" class="btn btn-primary float-end" name="save" value="<?= lang("Basic.global.Save") ?>">
</div><!-- /.card-footer -->
</form>
</div><!-- //.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>

View File

@ -0,0 +1,173 @@
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->include('themes/_commonPartialsBs/sweetalert') ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?=lang('PapelGenerico.papelGenericoList') ?></h3>
<?=anchor(route_to('newPapelGenerico'), lang('Basic.global.addNew').' '.lang('PapelGenerico.papelGenerico'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfPapelesgenericos" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th><?=lang('PapelGenerico.id')?></th>
<th><?= lang('PapelGenerico.nombre') ?></th>
<th><?= lang('PapelGenerico.code') ?></th>
<th><?= lang('PapelGenerico.codeOt') ?></th>
<th><?= lang('PapelGenerico.showInClient') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div><!--//.card-body -->
<div class="card-footer">
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?=$this->endSection() ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfPapelesgenericos').find("tr:first th").length - 1;
const actionBtns = function(data) {
return `<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<button class="btn btn-sm btn-warning btn-edit me-1" data-id="${data.id}"><?= lang('Basic.global.edit') ?></button>
<button class="btn btn-sm btn-danger btn-delete ms-1" data-id="${data.id}"><?= lang('Basic.global.Delete') ?></button>
</div>
</td>`;
};
theTable = $('#tableOfPapelesgenericos').DataTable({
processing: true,
serverSide: true,
autoWidth: true,
responsive: true,
scrollX: true,
lengthMenu: [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
pageLength: 10,
lengthChange: true,
"dom": 'lfBrtip', // 'lfBrtip', // you can try different layout combinations by uncommenting one or the other
// "dom": '<"top"lf><"clear">rt<"bottom"ipB><"clear">', // remember to comment this line if you uncomment the above
"buttons": [
'copy', 'csv', 'excel', 'print', {
extend: 'pdfHtml5',
orientation: 'landscape',
pageSize: 'A4'
}
],
stateSave: true,
order: [[1, 'asc']],
language: {
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
},
ajax : $.fn.dataTable.pipeline( {
url: '<?= route_to('dataTableOfPapelesGenericos') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [0,lastColNr]
}
],
columns : [
{ 'data': 'id' },
{ 'data': 'nombre' },
{ 'data': 'code' },
{ 'data': 'code_ot' },
{ 'data': 'show_in_client' },
{ 'data': actionBtns }
]
});
theTable.on( 'draw.dt', function () {
const boolCols = [5];
for (let coln of boolCols) {
theTable.column(coln, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = cell.innerHTML == '1' ? '<i class="text-success bi bi-check-lg"></i>' : '';
});
}
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `<?= route_to('papelGenericoList') ?>/${$(this).attr('data-id')}/edit`;
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('PapelGenerico.papel generico'))]) ?>',
text: '<?= lang('Basic.global.sweet.sureToDeleteText') ?>',
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
confirmButtonText: '<?= lang('Basic.global.sweet.deleteConfirmationButton') ?>',
cancelButtonText: '<?= lang('Basic.global.Cancel') ?>',
cancelButtonColor: '#d33'
})
.then((result) => {
const dataId = $(this).data('id');
const row = $(this).closest('tr');
if (result.value) {
$.ajax({
url: `<?= route_to('papelGenericoList') ?>/${dataId}`,
method: 'DELETE',
}).done((data, textStatus, jqXHR) => {
Toast.fire({
icon: 'success',
title: data.msg ?? jqXHR.statusText,
});
theTable.clearPipeline();
theTable.row($(row)).invalidate().draw();
}).fail((jqXHR, textStatus, errorThrown) => {
Toast.fire({
icon: 'error',
title: jqXHR.responseJSON.messages.error,
});
})
}
});
});
<?=$this->endSection() ?>
<?=$this->section('css') ?>
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
<?=$this->endSection() ?>
<?= $this->section('additionalExternalJs') ?>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.bootstrap5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.0/jszip.min.js" integrity="sha512-xcHCGC5tQ0SHlRX8Anbz6oy/OullASJkEhb4gjkneVpGE3/QGYejf14CUO5n5q5paiHfRFTa9HKgByxzidw2Bw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/pdfmake.min.js" integrity="sha512-rDbVu5s98lzXZsmJoMa0DjHNE+RwPJACogUCLyq3Xxm2kJO6qsQwjbE5NDk2DqmlKcxDirCnU1wAzVLe12IM3w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.5/vfs_fonts.js" integrity="sha512-cktKDgjEiIkPVHYbn8bh/FEyYxmt4JDJJjOCu5/FQAkW4bc911XtKYValiyzBiJigjVEvrIAyQFEbRJZyDA1wQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<?=$this->endSection() ?>

View File

@ -1,5 +1,5 @@
<?= $this->include("Themes/_commonPartialsBs/select2bs5") ?>
<?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?>
<?= $this->include("themes/_commonPartialsBs/select2bs5") ?>
<?=$this->extend('themes/backend/vuexy/main/defaultlayout') ?>
<?= $this->section("content") ?>
<div class="row">
<div class="col-12">
@ -10,7 +10,7 @@
<form id="tipologiaLibrosForm" method="post" action="<?= $formAction ?>">
<?= csrf_field() ?>
<div class="card-body">
<?= view("Themes/_commonPartialsBs/_alertBoxes") ?>
<?= view("themes/_commonPartialsBs/_alertBoxes") ?>
<?= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
<?= view("themes/backend/vuexy/form/configuracion/tipologias/_tipologiaLibrosFormItems") ?>
</div><!-- /.card-body -->

View File

@ -1,5 +1,5 @@
<?=$this->include('Themes/_commonPartialsBs/datatables') ?>
<?=$this->extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?>
<?=$this->include('themes/_commonPartialsBs/datatables') ?>
<?=$this->extend('themes'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?>
<?=$this->section('content'); ?>
<div class="row">
<div class="col-md-12">
@ -9,7 +9,7 @@
<h3 class="card-title"><?=lang('TipologiasLibros.tipologiaLibrosList') ?></h3>
</div><!--//.card-header -->
<div class="card-body">
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfTipologiaslibros" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
<thead>