Skip to content

Commit

Permalink
Merge branch 'main' into feat/cookies-notice
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierChao committed Dec 12, 2024
2 parents e8d771f + ed89ae0 commit 2f8bb9d
Show file tree
Hide file tree
Showing 33 changed files with 279 additions and 312 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"editor.formatOnSave": true
},
"isort.args": ["--profile", "black"],
"php.version": "8.4",
"yaml.schemas": {
"https://json.schemastore.org/pull-request-labeler-5.json": ".github/labeler.yml",
"https://raw.githubusercontent.com/compose-spec/compose-spec/refs/heads/main/schema/compose-spec.json": "compose.test.yml"
Expand Down
18 changes: 10 additions & 8 deletions app/src/app/Core/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,21 @@ protected function handleMiddlewares(array $middlewares): void
throw new Exception("Middleware {$middlewareClass} must implement MiddlewareInterface");
}

$middleware->handle($_REQUEST, fn () => null);
$middleware->handle($_REQUEST, fn() => null);
}
}

protected function abort(int $statusCode, string $message): void
{
if ($statusCode === 404) {
View::render([
'view' => 'Error/404',
'title' => 'Error 404',
'layout' => 'BlankLayout'
]);
}
View::render([
'view' => "Error",
'title' => "Error $statusCode",
'layout' => 'PublicLayout',
'data' => [
'code' => $statusCode,
'message' => $message,
],
]);
http_response_code($statusCode);
exit;
}
Expand Down
26 changes: 13 additions & 13 deletions app/src/app/Layouts/Admin/AdminInventoryLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
<?php echo $title . ' - ' . getenv('APP_NAME'); ?>
<?= $title . ' - ' . getenv('APP_NAME'); ?>
</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="/assets/css/app.css">
Expand All @@ -17,12 +17,12 @@
<!-- Sidebar -->
<aside class="bg-gray-800 w-64 flex-shrink-0">
<div class="text-white text-2xl font-bold p-4 border-b border-gray-700">
<?php echo getenv('APP_NAME'); ?>
<?= getenv('APP_NAME'); ?>
</div>
<nav class="mt-4">
<?php $currentPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); ?>
<a href="/admin/dashboard"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -32,7 +32,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Dashboard
</a>
<a href="/admin/users"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/users' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/users' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -42,7 +42,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Users
</a>
<a href="/admin/work-orders"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/work-orders' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/work-orders' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -52,7 +52,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Work Orders
</a>
<a href="/admin/zones"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/zones' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/zones' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -62,7 +62,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Zones
</a>
<a href="/admin/tree-types"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/tree-types' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/tree-types' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -72,7 +72,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Tree Types
</a>
<a href="/admin/elements"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/elements' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/elements' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -82,7 +82,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Elements
</a>
<a href="/admin/task-types"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/task-types' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/task-types' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -92,7 +92,7 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
Manage Task Types
</a>
<a href="/admin/contracts"
class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath === '/contracts' ? 'bg-gray-700' : ''; ?>">
class="block py-2 px-4 text-white hover:bg-gray-700 <?= $currentPath === '/contracts' ? 'bg-gray-700' : ''; ?>">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-5 h-5 inline">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -109,11 +109,11 @@ class="block py-2 px-4 text-white hover:bg-gray-700 <?php echo $currentPath ===
<div class="flex-1 flex flex-col">
<!-- Top bar -->
<header class="bg-white shadow p-4 flex justify-between items-center">
<div class="text-xl font-bold"><?php echo $title; ?>
<div class="text-xl font-bold"><?= $title; ?>
</div>
<div class="flex items-center space-x-4">
<span class="text-gray-600">Welcome,
<?php echo $_SESSION['user']['name'] . ' ' . $_SESSION['user']['surname']; ?></span>
<?= $_SESSION['user']['name'] . ' ' . $_SESSION['user']['surname']; ?></span>
<a href="/logout"
class="bg-gray-700 hover:bg-gray-600 text-white font-medium py-2 px-4 rounded-lg shadow focus:outline-none focus:ring focus:ring-green-500">
Logout</a>
Expand All @@ -122,7 +122,7 @@ class="bg-gray-700 hover:bg-gray-600 text-white font-medium py-2 px-4 rounded-lg

<!-- Content area -->
<main class="flex-grow p-6 overflow-auto">
<?php echo $content; ?>
<?= $content; ?>
</main>
</div>
</div>
Expand Down
82 changes: 32 additions & 50 deletions app/src/app/Layouts/Admin/AdminLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $title . ' - ' . getenv('APP_NAME'); ?></title>
<title><?= $title . ' - ' . getenv('APP_NAME'); ?></title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="/assets/css/app.css">
<script src="/assets/js/tailwind.js"></script>
Expand All @@ -14,40 +14,22 @@

<body>
<!-- Navigation Bar -->
<div class="border-b-2 border-slate-300">
<div class="border-b border-gray">
<nav class="flex items-center justify-between px-4 py-4 h-16 max-w-7xl mx-auto">
<!-- Mobile Menu Button (Visible only on small screens) -->
<button id="menuButton"
class="group inline-flex w-12 h-12 text-slate-800 bg-white text-center items-center justify-center rounded transition md:hidden"
aria-pressed="false"
onclick="this.setAttribute('aria-pressed', !(this.getAttribute('aria-pressed') === 'true'))">
<span class="sr-only">Menu</span>
<svg class="w-6 h-6 fill-current pointer-events-none" viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg">
<rect
class="origin-center -translate-y-[5px] translate-x-[7px] transition-all duration-300 ease-[cubic-bezier(.5,.85,.25,1.1)] group-[[aria-pressed=true]]:translate-x-0 group-[[aria-pressed=true]]:translate-y-0 group-[[aria-pressed=true]]:rotate-[315deg]"
y="7" width="9" height="2" rx="1"></rect>
<rect
class="origin-center transition-all duration-300 ease-[cubic-bezier(.5,.85,.25,1.8)] group-[[aria-pressed=true]]:rotate-45"
y="7" width="16" height="2" rx="1"></rect>
<rect
class="origin-center translate-y-[5px] transition-all duration-300 ease-[cubic-bezier(.5,.85,.25,1.1)] group-[[aria-pressed=true]]:translate-y-0 group-[[aria-pressed=true]]:rotate-[135deg]"
y="7" width="9" height="2" rx="1"></rect>
</svg>
</button>

<!-- Logo -->
<a href="#">
<img class="md:block hidden w-48" src="/assets/images/logotip-horizontal.png" alt="Logo">
<img class="md:hidden block" src="/assets/images/isotip.png" alt="Logo">
</a>
<!-- Navigation Links (Visible only on large screens) -->
<div class="hidden md:flex gap-6 ml-20">
<div class="hidden md:flex gap-6">
<a href="/admin"
class="menu-link <?php echo (strpos($currentPath, '/admin') === 0 && strpos($currentPath, '/admin/inventory') === false) ? 'active' : ''; ?>">
class="menu-link <?= (strpos($currentPath, '/admin') === 0 && strpos($currentPath, '/admin/inventory') === false) ? 'active' : ''; ?>">
Gestión
</a>
<a href="/admin/inventory"
class="menu-link <?php echo ($currentPath === '/admin/inventory') ? 'active' : ''; ?>">
class="menu-link <?= ($currentPath === '/admin/inventory') ? 'active' : ''; ?>">
Inventario
</a>
</div>
Expand Down Expand Up @@ -81,9 +63,9 @@ class="flex items-center gap-2 bg-white px-3 py-2 text-sm text-gray-900 rounded-
onclick="profileDropdown.classList.toggle('hidden')">
<img class="h-10 rounded-full" src="/assets/images/avatar.png" alt="User Avatar">
<div class="hidden md:block text-sm relative">
<span class="block text-gray-700"><?php echo $_SESSION['user']['name']; ?></span>
<span class="block text-gray-700"><?= $_SESSION['user']['name']; ?></span>
<span class="block text-gray-500">
<?php echo ($_SESSION['user']['role'] == 2) ? 'ADMINISTRADOR' : 'USUARIO'; ?>
<?= ($_SESSION['user']['role'] == 2) ? 'ADMINISTRADOR' : 'USUARIO'; ?>
</span>
<div id="profile-dropdown"
class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black/5 focus:outline-none"
Expand All @@ -106,77 +88,77 @@ class="hidden absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-whi
</div>
<!-- Submenu Section (Hidden by default on small screens, visible on medium and larger screens) -->
<?php if ($currentPath !== '/admin/inventory') { ?>
<div id="submenu" class="md:flex hidden justify-center items-center gap-6 p-6 border-b-2 md:border-b-0">
<div class="submenu flex space-x-6">
<div id="submenu"
class="md:flex overflow-x-auto justify-center items-center gap-6 p-6 shadow-md sm:shadow-none px-2 py-1 sm:py-4">
<!-- class="md:flex hidden overflow-x-auto whitespace-nowrap justify-start items-center gap-4 p-4 shadow-md sm:shadow-none px-2 py-1 sm:py-4"> -->

<div class="submenu text-center flex items-center space-x-6">
<!-- Contracts -->
<div class="submenu-item">
<a href="/admin/contracts"
class="link-primary <?php echo ($currentPath == '/admin/contracts') ? 'active' : ''; ?>">
<i class="fas fa-file-contract md:block"></i>
<span>Contratos</span>
class="link-primary <?= ($currentPath == '/admin/contracts') ? 'active' : ''; ?>">
<i class="fas fa-file-contract block"></i>
<span class="text-sm font-medium whitespace-nowrap">Contratos</span>
</a>
</div>

<!-- Work Orders-->
<div class="submenu-item">
<a href="/admin/work-orders"
class="link-primary <?php echo ($currentPath == '/admin/work-orders') ? 'active' : ''; ?>">
class="link-primary <?= ($currentPath == '/admin/work-orders') ? 'active' : ''; ?>">
<i class="fas fa-briefcase md:block"></i>
<span>Orden de Trabajo</span>
<span class="text-sm font-medium whitespace-nowrap">Orden de Trabajo</span>
</a>
</div>

<!-- Zones -->
<div class="submenu-item">
<a href="/admin/zones"
class="link-primary <?php echo ($currentPath == '/admin/zones') ? 'active' : ''; ?>">
<a href="/admin/zones" class="link-primary <?= ($currentPath == '/admin/zones') ? 'active' : ''; ?>">
<i class="fas fa-map-marker-alt md:block"></i>
<span>Zonas</span>
<span class="text-sm font-medium whitespace-nowrap">Zonas</span>
</a>
</div>

<!-- Elements -->
<div class="submenu-item">
<a href="/admin/elements"
class="link-primary <?php echo ($currentPath == '/admin/elements') ? 'active' : ''; ?>">
class="link-primary <?= ($currentPath == '/admin/elements') ? 'active' : ''; ?>">
<i class="fas fa-cube md:block"></i>
<span>Elementos</span>
<span class="text-sm font-medium whitespace-nowrap">Elementos</span>
</a>
</div>

<!-- Task Types -->
<div class="submenu-item">
<a href="/admin/task-types"
class="link-primary <?php echo ($currentPath == '/admin/task-types') ? 'active' : ''; ?>">
class="link-primary <?= ($currentPath == '/admin/task-types') ? 'active' : ''; ?>">
<i class="fas fa-tasks md:block"></i>
<span>Tipo Tarea</span>
<span class="text-sm font-medium whitespace-nowrap">Tipo Tarea</span>
</a>
</div>

<!-- Users -->
<div class="submenu-item">
<a href="/admin/users"
class="link-primary <?php echo ($currentPath == '/admin/users') ? 'active' : ''; ?>">
<a href="/admin/users" class="link-primary <?= ($currentPath == '/admin/users') ? 'active' : ''; ?>">
<i class="fas fa-users md:block"></i>
<span>Usuarios</span>
<span class="text-sm font-medium whitespace-nowrap">Usuarios</span>
</a>
</div>

<!-- Partes -->
<div class="submenu-item">
<a href="/admin/work-reports"
class="link-primary <?php echo ($currentPath == '/admin/work-reports') ? 'active' : ''; ?>">
class="link-primary <?= ($currentPath == '/admin/work-reports') ? 'active' : ''; ?>">
<i class="fas fa-clipboard-list md:block"></i>
<span>Partes</span>
<span class="text-sm font-medium whitespace-nowrap">Partes</span>
</a>
</div>

<!-- Stats -->
<div class="submenu-item">
<a href="/admin/stats"
class="link-primary <?php echo ($currentPath == '/admin/stats') ? 'active' : ''; ?>">
<a href="/admin/stats" class="link-primary <?= ($currentPath == '/admin/stats') ? 'active' : ''; ?>">
<i class="fas fa-chart-bar md:block"></i>
<span>Estadísticas</span>
<span class="text-sm font-medium whitespace-nowrap">Estadísticas</span>
</a>
</div>
</div>
Expand All @@ -187,7 +169,7 @@ class="link-primary <?php echo ($currentPath == '/admin/stats') ? 'active' : '';

<!-- Main Content -->
<div class="max-w-7xl mx-auto px-6">
<?php echo $content; ?>
<?= $content; ?>
</div>

<script src="/assets/js/app.js"></script>
Expand All @@ -213,4 +195,4 @@ class="link-primary <?php echo ($currentPath == '/admin/stats') ? 'active' : '';
</script>
</body>

</html>
</html>
Loading

0 comments on commit 2f8bb9d

Please sign in to comment.