mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
funcionando la vista papel generico. investiganto ruta del boton añadir. falta poder quitar botones primera col
This commit is contained in:
274
ci4/app/Controllers/Configuracion/PapelesGenericos.php
Normal file
274
ci4/app/Controllers/Configuracion/PapelesGenericos.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Configuracion\PapelGenerico;
|
||||
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
|
||||
class PapelesGenericos 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 = 'papelesgenericos';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/papel/';
|
||||
|
||||
protected $indexRoute = 'papelGenericoList';
|
||||
|
||||
|
||||
|
||||
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')]),
|
||||
'papelGenerico' => new PapelGenerico(),
|
||||
'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/papelesgenericos/{$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['papelGenerico'] = isset($sanitizedData) ? new PapelGenerico($sanitizedData) : new PapelGenerico();
|
||||
|
||||
$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);
|
||||
$papelGenerico = $this->model->find($id);
|
||||
|
||||
if ($papelGenerico == 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;
|
||||
|
||||
$papelGenerico->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = true;
|
||||
endif;
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $papelGenerico->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('PapelGenerico.papelGenerico'))]).'.';
|
||||
$message .= anchor( "admin/papelesgenericos/{$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['papelGenerico'] = $papelGenerico;
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
22
ci4/app/Entities/Configuracion/Imposicion.php
Normal file
22
ci4/app/Entities/Configuracion/Imposicion.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class Imposicion extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"ancho" => null,
|
||||
"alto" => null,
|
||||
"unidades" => null,
|
||||
"orientacion" => null,
|
||||
"maquina" => null,
|
||||
"etiqueta" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"ancho" => "int",
|
||||
"alto" => "int",
|
||||
"unidades" => "?int",
|
||||
];
|
||||
}
|
||||
22
ci4/app/Entities/Configuracion/PapelGenerico.php
Normal file
22
ci4/app/Entities/Configuracion/PapelGenerico.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PapelGenerico 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",
|
||||
];
|
||||
}
|
||||
26
ci4/app/Entities/GoBaseEntity.php
Normal file
26
ci4/app/Entities/GoBaseEntity.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
/**
|
||||
* Base Entity Class for providing common methods to all child entities
|
||||
*
|
||||
* @author Gökhan Ozar
|
||||
*/
|
||||
abstract class GoBaseEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
/**
|
||||
* Merges the current object's property values with the passed in arguments in array format
|
||||
*
|
||||
* @param array $args - an associative array of properties to be set
|
||||
* @return $this - returns the current object instance
|
||||
*/
|
||||
public function mergeAttributes(array $args = []) {
|
||||
foreach ($args as $key => $value) {
|
||||
if (isset($this->attributes[$key])) {
|
||||
$this->attributes[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
115
ci4/app/Models/Configuracion/ImposicionModel.php
Normal file
115
ci4/app/Models/Configuracion/ImposicionModel.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class ImposicionModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_imposiciones";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.ancho",
|
||||
3 => "t1.alto",
|
||||
4 => "t1.unidades",
|
||||
5 => "t1.orientacion",
|
||||
6 => "t1.maquina",
|
||||
7 => "t1.etiqueta",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["ancho", "alto", "unidades", "orientacion", "maquina", "etiqueta"];
|
||||
protected $returnType = "App\Entities\Configuracion\Imposicion";
|
||||
|
||||
public static $labelField = "ancho";
|
||||
|
||||
protected $validationRules = [
|
||||
"alto" => [
|
||||
"label" => "Imposiciones.alto",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"ancho" => [
|
||||
"label" => "Imposiciones.ancho",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
"etiqueta" => [
|
||||
"label" => "Imposiciones.etiqueta",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"maquina" => [
|
||||
"label" => "Imposiciones.maquina",
|
||||
"rules" => "trim|max_length[100]",
|
||||
],
|
||||
"orientacion" => [
|
||||
"label" => "Imposiciones.orientacion",
|
||||
"rules" => "permit_empty|in_list[H,V]",
|
||||
],
|
||||
"unidades" => [
|
||||
"label" => "Imposiciones.unidades",
|
||||
"rules" => "integer|permit_empty",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto" => [
|
||||
"integer" => "Imposiciones.validation.alto.integer",
|
||||
"required" => "Imposiciones.validation.alto.required",
|
||||
],
|
||||
"ancho" => [
|
||||
"integer" => "Imposiciones.validation.ancho.integer",
|
||||
"required" => "Imposiciones.validation.ancho.required",
|
||||
],
|
||||
"etiqueta" => [
|
||||
"max_length" => "Imposiciones.validation.etiqueta.max_length",
|
||||
],
|
||||
"maquina" => [
|
||||
"max_length" => "Imposiciones.validation.maquina.max_length",
|
||||
],
|
||||
"orientacion" => [
|
||||
"in_list" => "Imposiciones.validation.orientacion.in_list",
|
||||
],
|
||||
"unidades" => [
|
||||
"integer" => "Imposiciones.validation.unidades.integer",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orlike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->orlike("t1.id", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="ancho" class="form-label">
|
||||
<?=lang('Imposiciones.ancho') ?>*
|
||||
</label>
|
||||
<input type="number" id="ancho" name="ancho" required maxLength="11" class="form-control" value="<?=old('ancho', $imposicion->ancho) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="alto" class="form-label">
|
||||
<?=lang('Imposiciones.alto') ?>*
|
||||
</label>
|
||||
<input type="number" id="alto" name="alto" required maxLength="11" class="form-control" value="<?=old('alto', $imposicion->alto) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="unidades" class="form-label">
|
||||
<?=lang('Imposiciones.unidades') ?>
|
||||
</label>
|
||||
<input type="number" id="unidades" name="unidades" maxLength="11" class="form-control" value="<?=old('unidades', $imposicion->unidades) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="orientacion" class="form-label">
|
||||
<?=lang('Imposiciones.orientacion') ?>
|
||||
</label>
|
||||
|
||||
<div class="form-check">
|
||||
<label for="h" class="form-check-label">
|
||||
<input type="radio" id="h" name="orientacion" value="H" class="form-check-input" <?= $imposicion->orientacion == 'H' ? 'checked' : '' ?>>
|
||||
<?= lang('Imposiciones.H') ?>
|
||||
</label>
|
||||
</div><!--//.form-check -->
|
||||
|
||||
|
||||
<div class="form-check">
|
||||
<label for="v" class="form-check-label">
|
||||
<input type="radio" id="v" name="orientacion" value="V" class="form-check-input" <?= $imposicion->orientacion == 'V' ? 'checked' : '' ?>>
|
||||
<?= lang('Imposiciones.V') ?>
|
||||
</label>
|
||||
</div><!--//.form-check -->
|
||||
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="maquina" class="form-label">
|
||||
<?=lang('Imposiciones.maquina') ?>
|
||||
</label>
|
||||
<input type="text" id="maquina" name="maquina" maxLength="100" class="form-control" value="<?=old('maquina', $imposicion->maquina) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
<div class="col-md-12 col-lg-6 px-4">
|
||||
<div class="mb-3">
|
||||
<label for="etiqueta" class="form-label">
|
||||
<?=lang('Imposiciones.etiqueta') ?>
|
||||
</label>
|
||||
<input type="text" id="etiqueta" name="etiqueta" maxLength="100" class="form-control" value="<?=old('etiqueta', $imposicion->etiqueta) ?>">
|
||||
</div><!--//.mb-3 -->
|
||||
|
||||
</div><!--//.col -->
|
||||
|
||||
</div><!-- //.row -->
|
||||
@ -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="imposicionForm" 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/imposiciones/_imposicionFormItems") ?>
|
||||
</div><!-- /.card-body -->
|
||||
<div class="card-footer">
|
||||
<?= anchor(route_to("imposicionList"), 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() ?>
|
||||
@ -0,0 +1,171 @@
|
||||
<?=$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('Imposiciones.imposicionList') ?></h3>
|
||||
<?=anchor(route_to('newImposicion'), lang('Basic.global.addNew').' '.lang('Imposiciones.imposicion'), ['class'=>'btn btn-primary float-end']); ?>
|
||||
</div><!--//.card-header -->
|
||||
<div class="card-body">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
|
||||
<table id="tableOfImposiciones" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php // <th class="text-nowrap"><?= lang('Basic.global.Action') ?></th> ?>
|
||||
<th><?=lang('Imposiciones.id')?></th>
|
||||
<th><?= lang('Imposiciones.ancho') ?></th>
|
||||
<th><?= lang('Imposiciones.alto') ?></th>
|
||||
<th><?= lang('Imposiciones.unidades') ?></th>
|
||||
<th><?= lang('Imposiciones.orientacion') ?></th>
|
||||
<th><?= lang('Imposiciones.maquina') ?></th>
|
||||
<th><?= lang('Imposiciones.etiqueta') ?></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 = $('#tableOfImposiciones').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 = $('#tableOfImposiciones').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('dataTableOfImposiciones') ?>',
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columnDefs: [
|
||||
{
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
targets: [lastColNr]
|
||||
}
|
||||
],
|
||||
columns : [
|
||||
//{ 'data': actionBtns },
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'ancho' },
|
||||
{ 'data': 'alto' },
|
||||
{ 'data': 'unidades' },
|
||||
{ 'data': 'orientacion' },
|
||||
{ 'data': 'maquina' },
|
||||
{ 'data': 'etiqueta' },
|
||||
{ 'data': actionBtns }
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.btn-edit', function(e) {
|
||||
window.location.href = `<?= route_to('imposicionList') ?>/${$(this).attr('data-id')}/edit`;
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Imposiciones.imposicion'))]) ?>',
|
||||
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('imposicionList') ?>/${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.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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.<?=config('Basics')->theme['name'] == 'Bootstrap5' ? 'bootstrap5' : 'bootstrap4' ?>.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() ?>
|
||||
|
||||
Reference in New Issue
Block a user