mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
add calendar festivos
This commit is contained in:
@ -53,7 +53,6 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
|
||||
$routes->post('duplicate/(:num)', 'Papelesimpresion::duplicate/$1', ['as' => 'duplicatePapelImpresion']);
|
||||
$routes->get('select', 'Papelesimpresion::papel_impresion_select', ['as' => 'papelImpresionSelect']);
|
||||
$routes->get('show/(:num)', 'Papelesimpresion::papel_impresion_find/$1', ['as' => 'showPapelImpresion']);
|
||||
|
||||
});
|
||||
|
||||
/* Maquinas */
|
||||
@ -149,5 +148,15 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion']
|
||||
$routes->group("messages", ["namespace" => 'App\Controllers\Chat'], function ($routes) {
|
||||
$routes->get('', 'ChatController::config_view', ['as' => 'configMessagesIndex']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/* Festivos */
|
||||
$routes->group("festivos", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) {
|
||||
$routes->get('', 'FestivoController::index', ['as' => 'festivosList']);
|
||||
$routes->post('', 'FestivoController::store_festivo_date', ['as' => 'storeFestivoDate']);
|
||||
$routes->delete('(:num)', 'FestivoController::delete_festivo_date/$1', ['as' => 'deleteFestivoDate']);
|
||||
$routes->get('all', 'FestivoController::find_all', ['as' => 'getFindAllFestivos']);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
103
ci4/app/Controllers/Configuracion/FestivoController.php
Normal file
103
ci4/app/Controllers/Configuracion/FestivoController.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Configuracion;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\BaseResourceController;
|
||||
use App\Entities\Configuracion\FestivoEntity;
|
||||
use App\Models\Collection;
|
||||
|
||||
use App\Entities\Configuracion\Imposicion;
|
||||
use App\Models\Configuracion\FestivoModel;
|
||||
use App\Models\Configuracion\ImposicionEsquemaModel;
|
||||
use App\Models\Configuracion\ImposicionModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Validation;
|
||||
use Hermawan\DataTables\DataTable;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class FestivoController extends BaseController
|
||||
{
|
||||
|
||||
protected $modelName = FestivoModel::class;
|
||||
protected FestivoModel $model;
|
||||
protected static $controllerSlug = 'festivos';
|
||||
protected $format = 'json';
|
||||
|
||||
protected string $viewPath = 'themes/vuexy/form/configuracion/festivos/';
|
||||
|
||||
protected $indexRoute = 'festivoList';
|
||||
protected array $viewData = [];
|
||||
protected Validation $validation;
|
||||
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->viewData['pageTitle'] = lang('Festivos.moduleTitle');
|
||||
$this->viewData['usingSweetAlert'] = true;
|
||||
$this->model = model($this->modelName);
|
||||
$this->validation = service("validation");
|
||||
parent::initController($request, $response, $logger);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
return view($this->viewPath . $this->indexRoute);
|
||||
}
|
||||
|
||||
public function store_festivo_date()
|
||||
{
|
||||
$bodyData = $this->request->getPost();
|
||||
$date = $bodyData['date'];
|
||||
$count = $this->model->where('date',$date)->countAllResults();
|
||||
if ($count) {
|
||||
$status = $this->model->where('date', $date)->delete(purge: true);
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.user_alert_delete"),
|
||||
"status" => $status,
|
||||
]);
|
||||
} else {
|
||||
|
||||
$status = $this->model->insert($bodyData);
|
||||
if ($status) {
|
||||
$festivoEntity = $this->model->find($status);
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.global_alert_save_success"),
|
||||
"status" => $status,
|
||||
"data" => $festivoEntity
|
||||
]);
|
||||
} else {
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.global_alert_save_error"),
|
||||
"errors" => $this->model->errors(),
|
||||
"status" => true
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
}
|
||||
public function delete_festivo_date($id)
|
||||
{
|
||||
$status = $this->model->delete($id, true);
|
||||
if ($status) {
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.user_alert_delete"),
|
||||
"status" => $status,
|
||||
]);
|
||||
} else {
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.global_alert_save_error"),
|
||||
"errors" => $this->model->errors(),
|
||||
"status" => true
|
||||
])->setStatusCode(400);
|
||||
}
|
||||
}
|
||||
public function find_all()
|
||||
{
|
||||
$festivos = $this->model->findAll();
|
||||
return $this->response->setJSON([
|
||||
"message" => lang("App.global_alert_fetch_success"),
|
||||
"status" => true,
|
||||
"data" => $festivos
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateTableFestivos extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"auto_increment" => true
|
||||
],
|
||||
"date" => [
|
||||
"type" => "DATE",
|
||||
"unique" => true,
|
||||
],
|
||||
];
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->createTable("festivos", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropTable("festivos", true);
|
||||
}
|
||||
}
|
||||
@ -676,6 +676,7 @@ return [
|
||||
"menu_tarifacliente" => "Fees",
|
||||
|
||||
"menu_configuration" => "Settings",
|
||||
"menu_config_holidays" => "Holidays",
|
||||
"menu_calendario" => "Calendar",
|
||||
"menu_paises" => "Countries",
|
||||
"menu_correo" => "Mail",
|
||||
|
||||
7
ci4/app/Language/en/Festivos.php
Normal file
7
ci4/app/Language/en/Festivos.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'date' => 'Date',
|
||||
'moduleTitle' => 'Holidays'
|
||||
];
|
||||
@ -690,6 +690,7 @@ return [
|
||||
"menu_configuration" => "Configuración",
|
||||
"menu_variables" => "Variables sistema",
|
||||
"menu_config_messages" => "Mensajería",
|
||||
"menu_config_holidays" => "Festivos",
|
||||
"menu_error_presupuesto" => "Errores presupuesto",
|
||||
"menu_calendario" => "Calendario",
|
||||
"menu_paises" => "Paises",
|
||||
|
||||
7
ci4/app/Language/es/Festivos.php
Normal file
7
ci4/app/Language/es/Festivos.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
return [
|
||||
'date' => 'Fecha',
|
||||
'moduleTitle' => 'Festivos'
|
||||
];
|
||||
@ -3,130 +3,66 @@
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
use App\Entities\Configuracion\FestivoEntity;
|
||||
use App\Entities\Configuracion\Imposicion;
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class ImposicionModel extends BaseModel
|
||||
class FestivoModel extends BaseModel
|
||||
{
|
||||
protected $table = "festivos";
|
||||
|
||||
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
protected $allowedFields = ["date"];
|
||||
protected $returnType = FestivoEntity::class;
|
||||
protected $useAutoIncrement = true;
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
|
||||
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 static $labelField = "ancho";
|
||||
|
||||
protected $validationRules = [
|
||||
|
||||
"date" => [
|
||||
"label" => "Festivos.fecha",
|
||||
"rules" => "required|datetime",
|
||||
"label" => "Festivos.date",
|
||||
"rules" => "required|valid_date[Y-m-d]",
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto" => [
|
||||
"integer" => "Imposiciones.validation.alto.integer",
|
||||
"required" => "Imposiciones.validation.alto.required",
|
||||
],
|
||||
"ancho" => [
|
||||
"integer" => "Imposiciones.validation.ancho.integer",
|
||||
"required" => "Imposiciones.validation.ancho.required",
|
||||
],
|
||||
"etiqueta" => [
|
||||
"max_length" => "Imposiciones.validation.etiqueta.max_length",
|
||||
],
|
||||
"maquina" => [
|
||||
"max_length" => "Imposiciones.validation.maquina.max_length",
|
||||
],
|
||||
"orientacion" => [
|
||||
"in_list" => "Imposiciones.validation.orientacion.in_list",
|
||||
],
|
||||
"unidades" => [
|
||||
"integer" => "Imposiciones.validation.unidades.integer",
|
||||
],
|
||||
"imposicion_esquema_id" => [
|
||||
"integer" => "Imposiciones.validation.unidades.integer",
|
||||
"date" => [
|
||||
"valid_date" => "Validation.valid_date",
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Get resource data.
|
||||
*
|
||||
* @param string $search
|
||||
*
|
||||
* @return \CodeIgniter\Database\BaseBuilder
|
||||
*/
|
||||
public function getResource(string $search = "")
|
||||
{
|
||||
$builder = $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, t1.ancho AS ancho, t1.alto AS alto, t1.unidades AS unidades, t1.orientacion AS orientacion, t1.maquina AS maquina, t1.etiqueta AS etiqueta"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orlike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->orlike("t1.id", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.unidades", $search)
|
||||
->orLike("t1.orientacion", $search)
|
||||
->orLike("t1.maquina", $search)
|
||||
->orLike("t1.etiqueta", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function querySelect(?string $q)
|
||||
{
|
||||
$query = $this->builder()->select([
|
||||
"id",
|
||||
"CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto,'_',COALESCE(lg_imposiciones.unidades,'NULL'),'_',COALESCE(lg_imposiciones.orientacion,'NULL')) as name",
|
||||
"COALESCE(lg_imposiciones.etiqueta,'" . lang("Produccion.imposicion_no_label") . "') as description"
|
||||
]);
|
||||
if ($q) {
|
||||
$query->orLike("CONCAT(lg_imposiciones.ancho,'x',lg_imposiciones.alto)", $q);
|
||||
$query->orLike("lg_imposiciones.etiqueta", $q);
|
||||
}
|
||||
return $query
|
||||
->orderBy('id', 'ASC')
|
||||
->get()->getResultArray();
|
||||
}
|
||||
public function queryDatatable()
|
||||
{
|
||||
return $this->builder()
|
||||
->select([
|
||||
"lg_imposiciones.id",
|
||||
"lg_imposiciones.ancho",
|
||||
"lg_imposiciones.alto",
|
||||
"lg_imposiciones.unidades",
|
||||
"lg_imposiciones.maquina",
|
||||
"lg_imposiciones.orientacion",
|
||||
"lg_imposiciones.etiqueta",
|
||||
"imposicion_esquemas.id as esquemaId",
|
||||
"imposicion_esquemas.name as esquemaName"
|
||||
])
|
||||
->join("imposicion_esquemas","imposicion_esquemas.id = lg_imposiciones.imposicion_esquema_id","left")
|
||||
->where('lg_imposiciones.deleted_at', null);
|
||||
}
|
||||
public static function datatable_buttons(int $id)
|
||||
{
|
||||
$btn = "";
|
||||
if(auth()->user()->inGroup("admin")){
|
||||
$btn.="<a type='button' href='/imposiciones/edit/{$id}' data-id='{$id}'><i class='ti ti-eye ti-sm'></i></a>";
|
||||
$btn.="<a type='button'><i class='ti ti-trash ti-sm imposicion-delete' data-id='{$id}'></i></a>";
|
||||
}
|
||||
return $btn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1759,7 +1759,7 @@ class ProductionService extends BaseService
|
||||
->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left")
|
||||
->join("lg_papel_impresion", "lg_papel_impresion.id = presupuesto_linea.papel_impresion_id", "left")
|
||||
->groupStart()
|
||||
->orWhere('orden_trabajo_tareas.maquina_id', $maquina_id)
|
||||
->orWhere('orden_trabajo_tareas.maquina_id', $maquina_id) //!TODO
|
||||
->orWhere('presupuesto_linea.maquina_id', $maquina_id)
|
||||
->groupEnd()
|
||||
// ->where('pedidos.fecha_impresion IS NOT NULL', null, false)
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
<?= $this->include('themes/_commonPartialsBs/select2bs5') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/datatables') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/sweetalert') ?>
|
||||
<?= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
|
||||
<?= $this->extend('themes/vuexy/main/defaultlayout') ?>
|
||||
<?= $this->section('content'); ?>
|
||||
<div class="container-fluid h-100">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
<div class="card card-info">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title"><?= lang('Festivos.moduleTitle') ?></h3>
|
||||
</div>
|
||||
<!--//.card-header -->
|
||||
<div class="card-body m-10 section-block" id="festivoCard">
|
||||
<?= view('themes/_commonPartialsBs/_alertBoxes'); ?>
|
||||
<div id="calendar"></div>
|
||||
<!--//.card-footer -->
|
||||
</div>
|
||||
<!--//.card -->
|
||||
</div>
|
||||
<!--//.col -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!--//.row -->
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('css') ?>
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/formvalidation/dist/css/formValidation.min.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/notiflix/notiflix.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/spinkit/spinkit.css') ?>" />
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section("additionalExternalJs") ?>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/notiflix/notiflix.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/FormValidation.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js") ?>"></script>
|
||||
<script src="<?= site_url("themes/vuexy/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js") ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/fullcalendar/dist/index.global.min.js') ?>"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/fullcalendar/packages/core/locales-all.global.min.js') ?>"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="module" src="<?= site_url("/assets/js/safekat/pages/configuracion/festivo/index.js") ?>"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
@ -134,6 +134,13 @@ if (
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if (auth()->user()->inGroup('admin')) { ?>
|
||||
<li class="menu-item">
|
||||
<a href="<?= route_to('festivosList') ?>" class="menu-link">
|
||||
<div> <?= lang("App.menu_config_holidays") ?></div>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
@ -156,10 +156,10 @@ $settings = $session->get('settings');
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<table class="h-50">
|
||||
<tr>
|
||||
<tr>
|
||||
<th>IDSK</th>
|
||||
<td class="t-cell">
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -330,18 +330,20 @@ $settings = $session->get('settings');
|
||||
</table>
|
||||
|
||||
<?php
|
||||
$encuadernacion_code = isset($encuadernaciones[0]) ? $encuadernaciones[0]->tarifa()->code : null;
|
||||
try {
|
||||
if ($encuadernacion_code) {
|
||||
echo view("/themes/vuexy/pdfs/encuadernados/$encuadernacion_code.php");
|
||||
} else {
|
||||
foreach ($encuadernaciones as $key => $encuadernacion) {
|
||||
$encuadernacion_code = $encuadernacion->tarifa()->code;
|
||||
try {
|
||||
if ($encuadernacion_code) {
|
||||
echo view("/themes/vuexy/pdfs/encuadernados/$encuadernacion_code.php");
|
||||
} else {
|
||||
echo view("/themes/vuexy/pdfs/encuadernados/default.php");
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$error_message = $th->getMessage();
|
||||
echo view("/themes/vuexy/pdfs/encuadernados/default.php");
|
||||
echo "<span style='color:red'>No se ha podido renderizar la tabla de encuadernación</span>";
|
||||
// echo "<br><span style='color:red'>$error_message</span>";
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
$error_message = $th->getMessage();
|
||||
echo view("/themes/vuexy/pdfs/encuadernados/default.php");
|
||||
echo "<span style='color:red'>No se ha podido renderizar la tabla de encuadernación</span>";
|
||||
// echo "<br><span style='color:red'>$error_message</span>";
|
||||
}
|
||||
?>
|
||||
<?php if (count($encuadernaciones) > 0): ?>
|
||||
|
||||
Reference in New Issue
Block a user