add errores presupuesto

This commit is contained in:
amazuecos
2024-10-17 23:48:16 +00:00
parent 7c9b8a0b6d
commit 23491b2e1a
13 changed files with 414 additions and 0 deletions

View File

@ -93,6 +93,12 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
$routes->delete('delete/(:num)', 'ConfigVariables::delete/$1', ['as' => 'deleteVariable']);
$routes->get('datatable', 'ConfigVariables::datatable', ['as' => 'datatableVariables']);
});
$routes->group("errores-presupuesto",["namespace" => 'App\Controllers\Configuracion'],function($routes){
$routes->get('', 'ErrorPresupuestoController::index', ['as' => 'errorPresupuestoIndex']);
$routes->get('edit', 'ErrorPresupuestoController::viewForm/$1', ['as' => 'errorPresupuestoFormIndex']);
$routes->get('datatable', 'ErrorPresupuestoController::datatable', ['as' => 'errorPresupuestoDatatable']);
$routes->post('edit/(:num)', 'ErrorPresupuestoController::update_error_presupuesto/$1', ['as' => 'updateErrorPresupuesto']);
});
});

View File

@ -0,0 +1,80 @@
<?php
namespace App\Controllers\Configuracion;
use App\Controllers\BaseResourceController;
use App\Models\Collection;
use App\Models\Presupuestos\ErrorPresupuesto;
use CodeIgniter\HTTP\Response;
use Hermawan\DataTables\DataTable;
class ErrorPresupuestoController extends BaseResourceController
{
protected ErrorPresupuesto $errorPresupuestoModel;
protected $format = 'json';
protected array $viewData = [];
protected static $controllerSlug = 'error-presupuesto';
protected static $viewPath = 'themes/vuexy/form/configuracion/error_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(ErrorPresupuesto::class);
}
public function index()
{
$viewData = [
'currentModule' => static::$controllerSlug,
];
$viewData = array_merge($this->viewData, $viewData); // merge any possible values from the parent controller class
return view(static::$viewPath . $this->indexRoute, $viewData);
}
public function viewForm(int $error_presupuesto_id)
{
$viewData = [
'currentModule' => static::$controllerSlug,
'errorPresupuesto' => $this->errorPresupuestoModel->find($error_presupuesto_id),
];
return view(static::$viewPath . $this->indexRoute, $viewData);
}
public function store(){
$data = [];
$variableCreated = $this->errorPresupuestoModel->store($data);
return $this->response->setJSON($variableCreated);
}
public function get(int $error_presupuesto_id){
$data = $this->errorPresupuestoModel->find($error_presupuesto_id);
return $this->response->setJSON($data);
}
public function updateErrorPresupuesto(int $error_presupuesto_id){
}
public function datatable(){
$query = $this->errorPresupuestoModel->getQueryDatatable();
return DataTable::of($query)
->add("action",fn($q) => $q->id)
->toJson(true);
}
}

View File

@ -684,6 +684,7 @@ return [
"menu_configuration" => "Configuración",
"menu_variables" => "Variables sistema",
"menu_error_presupuesto" => "Errores presupuesto",
"menu_calendario" => "Calendario",
"menu_paises" => "Paises",
"menu_correo" => "Correo",

View File

@ -0,0 +1,21 @@
<?php
return [
"cardTitle" => "Errores presupuesto",
"datatable" =>
[
"columns" => [
"presupuesto_user "=> "Usuario presupuesto",
"last_user_id" => "Último usuario",
"visto" => "Visto",
"created_at" => "Creado"
]
],
"form" =>
[
"name" => "Nombre",
"value" => "Valor",
"description" => "Descripción",
]
];

View File

@ -0,0 +1,86 @@
<?php
namespace App\Models\Presupuestos;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Model;
class ErrorPresupuesto extends Model
{
protected $table = 'presupuesto_errores';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
"presupuesto_id",
"presupuesto_user_id",
"error",
"datos_presupuesto",
"visto",
"last_user_id",
"created_at",
"updated_at",
"deleted_at",
];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function insertError(int $presupuesto_id,int $presupuesto_user_id,string $error,mixed $datos)
{
$this->insert([
"presupuesto_id" => $presupuesto_id,
"presupuesto_user_id" => $presupuesto_user_id,
"error" => $error,
"datos" => json_encode($datos)
]);
}
public function getQueryDatatable() : BaseBuilder
{
$query = $this->builder()
->select([
"presupuesto_errores.id",
"CONCAT(t1.first_name,' ',t1.last_name) as presupuestoUser",
"CONCAT(t2.first_name,' ',t2.last_name) as lastUser",
"presupuestos.titulo as presupuestoTitulo",
"presupuesto_errores.created_at",
"presupuesto_errores.datos",
"presupuesto_errores.visto",
])
->join("users t1","t1.id = presupuesto_errores.presupuesto_user_id","left")
->join("users t2","t2.id = presupuesto_errores.last_user_id","left")
->join("presupuestos","presupuestos.id = presupuesto_errores.presupuesto_id","left")
->where("presupuesto_errores.deleted_at",null);
return $query;
}
}

View File

@ -0,0 +1,52 @@
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/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">[<?= $errorPresupuesto->id ?>]Error presupuesto</h3>
</div><!--//.card-header -->
<div class="card-body">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<div class="mb-3">
<form action="POST" class="form-control">
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4"></div>
<div class="col-md-4"></div>
</div>
<div class="row">
<div class="col-md-12">
<label for="error-presupuesto-form-datos" class="form-label">Datos</label>
<input
type="text"
name="datos"
id="error-presupuesto-form-datos"
class="form-control"
placeholder="Datos presupuesto" />
</div>
</div>
</form>
</div>
</div>
</div><!--//.card-body -->
<div class="card-footer">
</div><!--//.card-footer -->
</div><!--//.card -->
</div><!--//.col -->
</div><!--//.row -->
<?= $this->endSection() ?>
<?= $this->section("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/errorPresupuestoForm.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -0,0 +1,44 @@
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
<?= $this->extend('themes/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('ErrorPresupuesto.cardTitle') ?></h3>
</div><!--//.card-header -->
<div class="card-body" id="errorPresupuestoCard">
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
<table id="tableErrorPresupuesto" class="table table-striped table-hover" style="width: 100%;">
<thead>
<tr>
<th>#</th>
<th>Presupuesto</th>
<th>Usuario</th>
<th><?= lang('ErrorPresupuesto.datatable.columns.last_user_id') ?></th>
<th><?= lang('ErrorPresupuesto.datatable.columns.visto') ?></th>
<th><?= lang('ErrorPresupuesto.datatable.columns.created_at') ?></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("additionalExternalJs") ?>
<script type="module" src="<?= site_url('assets/js/safekat/pages/configuracion/error_presupuesto/indexView.js') ?>"></script>
<?= $this->endSection() ?>

View File

@ -105,6 +105,13 @@ if (
</a>
</li>
<?php } ?>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<li class="menu-item">
<a href="<?= route_to('errorPresupuestoIndex') ?>" class="menu-link">
<?= lang("App.menu_error_presupuesto") ?>
</a>
</li>
<?php } ?>
</ul>
</li>
<?php } ?>

View File

@ -0,0 +1,47 @@
class ErrorPresupuestoView {
constructor(domItem) {
this.item = domItem
this.datatableItem = this.item.find("#tableErrorPresupuesto")
this.datatableColumns = [
{ data: 'id', name: "id", searchable: true, sortable: false },
{ data: 'presupuestoTitulo',searchable: true, sortable: false },
{ data: 'presupuestoUser',searchable: true, sortable: false },
{ data: 'lastUser', searchable: true, sortable: false },
{ data: 'visto', searchable: false, sortable: false ,
render : (d,t) => {
const iconClass = d ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
return `<span class="${iconClass}"</span>`
}
},
{ data: 'created_at', searchable: false, sortable: true },
{
data: 'action', sortable: false, searchable: false,
render: (d, t) => {
return `
<div class="btn-group btn-group-sm">
<a href="/configuracion/errores-presupuesto/edit/${d}" data-id="${d}" class="edit-error-presupuesto"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>
`
}
},
]
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
dom: 'Brtip',
serverSide: true,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/errores-presupuesto/datatable'
});
}
}
export default ErrorPresupuestoView;

View File

@ -0,0 +1,44 @@
import Ajax from "../../../components/ajax.js"
class ErrorPresupuestoView {
constructor(domItem) {
this.item = domItem
this.datatableItem = this.item.find("#tableErrorPresupuesto")
this.datatableColumns = [
{ data: 'id', searchable: true, sortable: false },
{ data: 'presupuestoTitulo', searchable: true, sortable: false },
{ data: 'presupuestoUser', searchable: true, sortable: false },
{ data: 'visto', searchable: false, sortable: false },
{ data: 'lastUser', searchable: true, sortable: false },
{
data: 'action', sortable: false, searchable: false,
render: (d, t) => {
return `
<div class="btn-group btn-group-sm">
<a href="javascript:void(0)" data-id="${d}" class="edit-error-presupuesto"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>
`
}
},
]
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
dom: 'Brtip',
serverSide: true,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/errores-presupuesto/datatable'
});
}
}
export default ErrorPresupuestoView;

View File

@ -0,0 +1,6 @@
import ErrorPresupuestoView from "./errorPresupuesto.js";
$(document).ready(()=>{
const errorPresupuesto = new ErrorPresupuestoView($("#errorPresupuestoCard"))
errorPresupuesto.init()
})

View File

@ -25519,3 +25519,23 @@
[348] Log closed at 2024-10-17 17:34:23.659733
[7640] Log opened at 2024-10-17 21:51:03.869662
[7640] [Config] INFO: Control socket set up succesfully: '@xdebug-ctrl.7640'
[7640] [Step Debug] INFO: Connecting to configured address/port: 172.28.188.187:9003.
[7640] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 172.28.188.187:9003 (through xdebug.client_host/xdebug.client_port).
[7640] [Step Debug] INFO: Connecting to configured address/port: 172.28.188.187:9003.
[7640] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 172.28.188.187:9003 (through xdebug.client_host/xdebug.client_port).
[7640] Log closed at 2024-10-17 21:51:04.556593
[9851] Log opened at 2024-10-17 21:54:30.472221
[9851] [Config] INFO: Control socket set up succesfully: '@xdebug-ctrl.9851'
[9851] [Step Debug] INFO: Connecting to configured address/port: 172.28.188.187:9003.
[9851] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 172.28.188.187:9003 (through xdebug.client_host/xdebug.client_port).
[10190] Log opened at 2024-10-17 21:54:55.986235
[10190] [Config] INFO: Control socket set up succesfully: '@xdebug-ctrl.10190'
[10190] [Step Debug] INFO: Connecting to configured address/port: 172.28.188.187:9003.
[10190] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 172.28.188.187:9003 (through xdebug.client_host/xdebug.client_port).
[10190] [Step Debug] INFO: Connecting to configured address/port: 172.28.188.187:9003.
[10190] [Step Debug] ERR: Time-out connecting to debugging client, waited: 200 ms. Tried: 172.28.188.187:9003 (through xdebug.client_host/xdebug.client_port).
[10190] Log closed at 2024-10-17 21:55:14.675874