mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'dev/maquinas_calles' into 'main'
implementado calles en maquinas See merge request jjimenez/safekat!64
This commit is contained in:
@ -243,6 +243,7 @@ $routes->group('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Conf
|
||||
$routes->post('create', 'Maquinastarifasimpresion::create', ['as' => 'ajaxCreateMaquinasTarifaImpresion']);
|
||||
$routes->put('(:num)/update', 'Maquinastarifasimpresion::update/$1', ['as' => 'ajaxUpdateMaquinasTarifaImpresion']);
|
||||
$routes->post('(:num)/edit', 'Maquinastarifasimpresion::edit/$1', ['as' => 'updateMaquinasTarifaImpresion']);
|
||||
$routes->get('delete/(:num)', 'Maquinastarifasimpresion::delete/$1', ['as' => 'deleteMaquinastarifasimpresion']);
|
||||
$routes->post('datatable_editor', 'Maquinastarifasimpresion::datatable_editor', ['as' => 'editorOfMaquinasTarifaImpresion']);
|
||||
$routes->post('datatable', 'Maquinastarifasimpresion::datatable', ['as' => 'dataTableOfMaquinasTarifasImpresion']);
|
||||
$routes->post('allmenuitems', 'Maquinastarifasimpresion::allItemsSelect', ['as' => 'select2ItemsOfMaquinasTarifasImpresion']);
|
||||
@ -250,6 +251,14 @@ $routes->group('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Conf
|
||||
});
|
||||
$routes->resource('maquinastarifasimpresion', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinastarifasimpresion', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('maquinascalles', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'Maquinascalles::index', ['as' => 'maquinasCallesList']);
|
||||
$routes->get('delete/(:num)', 'Maquinascalles::delete/$1', ['as' => 'deleteMaquinascalles']);
|
||||
$routes->post('datatable_editor', 'Maquinascalles::datatable_editor', ['as' => 'editorOfMaquinascalles']);
|
||||
$routes->post('datatable', 'Maquinascalles::datatable', ['as' => 'dataTableOfMaquinascalles']);
|
||||
});
|
||||
$routes->resource('maquinascalles', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'maquinascalles', 'except' => 'show,new,create,update']);
|
||||
|
||||
$routes->group('maquinaspapelesimpresion', ['namespace' => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->post('datatable', 'Maquinaspapelesimpresion::datatable', ['as' => 'dataTableOfMaquinasPapelesImpresion']);
|
||||
$routes->post('datatable_2', 'Maquinaspapelesimpresion::datatable_2', ['as' => 'dataTableOfPapelesImpresionMaquinas']);
|
||||
|
||||
201
ci4/app/Controllers/Configuracion/Maquinascalles.php
Normal file
201
ci4/app/Controllers/Configuracion/Maquinascalles.php
Normal file
@ -0,0 +1,201 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Models\Configuracion\MaquinasCallesModel;
|
||||
use App\Entities\Configuracion\MaquinasCallesEntity;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Editor\Field;
|
||||
|
||||
|
||||
class Maquinascalles extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
protected static $controllerSlug = 'maquinascalles';
|
||||
|
||||
protected $modelName = MaquinasCallesModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Maquina calle';
|
||||
protected static $singularObjectNameCc = 'maquinaCalle';
|
||||
protected static $pluralObjectName = 'Maquinas calles';
|
||||
protected static $pluralObjectNameCc = 'maquinasCalles';
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('MaquinasCalles.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->viewData = ['usingServerSideDataTable' => true]; // JJO
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function datatable_editor()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
include(APPPATH . "ThirdParty/DatatablesEditor/DataTables.php");
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
$response = Editor::inst($db, 'maquinas_calles')
|
||||
->fields(
|
||||
Field::inst('formas_min')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('MaquinasCalles.validation.formas_min.integer'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasCalles.validation.formas_min.required'))
|
||||
),
|
||||
Field::inst('formas_max')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('MaquinasCalles.validation.formas_max.integer'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasCalles.validation.formas_max.required'))
|
||||
),
|
||||
Field::inst('internas')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('MaquinasCalles.validation.internas.decimal'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasCalles.validation.internas.required'))
|
||||
),
|
||||
Field::inst('externas')
|
||||
->validator('Validate::numeric', array(
|
||||
'message' => lang('MaquinasCalles.validation.externas.decimal'))
|
||||
)
|
||||
->validator('Validate::notEmpty', array(
|
||||
'message' => lang('MaquinasCalles.validation.externas.required'))
|
||||
),
|
||||
Field::inst('maquina_id'),
|
||||
Field::inst('user_created_id'),
|
||||
Field::inst('created_at'),
|
||||
Field::inst('user_updated_id'),
|
||||
Field::inst('updated_at'),
|
||||
Field::inst('is_deleted'),
|
||||
Field::inst('deleted_at'),
|
||||
|
||||
)
|
||||
->validator(function ($editor, $action, $data) {
|
||||
if ($action === Editor::ACTION_CREATE || $action === Editor::ACTION_EDIT) {
|
||||
foreach ($data['data'] as $pkey => $values) {
|
||||
// Si no se quiere borrar...
|
||||
if ($data['data'][$pkey]['is_deleted'] != 1) {
|
||||
$process_data['formas_min'] = $data['data'][$pkey]['formas_min'];
|
||||
$process_data['formas_max'] = $data['data'][$pkey]['formas_max'];
|
||||
$process_data['maquina_id'] = $data['data'][$pkey]['maquina_id'];
|
||||
$response = $this->model->checkIntervals($process_data, $pkey);
|
||||
// No se pueden duplicar valores al crear o al editar
|
||||
if (!empty($response)) {
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
->on('preCreate', function ($editor, &$values) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field('user_created_id')
|
||||
->setValue($session->id_user);
|
||||
$editor
|
||||
->field('created_at')
|
||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||
})
|
||||
->on('preEdit', function ($editor, &$values) {
|
||||
$session = session();
|
||||
$datetime = (new \CodeIgniter\I18n\Time("now"));
|
||||
$editor
|
||||
->field('user_updated_id')
|
||||
->setValue($session->id_user);
|
||||
$editor
|
||||
->field('updated_at')
|
||||
->setValue($datetime->format('Y-m-d H:i:s'));
|
||||
})
|
||||
->debug(true)
|
||||
->process($_POST)
|
||||
->data();
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$response[$csrfTokenName] = $newTokenHash;
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
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'] ?? 0;
|
||||
$order = MaquinasCallesModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$id_M = $reqData['maquina_id'] ?? -1;
|
||||
|
||||
$resourceData = $this->model->getResource("", $id_M)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search, $id_M)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function menuItems()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
|
||||
$provTipoModel = new ProveedorTipoModel();
|
||||
$provModel = new ProveedorModel();
|
||||
|
||||
$tipoId = $provTipoModel->getTipoId("Encuadernacion");
|
||||
$provList = $provModel->getProvList($tipoId);
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$data = [
|
||||
'data' => $provList,
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
return $this->respond($data);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -13,14 +13,7 @@ use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
use
|
||||
DataTables\Editor,
|
||||
DataTables\Database,
|
||||
DataTables\Editor\Field,
|
||||
DataTables\Editor\Format,
|
||||
DataTables\Editor\Mjoin,
|
||||
DataTables\Editor\Options,
|
||||
DataTables\Editor\Upload,
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
DataTables\Editor\Field;
|
||||
|
||||
class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
@ -44,6 +37,13 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('MaquinasTarifasImpresions.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
|
||||
// Se indica que este controlador trabaja con soft_delete
|
||||
$this->soft_delete = true;
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -129,6 +129,7 @@ class Maquinastarifasimpresion extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
return $this->displayForm(__METHOD__);
|
||||
} // end function add()
|
||||
|
||||
|
||||
public function edit($requestedId = null)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
use App\Models\Configuracion\MaquinasCallesModel;
|
||||
|
||||
class Test extends BaseController
|
||||
{
|
||||
@ -15,9 +15,10 @@ class Test extends BaseController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$model = new PapelGenericoModel();
|
||||
$model = new MaquinasCallesModel();
|
||||
echo '<pre>';
|
||||
var_dump($model->getGramajeComparador('CARTULINA GRÁFICA ESTUCADA 1/C'));
|
||||
$resourceData = $model->getResource("", 113)->get()->getResultObject();
|
||||
var_dump($resourceData);
|
||||
echo '</pre>';
|
||||
}
|
||||
}
|
||||
|
||||
31
ci4/app/Entities/Configuracion/MaquinasCallesEntity.php
Normal file
31
ci4/app/Entities/Configuracion/MaquinasCallesEntity.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace App\Entities\Configuracion;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class MaquinasCallesEntity extends \CodeIgniter\Entity\Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"maquina_id" => null,
|
||||
"formas_min" => null,
|
||||
"formas_max" => null,
|
||||
"internas" => 3.32,
|
||||
"externas" => 1.66,
|
||||
"user_created_id" => 0,
|
||||
"user_updated_id" => 0,
|
||||
"is_deleted" => 0,
|
||||
"created_at" => null,
|
||||
"updated_at" => null,
|
||||
];
|
||||
protected $casts = [
|
||||
"maquina_id" => "int",
|
||||
"formas_min" => "int",
|
||||
"formas_max" => "int",
|
||||
"internas" => "float",
|
||||
"externas" => "float",
|
||||
"user_created_id" => "int",
|
||||
"user_updated_id" => "int",
|
||||
"is_deleted" => "int",
|
||||
];
|
||||
}
|
||||
@ -145,6 +145,7 @@ class LoginAuthFilter implements FilterInterface
|
||||
'GoBaseResourceController',
|
||||
'Maquinaspapelesimpresion',
|
||||
'Maquinastarifasimpresion',
|
||||
'Maquinascalles',
|
||||
'My', 'Usuarios', 'Notification' // PARA LA DEMO
|
||||
|
||||
];
|
||||
|
||||
43
ci4/app/Language/en/MaquinasCalles.php
Normal file
43
ci4/app/Language/en/MaquinasCalles.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Streets config',
|
||||
'deleteLine' => 'the selected register',
|
||||
'formas_min' => 'Shapes mín.',
|
||||
'formas_max' => 'Shapes max.',
|
||||
'internas' => 'Internal streets',
|
||||
'externas' => 'External streets',
|
||||
'validation' => [
|
||||
'error_calle_overlap' => 'The range [Shapes mín, Shapes max] is overlapped with another one.',
|
||||
'error_calle_range' => 'The field Shapes min. must be lower than the field Shapes max.',
|
||||
'formas_min' => [
|
||||
'integer' => 'Must be a integer number.',
|
||||
'required' => 'Required.',
|
||||
|
||||
],
|
||||
|
||||
'formas_max' => [
|
||||
'integer' => 'Must be a integer number.',
|
||||
'required' => 'Required.',
|
||||
|
||||
],
|
||||
|
||||
'internas' => [
|
||||
'decimal' => 'Must be a decimal number.',
|
||||
'required' => 'Required.',
|
||||
|
||||
],
|
||||
|
||||
'externas' => [
|
||||
'decimal' => 'Must be a decimal number.',
|
||||
'required' => 'Required.',
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
43
ci4/app/Language/es/MaquinasCalles.php
Normal file
43
ci4/app/Language/es/MaquinasCalles.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'moduleTitle' => 'Configuración Calles',
|
||||
'deleteLine' => 'el registro seleccionado',
|
||||
'formas_min' => 'Formas mín.',
|
||||
'formas_max' => 'Formas max.',
|
||||
'internas' => 'Calles internas',
|
||||
'externas' => 'Calles externas',
|
||||
'validation' => [
|
||||
'error_calle_overlap' => 'El rango [Formas mín, Formas max] se solapa con otro existente para el tipo seleccionado.',
|
||||
'error_calle_range' => 'El campo Formas mín. debe ser menor que el campo Formas max.',
|
||||
'formas_min' => [
|
||||
'integer' => 'Debe contener un número entero.',
|
||||
'required' => 'Requerido.',
|
||||
|
||||
],
|
||||
|
||||
'formas_max' => [
|
||||
'integer' => 'Debe contener un número entero.',
|
||||
'required' => 'Requerido.',
|
||||
|
||||
],
|
||||
|
||||
'internas' => [
|
||||
'decimal' => 'Debe contener un número decimal.',
|
||||
'required' => 'Requerido.',
|
||||
|
||||
],
|
||||
|
||||
'externas' => [
|
||||
'decimal' => 'Debe contener un número decimal.',
|
||||
'required' => 'Requerido.',
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
125
ci4/app/Models/Configuracion/MaquinasCallesModel.php
Normal file
125
ci4/app/Models/Configuracion/MaquinasCallesModel.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class MaquinasCallesModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "maquinas_calles";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.formas_min",
|
||||
1 => "t1.formas_max",
|
||||
2 => "t1.internas",
|
||||
3 => "t1.externas",
|
||||
];
|
||||
|
||||
protected $allowedFields = [
|
||||
"maquina_id",
|
||||
"formas_min",
|
||||
"formas_max",
|
||||
"internas",
|
||||
"externas",
|
||||
"user_created_id",
|
||||
"user_updated_id",
|
||||
"is_deleted",
|
||||
"deleted_at",
|
||||
"created_at",
|
||||
"updated_at"];
|
||||
protected $returnType = "App\Entities\Configuracion\MaquinasCallesEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "maquina_id";
|
||||
|
||||
protected $validationRules = [
|
||||
"formas_min" => [
|
||||
"rules" => "required|int",
|
||||
],
|
||||
"formas_max" => [
|
||||
"rules" => "required|int",
|
||||
],
|
||||
"internas" => [
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"externas" => [
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "", $maquina_id=-1)
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.maquina_id as maquina, t1.formas_min AS formas_min,
|
||||
t1.formas_max AS formas_max, t1.internas AS internas, t1.externas AS externas,"
|
||||
);
|
||||
|
||||
//JJO
|
||||
$builder->where('maquina_id', $maquina_id);
|
||||
$builder->where("t1.is_deleted", 0);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.formas_min", $search)
|
||||
->orLike("t1.formas_max", $search)
|
||||
->orLike("t1.internas", $search)
|
||||
->orLike("t1.externas", $search)
|
||||
->orLike("t1.formas_min", $search)
|
||||
->orLike("t1.formas_max", $search)
|
||||
->orLike("t1.internas", $search)
|
||||
->orLike("t1.externas", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function checkIntervals($data = [], $id = null){
|
||||
|
||||
helper('general');
|
||||
|
||||
if(floatval($data["formas_min"])>= floatval($data["formas_max"])){
|
||||
return lang('MaquinasCalles.validation.error_calle_range');
|
||||
}
|
||||
|
||||
|
||||
$rows = $this->db
|
||||
->table($this->table)
|
||||
->select("id, formas_min, formas_max")
|
||||
->where("is_deleted", 0)
|
||||
->where("maquina_id", $data['maquina_id'])
|
||||
->get()->getResultObject();
|
||||
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (!is_null($id)){
|
||||
if($row->id == $id){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(check_overlap(floatval($data["formas_min"]), floatval($data["formas_max"]),
|
||||
$row->formas_min, $row->formas_max)){
|
||||
return lang('MaquinasCalles.validation.error_calle_overlap');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -63,6 +63,39 @@
|
||||
</div> <!-- //.accordion -->
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(str_contains($formAction,'edit')): ?>
|
||||
|
||||
<div class="accordion mt-3" id="accordianPapelesCalles">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingOne">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionTip3" aria-expanded="false" aria-controls="accordionTip3">
|
||||
<h3><?= lang("MaquinasCalles.moduleTitle") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
|
||||
<div id="accordionTip3" class="accordion-collapse collapse show" data-bs-parent="#accordianPapelesCalles">
|
||||
<div class="accordion-body">
|
||||
<table id="tableOfCalles" class="table table-striped table-hover" style="width: 100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= lang('MaquinasCalles.formas_min') ?></th>
|
||||
<th><?= lang('MaquinasCalles.formas_max') ?></th>
|
||||
<th><?= lang('MaquinasCalles.internas') ?></th>
|
||||
<th><?= lang('MaquinasCalles.externas') ?></th>
|
||||
<th class="text-nowrap"><?= lang('Basic.global.Action') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- //.accordion -->
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(str_contains($formAction,'edit')): ?>
|
||||
|
||||
<div class="accordion mt-3" id="accordianPapelesImpresion">
|
||||
@ -110,6 +143,9 @@
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
const lastColNr2 = $('#tableOfPapelesImpresion').find("tr:first th").length - 1;
|
||||
@ -223,9 +259,9 @@
|
||||
|
||||
const actionBtns = function(data) {
|
||||
return `
|
||||
<span class="edit"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></span>
|
||||
<span class="edit"><a href="javascript:void(0);"><i class="ti ti-pencil ti-sm btn-edit mx-2" data-id="${data.id}"></i></a></span>
|
||||
<a href="javascript:void(0);"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}" data-bs-toggle="modal" data-bs-target="#confirm2delete"></i></a>
|
||||
<span class="cancel"></span>
|
||||
<span class="remove"><i class="ti ti-trash ti-sm btn-delete mx-2" data-id="${data.id}"></i></span>
|
||||
`;
|
||||
};
|
||||
|
||||
@ -432,7 +468,7 @@
|
||||
editor: editor,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<i class="ti ti-device-floppy"/>'
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
}
|
||||
} ]
|
||||
} );
|
||||
@ -520,9 +556,9 @@
|
||||
editor.inline(
|
||||
theTable.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<i class="ti ti-x"></i>',
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<i class="ti ti-device-floppy"></i>',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
@ -539,37 +575,199 @@
|
||||
});
|
||||
|
||||
// Delete row
|
||||
$('#tableOfMaquinastarifasimpresion').on( 'click', 'tbody span.remove', function (e) {
|
||||
$(document).on('click', '.btn-delete', function(e) {
|
||||
$(".btn-remove").attr('data-id', $(this).attr('data-id'));
|
||||
const row = $(this).closest('tr')[0]._DT_RowIndex;
|
||||
|
||||
Swal.fire({
|
||||
title: '<?= lang('Basic.global.sweet.sureToDeleteTitle', [mb_strtolower(lang('Basic.global.sweet.line'))]) ?>',
|
||||
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) {
|
||||
editor
|
||||
.create( false )
|
||||
.edit( this.parentNode, false)
|
||||
.set( 'deleted_at', new Date().toISOString().slice(0, 19).replace('T', ' ') )
|
||||
.set( 'is_deleted', 1 )
|
||||
.submit();
|
||||
}
|
||||
});
|
||||
if($(this).closest('table').attr('id').includes('tarifas')){
|
||||
$(".btn-remove").attr('table', "tarifas");
|
||||
$(".btn-remove").attr('row_index', row);
|
||||
}
|
||||
else if($(this).closest('table').attr('id').includes('Calles')){
|
||||
$(".btn-remove").attr('table', "calles");
|
||||
$(".btn-remove").attr('row_index', row);
|
||||
}
|
||||
else{
|
||||
$(".btn-remove").attr('table', );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-remove', function(e) {
|
||||
const dataId = $(this).attr('data-id');
|
||||
const row = $(this).attr('row_index');
|
||||
|
||||
if ($.isNumeric(dataId)) {
|
||||
|
||||
if($(this).attr('table').includes('tarifas')){
|
||||
remove_tarifas(dataId, row);
|
||||
}
|
||||
else if ($(this).attr('table').includes('calles')){
|
||||
remove_calles(dataId, row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function remove_calles(dataId, row){
|
||||
$.ajax({
|
||||
url: `/maquinascalles/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)
|
||||
});
|
||||
};
|
||||
|
||||
function remove_tarifas(dataId, row){
|
||||
|
||||
$.ajax({
|
||||
url: `/maquinastarifasimpresion/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() ?>
|
||||
|
||||
|
||||
<!------------------------------------------->
|
||||
<!-- Código JS para tabla calles -->
|
||||
<!------------------------------------------->
|
||||
<?= $this->section("additionalInlineJs") ?>
|
||||
|
||||
var editor3 = new $.fn.dataTable.Editor( {
|
||||
ajax: {
|
||||
url: "<?= route_to('editorOfMaquinascalles') ?>",
|
||||
headers: {
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v,
|
||||
},
|
||||
},
|
||||
table : "#tableOfCalles",
|
||||
idSrc: 'id',
|
||||
fields: [ {
|
||||
name: "formas_min"
|
||||
}, {
|
||||
name: "formas_max"
|
||||
}, {
|
||||
name: "internas"
|
||||
}, {
|
||||
name: "externas"
|
||||
}, {
|
||||
"name": "maquina_id",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "deleted_at",
|
||||
"type": "hidden"
|
||||
},{
|
||||
"name": "is_deleted",
|
||||
"type": "hidden"
|
||||
},
|
||||
]
|
||||
} );
|
||||
|
||||
|
||||
editor3.on( 'preSubmit', function ( e, d, type ) {
|
||||
if ( type === 'create'){
|
||||
d.data[0]['maquina_id'] = id;
|
||||
}
|
||||
else if(type === 'edit' ) {
|
||||
for (v in d.data){
|
||||
d.data[v]['maquina_id'] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
editor3.on( 'postSubmit', function ( e, json, data, action ) {
|
||||
|
||||
yeniden(json.<?= csrf_token() ?>);
|
||||
});
|
||||
|
||||
|
||||
editor3.on( 'submitSuccess', function ( e, json, data, action ) {
|
||||
|
||||
theTable3.clearPipeline();
|
||||
theTable3.draw();
|
||||
});
|
||||
|
||||
theTable3 = $('#tableOfCalles').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
autoWidth: true,
|
||||
responsive: true,
|
||||
scrollX: true,
|
||||
lengthMenu: [ 5],
|
||||
pageLength: 10,
|
||||
lengthChange: false,
|
||||
searching: false,
|
||||
info: false,
|
||||
"dom": '<"mt-4"><"float-end"B><"float-start"l><t><"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('dataTableOfMaquinascalles') ?>',
|
||||
data: {
|
||||
maquina_id: id,
|
||||
},
|
||||
method: 'POST',
|
||||
headers: {'X-Requested-With': 'XMLHttpRequest'},
|
||||
async: true,
|
||||
}),
|
||||
columns : [
|
||||
{ 'data': 'formas_min' },
|
||||
{ 'data': 'formas_max' },
|
||||
{ 'data': 'internas' },
|
||||
{ 'data': 'externas' },
|
||||
{ data: actionBtns,
|
||||
className: 'row-edit dt-center'}
|
||||
],
|
||||
buttons: [ {
|
||||
className: 'btn btn-primary float-end me-sm-3 me-1',
|
||||
extend: "createInline",
|
||||
editor: editor3,
|
||||
formOptions: {
|
||||
submitTrigger: -1,
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>'
|
||||
}
|
||||
} ]
|
||||
});
|
||||
|
||||
// Activate an inline edit on click of a table cell
|
||||
$('#tableOfCalles').on( 'click', 'tbody span.edit', function (e) {
|
||||
editor3.inline(
|
||||
theTable3.cells(this.parentNode.parentNode, '*').nodes(),
|
||||
{
|
||||
cancelHtml: '<a href="javascript:void(0);"><i class="ti ti-x"></i></a>',
|
||||
cancelTrigger: 'span.cancel',
|
||||
submitHtml: '<a href="javascript:void(0);"><i class="ti ti-device-floppy"></i></a>',
|
||||
submitTrigger: 'span.edit',
|
||||
submit: 'allIfChanged'
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
<?=$this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.bootstrap5.min.css">
|
||||
|
||||
Reference in New Issue
Block a user