kokjan/backend/views/site/index.php

317 lines
12 KiB
PHP
Executable File

<?php
/* @var $this yii\web\View */
use common\models\CmsPage;
use common\models\CmsPost;
use common\models\User;
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = 'แดชบอร์ดจัดการระบบ - ' . Yii::$app->params['org_short'];
$this->params['breadcrumbs'][] = 'Dashboard';
// Statistics for cards
$totalPosts = CmsPost::find()->count();
$totalPages = CmsPage::find()->count();
$totalUsers = User::find()->count();
// Recent posts
$recentPosts = CmsPost::find()->orderBy(['created_at' => SORT_DESC])->limit(5)->all();
?>
<style>
.dash-card {
border: none;
border-radius: 15px;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
overflow: hidden;
}
.dash-card:hover {
transform: translateY(-5px);
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.stat-icon {
font-size: 3rem;
opacity: 0.3;
position: absolute;
right: 20px;
bottom: 10px;
}
.quick-link-btn {
border-radius: 12px;
padding: 15px;
text-align: center;
margin-bottom: 20px;
background: #fff;
border: 1px solid #eee;
color: #333;
display: block;
transition: all 0.2s;
}
.quick-link-btn:hover {
background: #FFDBBB;
border-color: #FFC068;
color: #8e1d1d;
text-decoration: none;
}
.quick-link-btn i {
display: block;
font-size: 1.5rem;
margin-bottom: 8px;
color: #FFC068;
}
/* Module Card Styling */
.module-card {
background: #fff;
border-radius: 15px;
padding: 15px 10px;
text-align: center;
border: 1.5px solid #f0f0f0;
transition: all 0.3s ease;
margin-bottom: 20px;
display: block;
color: #2c1810;
text-decoration: none !important;
height: 100%;
}
.module-card:hover {
border-color: #FFC068;
box-shadow: 0 10px 25px rgba(255, 192, 104, 0.2);
transform: translateY(-5px);
}
.module-icon-wrap {
width: 50px;
height: 50px;
background: #f8f9fa;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 12px;
font-size: 1.3rem;
color: #d35400;
transition: all 0.3s;
}
.module-card:hover .module-icon-wrap {
background: #FFC068;
color: #8e1d1d;
}
.module-label {
font-weight: 700;
font-size: 0.85rem;
display: block;
line-height: 1.2;
margin-bottom: 3px;
}
.module-sub-label {
font-size: 0.65rem;
color: #aaa;
display: block;
text-transform: uppercase;
}
.category-title {
font-size: 1rem;
font-weight: 800;
color: #2c1810;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 2px solid #FFDBBB;
display: flex;
align-items: center;
}
.category-title i {
width: 35px;
height: 35px;
background: #FFDBBB;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
color: #8e1d1d;
font-size: 0.9rem;
}
.table-card {
border-radius: 15px;
border: none;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.bg-peach { background-color: #FFDBBB; }
.text-thai-red { color: #8e1d1d; }
</style>
<!-- Main Stats Summary -->
<div class="row">
<div class="col-xl-3 col-lg-6 col-12 mb-4">
<div class="card dash-card bg-primary text-white">
<div class="card-body position-relative">
<h6 class="text-uppercase mb-2">ข่าวสารทั้งหมด</h6>
<h2 class="display-4 font-weight-bold mb-0"><?= number_format($totalPosts) ?></h2>
<i class="fas fa-newspaper stat-icon"></i>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 mb-4">
<div class="card dash-card bg-danger text-white">
<div class="card-body position-relative">
<h6 class="text-uppercase mb-2">หน้าเว็บไซต์</h6>
<h2 class="display-4 font-weight-bold mb-0"><?= number_format($totalPages) ?></h2>
<i class="far fa-file-alt stat-icon"></i>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 mb-4">
<div class="card dash-card bg-success text-white">
<div class="card-body position-relative">
<h6 class="text-uppercase mb-2">ผู้ใช้งานระบบ</h6>
<h2 class="display-4 font-weight-bold mb-0"><?= number_format($totalUsers) ?></h2>
<i class="fas fa-users stat-icon"></i>
</div>
</div>
</div>
<div class="col-xl-3 col-lg-6 col-12 mb-4">
<div class="card dash-card bg-warning text-white">
<div class="card-body position-relative">
<h6 class="text-uppercase mb-2">ผู้เข้าชมทั้งหมด</h6>
<h2 class="display-4 font-weight-bold mb-0"><?= number_format(Yii::$app->abt->getCounterTotal()) ?></h2>
<i class="fas fa-chart-line stat-icon"></i>
</div>
</div>
</div>
</div>
<?php //= $this->render('_menu') ?>
<div class="row">
<!-- Left Column: Visitor Details & Recent Posts -->
<div class="col-lg-8">
<!-- Visitor Details Table -->
<div class="card table-card mb-4">
<div class="card-header bg-white border-0 py-3">
<h5 class="mb-0 font-weight-bold"><i class="fas fa-chart-bar mr-2 text-primary"></i> รายละเอียดสถิติผู้เข้าชม</h5>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="bg-light text-muted small text-uppercase">
<tr>
<th>ช่วงเวลา</th>
<th class="text-right">จำนวนผู้เข้าชม (คน)</th>
<th class="text-center">สถานะ</th>
</tr>
</thead>
<tbody>
<tr>
<td>วันนี้</td>
<td class="text-right font-weight-bold"><?= number_format(Yii::$app->abt->getCounterToday()) ?></td>
<td class="text-center"><span class="badge badge-pill badge-success">Online</span></td>
</tr>
<tr>
<td>เมื่อวาน</td>
<td class="text-right"><?= number_format(Yii::$app->abt->getCounterYesterday()) ?></td>
<td class="text-center">-</td>
</tr>
<tr>
<td>เดือนนี้ (<?= date('M Y') ?>)</td>
<td class="text-right font-weight-bold text-primary"><?= number_format(Yii::$app->abt->getCounterThisMonth()) ?></td>
<td class="text-center"><i class="fas fa-arrow-up text-success"></i></td>
</tr>
<tr>
<td>เดือนที่แล้ว</td>
<td class="text-right"><?= number_format(Yii::$app->abt->getCounterLastMonth()) ?></td>
<td class="text-center">-</td>
</tr>
<tr class="bg-peach text-thai-red">
<td class="font-weight-bold">รวมทั้งหมด</td>
<td class="text-right font-weight-bold"><?= number_format(Yii::$app->abt->getCounterTotal()) ?></td>
<td class="text-center"><i class="fas fa-globe"></i></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Recent Posts Table -->
<div class="card table-card">
<div class="card-header bg-white border-0 py-3 d-flex justify-content-between align-items-center">
<h5 class="mb-0 font-weight-bold"><i class="far fa-clock mr-2 text-danger"></i> ข่าวสารล่าสุด</h5>
<?= Html::a('ดูทั้งหมด', ['/cms/post/index'], ['class' => 'btn btn-sm btn-outline-danger px-3']) ?>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<tbody>
<?php foreach($recentPosts as $post): ?>
<tr>
<td style="width: 60px;">
<div class="bg-light rounded p-2 text-center">
<i class="far fa-file-alt text-muted"></i>
</div>
</td>
<td>
<div class="font-weight-bold text-truncate" style="max-width: 400px;"><?= Html::encode($post->name) ?></div>
<small class="text-muted"><?= Yii::$app->formatter->asDate($post->created_at, 'medium') ?></small>
</td>
<td class="text-right align-middle">
<?= Html::a('<i class="fas fa-edit"></i>', ['/cms/post/update', 'id' => $post->id], ['class' => 'btn btn-sm btn-light']) ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Right Column: Quick Links & Helpful Info -->
<div class="col-lg-4">
<h5 class="mb-3 font-weight-bold">ทางลัดการใช้งานระบบหลัก</h5>
<div class="row">
<div class="col-6">
<a href="<?= Url::to(['/cms/post/create']) ?>" class="quick-link-btn">
<i class="fas fa-plus-circle"></i>
<span>เพิ่มข่าวใหม่</span>
</a>
</div>
<div class="col-6">
<a href="<?= Url::to(['/administrator/menu-frontend/index']) ?>" class="quick-link-btn">
<i class="fas fa-bars"></i>
<span>จัดการเมนู</span>
</a>
</div>
<div class="col-6">
<a href="<?= Url::to(['/cms/page/index']) ?>" class="quick-link-btn">
<i class="far fa-copy"></i>
<span>จัดการหน้าเว็บ</span>
</a>
</div>
<div class="col-6">
<a href="<?= Url::to(['/administrator/filemanager/index']) ?>" class="quick-link-btn">
<i class="fas fa-folder-open"></i>
<span>คลังเอกสาร</span>
</a>
</div>
</div>
<div class="card dash-card mt-2" style="background: linear-gradient(45deg, #2c1810, #8e1d1d); color: #fff;">
<div class="card-body text-center py-4">
<i class="fas fa-info-circle mb-3" style="font-size: 2.5rem; opacity: 0.5;"></i>
<h5>ระบบจัดการเว็บไซต์</h5>
<p class="small opacity-75">เวอร์ชัน 2.0.0<br>พัฒนาโดย HANUMANIT Co., Ltd.</p>
<hr style="border-color: rgba(255,255,255,0.1);">
<div class="d-flex justify-content-around small">
<div><i class="fas fa-check-circle mr-1"></i> SSL Protected</div>
<div><i class="fas fa-check-circle mr-1"></i> PHP 7.4+</div>
</div>
</div>
</div>
</div>
</div>