mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
69 lines
2.3 KiB
PHP
69 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Configuracion;
|
|
|
|
use App\Controllers\BaseResourceController;
|
|
use App\Models\Collection;
|
|
use App\Models\Presupuestos\ErrorPresupuesto as ErrorPresupuestoModel;
|
|
use CodeIgniter\HTTP\Response;
|
|
use Hermawan\DataTables\DataTable;
|
|
|
|
class ConfigErrores extends BaseResourceController
|
|
{
|
|
|
|
protected ErrorPresupuestoModel $errorPresupuestoModel;
|
|
protected $format = 'json';
|
|
protected array $viewData = [];
|
|
|
|
|
|
protected static $viewPath = 'themes/vuexy/form/configuracion/error_presupuesto/';
|
|
protected static $controllerSlug = "errores-presupuesto";
|
|
protected $indexRoute = 'viewErrorPresupuestoList';
|
|
|
|
|
|
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
|
{
|
|
|
|
|
|
parent::initController($request, $response, $logger);
|
|
$this->errorPresupuestoModel = model(ErrorPresupuestoModel::class);
|
|
}
|
|
|
|
|
|
public function index()
|
|
{
|
|
|
|
return view(static::$viewPath . $this->indexRoute, $this->viewData);
|
|
}
|
|
public function viewForm(int $error_presupuesto_id)
|
|
{
|
|
return view(static::$viewPath . 'viewErrorPresupuestoForm', ["error_presupuesto_id" => $error_presupuesto_id]);
|
|
}
|
|
public function store()
|
|
{
|
|
$data = [];
|
|
$variableCreated = $this->errorPresupuestoModel->store($data);
|
|
return $this->response->setJSON($variableCreated);
|
|
}
|
|
public function get_error_presupuesto(int $error_presupuesto_id)
|
|
{
|
|
$data = $this->errorPresupuestoModel->getQueryDatatable()
|
|
->where("presupuesto_errores.id", $error_presupuesto_id)->get()->getResultObject()[0];
|
|
return $this->response->setJSON(["data" => $data]);
|
|
}
|
|
public function update_error_presupuesto(int $error_presupuesto_id)
|
|
{
|
|
$bodyData = $this->request->getPost();
|
|
$this->errorPresupuestoModel->updateComment($error_presupuesto_id, $bodyData["comments"]);
|
|
return $this->response->setJSON(["message" => "Comentario actualizado", "status" => true]);
|
|
}
|
|
|
|
public function datatable()
|
|
{
|
|
|
|
$query = $this->errorPresupuestoModel->getQueryDatatable();
|
|
return DataTable::of($query)
|
|
->add("action", fn($q) => $q->id)
|
|
->toJson(true);
|
|
}
|
|
} |