mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminando la consulta get resource del modelo maquinaspapelimpresion
This commit is contained in:
@ -5,9 +5,9 @@ use App\Controllers\GoBaseResourceController;
|
||||
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Configuracion\MaquinasTarifasImpresionEntity;
|
||||
use App\Entities\Configuracion\MaquinasPapelesImpresionEntity;
|
||||
|
||||
use App\Models\Configuracion\MaquinasTarifasImpresionModel;
|
||||
use App\Models\Configuracion\MaquinasPapelesImpresionModel;
|
||||
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
|
||||
@ -22,38 +22,74 @@ use
|
||||
DataTables\Editor\Validate,
|
||||
DataTables\Editor\ValidateOptions;
|
||||
|
||||
class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController {
|
||||
class Maquinaspapelesimpresion extends \App\Controllers\GoBaseResourceController {
|
||||
|
||||
|
||||
protected $modelName = MaquinasPapelesImpresionModel::class;
|
||||
protected $format = 'json';
|
||||
|
||||
protected static $singularObjectName = 'Maquinas Papel Impresion';
|
||||
protected static $singularObjectNameCc = 'maquinasPapelImpresion';
|
||||
protected static $pluralObjectName = 'Maquinas Papeles Impresion';
|
||||
protected static $pluralObjectNameCc = 'maquinasPapelesImpresion';
|
||||
|
||||
protected static $controllerSlug = 'maquinaspapelesimpresion';
|
||||
|
||||
protected static $viewPath = 'themes/backend/vuexy/form/configuracion/maquinas/';
|
||||
|
||||
protected $indexRoute = '';
|
||||
|
||||
public function datatable_maquinas() {
|
||||
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 = MaquinasTarifasImpresionModel::SORTABLE[$requestedOrder > 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
// el primer dato representa el uso y el segundo el tipo
|
||||
$tarifas = $reqData['tarifas'] ?? null;
|
||||
// Para saber si el papel que se tiene que mostrar es para rotativa
|
||||
$isRotativa= $reqData['isRotativa'] ?? false;
|
||||
|
||||
$resourceData = $this->model->getResource("", $tarifas, $isRotativa)->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 initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) {
|
||||
$this->viewData['pageTitle'] = '';
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
$viewData = [
|
||||
'currentModule' => static::$controllerSlug,
|
||||
'pageSubTitle' => '',
|
||||
'maquinasTarifasImpresion' => new Maquinaspapelesimpresion(),
|
||||
'usingServerSideDataTable' => true,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
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 = MaquinasPapelesImpresionModel::SORTABLE[$requestedOrder >= 0 ? $requestedOrder : 1];
|
||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||
|
||||
}
|
||||
// el primer dato representa el uso y el segundo el tipo
|
||||
//$tarifas = $reqData['tarifas'] ?? [];
|
||||
// Para saber si el papel que se tiene que mostrar es para rotativa
|
||||
$isRotativa= $reqData['isRotativa'] ?? 0;
|
||||
|
||||
$resourceData = $this->model->getResource("", $isRotativa)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
|
||||
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search, $isRotativa)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -235,10 +235,6 @@ if ($this->request->getPost('predeterminado') == null ) {
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') )
|
||||
),
|
||||
Field::inst( 'predeterminado' )
|
||||
->validator( 'Validate::notEmpty',array(
|
||||
'message' => lang('MaquinasTarifasImpresions.validation.tipo.required') )
|
||||
),
|
||||
Field::inst( 'maquina_id' ),
|
||||
Field::inst( 'user_created_id' ),
|
||||
Field::inst( 'created_at' ),
|
||||
@ -254,6 +250,10 @@ if ($this->request->getPost('predeterminado') == null ) {
|
||||
// Si no se quiere borrar...
|
||||
if($data['data'][$pkey]['is_deleted'] != 1)
|
||||
{
|
||||
// Cubierta y sobrecubierta sólo pueden ser en color
|
||||
if($values['uso'] != 'interior' && $values['tipo'] != 'color'){
|
||||
return lang('MaquinasTarifasImpresions.validation.cubierta_sobrecubierta_color');
|
||||
}
|
||||
|
||||
$builder = $this->model->select('*')
|
||||
->where(array(
|
||||
@ -338,7 +338,7 @@ if ($this->request->getPost('predeterminado') == null ) {
|
||||
return $this->respond(Collection::datatable(
|
||||
$resourceData,
|
||||
$this->model->getResource()->countAllResults(),
|
||||
$this->model->getResource($search)->countAllResults()
|
||||
$this->model->getResource($search, $id_M)->countAllResults()
|
||||
));
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
|
||||
Reference in New Issue
Block a user