Terminando formulario

This commit is contained in:
Jaime Jimenez
2023-07-12 12:24:55 +02:00
parent 247f4ea485
commit 810e1c8b37
6 changed files with 177 additions and 282 deletions

View File

@ -260,18 +260,19 @@ $routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Conf
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
$routes->group('maquinadefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList']);
$routes->get('index', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoIndex']);
$routes->get('list', 'Maquinadefecto::index', ['as' => 'maquinaPorDefectoList2']);
$routes->get('add', 'Maquinadefecto::add', ['as' => 'newMaquinaPorDefecto']);
$routes->post('add', 'Maquinadefecto::add', ['as' => 'createMaquinaPorDefecto']);
$routes->get('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'editMaquinaPorDefecto']);
$routes->post('edit/(:num)', 'Maquinadefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']);
$routes->get('delete/(:num)', 'Maquinadefecto::delete/$1', ['as' => 'deleteMaquinaPorDefecto']);
$routes->post('allmenuitems', 'Maquinadefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']);
$routes->post('menuitems', 'Maquinadefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']);
$routes->group('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
$routes->get('', 'Maquinasdefecto::index', ['as' => 'maquinaPorDefectoList']);
$routes->get('add', 'Maquinasdefecto::add', ['as' => 'newMaquinaPorDefecto']);
$routes->post('add', 'Maquinasdefecto::add', ['as' => 'createMaquinaPorDefecto']);
$routes->post('create', 'Maquinasdefecto::create', ['as' => 'ajaxCreateMaquinaPorDefecto']);
$routes->put('(:num)/update', 'Maquinasdefecto::update/$1', ['as' => 'ajaxUpdateMaquinaPorDefecto']);
$routes->post('(:num)/edit', 'Maquinasdefecto::edit/$1', ['as' => 'updateMaquinaPorDefecto']);
$routes->post('datatable', 'Maquinasdefecto::datatable', ['as' => 'dataTableOfMaquinasPorDefecto']);
$routes->post('allmenuitems', 'Maquinasdefecto::allItemsSelect', ['as' => 'select2ItemsOfMaquinasPorDefecto']);
$routes->post('menuitems', 'Maquinasdefecto::menuItems', ['as' => 'menuItemsOfMaquinasPorDefecto']);
});
$routes->resource('maquinasdefecto', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinasdefecto', 'except' => 'show,new,create,update']);
$routes->group('profile', ['namespace' => 'App\Controllers'], function ($routes) {
$routes->get('', 'Profile::index', ['as' => 'profileList']);

View File

@ -1,36 +0,0 @@
<?php
namespace App\Entities\Configuracion;
use CodeIgniter\Entity;
class MaquinaDefectoEntity extends \CodeIgniter\Entity\Entity
{
protected $attributes = [
"id" => null,
"tipo" => null,
"ancho_min" => 0.0,
"ancho_max" => 0.0,
"alto_min" => 0.0,
"alto_max" => 0.0,
"tirada_min" => 1,
"tirada_max" => 10000,
"maquina_id" => null,
"user_created_id" => 0,
"user_updated_id" => 0,
"is_deleted" => 0,
"created_at" => null,
"updated_at" => null,
];
protected $casts = [
"ancho_min" => "float",
"ancho_max" => "float",
"alto_min" => "float",
"alto_max" => "float",
"tirada_min" => "int",
"tirada_max" => "int",
"maquina_id" => "int",
"user_created_id" => "int",
"user_updated_id" => "int",
"is_deleted" => "int",
];
}

View File

@ -1,118 +0,0 @@
<?php
namespace App\Models\Configuracion;
class MaquinaDefectoModel extends \App\Models\GoBaseModel
{
protected $table = "lg_maquina_por_defecto";
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = [
"tipo",
"ancho_min",
"ancho_max",
"alto_min",
"alto_max",
"tirada_min",
"tirada_max",
"maquina_id",
];
protected $returnType = "App\Entities\Configuracion\MaquinaDefectoEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $createdField = "created_at";
protected $updatedField = "updated_at";
public static $labelField = "tipo";
protected $validationRules = [
"alto_max" => [
"label" => "MaquinaPorDefectoes.altoMax",
"rules" => "required|decimal",
],
"alto_min" => [
"label" => "MaquinaPorDefectoes.altoMin",
"rules" => "required|decimal",
],
"ancho_max" => [
"label" => "MaquinaPorDefectoes.anchoMax",
"rules" => "required|decimal",
],
"ancho_min" => [
"label" => "MaquinaPorDefectoes.anchoMin",
"rules" => "required|decimal",
],
"tipo" => [
"label" => "MaquinaPorDefectoes.tipo",
"rules" => "required|in_list[bn,bnhq,color,portada,cubierta,rotativa]",
],
"tirada_max" => [
"label" => "MaquinaPorDefectoes.tiradaMax",
"rules" => "required|integer",
],
"tirada_min" => [
"label" => "MaquinaPorDefectoes.tiradaMin",
"rules" => "required|integer",
],
];
protected $validationMessages = [
"alto_max" => [
"decimal" => "MaquinaPorDefectoes.validation.alto_max.decimal",
"required" => "MaquinaPorDefectoes.validation.alto_max.required",
],
"alto_min" => [
"decimal" => "MaquinaPorDefectoes.validation.alto_min.decimal",
"required" => "MaquinaPorDefectoes.validation.alto_min.required",
],
"ancho_max" => [
"decimal" => "MaquinaPorDefectoes.validation.ancho_max.decimal",
"required" => "MaquinaPorDefectoes.validation.ancho_max.required",
],
"ancho_min" => [
"decimal" => "MaquinaPorDefectoes.validation.ancho_min.decimal",
"required" => "MaquinaPorDefectoes.validation.ancho_min.required",
],
"tipo" => [
"in_list" => "MaquinaPorDefectoes.validation.tipo.in_list",
"required" => "MaquinaPorDefectoes.validation.tipo.required",
],
"tirada_max" => [
"integer" => "MaquinaPorDefectoes.validation.tirada_max.integer",
"required" => "MaquinaPorDefectoes.validation.tirada_max.required",
],
"tirada_min" => [
"integer" => "MaquinaPorDefectoes.validation.tirada_min.integer",
"required" => "MaquinaPorDefectoes.validation.tirada_min.required",
],
];
public function findAllWithMaquinas(string $selcols = "*", int $limit = null, int $offset = 0)
{
$sql =
"SELECT t1." .
$selcols .
", t2.nombre AS maquina FROM " .
$this->table .
" t1 LEFT JOIN lg_maquinas t2 ON t1.maquina_id = t2.id";
if (!is_null($limit) && intval($limit) > 0) {
$sql .= " LIMIT " . $limit;
}
if (!is_null($offset) && intval($offset) > 0) {
$sql .= " OFFSET " . $offset;
}
$query = $this->db->query($sql);
$result = $query->getResultObject();
return $result;
}
}

View File

@ -2,72 +2,72 @@
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="tipo" class="form-label">
<?=lang('MaquinaPorDefectoes.tipo') ?>*
<?=lang('MaquinasPorDefecto.tipo') ?>*
</label>
<select id="tipo" name="tipo" required class="form-control select2bs" style="width: 100%;" >
<option value="" selected="selected"><?=lang('Basic.global.pleaseSelectOne') ?></option>
<option value="bn"<?=$maquinaDefectoEntity->tipo == 'bn' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.bn') ?></option>
<option value="bnhq"<?=$maquinaDefectoEntity->tipo == 'bnhq' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.bnhq') ?></option>
<option value="color"<?=$maquinaDefectoEntity->tipo == 'color' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.color') ?></option>
<option value="portada"<?=$maquinaDefectoEntity->tipo == 'portada' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.portada') ?></option>
<option value="cubierta"<?=$maquinaDefectoEntity->tipo == 'cubierta' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.cubierta') ?></option>
<option value="rotativa"<?=$maquinaDefectoEntity->tipo == 'rotativa' ? ' selected':'' ?>><?= lang('MaquinaPorDefectoes.rotativa') ?></option>
<option value="bn"<?=$maquinasDefectoEntity->tipo == 'bn' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.bn') ?></option>
<option value="bnhq"<?=$maquinasDefectoEntity->tipo == 'bnhq' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.bnhq') ?></option>
<option value="color"<?=$maquinasDefectoEntity->tipo == 'color' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.color') ?></option>
<option value="portada"<?=$maquinasDefectoEntity->tipo == 'portada' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.portada') ?></option>
<option value="cubierta"<?=$maquinasDefectoEntity->tipo == 'cubierta' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.cubierta') ?></option>
<option value="rotativa"<?=$maquinasDefectoEntity->tipo == 'rotativa' ? ' selected':'' ?>><?= lang('MaquinasPorDefecto.rotativa') ?></option>
</select>
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="anchoMin" class="form-label">
<?=lang('MaquinaPorDefectoes.anchoMin') ?>*
<?=lang('MaquinasPorDefecto.anchoMin') ?>*
</label>
<input type="number" id="anchoMin" name="ancho_min" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_min', $maquinaDefectoEntity->ancho_min) ?>">
<input type="number" id="anchoMin" name="ancho_min" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_min', $maquinasDefectoEntity->ancho_min) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="anchoMax" class="form-label">
<?=lang('MaquinaPorDefectoes.anchoMax') ?>*
<?=lang('MaquinasPorDefecto.anchoMax') ?>*
</label>
<input type="number" id="anchoMax" name="ancho_max" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_max', $maquinaDefectoEntity->ancho_max) ?>">
<input type="number" id="anchoMax" name="ancho_max" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('ancho_max', $maquinasDefectoEntity->ancho_max) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="altoMin" class="form-label">
<?=lang('MaquinaPorDefectoes.altoMin') ?>*
<?=lang('MaquinasPorDefecto.altoMin') ?>*
</label>
<input type="number" id="altoMin" name="alto_min" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_min', $maquinaDefectoEntity->alto_min) ?>">
<input type="number" id="altoMin" name="alto_min" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_min', $maquinasDefectoEntity->alto_min) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="altoMax" class="form-label">
<?=lang('MaquinaPorDefectoes.altoMax') ?>*
<?=lang('MaquinasPorDefecto.altoMax') ?>*
</label>
<input type="number" id="altoMax" name="alto_max" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_max', $maquinaDefectoEntity->alto_max) ?>">
<input type="number" id="altoMax" name="alto_max" required placeholder="0.00" maxLength="8" step="0.01" class="form-control" value="<?=old('alto_max', $maquinasDefectoEntity->alto_max) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="tiradaMin" class="form-label">
<?=lang('MaquinaPorDefectoes.tiradaMin') ?>*
<?=lang('MaquinasPorDefecto.tiradaMin') ?>*
</label>
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="1" maxLength="11" class="form-control" value="<?=old('tirada_min', $maquinaDefectoEntity->tirada_min) ?>">
<input type="number" id="tiradaMin" name="tirada_min" required placeholder="1" maxLength="11" class="form-control" value="<?=old('tirada_min', $maquinasDefectoEntity->tirada_min) ?>">
</div><!--//.mb-3 -->
<div class="mb-3">
<label for="tiradaMax" class="form-label">
<?=lang('MaquinaPorDefectoes.tiradaMax') ?>*
<?=lang('MaquinasPorDefecto.tiradaMax') ?>*
</label>
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="10000" maxLength="11" class="form-control" value="<?=old('tirada_max', $maquinaDefectoEntity->tirada_max) ?>">
<input type="number" id="tiradaMax" name="tirada_max" required placeholder="10000" maxLength="11" class="form-control" value="<?=old('tirada_max', $maquinasDefectoEntity->tirada_max) ?>">
</div><!--//.mb-3 -->
</div><!--//.col -->
<div class="col-md-12 col-lg-6 px-4">
<div class="mb-3">
<label for="maquinaId" class="form-label">
<?=lang('MaquinaPorDefectoes.maquinaId') ?>*
<?=lang('MaquinasPorDefecto.maquinaId') ?>*
</label>
<select id="maquinaId" name="maquina_id" required class="form-control select2bs2" style="width: 100%;" >
<select id="maquinaId" name="maquina_id" required class="form-control select2 form-select" style="width: 100%;" >
<?php if ( isset($maquinaList) && is_array($maquinaList) && !empty($maquinaList) ) :
foreach ($maquinaList as $k => $v) : ?>
<option value="<?=$k ?>"<?=$k==$maquinaDefectoEntity->maquina_id ? ' selected':'' ?>>
<option value="<?=$k ?>"<?=$k==$maquinasDefectoEntity->maquina_id ? ' selected':'' ?>>
<?=$v ?>
</option>
<?php endforeach;

View File

@ -1,5 +1,6 @@
<?= $this->include("Themes/_commonPartialsBs/select2bs5") ?>
<?= $this->extend("Themes/" . config("Basics")->theme["name"] . "/AdminLayout/defaultLayout") ?>
<?= $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">
@ -10,12 +11,12 @@
<form id="maquinaPorDefectoForm" 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/maquinas/_maquinaPorDefectoFormItems") ?>
</div><!-- /.card-body -->
<div class="card-footer">
<?= anchor(route_to("maquinaPorDefectoList2"), lang("Basic.global.Cancel"), [
<?= anchor(route_to("maquinaPorDefectoList"), 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") ?>">

View File

@ -1,84 +1,167 @@
<?=$this->include('Themes/_commonPartialsBs/select2bs5') ?>
<?=$this->include('Themes/_commonPartialsBs/datatables') ?>
<?=$this->extend('Themes/'.config('Basics')->theme['name'].'/AdminLayout/defaultLayout') ?>
<?=$this->include('themes/_commonPartialsBs/select2bs5') ?>
<?=$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('MaquinaPorDefectoes.maquinaPorDefectoList') ?></h3>
<h3 class="card-title"><?=lang('MaquinasPorDefecto.maquinaPorDefectoList') ?></h3>
<?=anchor(route_to('newMaquinaPorDefecto'), lang('Basic.global.addNew').' '.lang('MaquinasPorDefecto.maquinaPorDefecto'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-header -->
<div class="card-body">
<?= view('Themes/_commonPartialsBs/_alertBoxes'); ?>
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableOfMaquinaspordefecto" class="table table-striped table-hover using-exportable-data-table" style="width: 100%;">
<table id="tableOfMaquinaspordefecto" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
<th><?= lang('MaquinaPorDefectoes.id') ?></th>
<th><?= lang('MaquinaPorDefectoes.tipo') ?></th>
<th><?= lang('MaquinaPorDefectoes.anchoMin') ?></th>
<th><?= lang('MaquinaPorDefectoes.anchoMax') ?></th>
<th><?= lang('MaquinaPorDefectoes.altoMin') ?></th>
<th><?= lang('MaquinaPorDefectoes.altoMax') ?></th>
<th><?= lang('MaquinaPorDefectoes.tiradaMin') ?></th>
<th><?= lang('MaquinaPorDefectoes.tiradaMax') ?></th>
<th><?= lang('MaquinasPorDefecto.tipo') ?></th>
<th><?= lang('Maquinas.maquina') ?></th>
<th><?= lang('MaquinasPorDefecto.anchoMin') ?></th>
<th><?= lang('MaquinasPorDefecto.anchoMax') ?></th>
<th><?= lang('MaquinasPorDefecto.altoMin') ?></th>
<th><?= lang('MaquinasPorDefecto.altoMax') ?></th>
<th><?= lang('MaquinasPorDefecto.tiradaMin') ?></th>
<th><?= lang('MaquinasPorDefecto.tiradaMax') ?></th>
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($maquinaPorDefectoList as $item ) : ?>
<tr>
<td class="align-middle text-center text-nowrap">
<?=anchor(route_to('editMaquinaPorDefecto', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteMaquinaPorDefecto', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
</td>
<td class="align-middle text-center">
<?=$item->id ?>
</td>
<td class="align-middle">
<?= esc($item->tipo) ?>
</td>
<td class="align-middle">
<?= esc($item->ancho_min) ?>
</td>
<td class="align-middle">
<?= esc($item->ancho_max) ?>
</td>
<td class="align-middle">
<?= esc($item->alto_min) ?>
</td>
<td class="align-middle">
<?= esc($item->alto_max) ?>
</td>
<td class="align-middle">
<?= esc($item->tirada_min) ?>
</td>
<td class="align-middle">
<?= esc($item->tirada_max) ?>
</td>
<td class="align-middle">
<?= esc($item->maquina) ?>
</td>
<td class="align-middle text-center text-nowrap">
<?=anchor(route_to('editMaquinaPorDefecto', $item->id), lang('Basic.global.edit'), ['class'=>'btn btn-sm btn-warning btn-edit me-1', 'data-id'=>$item->id,]); ?>
<?=anchor('#confirm2delete', lang('Basic.global.Delete'), ['class'=>'btn btn-sm btn-danger btn-delete ms-1', 'data-href'=>route_to('deleteMaquinaPorDefecto', $item->id), 'data-bs-toggle'=>'modal', 'data-bs-target'=>'#confirm2delete']); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div><!--//.card-body -->
<div class="card-footer">
<?=anchor(route_to('newMaquinaPorDefecto'), lang('Basic.global.addNew').' '.lang('MaquinaPorDefectoes.maquinaPorDefecto'), ['class'=>'btn btn-primary float-end']); ?>
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?=$this->endSection() ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr = $('#tableOfMaquinaspordefecto').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">
<i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i>
<i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i>
</div>
</td>`;
};
theTable = $('#tableOfMaquinaspordefecto').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',
"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('dataTableOfMaquinasPorDefecto') ?>',
method: 'POST',
headers: {'X-Requested-With': 'XMLHttpRequest'},
async: true,
}),
columnDefs: [
{
orderable: false,
searchable: false,
targets: [lastColNr]
}
],
columns : [
{ 'data': 'tipo', "render": function ( data, type, row, meta ) {
if(data=='bn')
return '<?= lang('MaquinasPorDefecto.bn') ?>';
else if(data=='bnhq')
return '<?= lang('MaquinasPorDefecto.bnhq') ?>';
else if(data=='color')
return '<?= lang('MaquinasPorDefecto.color') ?>';
else if(data=='cubierta')
return '<?= lang('MaquinasPorDefecto.cubierta') ?>';
else if(data=='portada')
return '<?= lang('MaquinasPorDefecto.portada') ?>';
else if(data=='rotativa')
return '<?= lang('MaquinasPorDefecto.rotativa') ?>';
}
},
{ 'data': 'maquina' },
{ 'data': 'ancho_min' },
{ 'data': 'ancho_max' },
{ 'data': 'alto_min' },
{ 'data': 'alto_max' },
{ 'data': 'tirada_min' },
{ 'data': 'tirada_max' },
{ 'data': actionBtns }
]
});
$(document).on('click', '.btn-edit', function(e) {
window.location.href = `configuracion/maquinasdefecto/edit/${$(this).attr('data-id')}`;
});
$(document).on('click', '.btn-delete', function(e) {
Swal.fire({
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('MaquinasPorDefecto.maquina por defecto'))]) ?>',
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('maquinaPorDefectoList') ?>/${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() ?>
@ -100,39 +183,3 @@
<?=$this->endSection() ?>
<?=$this->section('additionalInlineJs') ?>
const lastColNr2 = $(".using-exportable-data-table").find("tr:first th").length - 1;
theTable = $('.using-exportable-data-table').DataTable({
"responsive": true,
"paging": true,
"lengthMenu": [ 5, 10, 25, 50, 75, 100, 250, 500, 1000, 2500 ],
"pageLength": 10,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"dom": 'lfrtipB', // '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'
}
],
"autoWidth": true,
"scrollX": true,
"stateSave": true,
"language": {
url: "/assets/dt/<?= config('Basics')->languages[$currentLocale] ?? config('Basics')->i18n ?>.json"
},
"columnDefs": [
{
orderable: false,
searchable: false,
targets: [0,lastColNr2]
}
]
});
<?=$this->endSection() ?>