Initial commit

This commit is contained in:
Porawit Dongwang
2026-09-16 23:20:08 +07:00
commit 0041668dbb
32577 changed files with 3687927 additions and 0 deletions
@@ -0,0 +1,16 @@
<?php
namespace app\Controllers;
use app\Core\Controller;
class HomeController extends Controller {
public function index() {
$data = [
'title' => 'Dashboard - ' . APP_NAME
];
$this->view('templates/header', $data);
$this->view('home/index', $data);
$this->view('templates/footer');
}
}
@@ -0,0 +1,43 @@
<?php
namespace app\Core;
class App {
protected $controller = 'Home';
protected $method = 'index';
protected $params = [];
public function __construct() {
$url = $this->parseUrl();
// Check if controller exists
if(isset($url[0]) && file_exists('../app/Controllers/' . ucfirst($url[0]) . 'Controller.php')) {
$this->controller = ucfirst($url[0]);
unset($url[0]);
}
require_once '../app/Controllers/' . $this->controller . 'Controller.php';
$controllerClass = '\\app\\Controllers\\' . $this->controller . 'Controller';
$this->controller = new $controllerClass;
// Check if method exists
if(isset($url[1])) {
if(method_exists($this->controller, $url[1])) {
$this->method = $url[1];
unset($url[1]);
}
}
// Get params
$this->params = $url ? array_values($url) : [];
// Call the method with params
call_user_func_array([$this->controller, $this->method], $this->params);
}
public function parseUrl() {
if(isset($_GET['url'])) {
return explode('/', filter_var(rtrim($_GET['url'], '/'), FILTER_SANITIZE_URL));
}
return [];
}
}
@@ -0,0 +1,22 @@
<?php
namespace app\Core;
class Controller {
// Load model
public function model($model) {
require_once '../app/Models/' . $model . '.php';
$modelClass = '\\app\\Models\\' . $model;
return new $modelClass();
}
// Load view
public function view($view, $data = []) {
if(file_exists('../app/Views/' . $view . '.php')) {
// Extract data to variables for the view
extract($data);
require_once '../app/Views/' . $view . '.php';
} else {
die('View does not exist');
}
}
}
@@ -0,0 +1,89 @@
<?php
namespace app\Core;
use PDO;
use PDOException;
class Database {
private $host = DB_HOST;
private $user = DB_USER;
private $pass = DB_PASS;
private $dbname = DB_NAME;
private $dbh;
private $stmt;
private $error;
public function __construct() {
// Set DSN
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname . ';charset=utf8mb4';
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
);
// Create PDO instance
try {
$this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
} catch(PDOException $e) {
$this->error = $e->getMessage();
// Fallback for when DB isn't created yet during dev
// echo $this->error;
}
}
// Prepare statement
public function query($sql) {
if ($this->dbh) {
$this->stmt = $this->dbh->prepare($sql);
}
}
// Bind values
public function bind($param, $value, $type = null) {
if(is_null($type)) {
switch(true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case is_null($value):
$type = PDO::PARAM_NULL;
break;
default:
$type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($param, $value, $type);
}
// Execute the prepared statement
public function execute() {
return $this->stmt->execute();
}
// Get multiple records as array of objects
public function resultSet() {
$this->execute();
return $this->stmt->fetchAll();
}
// Get single record as object
public function single() {
$this->execute();
return $this->stmt->fetch();
}
// Get row count
public function rowCount() {
return $this->stmt->rowCount();
}
// Get last insert ID
public function lastInsertId() {
return $this->dbh->lastInsertId();
}
}
@@ -0,0 +1,134 @@
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Dashboard Overview</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<div class="btn-group me-2">
<button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
</div>
<button type="button" class="btn btn-sm btn-outline-primary d-flex align-items-center gap-1">
<i class="bi bi-calendar3"></i>
Budget Year 2026
</button>
</div>
</div>
<div class="row g-4 mb-4">
<div class="col-12 col-sm-6 col-xxl-3">
<div class="card bg-primary text-white h-100 border-0 shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="card-title mb-0">Total Procurement Plans</h6>
<i class="bi bi-cart3 fs-4 text-white-50"></i>
</div>
<h2 class="mb-0">124</h2>
<small class="text-white-50">+12% from last month</small>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-xxl-3">
<div class="card bg-success text-white h-100 border-0 shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="card-title mb-0">Active Equipments</h6>
<i class="bi bi-pc-display fs-4 text-white-50"></i>
</div>
<h2 class="mb-0">842</h2>
<small class="text-white-50">Deployed across hospitals</small>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-xxl-3">
<div class="card bg-info text-white h-100 border-0 shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="card-title mb-0">Active Subscriptions</h6>
<i class="bi bi-windows fs-4 text-white-50"></i>
</div>
<h2 class="mb-0">45</h2>
<small class="text-white-50">Total Software Licenses</small>
</div>
</div>
</div>
<div class="col-12 col-sm-6 col-xxl-3">
<div class="card bg-danger text-white h-100 border-0 shadow-sm">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-3">
<h6 class="card-title mb-0">Expiring Soon (&lt;30 Days)</h6>
<i class="bi bi-exclamation-triangle fs-4 text-white-50"></i>
</div>
<h2 class="mb-0">3</h2>
<small class="text-white-50">Needs immediate renewal</small>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-8 mb-4">
<div class="card border-0 shadow-sm">
<div class="card-header bg-white border-bottom-0 pt-3 pb-0">
<h6 class="mb-0">Recent Software Renewals</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th>Software</th>
<th>Vendor</th>
<th>Type</th>
<th>Expiry Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td><div class="fw-medium">Microsoft 365</div><small class="text-muted">100 Licenses</small></td>
<td>Microsoft Corp.</td>
<td><span class="badge bg-light text-dark border">Subscription (1 Year)</span></td>
<td>Dec 31, 2026</td>
<td><span class="badge bg-success bg-opacity-10 text-success border border-success border-opacity-25">Active</span></td>
</tr>
<tr>
<td><div class="fw-medium">Adobe Creative Cloud</div><small class="text-muted">15 Licenses</small></td>
<td>Adobe Inc.</td>
<td><span class="badge bg-light text-dark border">Subscription (3 Years)</span></td>
<td>Oct 15, 2026</td>
<td><span class="badge bg-warning bg-opacity-10 text-warning border border-warning border-opacity-25">Expiring Soon</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-4 mb-4">
<div class="card border-0 shadow-sm h-100">
<div class="card-header bg-white border-bottom-0 pt-3 pb-0">
<h6 class="mb-0">System Activity Log</h6>
</div>
<div class="card-body">
<div class="d-flex align-items-start mb-3">
<div class="bg-primary bg-opacity-10 text-primary rounded-circle p-2 me-3">
<i class="bi bi-arrow-repeat"></i>
</div>
<div>
<p class="mb-0 fw-medium text-dark" style="font-size: 0.9rem;">Renewal Cycle Changed</p>
<p class="mb-0 text-muted small">Microsoft 365 (1 Year &rarr; 3 Years) by Somchai</p>
<small class="text-muted" style="font-size: 0.75rem;">10 mins ago</small>
</div>
</div>
<div class="d-flex align-items-start mb-3">
<div class="bg-success bg-opacity-10 text-success rounded-circle p-2 me-3">
<i class="bi bi-check-circle"></i>
</div>
<div>
<p class="mb-0 fw-medium text-dark" style="font-size: 0.9rem;">Procurement Approved</p>
<p class="mb-0 text-muted small">Plan PR-2026-001 by Director</p>
<small class="text-muted" style="font-size: 0.75rem;">1 hour ago</small>
</div>
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,8 @@
</main>
</div>
</div>
<!-- Bootstrap 5.3 JS Bundle -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $data['title'] ?? APP_NAME; ?></title>
<!-- Bootstrap 5.3 CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap Icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f8f9fa;
}
.navbar-brand {
font-weight: 700;
}
.sidebar {
min-height: calc(100vh - 56px);
background-color: #fff;
border-right: 1px solid #dee2e6;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand" href="<?= APP_URL; ?>"><i class="bi bi-box-seam me-2"></i><?= APP_NAME; ?></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" href="<?= APP_URL; ?>">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= APP_URL; ?>/assets">Assets</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= APP_URL; ?>/software">Software Licenses</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?= APP_URL; ?>/settings">Settings</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<!-- Sidebar -->
<div class="col-md-3 col-lg-2 d-md-block sidebar collapse p-3">
<ul class="nav flex-column">
<li class="nav-item mb-2">
<a class="nav-link active text-dark fw-medium" href="<?= APP_URL; ?>">
<i class="bi bi-speedometer2 me-2 text-primary"></i> Dashboard
</a>
</li>
<li class="nav-item mb-2">
<a class="nav-link text-dark" href="<?= APP_URL; ?>/procurement">
<i class="bi bi-cart3 me-2"></i> Procurement Plan
</a>
</li>
<li class="nav-item mb-2">
<a class="nav-link text-dark" href="<?= APP_URL; ?>/assets">
<i class="bi bi-pc-display me-2"></i> Materials & Equip.
</a>
</li>
<li class="nav-item mb-2">
<a class="nav-link text-dark" href="<?= APP_URL; ?>/software">
<i class="bi bi-windows me-2"></i> Software & Subs
</a>
</li>
<li class="nav-item mb-2">
<a class="nav-link text-dark" href="<?= APP_URL; ?>/reports">
<i class="bi bi-file-earmark-bar-graph me-2"></i> Reports
</a>
</li>
<hr>
<li class="nav-item mb-2">
<a class="nav-link text-dark" href="<?= APP_URL; ?>/audit">
<i class="bi bi-clock-history me-2"></i> Audit Logs
</a>
</li>
</ul>
</div>
<!-- Main Content -->
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 py-4">