mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
papel impresion terminado a falta de añadir maquinas y revisar UI
This commit is contained in:
@ -5,14 +5,35 @@ namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
// DataTables PHP library
|
||||
|
||||
|
||||
// Alias Editor classes so they are easy to use
|
||||
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;
|
||||
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
|
||||
|
||||
use App\Entities\Configuracion\PapelImpresion;
|
||||
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
|
||||
use App\Models\Configuracion\PapelGenericoModel;
|
||||
|
||||
use App\Models\Configuracion\PapelImpresionTipologiaModel;
|
||||
|
||||
|
||||
class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
{
|
||||
|
||||
@ -30,8 +51,6 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
protected $indexRoute = 'papelImpresionList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('PapelImpresion.moduleTitle');
|
||||
@ -42,6 +61,8 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
// Se indica el flag para los ficheros borrados
|
||||
$this->delete_flag = 1;
|
||||
|
||||
$this->tpModel = new PapelImpresionTipologiaModel();
|
||||
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
@ -230,6 +251,7 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('PapelImpresion.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||
|
||||
$this->viewData['usingServerSideDataTable'] = true; //JJO
|
||||
|
||||
return $this->displayForm(__METHOD__, $id);
|
||||
} // end function edit(...)
|
||||
@ -239,72 +261,118 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
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;
|
||||
}
|
||||
$id_PG = $reqData['id_PG'] ?? -1;
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
if($id_PG<0){
|
||||
if(isset($reqData['id_PI'])){
|
||||
|
||||
$resourceData = $this->model->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$id_PI = $reqData['id_PI'] ?? -1;
|
||||
|
||||
if($id_PI>=0){
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
));
|
||||
}else{
|
||||
$resourceData = $this->model->getResource($search, $id_PG)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$data = $this->tpModel->findTipologiasForPapelImpresion($id_PI);
|
||||
$resourceData = $data->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("", $id_PG)->countAllResults(),
|
||||
$this->model->getResource($search, $id_PG)->countAllResults()
|
||||
));
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->tpModel->findTipologiasForPapelImpresion($id_PI)->countAllResults(),
|
||||
$this->tpModel->findTipologiasForPapelImpresion($id_PI)->countAllResults()
|
||||
));
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
$id_PG = $reqData['id_PG'] ?? -1;
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = PapelImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
if($id_PG<0){
|
||||
|
||||
$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{
|
||||
$resourceData = $this->model->getResource($search, $id_PG)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("", $id_PG)->countAllResults(),
|
||||
$this->model->getResource($search, $id_PG)->countAllResults()
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
public function datatablePG()
|
||||
{
|
||||
|
||||
public function datatable_editor(){
|
||||
/*if ($this->request->isAJAX()) {
|
||||
|
||||
$reqData = $this->request->getPost();
|
||||
$rows_id = array_keys($reqData['data']);
|
||||
echo '<pre>' ;
|
||||
var_dump($reqData['data'][$keys[0]]) ;
|
||||
echo '</pre>';
|
||||
}*/
|
||||
|
||||
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;
|
||||
}
|
||||
$generico_id = $reqData['id'] ?? null;
|
||||
$start = $reqData['start'] ?? 0;
|
||||
$length = $reqData['length'] ?? 5;
|
||||
$search = $reqData['search']['value'];
|
||||
$requestedOrder = $reqData['order']['0']['column'] ?? 1;
|
||||
$order = PapelImpresionModel::SORTABLE2[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
$resourceData = $this->model->getResource($search, $generico_id)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
$sql_details = array(
|
||||
"type" => "Mysql", // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite" or "Oracle"
|
||||
"user" => "sk_jjo", // Database user name
|
||||
"pass" => "61tv&G1Zf^XY", // Database password
|
||||
"host" => "localhost", // Database host
|
||||
"port" => "", // Database connection port (can be left empty for default)
|
||||
"db" => "sk_jjo", // Database name
|
||||
"dsn" => "", // PHP DSN extra information. Set as `charset=utf8mb4` if you are using MySQL
|
||||
"pdoAttr" => array() // PHP PDO attributes array. See the PHP documentation for all options
|
||||
);
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource("", $generico_id)->countAllResults(),
|
||||
$this->model->getResource($search, $generico_id)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
$db = new Database( array(
|
||||
"type" => "Mysql",
|
||||
"pdo" => $sql_details
|
||||
) );
|
||||
|
||||
|
||||
// Build our Editor instance and process the data coming from _POST
|
||||
Editor::inst( $db, 'lg_papel_impresion_tipologias' )
|
||||
->fields(
|
||||
Field::inst( 'tipo' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),//->validator( Validate::values( array('negro', 'color', 'bicolor') ) ),
|
||||
Field::inst( 'negro' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
Field::inst( 'cyan' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
Field::inst( 'magenta' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
Field::inst( 'amarillo' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
Field::inst( 'gota_negro' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
Field::inst( 'got_color' ),
|
||||
//->validator( Validate::notEmpty( ValidateOptions::inst()) ),
|
||||
)
|
||||
->process( $_POST )
|
||||
->json();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function allItemsSelect()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
@ -355,6 +423,24 @@ class Papelesimpresion extends \App\Controllers\GoBaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
function fetch_single_data()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$reqData = $this->request->getPost();
|
||||
if(isset($reqData['id']))
|
||||
{
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
|
||||
$data = [
|
||||
'data' => $this->tpModel->getResource($reqData['id'])->get()->getResultObject()[0],
|
||||
$csrfTokenName => $newTokenHash
|
||||
];
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPapelGenericoListItems($selId = null)
|
||||
{
|
||||
|
||||
326
ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php
Normal file
326
ci4/app/Controllers/Configuracion/Papelimpresiontipologias.php
Normal file
@ -0,0 +1,326 @@
|
||||
<?php namespace App\Controllers\Configuracion;
|
||||
|
||||
|
||||
use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Configuracion\PapelImpresionTipologia;
|
||||
|
||||
use App\Models\Configuracion\PapelImpresionTipologiaModel;
|
||||
|
||||
use App\Models\Configuracion\PapelImpresionModel;
|
||||
|
||||
class Papelimpresiontipologias extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
protected $modelName = PapelImpresionTipologiaModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Papel Impresion Tipologia';
|
||||
protected static $singularObjectNameCc = 'papelImpresionTipologia';
|
||||
protected static $pluralObjectName = 'Papel Impresion Tipologias';
|
||||
protected static $pluralObjectNameCc = 'papelImpresionTipologias';
|
||||
|
||||
protected static $controllerSlug = 'papelimpresiontipologias';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/papel/';
|
||||
|
||||
protected $indexRoute = 'papelImpresionTipologiaList';
|
||||
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = lang('ImpresionTipologias.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('ImpresionTipologias.papelImpresionTipologia')]),
|
||||
'papelImpresionTipologia' => new PapelImpresionTipologia(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
|
||||
|
||||
//return view(static::$viewPath.'viewPapelImpresionTipologiaList', $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;
|
||||
$successfulResult = false; // for now
|
||||
|
||||
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('ImpresionTipologias.papelImpresionTipologia'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
endif;
|
||||
|
||||
$thenRedirect = false; // Change this to false if you want your user to stay on the form after submission
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
|
||||
$id = $this->model->db->insertID();
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
|
||||
$message .= anchor( "papelimpresiontipologias/{$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);
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$output = array(
|
||||
'success' => 'yes',
|
||||
$csrfTokenName => $newTokenHash
|
||||
);
|
||||
return json_encode($output);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['papelImpresionTipologia'] = isset($sanitizedData) ? new PapelImpresionTipologia($sanitizedData) : new PapelImpresionTipologia();
|
||||
$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($papelImpresionTipologia->papel_impresion_id ?? null);
|
||||
$this->viewData['tipoList'] = $this->getTipoOptions();
|
||||
|
||||
$this->viewData['formAction'] = route_to('createPapelImpresionTipologia');
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.addNew').' '.lang('ImpresionTipologias.moduleTitle').' '.lang('Basic.global.addNewSuffix');
|
||||
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$output = array(
|
||||
'success' => 'no',
|
||||
$csrfTokenName => $newTokenHash
|
||||
);
|
||||
return json_encode($output);
|
||||
//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);
|
||||
$papelImpresionTipologia = $this->model->find($id);
|
||||
|
||||
if ($papelImpresionTipologia == false) :
|
||||
$message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia')), $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);
|
||||
|
||||
$noException = true;
|
||||
$successfulResult = false; // for now
|
||||
|
||||
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('ImpresionTipologias.papelImpresionTipologia'))]);
|
||||
$this->session->setFlashdata('formErrors', $this->model->errors());
|
||||
|
||||
endif;
|
||||
|
||||
$papelImpresionTipologia->fill($sanitizedData);
|
||||
|
||||
$thenRedirect = false;
|
||||
|
||||
if ($noException && $successfulResult) :
|
||||
$id = $papelImpresionTipologia->id ?? $id;
|
||||
$message = lang('Basic.global.updateSuccess', [mb_strtolower(lang('ImpresionTipologias.papelImpresionTipologia'))]).'.';
|
||||
$message .= anchor( "papelimpresiontipologias/{$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:
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$output = array(
|
||||
'success' => 'yes',
|
||||
$csrfTokenName => $newTokenHash
|
||||
);
|
||||
|
||||
return json_encode($output);
|
||||
//$this->session->setFlashData('sweet-success', $message);
|
||||
endif;
|
||||
|
||||
endif; // $noException && $successfulResult
|
||||
endif; // ($requestMethod === 'post')
|
||||
|
||||
$this->viewData['papelImpresionTipologia'] = $papelImpresionTipologia;
|
||||
$this->viewData['papelImpresionList'] = $this->getPapelImpresionListItems($papelImpresionTipologia->papel_impresion_id ?? null);
|
||||
$this->viewData['tipoList'] = $this->getTipoOptions();
|
||||
|
||||
$this->viewData['formAction'] = route_to('updatePapelImpresionTipologia', $id);
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2').' '.lang('ImpresionTipologias.moduleTitle').' '.lang('Basic.global.edit3');
|
||||
|
||||
//return $this->displayForm(__METHOD__, $id);
|
||||
$newTokenHash = csrf_hash();
|
||||
$csrfTokenName = csrf_token();
|
||||
$output = array(
|
||||
'success' => 'no',
|
||||
$csrfTokenName => $newTokenHash
|
||||
);
|
||||
return json_encode($output);
|
||||
} // 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 = PapelImpresionTipologiaModel::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.', papel_impresion_id', 'papel_impresion_id', $onlyActiveOnes, false);
|
||||
$nonItem = new \stdClass;
|
||||
$nonItem->id = '';
|
||||
$nonItem->papel_impresion_id = '- '.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 ?? 'papel_impresion_id'];
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function getPapelImpresionListItems($selId = null) {
|
||||
$data = [''=>lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('PapelImpresions.papelImpresion'))])];
|
||||
if (!empty($selId)) :
|
||||
$papelImpresionModel = model('App\Models\Configuracion\PapelImpresionModel');
|
||||
|
||||
$selOption = $papelImpresionModel->where('id', $selId)->findColumn('id');
|
||||
if (!empty($selOption)) :
|
||||
$data[$selId] = $selOption[0];
|
||||
endif;
|
||||
endif;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
protected function getTipoOptions() {
|
||||
$tipoOptions = [
|
||||
'' => lang('Basic.global.pleaseSelect'),
|
||||
'negro' => 'negro',
|
||||
'color' => 'color',
|
||||
'bicolor' => 'bicolor',
|
||||
];
|
||||
return $tipoOptions;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user