Compare commits
10 Commits
338d089fca
...
619ad8960d
| Author | SHA1 | Date |
|---|---|---|
|
|
619ad8960d | |
|
|
e622cda9f3 | |
|
|
5be35f3851 | |
|
|
4b2eeb4f8e | |
|
|
6f6eabcaef | |
|
|
80057c1acc | |
|
|
7c804bf715 | |
|
|
c2e22b1dae | |
|
|
f24f8652bf | |
|
|
23d615c570 |
|
|
@ -21,15 +21,17 @@ public function index(Request $request)
|
|||
->get();
|
||||
|
||||
$availablePeriodeIds = $periodeList->pluck('id')->map(fn($id) => (string) $id);
|
||||
|
||||
$periodeAktif = $request->periode_id && $availablePeriodeIds->contains((string) $request->periode_id)
|
||||
? $periodeList->firstWhere('id', (int) $request->periode_id)
|
||||
: $periodeList->first();
|
||||
|
||||
$periodeId = $periodeAktif->id ?? null;
|
||||
|
||||
// Evaluasi ini berbasis pseudo-label dari rating/rule otomatis.
|
||||
// Evaluasi ini berbasis pseudo-label dari rating/rule otomatis
|
||||
$evaluasi = DB::table('evaluasi_model')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->latest()
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
|
||||
$jumlahKelasAnalisis = DB::table('hasil_analisis')
|
||||
|
|
@ -42,20 +44,30 @@ public function index(Request $request)
|
|||
->count();
|
||||
|
||||
// Dropdown wisata
|
||||
$wisataList = HasilAnalisis::select('wisata')
|
||||
$wisataList = HasilAnalisis::query()
|
||||
->select('wisata')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->distinct()
|
||||
->pluck('wisata');
|
||||
|
||||
// Query hasil analisis dengan filter
|
||||
$query = HasilAnalisis::query();
|
||||
$query->when($periodeId, fn($q) => $q->where('periode_id', $periodeId));
|
||||
// Diurutkan berdasarkan tanggal ulasan terbaru dari tabel ulasan
|
||||
$query = HasilAnalisis::query()
|
||||
->leftJoin('ulasan as u', 'hasil_analisis.ulasan_id', '=', 'u.id')
|
||||
->select('hasil_analisis.*');
|
||||
|
||||
$query->when($periodeId, fn($q) => $q->where('hasil_analisis.periode_id', $periodeId));
|
||||
|
||||
if ($request->filled('wisata')) {
|
||||
$query->where('wisata', $request->wisata);
|
||||
$query->where('hasil_analisis.wisata', $request->wisata);
|
||||
}
|
||||
|
||||
$hasil = $query->latest()->paginate(10);
|
||||
$hasil = $query
|
||||
->orderByRaw('COALESCE(u.tanggal, hasil_analisis.created_at) DESC')
|
||||
->orderBy('hasil_analisis.id', 'desc')
|
||||
->paginate(10)
|
||||
->withQueryString();
|
||||
|
||||
$standalone = true;
|
||||
|
||||
return view('analisis.index', compact(
|
||||
|
|
@ -64,7 +76,9 @@ public function index(Request $request)
|
|||
'evaluasi',
|
||||
'standalone',
|
||||
'jumlahKelasAnalisis',
|
||||
'totalHasilAnalisis'
|
||||
'totalHasilAnalisis',
|
||||
'periodeAktif',
|
||||
'periodeList'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
public function sendResetLinkEmail(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|email'
|
||||
]);
|
||||
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
return $status === Password::RESET_LINK_SENT
|
||||
? back()->with('status', __($status))
|
||||
: back()->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\User;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
public function showResetForm(Request $request, $token = null)
|
||||
{
|
||||
return view('auth.reset-password', [
|
||||
'token' => $token,
|
||||
'email' => $request->email
|
||||
]);
|
||||
}
|
||||
|
||||
public function reset(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'token' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:8|confirmed',
|
||||
]);
|
||||
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user, $password) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
}
|
||||
);
|
||||
|
||||
// return $status == Password::PASSWORD_RESET
|
||||
// ? redirect()->route('login')->with('status', 'Password berhasil direset!')
|
||||
// : back()->withErrors(['email' => [__($status)]]);
|
||||
return view('auth.reset-success');
|
||||
}
|
||||
}
|
||||
|
|
@ -60,316 +60,412 @@ class DashboardController extends Controller
|
|||
],
|
||||
];
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$tab = $request->input('tab', 'dashboard');
|
||||
$wisata = $tab === 'analisis' ? $request->wisata : null;
|
||||
$destinasi = $tab === 'rekomendasi' ? $request->destinasi : null;
|
||||
public function index(Request $request)
|
||||
{
|
||||
$tab = $request->input('tab', 'dashboard');
|
||||
$wisata = $tab === 'analisis' ? $request->wisata : null;
|
||||
$destinasi = $tab === 'rekomendasi' ? $request->destinasi : null;
|
||||
|
||||
// ================================================================
|
||||
// PERIODE BULAN YANG DIPILIH
|
||||
// ================================================================
|
||||
$periodeBulan = $request->input('periode_bulan', now()->format('Y-m'));
|
||||
$currentMonth = now()->month;
|
||||
$currentYear = now()->year;
|
||||
|
||||
[$tahun, $bulan] = explode('-', $periodeBulan);
|
||||
// ================================================================
|
||||
// AMBIL SEMUA PERIODE YANG PUNYA DATA
|
||||
// ================================================================
|
||||
$periodeList = DB::table('periode_analisis as p')
|
||||
->whereExists(function ($q) {
|
||||
$q->select(DB::raw(1))->from('ulasan as u')->whereColumn('u.periode_id', 'p.id');
|
||||
})
|
||||
->orWhereExists(function ($q) {
|
||||
$q->select(DB::raw(1))->from('hasil_analisis as h')->whereColumn('h.periode_id', 'p.id');
|
||||
})
|
||||
->orderBy('p.tahun', 'desc')
|
||||
->orderBy('p.bulan', 'desc')
|
||||
->select('p.*')
|
||||
->get();
|
||||
|
||||
// ================================================================
|
||||
// AMBIL SEMUA PERIODE & PERIODE AKTIF
|
||||
// ================================================================
|
||||
$periodeList = DB::table('periode_analisis as p')
|
||||
->whereExists(function ($q) {
|
||||
$q->select(DB::raw(1))
|
||||
->from('ulasan as u')
|
||||
->whereColumn('u.periode_id', 'p.id');
|
||||
})
|
||||
->orWhereExists(function ($q) {
|
||||
$q->select(DB::raw(1))
|
||||
->from('hasil_analisis as h')
|
||||
->whereColumn('h.periode_id', 'p.id');
|
||||
})
|
||||
->orderBy('p.id', 'desc')
|
||||
->select('p.*')
|
||||
->get();
|
||||
// ================================================================
|
||||
// TENTUKAN PERIODE AKTIF
|
||||
// Dashboard, Hasil Analisis, Rekomendasi:
|
||||
// - Kalau request manual → pakai itu
|
||||
// - Kalau tidak → cari bulan ini; kalau belum ada data → fallback ke bulan terakhir
|
||||
// ================================================================
|
||||
if ($request->filled('periode_id')) {
|
||||
// Prioritas utama: periode_id langsung (dikirim saat filter destinasi/wisata)
|
||||
$periodeAktif = $periodeList->firstWhere('id', (int) $request->periode_id);
|
||||
} elseif ($request->filled('periode_bulan')) {
|
||||
[$tahun, $bulan] = explode('-', $request->periode_bulan);
|
||||
$periodeAktif = $periodeList->first(fn($p) =>
|
||||
$p->tahun == (int) $tahun && $p->bulan == (int) $bulan
|
||||
);
|
||||
} else {
|
||||
// Cari bulan ini
|
||||
$periodeAktif = $periodeList->first(fn($p) =>
|
||||
$p->bulan == $currentMonth && $p->tahun == $currentYear
|
||||
);
|
||||
// Belum ada data bulan ini → fallback ke bulan terakhir yang ada data
|
||||
if (!$periodeAktif) {
|
||||
$periodeAktif = $periodeList->first(); // sudah urut desc
|
||||
}
|
||||
}
|
||||
|
||||
// Cocokkan pakai kolom bulan & tahun
|
||||
$periodeAktif = $periodeList->first(function ($p) use ($tahun, $bulan) {
|
||||
return $p->tahun == (int)$tahun && $p->bulan == (int)$bulan;
|
||||
});
|
||||
$noDataPesan = null;
|
||||
if (!$periodeAktif) {
|
||||
$noDataPesan = 'Belum ada data.';
|
||||
}
|
||||
|
||||
// Jika tidak ada data di bulan tsb
|
||||
$noDataPesan = null;
|
||||
if (!$periodeAktif) {
|
||||
$namaBulanDipilih = \Carbon\Carbon::createFromDate($tahun, $bulan, 1)
|
||||
->locale('id')->isoFormat('MMMM YYYY');
|
||||
$noDataPesan = "Tidak ada data untuk bulan {$namaBulanDipilih}.";
|
||||
}
|
||||
$periodeId = $periodeAktif->id ?? null;
|
||||
|
||||
$periodeId = $periodeAktif->id ?? null;
|
||||
// ================================================================
|
||||
// EVALUASI MODEL
|
||||
// ================================================================
|
||||
$evaluasi = DB::table('evaluasi_model')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
$evaluasi = DB::table('evaluasi_model')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->latest()->first();
|
||||
// ================================================================
|
||||
// TOTAL ULASAN
|
||||
// ================================================================
|
||||
$totalUlasan = DB::table('ulasan')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
// ================================================================
|
||||
// TOTAL ULASAN
|
||||
// ================================================================
|
||||
$totalUlasan = DB::table('ulasan')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
// ================================================================
|
||||
// CEK ADA ANALISIS ATAU BELUM
|
||||
// ================================================================
|
||||
$hasAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->count() > 0;
|
||||
|
||||
// ================================================================
|
||||
// CEK ADA ANALISIS ATAU BELUM
|
||||
// ================================================================
|
||||
$hasAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->count() > 0;
|
||||
// ================================================================
|
||||
// HITUNG SENTIMEN
|
||||
// ================================================================
|
||||
$positif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'positif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
// ================================================================
|
||||
// HITUNG SENTIMEN
|
||||
// ================================================================
|
||||
$positif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'positif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
$negatif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
$negatif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
$netral = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'netral')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
$netral = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'netral')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
$totalSentimen = $positif + $negatif + $netral;
|
||||
|
||||
$totalSentimen = $positif + $negatif + $netral;
|
||||
$stats = [
|
||||
'total' => $totalUlasan,
|
||||
'positif_persen' => $totalSentimen > 0 ? round(($positif / $totalSentimen) * 100) : 0,
|
||||
'negatif_persen' => $totalSentimen > 0 ? round(($negatif / $totalSentimen) * 100) : 0,
|
||||
'netral_persen' => $totalSentimen > 0 ? round(($netral / $totalSentimen) * 100) : 0,
|
||||
];
|
||||
|
||||
$stats = [
|
||||
'total' => $totalUlasan,
|
||||
'positif_persen' => $totalSentimen > 0 ? round(($positif / $totalSentimen) * 100) : 0,
|
||||
'negatif_persen' => $totalSentimen > 0 ? round(($negatif / $totalSentimen) * 100) : 0,
|
||||
'netral_persen' => $totalSentimen > 0 ? round(($netral / $totalSentimen) * 100) : 0,
|
||||
];
|
||||
|
||||
// ================================================================
|
||||
// CHART DATA
|
||||
// ================================================================
|
||||
$chartSentimen = $hasAnalisis
|
||||
? DB::table('hasil_analisis')
|
||||
// ================================================================
|
||||
// CHART DATA
|
||||
// ================================================================
|
||||
$rawSentimen = DB::table('hasil_analisis')
|
||||
->select('sentimen', DB::raw('count(*) as total'))
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->groupBy('sentimen')
|
||||
->orderByRaw("FIELD(sentimen, 'positif', 'negatif', 'netral')")
|
||||
->get()
|
||||
: collect();
|
||||
->pluck('total', 'sentimen');
|
||||
|
||||
$chartDestinasi = $hasAnalisis
|
||||
? DB::table('hasil_analisis')
|
||||
->select(
|
||||
'wisata',
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'positif' THEN 1 ELSE 0 END) as positif"),
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'negatif' THEN 1 ELSE 0 END) as negatif"),
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'netral' THEN 1 ELSE 0 END) as netral")
|
||||
)
|
||||
$chartSentimen = collect([
|
||||
['sentimen' => 'positif', 'total' => $rawSentimen['positif'] ?? 0],
|
||||
['sentimen' => 'negatif', 'total' => $rawSentimen['negatif'] ?? 0],
|
||||
['sentimen' => 'netral', 'total' => $rawSentimen['netral'] ?? 0],
|
||||
]);
|
||||
|
||||
$chartDestinasi = $hasAnalisis
|
||||
? DB::table('hasil_analisis')
|
||||
->select(
|
||||
'wisata',
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'positif' THEN 1 ELSE 0 END) as positif"),
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'negatif' THEN 1 ELSE 0 END) as negatif"),
|
||||
DB::raw("SUM(CASE WHEN sentimen = 'netral' THEN 1 ELSE 0 END) as netral")
|
||||
)
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->groupBy('wisata')
|
||||
->get()
|
||||
: collect();
|
||||
|
||||
// ================================================================
|
||||
// TOTAL PER DESTINASI + WORD CLOUD + LAST UPDATE
|
||||
// ================================================================
|
||||
$totalPerWisata = DB::table('ulasan')
|
||||
->select('wisata', DB::raw('count(*) as total'))
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->groupBy('wisata')
|
||||
->get();
|
||||
|
||||
$texts = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
$allText = count($texts) > 0 ? implode(' ', $texts) : '';
|
||||
|
||||
$lastUpdate = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->latest('created_at')
|
||||
->value('created_at');
|
||||
|
||||
$destinasiList = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->select('wisata')->distinct()->pluck('wisata');
|
||||
$wisataList = $destinasiList;
|
||||
|
||||
$totalDestinasiAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->distinct('wisata')->count('wisata');
|
||||
|
||||
$totalDestinasiBerkeluhan = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->distinct('wisata')->count('wisata');
|
||||
|
||||
$hasil = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->groupBy('wisata')
|
||||
->get()
|
||||
: collect();
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
// ================================================================
|
||||
// TOTAL PER DESTINASI + WORD CLOUD + LAST UPDATE
|
||||
// ================================================================
|
||||
$totalPerWisata = DB::table('ulasan')
|
||||
->select('wisata', DB::raw('count(*) as total'))
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->groupBy('wisata')
|
||||
->get();
|
||||
$jumlahKelasAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->distinct('sentimen')->count('sentimen');
|
||||
|
||||
$texts = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
$allText = count($texts) > 0 ? implode(' ', $texts) : '';
|
||||
$totalHasilAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
$lastUpdate = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->latest('created_at')->value('created_at');
|
||||
// ================================================================
|
||||
// REKOMENDASI
|
||||
// ================================================================
|
||||
$ulasanNegatif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
|
||||
$destinasiList = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->select('wisata')->distinct()->pluck('wisata');
|
||||
$wisataList = $destinasiList;
|
||||
$textRek = strtolower(implode(' ', $ulasanNegatif));
|
||||
$wordsRek = array_filter(preg_split('/\s+/', $textRek));
|
||||
|
||||
$totalDestinasiAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->distinct('wisata')
|
||||
->count('wisata');
|
||||
|
||||
$totalDestinasiBerkeluhan = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->distinct('wisata')
|
||||
->count('wisata');
|
||||
|
||||
$hasil = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->paginate(10);
|
||||
|
||||
$jumlahKelasAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->distinct('sentimen')
|
||||
->count('sentimen');
|
||||
|
||||
$totalHasilAnalisis = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($wisata && $wisata != 'Semua Destinasi', fn($q) => $q->where('wisata', $wisata))
|
||||
->count();
|
||||
|
||||
// ================================================================
|
||||
// REKOMENDASI
|
||||
// ================================================================
|
||||
$ulasanNegatif = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
|
||||
$textRek = strtolower(implode(' ', $ulasanNegatif));
|
||||
$wordsRek = array_filter(preg_split('/\s+/', $textRek));
|
||||
|
||||
$issueSkor = [];
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$skor = 0;
|
||||
foreach ($rule['keywords'] as $kw) {
|
||||
$skor += substr_count($textRek, $kw);
|
||||
$issueSkor = [];
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$skor = 0;
|
||||
foreach ($rule['keywords'] as $kw) {
|
||||
$skor += substr_count($textRek, $kw);
|
||||
}
|
||||
$issueSkor[$kategori] = $skor;
|
||||
}
|
||||
$issueSkor[$kategori] = $skor;
|
||||
}
|
||||
arsort($issueSkor);
|
||||
$issueSkorAktif = array_filter($issueSkor, fn($skor) => $skor > 0);
|
||||
$totalSkorIsu = array_sum($issueSkorAktif) ?: 1;
|
||||
arsort($issueSkor);
|
||||
$issueSkorAktif = array_filter($issueSkor, fn($skor) => $skor > 0);
|
||||
$totalSkorIsu = array_sum($issueSkorAktif) ?: 1;
|
||||
|
||||
$isuUtama = [];
|
||||
foreach (array_slice($issueSkorAktif, 0, 5, true) as $nama => $skor) {
|
||||
$isuUtama[] = [
|
||||
'nama' => $nama,
|
||||
'skor' => $skor,
|
||||
'persen' => round(($skor / $totalSkorIsu) * 100),
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
$isuUtama = [];
|
||||
foreach (array_slice($issueSkorAktif, 0, 5, true) as $nama => $skor) {
|
||||
$isuUtama[] = [
|
||||
'nama' => $nama,
|
||||
'skor' => $skor,
|
||||
'persen' => round(($skor / $totalSkorIsu) * 100),
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
$stopwords = [
|
||||
'yang','dan','di','ke','dari','untuk','dengan','ini','itu','tidak',
|
||||
'ada','juga','sangat','lebih','sudah','bisa','tapi','karena','pada',
|
||||
'akan','atau','saya','kami','mereka','nya','ga','gak','udah','pas',
|
||||
'kita','sih','deh','aja','ya','yg','tp','bgt','jadi','biar','kalau',
|
||||
];
|
||||
$freq = array_count_values($wordsRek);
|
||||
foreach ($stopwords as $sw) { unset($freq[$sw]); }
|
||||
foreach (array_keys($freq) as $w) {
|
||||
if (mb_strlen($w) < 3) unset($freq[$w]);
|
||||
}
|
||||
arsort($freq);
|
||||
$kataDominan = array_slice($freq, 0, 10, true);
|
||||
|
||||
$saranPerbaikan = [];
|
||||
foreach (array_slice($issueSkorAktif, 0, 3, true) as $nama => $skor) {
|
||||
$saranPerbaikan[] = [
|
||||
'nama' => 'Perbaikan ' . $nama,
|
||||
'tip' => $this->issueRules[$nama]['saran']['tip'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
$prioritas = [];
|
||||
$rank = 1;
|
||||
foreach (array_slice($issueSkorAktif, 0, 3, true) as $nama => $skor) {
|
||||
$prioritas[] = [
|
||||
'rank' => $rank++,
|
||||
'nama' => $nama,
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
'actions' => $this->issueRules[$nama]['saran']['actions'],
|
||||
'dampak' => $this->issueRules[$nama]['saran']['dampak'],
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
];
|
||||
}
|
||||
|
||||
$positifRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'positif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count();
|
||||
|
||||
$negatifRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count();
|
||||
|
||||
$totalSentimenRek = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count() ?: 1;
|
||||
|
||||
$totalNegatif = $negatifRek;
|
||||
$persenNegatif = round(($negatifRek / $totalSentimenRek) * 100, 2);
|
||||
$tingkatKepuasan = round(($positifRek / $totalSentimenRek) * 100);
|
||||
$labelKepuasan = match(true) {
|
||||
$tingkatKepuasan >= 80 => 'Baik',
|
||||
$tingkatKepuasan >= 60 => 'Sedang',
|
||||
default => 'Kurang',
|
||||
};
|
||||
$isuDominan = $isuUtama[0]['nama'] ?? '-';
|
||||
$isuDominanPersen = $isuUtama[0]['persen'] ?? 0;
|
||||
|
||||
// --- Variabel tambahan untuk tab Rekomendasi ---
|
||||
$netralRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'netral')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count();
|
||||
|
||||
$totalUlasanRek = $positifRek + $negatifRek + $netralRek;
|
||||
$totalPositif = $positifRek;
|
||||
$totalNetral = $netralRek;
|
||||
$persenPositif = $totalUlasanRek > 0 ? round(($positifRek / $totalUlasanRek) * 100) : 0;
|
||||
$persenNetral = $totalUlasanRek > 0 ? round(($netralRek / $totalUlasanRek) * 100) : 0;
|
||||
|
||||
// Isu negatif (sudah ada dari $isuUtama)
|
||||
$isuNegatif = $isuUtama;
|
||||
|
||||
// Isu netral (rule-based dari ulasan netral)
|
||||
$ulasanNetralRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'netral')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
$textNetral = strtolower(implode(' ', $ulasanNetralRek));
|
||||
$skorNetral = [];
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$skor = 0;
|
||||
foreach ($rule['keywords'] as $kw) { $skor += substr_count($textNetral, $kw); }
|
||||
$skorNetral[$kategori] = $skor;
|
||||
}
|
||||
arsort($skorNetral);
|
||||
$totalSkorNetral = array_sum($skorNetral) ?: 1;
|
||||
$isuNetral = [];
|
||||
foreach (array_slice($skorNetral, 0, 5, true) as $nama => $skor) {
|
||||
$isuNetral[] = [
|
||||
'nama' => $nama,
|
||||
'skor' => $skor,
|
||||
'persen' => round(($skor / $totalSkorNetral) * 100),
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
// Isu positif (rule-based dari ulasan positif)
|
||||
$ulasanPositifRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'positif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->pluck('ulasan_bersih')
|
||||
->toArray();
|
||||
$textPositif = strtolower(implode(' ', $ulasanPositifRek));
|
||||
$skorPositif = [];
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$skor = 0;
|
||||
foreach ($rule['keywords'] as $kw) { $skor += substr_count($textPositif, $kw); }
|
||||
$skorPositif[$kategori] = $skor;
|
||||
}
|
||||
arsort($skorPositif);
|
||||
$totalSkorPositif = array_sum($skorPositif) ?: 1;
|
||||
$isuPositif = [];
|
||||
foreach (array_slice($skorPositif, 0, 5, true) as $nama => $skor) {
|
||||
$isuPositif[] = [
|
||||
'nama' => $nama,
|
||||
'skor' => $skor,
|
||||
'persen' => round(($skor / $totalSkorPositif) * 100),
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// RETURN VIEW
|
||||
// ================================================================
|
||||
return view('dashboard', compact(
|
||||
'stats',
|
||||
'chartSentimen',
|
||||
'chartDestinasi',
|
||||
'totalPerWisata',
|
||||
'allText',
|
||||
'lastUpdate',
|
||||
'hasAnalisis',
|
||||
'destinasiList',
|
||||
'wisataList',
|
||||
'totalDestinasiAnalisis',
|
||||
'totalDestinasiBerkeluhan',
|
||||
'hasil',
|
||||
'jumlahKelasAnalisis',
|
||||
'totalHasilAnalisis',
|
||||
'evaluasi',
|
||||
'totalNegatif',
|
||||
'persenNegatif',
|
||||
'persenPositif',
|
||||
'persenNetral',
|
||||
'tingkatKepuasan',
|
||||
'labelKepuasan',
|
||||
'isuUtama',
|
||||
'isuNegatif',
|
||||
'isuNetral',
|
||||
'isuPositif',
|
||||
'isuDominan',
|
||||
'isuDominanPersen',
|
||||
'kataDominan',
|
||||
'saranPerbaikan',
|
||||
'prioritas',
|
||||
'periodeId',
|
||||
'totalPositif',
|
||||
'totalNetral',
|
||||
'periodeList',
|
||||
'periodeAktif',
|
||||
'noDataPesan',
|
||||
'currentMonth',
|
||||
'currentYear',
|
||||
))->with([
|
||||
'scraperDestinations' => $this->scraperDestinations(),
|
||||
]);
|
||||
}
|
||||
|
||||
$stopwords = [
|
||||
'yang','dan','di','ke','dari','untuk','dengan','ini','itu','tidak',
|
||||
'ada','juga','sangat','lebih','sudah','bisa','tapi','karena','pada',
|
||||
'akan','atau','saya','kami','mereka','nya','ga','gak','udah','pas',
|
||||
'kita','sih','deh','aja','ya','yg','tp','bgt','jadi','biar','kalau',
|
||||
];
|
||||
$freq = array_count_values($wordsRek);
|
||||
foreach ($stopwords as $sw) { unset($freq[$sw]); }
|
||||
foreach (array_keys($freq) as $w) {
|
||||
if (mb_strlen($w) < 3) unset($freq[$w]);
|
||||
}
|
||||
arsort($freq);
|
||||
$kataDominan = array_slice($freq, 0, 10, true);
|
||||
|
||||
$saranPerbaikan = [];
|
||||
foreach (array_slice($issueSkorAktif, 0, 3, true) as $nama => $skor) {
|
||||
$saranPerbaikan[] = [
|
||||
'nama' => 'Perbaikan ' . $nama,
|
||||
'tip' => $this->issueRules[$nama]['saran']['tip'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
$prioritas = [];
|
||||
$rank = 1;
|
||||
foreach (array_slice($issueSkorAktif, 0, 3, true) as $nama => $skor) {
|
||||
$prioritas[] = [
|
||||
'rank' => $rank++,
|
||||
'nama' => $nama,
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
'actions' => $this->issueRules[$nama]['saran']['actions'],
|
||||
'dampak' => $this->issueRules[$nama]['saran']['dampak'],
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
];
|
||||
}
|
||||
|
||||
$positifRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'positif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count();
|
||||
|
||||
$negatifRek = DB::table('hasil_analisis')
|
||||
->where('sentimen', 'negatif')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count();
|
||||
|
||||
$totalSentimenRek = DB::table('hasil_analisis')
|
||||
->when($periodeId, fn($q) => $q->where('periode_id', $periodeId))
|
||||
->when($destinasi && $destinasi != 'Semua Destinasi', fn($q) => $q->where('wisata', $destinasi))
|
||||
->count() ?: 1;
|
||||
|
||||
$totalNegatif = $negatifRek;
|
||||
$persenNegatif = round(($negatifRek / $totalSentimenRek) * 100, 2);
|
||||
$tingkatKepuasan = round(($positifRek / $totalSentimenRek) * 100);
|
||||
$labelKepuasan = match(true) {
|
||||
$tingkatKepuasan >= 80 => 'Baik',
|
||||
$tingkatKepuasan >= 60 => 'Sedang',
|
||||
default => 'Kurang',
|
||||
};
|
||||
$isuDominan = $isuUtama[0]['nama'] ?? '-';
|
||||
$isuDominanPersen = $isuUtama[0]['persen'] ?? 0;
|
||||
|
||||
// ================================================================
|
||||
// RETURN VIEW
|
||||
// ================================================================
|
||||
return view('dashboard', compact(
|
||||
'stats',
|
||||
'chartSentimen',
|
||||
'chartDestinasi',
|
||||
'totalPerWisata',
|
||||
'allText',
|
||||
'lastUpdate',
|
||||
'hasAnalisis',
|
||||
'destinasiList',
|
||||
'wisataList',
|
||||
'totalDestinasiAnalisis',
|
||||
'totalDestinasiBerkeluhan',
|
||||
'hasil',
|
||||
'jumlahKelasAnalisis',
|
||||
'totalHasilAnalisis',
|
||||
'evaluasi',
|
||||
'totalNegatif',
|
||||
'persenNegatif',
|
||||
'tingkatKepuasan',
|
||||
'labelKepuasan',
|
||||
'isuUtama',
|
||||
'isuDominan',
|
||||
'isuDominanPersen',
|
||||
'kataDominan',
|
||||
'saranPerbaikan',
|
||||
'prioritas',
|
||||
'periodeList',
|
||||
'periodeAktif',
|
||||
'noDataPesan', // ← tambahan baru
|
||||
))->with([
|
||||
'scraperDestinations' => $this->scraperDestinations(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function scraperDestinations(): array
|
||||
{
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,451 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanController extends Controller
|
||||
{
|
||||
public function downloadBulanan($periode)
|
||||
{
|
||||
$periodeData = DB::table('periode_analisis')
|
||||
->where('id', $periode)
|
||||
->first();
|
||||
|
||||
if (!$periodeData) {
|
||||
return back()->with('error', 'Periode tidak ditemukan');
|
||||
}
|
||||
|
||||
$data = $this->collectData($periode);
|
||||
|
||||
$data['periode'] = $periodeData;
|
||||
|
||||
$data['judulLaporan'] =
|
||||
'Laporan Analisis Sentimen - ' .
|
||||
($periodeData->nama ?? '-');
|
||||
|
||||
$data['evaluasi'] =
|
||||
DB::table('evaluasi_model')
|
||||
->where('periode_id', $periode)
|
||||
->orderByDesc('id')
|
||||
->first()
|
||||
?? (object)['accuracy' => 0];
|
||||
|
||||
// TOTAL ULASAN KOTOR
|
||||
$data['totalUlasanKotor'] =
|
||||
DB::table('ulasan')
|
||||
->where('periode_id', $periode)
|
||||
->count();
|
||||
|
||||
// TREND HARIAN
|
||||
$data['trendHarian'] =
|
||||
DB::table('hasil_analisis')
|
||||
->select(
|
||||
DB::raw('DATE(created_at) as tanggal'),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='positif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as positif
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='netral'
|
||||
THEN 1 ELSE 0 END
|
||||
) as netral
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='negatif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as negatif
|
||||
")
|
||||
)
|
||||
->where('periode_id', $periode)
|
||||
->groupBy(DB::raw('DATE(created_at)'))
|
||||
->orderBy(DB::raw('DATE(created_at)'))
|
||||
->get();
|
||||
|
||||
return view(
|
||||
'laporan.bulanan',
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function downloadTahunan(Request $request)
|
||||
{
|
||||
$tahun = $request->tahun;
|
||||
|
||||
$periodeList =
|
||||
DB::table('periode_analisis')
|
||||
->where('tahun', $tahun)
|
||||
->orderBy('bulan')
|
||||
->get();
|
||||
|
||||
if ($periodeList->isEmpty()) {
|
||||
|
||||
return back()->with(
|
||||
'error',
|
||||
'Tidak ada data tahun tersebut'
|
||||
);
|
||||
}
|
||||
|
||||
$periodeIds =
|
||||
$periodeList->pluck('id');
|
||||
|
||||
// TOTAL ULASAN
|
||||
$totalUlasan =
|
||||
DB::table('hasil_analisis')
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
->count();
|
||||
|
||||
// TOTAL SENTIMEN
|
||||
$positif =
|
||||
DB::table('hasil_analisis')
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'positif'
|
||||
)
|
||||
->count();
|
||||
|
||||
$netral =
|
||||
DB::table('hasil_analisis')
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'netral'
|
||||
)
|
||||
->count();
|
||||
|
||||
$negatif =
|
||||
DB::table('hasil_analisis')
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'negatif'
|
||||
)
|
||||
->count();
|
||||
|
||||
// PERSEN POSITIF
|
||||
$persenPositif =
|
||||
$totalUlasan > 0
|
||||
? round(
|
||||
($positif / $totalUlasan) * 100,
|
||||
2
|
||||
)
|
||||
: 0;
|
||||
|
||||
// AKURASI
|
||||
$akurasi =
|
||||
DB::table('evaluasi_model')
|
||||
->whereIn('periode_id', $periodeIds)
|
||||
->avg('accuracy') ?? 0;
|
||||
|
||||
|
||||
// TOTAL WISATA
|
||||
$totalWisata =
|
||||
DB::table('hasil_analisis')
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
->distinct()
|
||||
->count('wisata');
|
||||
|
||||
// REKAP BULANAN
|
||||
$rekapBulanan =
|
||||
DB::table('hasil_analisis as h')
|
||||
->join(
|
||||
'periode_analisis as p',
|
||||
'h.periode_id',
|
||||
'=',
|
||||
'p.id'
|
||||
)
|
||||
|
||||
->select(
|
||||
|
||||
'p.nama as bulan',
|
||||
|
||||
DB::raw(
|
||||
'COUNT(*) as total'
|
||||
),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='positif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as positif
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='netral'
|
||||
THEN 1 ELSE 0 END
|
||||
) as netral
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='negatif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as negatif
|
||||
")
|
||||
)
|
||||
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
|
||||
->groupBy(
|
||||
'p.nama',
|
||||
'p.bulan'
|
||||
)
|
||||
|
||||
->orderBy(
|
||||
'p.bulan'
|
||||
)
|
||||
|
||||
->get();
|
||||
|
||||
// WISATA POPULER
|
||||
$wisataPopuler =
|
||||
DB::table('hasil_analisis')
|
||||
|
||||
->select(
|
||||
|
||||
'wisata',
|
||||
|
||||
DB::raw(
|
||||
'COUNT(*) as jumlah'
|
||||
),
|
||||
|
||||
DB::raw("
|
||||
ROUND(
|
||||
(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='positif'
|
||||
THEN 1 ELSE 0 END
|
||||
)
|
||||
/
|
||||
COUNT(*)
|
||||
) * 100
|
||||
,2)
|
||||
as persen
|
||||
")
|
||||
)
|
||||
|
||||
->whereIn(
|
||||
'periode_id',
|
||||
$periodeIds
|
||||
)
|
||||
|
||||
->groupBy(
|
||||
'wisata'
|
||||
)
|
||||
|
||||
->orderByDesc(
|
||||
'persen'
|
||||
)
|
||||
|
||||
->limit(5)
|
||||
|
||||
->get();
|
||||
|
||||
return view(
|
||||
|
||||
'laporan.tahunan',
|
||||
|
||||
compact(
|
||||
|
||||
'tahun',
|
||||
'periodeList',
|
||||
'totalUlasan',
|
||||
'akurasi',
|
||||
'totalWisata',
|
||||
'rekapBulanan',
|
||||
'wisataPopuler',
|
||||
'positif',
|
||||
'netral',
|
||||
'negatif',
|
||||
'persenPositif'
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private function collectData($periodeId)
|
||||
{
|
||||
$totalUlasan =
|
||||
DB::table('hasil_analisis')
|
||||
->where(
|
||||
'periode_id',
|
||||
$periodeId
|
||||
)
|
||||
->count();
|
||||
|
||||
$totalPositif =
|
||||
DB::table('hasil_analisis')
|
||||
->where(
|
||||
'periode_id',
|
||||
$periodeId
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'positif'
|
||||
)
|
||||
->count();
|
||||
|
||||
$totalNetral =
|
||||
DB::table('hasil_analisis')
|
||||
->where(
|
||||
'periode_id',
|
||||
$periodeId
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'netral'
|
||||
)
|
||||
->count();
|
||||
|
||||
$totalNegatif =
|
||||
DB::table('hasil_analisis')
|
||||
->where(
|
||||
'periode_id',
|
||||
$periodeId
|
||||
)
|
||||
->where(
|
||||
'sentimen',
|
||||
'negatif'
|
||||
)
|
||||
->count();
|
||||
|
||||
$persen = [
|
||||
|
||||
'positif' =>
|
||||
$totalUlasan
|
||||
? round(
|
||||
($totalPositif /
|
||||
$totalUlasan) * 100,
|
||||
2
|
||||
)
|
||||
: 0,
|
||||
|
||||
'netral' =>
|
||||
$totalUlasan
|
||||
? round(
|
||||
($totalNetral /
|
||||
$totalUlasan) * 100,
|
||||
2
|
||||
)
|
||||
: 0,
|
||||
|
||||
'negatif' =>
|
||||
$totalUlasan
|
||||
? round(
|
||||
($totalNegatif /
|
||||
$totalUlasan) * 100,
|
||||
2
|
||||
)
|
||||
: 0,
|
||||
];
|
||||
|
||||
$perWisata =
|
||||
DB::table('hasil_analisis')
|
||||
|
||||
->select(
|
||||
|
||||
'wisata',
|
||||
|
||||
DB::raw(
|
||||
'COUNT(*) as total'
|
||||
),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='positif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as positif
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='netral'
|
||||
THEN 1 ELSE 0 END
|
||||
) as netral
|
||||
"),
|
||||
|
||||
DB::raw("
|
||||
SUM(
|
||||
CASE
|
||||
WHEN sentimen='negatif'
|
||||
THEN 1 ELSE 0 END
|
||||
) as negatif
|
||||
")
|
||||
)
|
||||
|
||||
->where(
|
||||
'periode_id',
|
||||
$periodeId
|
||||
)
|
||||
|
||||
->groupBy(
|
||||
'wisata'
|
||||
)
|
||||
|
||||
->orderByDesc(
|
||||
'positif'
|
||||
)
|
||||
|
||||
->get();
|
||||
|
||||
return [
|
||||
|
||||
'totalUlasan' =>
|
||||
$totalUlasan,
|
||||
|
||||
'totalPositif' =>
|
||||
$totalPositif,
|
||||
|
||||
'totalNetral' =>
|
||||
$totalNetral,
|
||||
|
||||
'totalNegatif' =>
|
||||
$totalNegatif,
|
||||
|
||||
'persen' =>
|
||||
$persen,
|
||||
|
||||
'perWisata' =>
|
||||
$perWisata,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -23,23 +23,34 @@ class RekomendasiController extends Controller
|
|||
],
|
||||
],
|
||||
'Parkir' => [
|
||||
'keywords' => ['parkir', 'lahan parkir', 'tempat parkir', 'parkiran', 'motor', 'mobil'],
|
||||
'keywords' => [
|
||||
// FIX: hapus 'motor', 'mobil', 'kendaraan' — terlalu ambigu,
|
||||
// sering muncul dalam konteks "harga tiket kendaraan" bukan keluhan parkir.
|
||||
// Hanya gunakan frasa yang secara spesifik merujuk pada area/masalah parkir.
|
||||
'parkir', 'lahan parkir', 'tempat parkir', 'parkiran',
|
||||
'bayar parkir', 'tarif parkir', 'biaya parkir',
|
||||
'jukir', 'tukang parkir', 'penjaga parkir', 'petugas parkir',
|
||||
'palak parkir', 'pungli parkir',
|
||||
],
|
||||
'color' => 'orange',
|
||||
'icon' => '🚗',
|
||||
'saran' => [
|
||||
'actions' => ['Penataan area parkir', 'Tarif transparan', 'Petugas lebih ramah'],
|
||||
'dampak' => 'Mengurangi keluhan',
|
||||
'tip' => 'Sistem parkir lebih rapi dan transparan.',
|
||||
'tip' => 'Sistem parkir lebih rapi dan tarif jelas.',
|
||||
],
|
||||
],
|
||||
'Harga / Tiket' => [
|
||||
'keywords' => ['mahal', 'harga', 'tiket', 'bayar', 'biaya', 'tarif', 'murah', 'terjangkau'],
|
||||
'keywords' => [
|
||||
'mahal', 'harga', 'tiket', 'bayar', 'biaya', 'tarif',
|
||||
'murah', 'terjangkau', 'htm', 'retribusi', 'pungli',
|
||||
],
|
||||
'color' => 'yellow',
|
||||
'icon' => '🎟️',
|
||||
'saran' => [
|
||||
'actions' => ['Evaluasi harga tiket', 'Promo wisata', 'Diskon tertentu'],
|
||||
'dampak' => 'Daya tarik meningkat',
|
||||
'tip' => 'Penyesuaian harga tiket agar lebih terjangkau.',
|
||||
'actions' => ['Evaluasi harga tiket masuk', 'Buat paket promo wisata', 'Transparansi retribusi'],
|
||||
'dampak' => 'Daya tarik wisatawan meningkat',
|
||||
'tip' => 'Penyesuaian HTM agar lebih terjangkau dan transparan.',
|
||||
],
|
||||
],
|
||||
'Fasilitas' => [
|
||||
|
|
@ -53,12 +64,12 @@ class RekomendasiController extends Controller
|
|||
],
|
||||
],
|
||||
'Keramaian' => [
|
||||
'keywords' => ['ramai', 'macet', 'antri', 'sesak', 'penuh', 'padat', 'berdesakan'],
|
||||
'keywords' => ['ramai', 'antri', 'penuh', 'sesak', 'macet', 'padat', 'berdesakan', 'keramaian', 'pengunjung banyak'],
|
||||
'color' => 'blue',
|
||||
'icon' => '👥',
|
||||
'saran' => [
|
||||
'actions' => ['Atur kapasitas pengunjung', 'Sistem antrean', 'Jam kunjungan fleksibel'],
|
||||
'dampak' => 'Pengalaman pengunjung lebih nyaman',
|
||||
'actions' => ['Terapkan sistem reservasi', 'Batasi kapasitas pengunjung', 'Tambah jalur masuk'],
|
||||
'dampak' => 'Kenyamanan kunjungan meningkat',
|
||||
'tip' => 'Manajemen kapasitas pengunjung lebih baik.',
|
||||
],
|
||||
],
|
||||
|
|
@ -72,81 +83,142 @@ public function index(Request $request)
|
|||
->distinct()
|
||||
->pluck('wisata');
|
||||
|
||||
// --- 2. Query dengan filter destinasi ---
|
||||
// --- 2. Resolve periode ---
|
||||
$periodeId = null;
|
||||
if ($request->filled('periode_id')) {
|
||||
$periodeId = (int) $request->periode_id;
|
||||
} elseif ($request->filled('periode_bulan')) {
|
||||
[$tahunParam, $bulanParam] = explode('-', $request->periode_bulan);
|
||||
$periodeRow = DB::table('periode_analisis')
|
||||
->where('bulan', (int) $bulanParam)
|
||||
->where('tahun', (int) $tahunParam)
|
||||
->first();
|
||||
$periodeId = $periodeRow?->id;
|
||||
}
|
||||
|
||||
if (!$periodeId) {
|
||||
$periodeRow = DB::table('periode_analisis')
|
||||
->where('bulan', now()->month)
|
||||
->where('tahun', now()->year)
|
||||
->first();
|
||||
$periodeId = $periodeRow?->id;
|
||||
}
|
||||
|
||||
// --- 3. Query builder ---
|
||||
$queryAll = HasilAnalisis::query();
|
||||
$queryFilter = HasilAnalisis::query();
|
||||
|
||||
if ($periodeId) {
|
||||
$queryAll->where('periode_id', $periodeId);
|
||||
$queryFilter->where('periode_id', $periodeId);
|
||||
}
|
||||
|
||||
if ($request->filled('destinasi')) {
|
||||
$queryFilter->where('wisata', $request->destinasi);
|
||||
}
|
||||
|
||||
// --- 3. Hitung total & sentimen ---
|
||||
$totalUlasan = $queryFilter->count();
|
||||
$totalNegatif = (clone $queryFilter)->where('sentimen', 'negatif')->count();
|
||||
$totalPositif = (clone $queryFilter)->where('sentimen', 'positif')->count();
|
||||
$totalNetral = (clone $queryFilter)->where('sentimen', 'netral')->count();
|
||||
// --- 4. Hitung total & sentimen ---
|
||||
$totalUlasan = $queryFilter->count();
|
||||
$totalNegatif = (clone $queryFilter)->where('sentimen', 'negatif')->count();
|
||||
$totalPositif = (clone $queryFilter)->where('sentimen', 'positif')->count();
|
||||
$totalNetral = (clone $queryFilter)->where('sentimen', 'netral')->count();
|
||||
|
||||
$persenNegatif = $totalUlasan > 0 ? round(($totalNegatif / $totalUlasan) * 100, 2) : 0;
|
||||
$tingkatKepuasan = $totalUlasan > 0 ? round(($totalPositif / $totalUlasan) * 100) : 0;
|
||||
$persenNegatif = $totalUlasan > 0 ? round(($totalNegatif / $totalUlasan) * 100, 2) : 0;
|
||||
$persenPositif = $totalUlasan > 0 ? round(($totalPositif / $totalUlasan) * 100) : 0;
|
||||
$persenNetral = $totalUlasan > 0 ? round(($totalNetral / $totalUlasan) * 100) : 0;
|
||||
$tingkatKepuasan = $persenPositif;
|
||||
|
||||
// --- 5. Statistik destinasi & periode ---
|
||||
$totalDestinasiAnalisis = (clone $queryAll)->distinct('wisata')->count('wisata');
|
||||
$totalDestinasiBerkeluhan = (clone $queryAll)->where('sentimen', 'negatif')
|
||||
->distinct('wisata')->count('wisata');
|
||||
|
||||
$periodeAktif = $periodeId
|
||||
? DB::table('periode_analisis')->find($periodeId)
|
||||
: null;
|
||||
|
||||
// Label kepuasan
|
||||
$labelKepuasan = match(true) {
|
||||
$tingkatKepuasan >= 80 => 'Baik',
|
||||
$tingkatKepuasan >= 60 => 'Sedang',
|
||||
default => 'Kurang',
|
||||
};
|
||||
|
||||
// --- 4. Ambil ulasan negatif & bersihkan teks ---
|
||||
$ulasanNegatif = (clone $queryFilter)
|
||||
->where('sentimen', 'negatif')
|
||||
->pluck('ulasan_bersih') // gunakan kolom yang sudah dipreproses
|
||||
->toArray();
|
||||
// =========================================================
|
||||
// PERBAIKAN UTAMA: Hitung isu per ulasan (bukan per keyword)
|
||||
// Logika: 1 ulasan dihitung 1x untuk setiap kategori yang
|
||||
// keyword-nya ditemukan dalam teks ulasan tersebut.
|
||||
// Persentase = jumlah_ulasan_mengandung_kategori / total_ulasan_sentimen × 100
|
||||
// =========================================================
|
||||
|
||||
$text = strtolower(implode(' ', $ulasanNegatif));
|
||||
$words = array_filter(preg_split('/\s+/', $text));
|
||||
$isuNegatif = $this->hitungIsuPerUlasan(
|
||||
(clone $queryFilter)->where('sentimen', 'negatif')->get(['ulasan_bersih', 'ulasan_asli']),
|
||||
$totalNegatif
|
||||
);
|
||||
|
||||
// --- 5. Rule-based: hitung skor tiap kategori isu ---
|
||||
$issueSkor = [];
|
||||
$issueWords = []; // kata dominan per kategori
|
||||
$isuNetral = $this->hitungIsuPerUlasan(
|
||||
(clone $queryFilter)->where('sentimen', 'netral')->get(['ulasan_bersih', 'ulasan_asli']),
|
||||
$totalNetral
|
||||
);
|
||||
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$skor = 0;
|
||||
$matchWords = [];
|
||||
$isuPositif = $this->hitungIsuPerUlasan(
|
||||
(clone $queryFilter)->where('sentimen', 'positif')->get(['ulasan_bersih', 'ulasan_asli']),
|
||||
$totalPositif
|
||||
);
|
||||
|
||||
foreach ($rule['keywords'] as $kw) {
|
||||
$count = substr_count($text, $kw);
|
||||
if ($count > 0) {
|
||||
$skor += $count;
|
||||
$matchWords[$kw] = $count;
|
||||
}
|
||||
// isuUtama = sama dengan isuNegatif (untuk kompatibilitas variabel lama)
|
||||
$isuUtama = $isuNegatif;
|
||||
|
||||
// --- 6. Isu dominan & prioritas rekomendasi ---
|
||||
if (empty($isuNegatif) || ($isuNegatif[0]['jumlah'] ?? 0) === 0) {
|
||||
$isuDominan = 'Tidak ada keluhan';
|
||||
$isuDominanPersen = 0;
|
||||
$prioritas = [];
|
||||
$saranPerbaikan = [];
|
||||
} else {
|
||||
$isuDominan = $isuNegatif[0]['nama'];
|
||||
$isuDominanPersen = $isuNegatif[0]['persen'];
|
||||
|
||||
// Prioritas: top 3 isu negatif berdasarkan jumlah ulasan
|
||||
$prioritas = [];
|
||||
$rank = 1;
|
||||
foreach (array_slice($isuNegatif, 0, 3) as $isu) {
|
||||
if ($isu['jumlah'] === 0) break;
|
||||
$nama = $isu['nama'];
|
||||
$prioritas[] = [
|
||||
'rank' => $rank++,
|
||||
'nama' => $nama,
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
'actions' => $this->issueRules[$nama]['saran']['actions'],
|
||||
'dampak' => $this->issueRules[$nama]['saran']['dampak'],
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'jumlah' => $isu['jumlah'],
|
||||
'persen' => $isu['persen'],
|
||||
];
|
||||
}
|
||||
|
||||
$issueSkor[$kategori] = $skor;
|
||||
$issueWords[$kategori] = $matchWords;
|
||||
$saranPerbaikan = [];
|
||||
foreach (array_slice($isuNegatif, 0, 3) as $isu) {
|
||||
if ($isu['jumlah'] === 0) break;
|
||||
$nama = $isu['nama'];
|
||||
$saranPerbaikan[] = [
|
||||
'nama' => 'Perbaikan ' . $nama,
|
||||
'tip' => $this->issueRules[$nama]['saran']['tip'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Urutkan berdasarkan skor tertinggi
|
||||
arsort($issueSkor);
|
||||
// --- 7. Kata kunci dominan dari ulasan negatif ---
|
||||
$ulasanNegatifTeks = (clone $queryFilter)
|
||||
->where('sentimen', 'negatif')
|
||||
->get(['ulasan_bersih', 'ulasan_asli'])
|
||||
->map(fn($r) => $r->ulasan_bersih ?? $r->ulasan_asli ?? '')
|
||||
->filter()
|
||||
->toArray();
|
||||
|
||||
$totalSkorIsu = array_sum($issueSkor) ?: 1; // hindari division by zero
|
||||
$textNegatif = strtolower(implode(' ', $ulasanNegatifTeks));
|
||||
$words = array_filter(preg_split('/\s+/', $textNegatif));
|
||||
|
||||
// --- 6. Isu utama (top 5) dengan persentase ---
|
||||
$isuUtama = [];
|
||||
foreach (array_slice($issueSkor, 0, 5, true) as $nama => $skor) {
|
||||
$isuUtama[] = [
|
||||
'nama' => $nama,
|
||||
'skor' => $skor,
|
||||
'persen' => round(($skor / $totalSkorIsu) * 100),
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
// --- 7. Isu dominan (ranking 1) ---
|
||||
$isuDominan = $isuUtama[0]['nama'] ?? 'Belum ada isu';
|
||||
$isuDominanPersen = $isuUtama[0]['persen'] ?? 0;
|
||||
|
||||
// --- 8. Kata kunci dominan (global, top 10, filter stopword) ---
|
||||
$stopwords = [
|
||||
'yang', 'dan', 'di', 'ke', 'dari', 'untuk', 'dengan',
|
||||
'ini', 'itu', 'tidak', 'ada', 'juga', 'sangat', 'lebih',
|
||||
|
|
@ -159,52 +231,34 @@ public function index(Request $request)
|
|||
foreach ($stopwords as $sw) {
|
||||
unset($freq[$sw]);
|
||||
}
|
||||
// filter kata pendek (< 3 karakter)
|
||||
foreach (array_keys($freq) as $w) {
|
||||
if (mb_strlen($w) < 3) unset($freq[$w]);
|
||||
}
|
||||
|
||||
arsort($freq);
|
||||
$kataDominan = array_slice($freq, 0, 10, true);
|
||||
|
||||
// --- 9. Prioritas rekomendasi (top 3 isu) ---
|
||||
$prioritas = [];
|
||||
$rank = 1;
|
||||
foreach (array_slice($issueSkor, 0, 3, true) as $nama => $skor) {
|
||||
$prioritas[] = [
|
||||
'rank' => $rank++,
|
||||
'nama' => $nama,
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
'actions' => $this->issueRules[$nama]['saran']['actions'],
|
||||
'dampak' => $this->issueRules[$nama]['saran']['dampak'],
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
];
|
||||
}
|
||||
|
||||
// --- 10. Saran perbaikan (top 3) ---
|
||||
$saranPerbaikan = [];
|
||||
foreach (array_slice($issueSkor, 0, 3, true) as $nama => $skor) {
|
||||
$saranPerbaikan[] = [
|
||||
'nama' => 'Perbaikan ' . $nama,
|
||||
'tip' => $this->issueRules[$nama]['saran']['tip'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
// --- 11. Filter destinasi yang sedang aktif ---
|
||||
$destinasiAktif = $request->input('destinasi', 'Semua Destinasi');
|
||||
|
||||
return view('rekomendasi.index', compact(
|
||||
'destinasiList',
|
||||
'destinasiAktif',
|
||||
'periodeId',
|
||||
'totalUlasan',
|
||||
'totalNegatif',
|
||||
'totalPositif',
|
||||
'totalNetral',
|
||||
'persenNegatif',
|
||||
'persenPositif',
|
||||
'persenNetral',
|
||||
'tingkatKepuasan',
|
||||
'labelKepuasan',
|
||||
'totalDestinasiAnalisis',
|
||||
'totalDestinasiBerkeluhan',
|
||||
'periodeAktif',
|
||||
'isuUtama',
|
||||
'isuNegatif',
|
||||
'isuNetral',
|
||||
'isuPositif',
|
||||
'isuDominan',
|
||||
'isuDominanPersen',
|
||||
'kataDominan',
|
||||
|
|
@ -212,4 +266,57 @@ public function index(Request $request)
|
|||
'prioritas',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hitung isu per ulasan — BENAR.
|
||||
*
|
||||
* Setiap ulasan hanya dihitung SATU KALI per kategori meski
|
||||
* keyword-nya muncul berkali-kali dalam satu ulasan yang sama.
|
||||
* Persentase = (jumlah ulasan mengandung kategori / total ulasan) × 100
|
||||
*
|
||||
* @param \Illuminate\Support\Collection $ulasanCollection hasil ->get(['ulasan_bersih','ulasan_asli'])
|
||||
* @param int $totalUlasan total ulasan pada sentimen yang sama
|
||||
* @return array top-5 isu, sudah diurutkan dari tertinggi
|
||||
*/
|
||||
private function hitungIsuPerUlasan($ulasanCollection, int $totalUlasan): array
|
||||
{
|
||||
// Siapkan teks tiap ulasan (fallback ke ulasan_asli jika ulasan_bersih kosong)
|
||||
$teksUlasan = $ulasanCollection
|
||||
->map(fn($r) => strtolower($r->ulasan_bersih ?? $r->ulasan_asli ?? ''))
|
||||
->filter()
|
||||
->values();
|
||||
|
||||
// Hitung berapa ulasan yang menyebut tiap kategori
|
||||
$jumlahPerKategori = [];
|
||||
foreach ($this->issueRules as $kategori => $rule) {
|
||||
$jumlah = 0;
|
||||
foreach ($teksUlasan as $teks) {
|
||||
foreach ($rule['keywords'] as $kw) {
|
||||
if (str_contains($teks, $kw)) {
|
||||
$jumlah++;
|
||||
break; // 1 ulasan dihitung 1x per kategori
|
||||
}
|
||||
}
|
||||
}
|
||||
$jumlahPerKategori[$kategori] = $jumlah;
|
||||
}
|
||||
|
||||
// Urutkan dari terbanyak
|
||||
arsort($jumlahPerKategori);
|
||||
|
||||
// Bangun array hasil top-5
|
||||
$hasil = [];
|
||||
foreach (array_slice($jumlahPerKategori, 0, 5, true) as $nama => $jumlah) {
|
||||
$persen = $totalUlasan > 0 ? round(($jumlah / $totalUlasan) * 100) : 0;
|
||||
$hasil[] = [
|
||||
'nama' => $nama,
|
||||
'jumlah' => $jumlah,
|
||||
'persen' => $persen,
|
||||
'color' => $this->issueRules[$nama]['color'],
|
||||
'icon' => $this->issueRules[$nama]['icon'],
|
||||
];
|
||||
}
|
||||
|
||||
return $hasil;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,72 +13,82 @@ class UlasanController extends Controller
|
|||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$currentMonth = now()->month;
|
||||
$currentYear = now()->year;
|
||||
|
||||
// Ambil semua periode yang punya data (ulasan atau hasil analisis)
|
||||
$periodeList = DB::table('periode_analisis as p')
|
||||
->whereExists(function ($q) {
|
||||
$q->select(DB::raw(1))
|
||||
->from('ulasan as u')
|
||||
->whereColumn('u.periode_id', 'p.id');
|
||||
$q->select(DB::raw(1))->from('ulasan as u')->whereColumn('u.periode_id', 'p.id');
|
||||
})
|
||||
->orWhereExists(function ($q) {
|
||||
$q->select(DB::raw(1))
|
||||
->from('hasil_analisis as h')
|
||||
->whereColumn('h.periode_id', 'p.id');
|
||||
$q->select(DB::raw(1))->from('hasil_analisis as h')->whereColumn('h.periode_id', 'p.id');
|
||||
})
|
||||
->orderBy('p.id', 'desc')
|
||||
->orderBy('p.tahun', 'desc')
|
||||
->orderBy('p.bulan', 'desc')
|
||||
->select('p.*')
|
||||
->get();
|
||||
|
||||
$availablePeriodeIds = $periodeList->pluck('id')->map(fn($id) => (string) $id);
|
||||
$requestedPeriodeId = $request->filled('periode_id') ? (string) $request->periode_id : null;
|
||||
$latestFilledPeriodeId = $periodeList->first()->id ?? null;
|
||||
$periodeId = $request->filled('periode_id')
|
||||
&& $availablePeriodeIds->contains($requestedPeriodeId)
|
||||
? $requestedPeriodeId
|
||||
: ($latestFilledPeriodeId ?: optional($periodeList->first())->id);
|
||||
$periodeAktif = $periodeId ? $periodeList->firstWhere('id', (int) $periodeId) : null;
|
||||
// Kalau request manual dari dropdown → pakai itu
|
||||
if ($request->filled('periode_id')) {
|
||||
$periodeId = (int) $request->periode_id;
|
||||
$periodeAktif = $periodeList->firstWhere('id', $periodeId)
|
||||
?? DB::table('periode_analisis')->find($periodeId);
|
||||
} else {
|
||||
// Cari / buat periode bulan ini (meski belum ada data → tetap tampil kosong)
|
||||
$periodeBulanIni = DB::table('periode_analisis')
|
||||
->where('bulan', $currentMonth)
|
||||
->where('tahun', $currentYear)
|
||||
->first();
|
||||
|
||||
$query = Ulasan::query();
|
||||
if (!$periodeBulanIni) {
|
||||
$periodeId = DB::table('periode_analisis')->insertGetId([
|
||||
'nama' => now()->locale('id')->isoFormat('MMMM YYYY'),
|
||||
'bulan' => $currentMonth,
|
||||
'tahun' => $currentYear,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$periodeAktif = DB::table('periode_analisis')->find($periodeId);
|
||||
} else {
|
||||
$periodeId = $periodeBulanIni->id;
|
||||
$periodeAktif = $periodeBulanIni;
|
||||
}
|
||||
}
|
||||
|
||||
// Query ulasan berdasarkan periode aktif
|
||||
$query = Ulasan::query()->where('periode_id', $periodeId);
|
||||
|
||||
// 🔍 SEARCH (ulasan + wisata)
|
||||
if ($request->filled('search')) {
|
||||
$search = $request->search;
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('ulasan', 'LIKE', "%$search%")
|
||||
->orWhere('wisata', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// 🔍 FILTER WISATA
|
||||
if ($request->filled('wisata')) {
|
||||
$query->where('wisata', 'LIKE', '%' . $request->wisata . '%');
|
||||
}
|
||||
|
||||
// ← default/reset menampilkan periode terbaru
|
||||
if ($periodeId) {
|
||||
$query->where('periode_id', $periodeId);
|
||||
}
|
||||
|
||||
$filteredQuery = clone $query;
|
||||
|
||||
$totalUlasan = (clone $filteredQuery)->count();
|
||||
$totalWisata = (clone $filteredQuery)->distinct('wisata')->count('wisata');
|
||||
$lastUpdate = (clone $filteredQuery)->latest()->value('created_at');
|
||||
$totalUlasan = (clone $filteredQuery)->count();
|
||||
$totalWisata = (clone $filteredQuery)->distinct('wisata')->count('wisata');
|
||||
$lastUpdate = (clone $filteredQuery)->latest()->value('created_at');
|
||||
|
||||
$mentah = $query->orderBy('tanggal', 'desc')->paginate(20)->withQueryString();
|
||||
|
||||
return view('ulasan.index', compact(
|
||||
'mentah',
|
||||
'totalUlasan',
|
||||
'totalWisata',
|
||||
'lastUpdate',
|
||||
'periodeList',
|
||||
'periodeId',
|
||||
'periodeAktif',
|
||||
'latestFilledPeriodeId'
|
||||
))->with([
|
||||
'scraperDestinations' => $this->scraperDestinations(),
|
||||
]);
|
||||
return view('ulasan.index', compact(
|
||||
'mentah',
|
||||
'totalUlasan',
|
||||
'totalWisata',
|
||||
'lastUpdate',
|
||||
'periodeList',
|
||||
'periodeId',
|
||||
'periodeAktif',
|
||||
'currentMonth',
|
||||
'currentYear'
|
||||
))->with(['scraperDestinations' => $this->scraperDestinations()]);
|
||||
}
|
||||
|
||||
public function riwayat()
|
||||
|
|
@ -224,72 +234,63 @@ public function importRiwayat(Request $request)
|
|||
}
|
||||
|
||||
public function ambilData(Request $request)
|
||||
{
|
||||
$this->allowLongRunningRequest();
|
||||
{
|
||||
$this->allowLongRunningRequest();
|
||||
|
||||
$validated = $request->validate([
|
||||
'periode_bulan' => ['nullable', 'date_format:Y-m'],
|
||||
'wisata' => ['nullable', 'string'],
|
||||
'redirect_to' => ['nullable', 'in:dashboard,ulasan'],
|
||||
]);
|
||||
$validated = $request->validate([
|
||||
'periode_bulan' => ['nullable', 'date_format:Y-m'],
|
||||
'wisata' => ['nullable', 'string'],
|
||||
'redirect_to' => ['nullable', 'in:dashboard,ulasan'],
|
||||
]);
|
||||
|
||||
$periodeBulan = \Carbon\Carbon::createFromFormat(
|
||||
'Y-m',
|
||||
$validated['periode_bulan'] ?? now()->format('Y-m')
|
||||
);
|
||||
$startDate = $periodeBulan->copy()->startOfMonth()->toDateString();
|
||||
$endDate = $periodeBulan->copy()->endOfMonth()->toDateString();
|
||||
$periodeBulan = \Carbon\Carbon::createFromFormat(
|
||||
'Y-m',
|
||||
$validated['periode_bulan'] ?? now()->format('Y-m')
|
||||
);
|
||||
$startDate = $periodeBulan->copy()->startOfMonth()->toDateString();
|
||||
$endDate = $periodeBulan->copy()->endOfMonth()->toDateString();
|
||||
|
||||
$scrapingArguments = [
|
||||
'--start-date', $startDate,
|
||||
'--end-date', $endDate,
|
||||
];
|
||||
$scrapingArguments = [
|
||||
'--start-date', $startDate,
|
||||
'--end-date', $endDate,
|
||||
];
|
||||
|
||||
if (!empty($validated['wisata'])) {
|
||||
$scrapingArguments[] = '--wisata';
|
||||
$scrapingArguments[] = $validated['wisata'];
|
||||
}
|
||||
if (!empty($validated['wisata'])) {
|
||||
$scrapingArguments[] = '--wisata';
|
||||
$scrapingArguments[] = $validated['wisata'];
|
||||
}
|
||||
|
||||
$scraping = $this->runPythonScript(base_path('scraper/scraping_pipeline.py'), 1800, $scrapingArguments);
|
||||
$scraping = $this->runPythonScript(base_path('scraper/scraping_pipeline.py'), 1800, $scrapingArguments);
|
||||
|
||||
if (!$scraping['success']) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Scraping gagal: ' . $scraping['output']);
|
||||
}
|
||||
if (!$scraping['success']) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Scraping gagal: ' . $scraping['output']);
|
||||
}
|
||||
|
||||
$periode = DB::table('periode_analisis')
|
||||
->where('bulan', \Carbon\Carbon::parse($startDate)->month)
|
||||
->where('tahun', \Carbon\Carbon::parse($startDate)->year)
|
||||
->first();
|
||||
// ✅ FIX: Ambil periode_id dari DB setelah scraping selesai
|
||||
$periode = DB::table('periode_analisis')
|
||||
->where('bulan', $periodeBulan->month)
|
||||
->where('tahun', $periodeBulan->year)
|
||||
->first();
|
||||
|
||||
$analisisArguments = $periode ? ['--periode-id', (string) $periode->id] : [];
|
||||
$analisis = $this->runPythonScript(base_path('scraper/analisis.py'), 900, $analisisArguments);
|
||||
$lokasiLabel = empty($validated['wisata']) ? 'semua lokasi' : $validated['wisata'];
|
||||
$redirectParameters = [
|
||||
'periode_id' => $periode->id ?? null,
|
||||
];
|
||||
|
||||
if (!$analisis['success']) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Analisis gagal: ' . $analisis['output']);
|
||||
}
|
||||
if (!empty($validated['wisata'])) {
|
||||
$redirectParameters['wisata'] = $validated['wisata'];
|
||||
}
|
||||
|
||||
$lokasiLabel = empty($validated['wisata']) ? 'semua lokasi' : $validated['wisata'];
|
||||
$redirectParameters = [
|
||||
'periode_id' => $periode->id ?? null,
|
||||
];
|
||||
if (($validated['redirect_to'] ?? 'ulasan') === 'ulasan') {
|
||||
return redirect()->route('ulasan.index', array_filter($redirectParameters))
|
||||
->with('success', 'Data berhasil diambil untuk ' . $lokasiLabel . ' periode ' . $periodeBulan->translatedFormat('F Y') . '.');
|
||||
}
|
||||
|
||||
if (!empty($validated['wisata'])) {
|
||||
$redirectParameters['wisata'] = $validated['wisata'];
|
||||
}
|
||||
$redirectParameters['tab'] = 'analisis';
|
||||
|
||||
if (($validated['redirect_to'] ?? 'dashboard') === 'ulasan') {
|
||||
return redirect()->route('ulasan.index', array_filter($redirectParameters))
|
||||
->with('success', 'Data berhasil diambil dan dianalisis untuk ' . $lokasiLabel . ' periode ' . $periodeBulan->translatedFormat('F Y') . '.');
|
||||
}
|
||||
|
||||
if (!empty($validated['wisata'])) {
|
||||
$redirectParameters['tab'] = 'analisis';
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard', array_filter($redirectParameters))
|
||||
->with('success', 'Data berhasil diambil dan dianalisis untuk ' . $lokasiLabel . ' periode ' . $periodeBulan->translatedFormat('F Y') . '.');
|
||||
return redirect()->route('dashboard', array_filter($redirectParameters))
|
||||
->with('success', 'Scraping berhasil untuk ' . $lokasiLabel . ' periode ' . $periodeBulan->translatedFormat('F Y') . '. Silakan jalankan proses analisis.');
|
||||
}
|
||||
|
||||
public function kosongkanPeriode(Request $request)
|
||||
|
|
@ -308,37 +309,64 @@ public function kosongkanPeriode(Request $request)
|
|||
->with('success', 'Data ulasan, hasil analisis, dan evaluasi untuk periode ini sudah dikosongkan.');
|
||||
}
|
||||
|
||||
public function analisisData(Request $request)
|
||||
{
|
||||
$this->allowLongRunningRequest();
|
||||
public function analisisData(Request $request)
|
||||
{
|
||||
$this->allowLongRunningRequest();
|
||||
|
||||
$periodeId = $request->input('periode_id')
|
||||
?: DB::table('ulasan')->max('periode_id');
|
||||
$periodeId = $request->input('periode_id')
|
||||
?: DB::table('ulasan')->max('periode_id');
|
||||
|
||||
if (!$periodeId) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Analisis gagal: belum ada ulasan. Jalankan Ambil Data terlebih dahulu.');
|
||||
}
|
||||
|
||||
$totalUlasan = DB::table('ulasan')->where('periode_id', $periodeId)->count();
|
||||
if ($totalUlasan === 0) {
|
||||
return redirect()->route('ulasan.index', ['periode_id' => $periodeId])
|
||||
->with('error', 'Analisis gagal: belum ada ulasan pada periode yang dipilih.');
|
||||
}
|
||||
|
||||
$analisis = $this->runPythonScript(base_path('scraper/analisis.py'), 900, [
|
||||
'--periode-id', (string) $periodeId,
|
||||
]);
|
||||
|
||||
if (!$analisis['success']) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Analisis gagal: ' . $analisis['output']);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard', ['periode_id' => $periodeId, 'tab' => 'analisis'])
|
||||
->with('success', 'Analisis berhasil dijalankan.');
|
||||
if (!$periodeId) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Analisis gagal: belum ada ulasan. Jalankan Ambil Data terlebih dahulu.');
|
||||
}
|
||||
|
||||
$totalUlasan = DB::table('ulasan')
|
||||
->where('periode_id', $periodeId)
|
||||
->count();
|
||||
|
||||
if ($totalUlasan === 0) {
|
||||
return redirect()->route('ulasan.index', ['periode_id' => $periodeId])
|
||||
->with('error', 'Analisis gagal: belum ada ulasan pada periode yang dipilih.');
|
||||
}
|
||||
|
||||
// Cek apakah masih ada ulasan baru yang belum dianalisis
|
||||
$totalUlasanBaru = DB::table('ulasan as u')
|
||||
->where('u.periode_id', $periodeId)
|
||||
->whereNotNull('u.ulasan')
|
||||
->whereRaw("TRIM(u.ulasan) != ''")
|
||||
->whereRaw("TRIM(u.ulasan) != '0'")
|
||||
->where('u.ulasan', 'not like', '%[Tanpa teks]%')
|
||||
->whereRaw("CHAR_LENGTH(TRIM(u.ulasan)) >= 3")
|
||||
->whereNotExists(function ($q) {
|
||||
$q->select(DB::raw(1))
|
||||
->from('hasil_analisis as h')
|
||||
->whereColumn('h.ulasan_id', 'u.id');
|
||||
})
|
||||
->count();
|
||||
|
||||
if ($totalUlasanBaru === 0) {
|
||||
return redirect()->route('dashboard', [
|
||||
'periode_id' => $periodeId,
|
||||
'tab' => 'analisis'
|
||||
])->with('error', 'Tidak ada data baru yang dapat dianalisis. Semua ulasan pada periode ini sudah dianalisis atau tidak memiliki teks ulasan yang layak dianalisis.');
|
||||
}
|
||||
|
||||
$analisis = $this->runPythonScript(base_path('scraper/analisis.py'), 900, [
|
||||
'--periode-id', (string) $periodeId,
|
||||
]);
|
||||
|
||||
if (!$analisis['success']) {
|
||||
return redirect()->route('ulasan.index')
|
||||
->with('error', 'Analisis gagal: ' . $analisis['output']);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard', [
|
||||
'periode_id' => $periodeId,
|
||||
'tab' => 'analisis'
|
||||
])->with('success', $totalUlasanBaru . ' ulasan baru berhasil dianalisis.');
|
||||
}
|
||||
|
||||
// private function runPythonScript(string $scriptPath, int $timeout, array $arguments = []): array
|
||||
// {
|
||||
// $this->allowLongRunningRequest();
|
||||
|
|
@ -386,6 +414,18 @@ private function runPythonScript(string $scriptPath, int $timeout, array $argume
|
|||
'TMP' => getenv('TMP') ?: 'C:\\Users\\Mufrida Farah\\AppData\\Local\\Temp',
|
||||
]);
|
||||
|
||||
// $envVars = array_merge($_SERVER, $_ENV, array_filter([
|
||||
// 'PATH' => getenv('PATH') ?: '/usr/bin:/usr/local/bin:/bin',
|
||||
// 'HOME' => getenv('HOME') ?: (getenv('USERPROFILE') ?: null),
|
||||
// 'TEMP' => getenv('TEMP') ?: (getenv('TMP') ?: sys_get_temp_dir()),
|
||||
// 'TMP' => getenv('TMP') ?: (getenv('TEMP') ?: sys_get_temp_dir()),
|
||||
// // Windows only — diisi kalau ada, di Linux otomatis null (dibuang array_filter)
|
||||
// 'SystemRoot' => getenv('SystemRoot') ?: null,
|
||||
// 'windir' => getenv('windir') ?: null,
|
||||
// 'USERPROFILE' => getenv('USERPROFILE') ?: null,
|
||||
// 'LOCALAPPDATA' => getenv('LOCALAPPDATA') ?: null,
|
||||
// ]));
|
||||
|
||||
// 3. Masukkan $envVars ke parameter ketiga Process
|
||||
$process = new Process(array_merge([$pythonPath, $scriptPath], $arguments), base_path(), $envVars);
|
||||
$process->setTimeout($timeout);
|
||||
|
|
|
|||
|
|
@ -101,23 +101,23 @@ public function destroy(int $id)
|
|||
->with('success', 'Pengguna berhasil dihapus.');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'role' => 'required|in:admin,staff',
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|email|unique:users,email',
|
||||
'role' => 'required|in:admin,staff',
|
||||
'password' => 'required|min:8|confirmed',
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'role' => $request->role,
|
||||
'password' => bcrypt($request->password),
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'role' => $request->role,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
|
||||
return redirect()->route('kelola-pengguna.index')
|
||||
->with('success', 'Pengguna berhasil ditambahkan.');
|
||||
return redirect()->back()->with('success', 'Pengguna berhasil ditambahkan.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,6 +7,9 @@
|
|||
class HasilAnalisis extends Model
|
||||
{
|
||||
protected $table = 'hasil_analisis';
|
||||
protected static function booted(){
|
||||
|
||||
}
|
||||
|
||||
protected $fillable = [
|
||||
'wisata',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PeriodeAnalisis extends Model
|
||||
{
|
||||
protected $table = 'periode_analisis';
|
||||
|
||||
protected $fillable = [
|
||||
'nama',
|
||||
'bulan',
|
||||
'tahun'
|
||||
];
|
||||
}
|
||||
|
|
@ -3,25 +3,28 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Auth\Notifications\ResetPassword;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
Paginator::useTailwind();
|
||||
\Carbon\Carbon::setLocale('id');
|
||||
//
|
||||
}
|
||||
{
|
||||
ResetPassword::toMailUsing(function ($notifiable, string $token) {
|
||||
|
||||
$url = url(route(
|
||||
'password.reset',
|
||||
[
|
||||
'token' => $token,
|
||||
'email' => $notifiable->getEmailForPasswordReset(),
|
||||
],
|
||||
false
|
||||
));
|
||||
|
||||
return (new \Illuminate\Notifications\Messages\MailMessage)
|
||||
->subject('Reset Password SENTARA')
|
||||
->view('emails.reset-password', [
|
||||
'actionUrl' => $url
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"model": "ComplementNB (Naive Bayes)",
|
||||
"best_params": {
|
||||
"clf__alpha": 0.1,
|
||||
"clf__norm": true,
|
||||
"tfidf__min_df": 3,
|
||||
"tfidf__ngram_range": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"tfidf__sublinear_tf": false
|
||||
},
|
||||
"cv_macro_f1": {
|
||||
"mean": 0.3964,
|
||||
"std": 0.0414
|
||||
},
|
||||
"evaluasi_test": {
|
||||
"accuracy": 0.7143,
|
||||
"macro_f1": 0.6746
|
||||
},
|
||||
"distribusi_label": {
|
||||
"positif": 19,
|
||||
"netral": 11,
|
||||
"negatif": 4
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
|
@ -3,13 +3,18 @@
|
|||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"framework"
|
||||
],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"laravel/framework": "^12.0",
|
||||
"barryvdh/laravel-dompdf": "^3.1",
|
||||
"laravel/framework": "^11.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"maatwebsite/excel": "^3.1"
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"nesbot/carbon": "^3.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// ── STEP 1: Seragamkan tipe data ──
|
||||
Schema::table('ulasan', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('id')->change();
|
||||
$table->unsignedBigInteger('periode_id')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('hasil_analisis', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('periode_id')->nullable()->change();
|
||||
$table->unsignedBigInteger('ulasan_id')->nullable()->change();
|
||||
});
|
||||
|
||||
Schema::table('evaluasi_model', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('periode_id')->nullable()->change();
|
||||
});
|
||||
|
||||
// ── STEP 2: Tambah foreign key ──
|
||||
Schema::table('ulasan', function (Blueprint $table) {
|
||||
$table->foreign('periode_id')
|
||||
->references('id')
|
||||
->on('periode_analisis')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
Schema::table('hasil_analisis', function (Blueprint $table) {
|
||||
$table->foreign('periode_id')
|
||||
->references('id')
|
||||
->on('periode_analisis')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('ulasan_id')
|
||||
->references('id')
|
||||
->on('ulasan')
|
||||
->onDelete('set null');
|
||||
});
|
||||
|
||||
Schema::table('evaluasi_model', function (Blueprint $table) {
|
||||
$table->foreign('periode_id')
|
||||
->references('id')
|
||||
->on('periode_analisis')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('ulasan', function (Blueprint $table) {
|
||||
$table->dropForeign(['periode_id']);
|
||||
});
|
||||
|
||||
Schema::table('hasil_analisis', function (Blueprint $table) {
|
||||
$table->dropForeign(['periode_id']);
|
||||
$table->dropForeign(['ulasan_id']);
|
||||
});
|
||||
|
||||
Schema::table('evaluasi_model', function (Blueprint $table) {
|
||||
$table->dropForeign(['periode_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "SistemAnalisisSentimen",
|
||||
"dependencies": {
|
||||
"chart.js": "^4.5.1"
|
||||
},
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
|
|
@ -9,15 +9,13 @@
|
|||
$evaluasiTersedia = $evaluasi && $jumlahKelasAnalisis >= 2;
|
||||
@endphp
|
||||
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-4">
|
||||
|
||||
{{-- ================= HEADER ================= --}}
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold">Hasil Analisis Sentimen</h2>
|
||||
<p class="text-gray-500 text-sm">
|
||||
Evaluasi memakai pseudo-label dari rating/rule otomatis, bukan anotasi manual.
|
||||
</p>
|
||||
|
||||
@if($totalHasilAnalisis > 0 && !$evaluasiTersedia)
|
||||
<p class="text-sm text-yellow-700 bg-yellow-50 border border-yellow-200 rounded-lg px-3 py-2 mt-3">
|
||||
Semua hasil hanya memiliki {{ $jumlahKelasAnalisis }} kelas sentimen. Precision, recall, F1, dan akurasi tidak dihitung karena evaluasi klasifikasi membutuhkan minimal 2 kelas. Detail hasil analisis tetap ditampilkan di bawah.
|
||||
|
|
@ -59,111 +57,49 @@
|
|||
|
||||
</div>
|
||||
|
||||
{{-- ================= MATRIX + PERFORMA ================= --}}
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
|
||||
{{-- CONFUSION MATRIX --}}
|
||||
<div class="bg-white p-6 rounded-xl shadow">
|
||||
<h3 class="font-semibold mb-4">Confusion Matrix</h3>
|
||||
<p class="text-xs text-gray-500 mb-3">
|
||||
Kolom tp/tn/fp/fn sederhana tidak representatif untuk 3 kelas, sehingga disimpan 0.
|
||||
</p>
|
||||
|
||||
<table class="w-full text-center border rounded-lg overflow-hidden">
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Positif</th>
|
||||
<th>Negatif</th>
|
||||
<th>Netral</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="bg-gray-50">Positif</th>
|
||||
<td class="bg-green-100">{{ $evaluasi->tp ?? 0 }}</td>
|
||||
<td class="bg-red-100">{{ $evaluasi->fp ?? 0 }}</td>
|
||||
<td class="bg-yellow-100">{{ $evaluasi->fn ?? 0 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-gray-50">Negatif</th>
|
||||
<td class="bg-red-100">{{ $evaluasi->fp ?? 0 }}</td>
|
||||
<td class="bg-green-100">{{ $evaluasi->tn ?? 0 }}</td>
|
||||
<td class="bg-yellow-100">0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="bg-gray-50">Netral</th>
|
||||
<td class="bg-yellow-100">0</td>
|
||||
<td class="bg-yellow-100">0</td>
|
||||
<td class="bg-green-100">0</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{{-- PERFORMA --}}
|
||||
<div class="bg-white p-6 rounded-xl shadow">
|
||||
<h3 class="font-semibold mb-4">Performa per Kelas</h3>
|
||||
|
||||
<table class="w-full text-sm border">
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
<th>Kelas</th>
|
||||
<th>Precision</th>
|
||||
<th>Recall</th>
|
||||
<th>F1</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-green-600 font-semibold">Positif</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-red-600 font-semibold">Negatif</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-yellow-600 font-semibold">Netral</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-' }}</td>
|
||||
<td>{{ $evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- ================= FILTER ================= --}}
|
||||
<form id="filter-form" class="flex items-center gap-3">
|
||||
<div class="flex items-end gap-3 mb-4">
|
||||
|
||||
<form id="filter-form"
|
||||
method="GET"
|
||||
action="{{ route('dashboard') }}"
|
||||
class="flex items-end gap-2">
|
||||
|
||||
<input type="hidden" name="tab" value="analisis">
|
||||
@if(($periodeAktif->id ?? request('periode_id')))
|
||||
<input type="hidden" name="periode_id" value="{{ $periodeAktif->id ?? request('periode_id') }}">
|
||||
@endif
|
||||
<input type="hidden" name="periode_id"
|
||||
value="{{ $periodeAktif->id ?? '' }}">
|
||||
|
||||
<select
|
||||
name="wisata"
|
||||
class="border rounded px-3 py-2 h-[46px]">
|
||||
|
||||
<select name="wisata" class="border rounded pl-3 pr-9 py-2 min-w-[220px]">
|
||||
<option value="">Semua Destinasi</option>
|
||||
@foreach(($wisataList ?? collect()) as $wisata)
|
||||
<option value="{{ $wisata }}" {{ request('wisata') == $wisata ? 'selected' : '' }}>
|
||||
{{ $wisata }}
|
||||
|
||||
@foreach($wisataList as $item)
|
||||
<option value="{{ $item }}"
|
||||
{{ request('wisata') == $item ? 'selected' : '' }}>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
|
||||
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded">
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-600 text-white px-4 rounded h-[46px]">
|
||||
Filter
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{{-- ================= TABLE ================= --}}
|
||||
<div class="bg-white rounded-xl shadow p-4">
|
||||
<div class="bg-white rounded-xl shadow p-4 h-fit">
|
||||
|
||||
<h3 class="font-semibold mb-4">Detail Hasil Analisis Sentimen</h3>
|
||||
|
||||
|
|
@ -180,7 +116,7 @@
|
|||
</thead>
|
||||
|
||||
<tbody>
|
||||
@forelse($hasil as $item)
|
||||
@forelse($hasil as $item)
|
||||
<tr class="border-b">
|
||||
<td>{{ ($hasil->currentPage() - 1) * $hasil->perPage() + $loop->iteration }}</td>
|
||||
<td>{{ $item->wisata }}</td>
|
||||
|
|
|
|||
|
|
@ -2,553 +2,70 @@
|
|||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Lupa Password - SENTARA</title>
|
||||
|
||||
@vite(['resources/css/app.css','resources/js/app.js'])
|
||||
|
||||
<style>
|
||||
body{
|
||||
background:#f5f7fb;
|
||||
font-family:'Poppins', sans-serif;
|
||||
}
|
||||
|
||||
.main-wrapper{
|
||||
min-height:100vh;
|
||||
padding:40px 20px;
|
||||
position:relative;
|
||||
overflow:hidden;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
}
|
||||
|
||||
/* BACKGROUND */
|
||||
.circle-top{
|
||||
position:absolute;
|
||||
top:-120px;
|
||||
right:-120px;
|
||||
width:350px;
|
||||
height:350px;
|
||||
background:#edf3ff;
|
||||
border-radius:50%;
|
||||
z-index:0;
|
||||
}
|
||||
|
||||
.circle-bottom{
|
||||
position:absolute;
|
||||
bottom:-150px;
|
||||
left:-150px;
|
||||
width:320px;
|
||||
height:320px;
|
||||
background:#edf3ff;
|
||||
border-radius:50%;
|
||||
z-index:0;
|
||||
}
|
||||
|
||||
.content{
|
||||
position:relative;
|
||||
z-index:2;
|
||||
width:100%;
|
||||
max-width:950px;
|
||||
}
|
||||
|
||||
/* CARD */
|
||||
.card-box{
|
||||
background:#fff;
|
||||
border-radius:26px;
|
||||
padding:50px;
|
||||
box-shadow:0 10px 35px rgba(0,0,0,0.06);
|
||||
}
|
||||
|
||||
/* ICON */
|
||||
.icon-wrapper{
|
||||
width:110px;
|
||||
height:110px;
|
||||
background:#edf3ff;
|
||||
border-radius:50%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
margin:0 auto 25px;
|
||||
}
|
||||
|
||||
/* TITLE */
|
||||
.title{
|
||||
text-align:center;
|
||||
font-size:54px;
|
||||
font-weight:700;
|
||||
color:#0d1b52;
|
||||
line-height:1.2;
|
||||
}
|
||||
|
||||
.subtitle{
|
||||
text-align:center;
|
||||
font-size:22px;
|
||||
color:#475569;
|
||||
margin-top:18px;
|
||||
line-height:1.7;
|
||||
}
|
||||
|
||||
.subtitle span{
|
||||
color:#2563eb;
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
/* ALERT */
|
||||
.info-box{
|
||||
margin-top:35px;
|
||||
background:#f4f8ff;
|
||||
border:1px solid #dbeafe;
|
||||
border-radius:18px;
|
||||
padding:22px 24px;
|
||||
display:flex;
|
||||
align-items:flex-start;
|
||||
gap:16px;
|
||||
}
|
||||
|
||||
.info-box p{
|
||||
color:#334155;
|
||||
font-size:18px;
|
||||
line-height:1.6;
|
||||
}
|
||||
|
||||
/* SECTION */
|
||||
.section-title{
|
||||
display:flex;
|
||||
align-items:center;
|
||||
gap:12px;
|
||||
margin-top:45px;
|
||||
margin-bottom:30px;
|
||||
}
|
||||
|
||||
.section-title h2{
|
||||
font-size:34px;
|
||||
font-weight:700;
|
||||
color:#0d1b52;
|
||||
}
|
||||
|
||||
/* STEP */
|
||||
.step{
|
||||
display:flex;
|
||||
gap:20px;
|
||||
margin-bottom:28px;
|
||||
}
|
||||
|
||||
.step-number{
|
||||
min-width:52px;
|
||||
height:52px;
|
||||
background:#2563eb;
|
||||
color:#fff;
|
||||
border-radius:50%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
font-weight:700;
|
||||
font-size:22px;
|
||||
}
|
||||
|
||||
.step-content h3{
|
||||
font-size:28px;
|
||||
font-weight:700;
|
||||
color:#0f172a;
|
||||
margin-bottom:6px;
|
||||
}
|
||||
|
||||
.step-content p{
|
||||
color:#475569;
|
||||
font-size:20px;
|
||||
line-height:1.7;
|
||||
}
|
||||
|
||||
/* CONTACT */
|
||||
.contact-box{
|
||||
margin-top:40px;
|
||||
background:#f8fbff;
|
||||
border:1px solid #e2e8f0;
|
||||
border-radius:22px;
|
||||
padding:32px;
|
||||
}
|
||||
|
||||
.contact-header{
|
||||
display:flex;
|
||||
align-items:center;
|
||||
gap:18px;
|
||||
margin-bottom:18px;
|
||||
}
|
||||
|
||||
.contact-icon{
|
||||
width:70px;
|
||||
height:70px;
|
||||
background:#edf3ff;
|
||||
border-radius:50%;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
}
|
||||
|
||||
.contact-header h3{
|
||||
font-size:30px;
|
||||
font-weight:700;
|
||||
color:#2563eb;
|
||||
}
|
||||
|
||||
.contact-header p{
|
||||
font-size:18px;
|
||||
color:#475569;
|
||||
margin-top:4px;
|
||||
}
|
||||
|
||||
.contact-list{
|
||||
display:flex;
|
||||
flex-wrap:wrap;
|
||||
gap:24px;
|
||||
align-items:center;
|
||||
margin-top:18px;
|
||||
padding-left:88px;
|
||||
}
|
||||
|
||||
.contact-item{
|
||||
display:flex;
|
||||
align-items:center;
|
||||
gap:12px;
|
||||
font-size:22px;
|
||||
font-weight:600;
|
||||
color:#0f172a;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
.footer{
|
||||
display:flex;
|
||||
justify-content:space-between;
|
||||
margin-top:28px;
|
||||
color:#64748b;
|
||||
font-size:18px;
|
||||
padding:0 8px;
|
||||
}
|
||||
|
||||
/* MOBILE */
|
||||
@media(max-width:768px){
|
||||
|
||||
.main-wrapper{
|
||||
padding:20px 14px;
|
||||
}
|
||||
|
||||
.card-box{
|
||||
padding:28px 22px;
|
||||
border-radius:22px;
|
||||
}
|
||||
|
||||
.icon-wrapper{
|
||||
width:90px;
|
||||
height:90px;
|
||||
}
|
||||
|
||||
.title{
|
||||
font-size:36px;
|
||||
}
|
||||
|
||||
.subtitle{
|
||||
font-size:17px;
|
||||
line-height:1.7;
|
||||
}
|
||||
|
||||
.info-box{
|
||||
padding:18px;
|
||||
}
|
||||
|
||||
.info-box p{
|
||||
font-size:15px;
|
||||
}
|
||||
|
||||
.section-title h2{
|
||||
font-size:25px;
|
||||
}
|
||||
|
||||
.step{
|
||||
gap:14px;
|
||||
}
|
||||
|
||||
.step-number{
|
||||
min-width:42px;
|
||||
height:42px;
|
||||
font-size:18px;
|
||||
}
|
||||
|
||||
.step-content h3{
|
||||
font-size:21px;
|
||||
}
|
||||
|
||||
.step-content p{
|
||||
font-size:15px;
|
||||
}
|
||||
|
||||
.contact-box{
|
||||
padding:22px;
|
||||
}
|
||||
|
||||
.contact-header{
|
||||
align-items:flex-start;
|
||||
}
|
||||
|
||||
.contact-header h3{
|
||||
font-size:24px;
|
||||
}
|
||||
|
||||
.contact-header p{
|
||||
font-size:15px;
|
||||
}
|
||||
|
||||
.contact-list{
|
||||
padding-left:0;
|
||||
flex-direction:column;
|
||||
align-items:flex-start;
|
||||
gap:18px;
|
||||
}
|
||||
|
||||
.contact-item{
|
||||
font-size:16px;
|
||||
word-break:break-word;
|
||||
}
|
||||
|
||||
.footer{
|
||||
flex-direction:column;
|
||||
gap:10px;
|
||||
text-align:center;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</head>
|
||||
<body class="bg-gray-100 min-h-screen flex items-center justify-center p-6">
|
||||
|
||||
<body>
|
||||
<div class="bg-white shadow-2xl rounded-3xl overflow-hidden grid md:grid-cols-2 max-w-5xl w-full">
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="bg-blue-700 text-white p-10 flex flex-col justify-center">
|
||||
<img src="{{ asset('images/logo-sentara.png') }}" class="w-48 mb-8">
|
||||
|
||||
<div class="circle-top"></div>
|
||||
<div class="circle-bottom"></div>
|
||||
<h1 class="text-3xl font-bold mb-4">
|
||||
Lupa Password?
|
||||
</h1>
|
||||
|
||||
<div class="content">
|
||||
<p class="text-blue-100 leading-relaxed">
|
||||
Masukkan email akun Anda untuk menerima link reset password.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- CARD -->
|
||||
<div class="card-box">
|
||||
<div class="p-10">
|
||||
|
||||
<!-- ICON -->
|
||||
<div class="icon-wrapper">
|
||||
<h2 class="text-2xl font-bold text-gray-800 mb-2">
|
||||
Reset Password
|
||||
</h2>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="55"
|
||||
height="55"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
<p class="text-gray-500 mb-8">
|
||||
Kami akan mengirim link reset password ke email Anda.
|
||||
</p>
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M16 11V7a4 4 0 10-8 0v4m-2 0h12a2 2 0 012 2v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5a2 2 0 012-2z"/>
|
||||
@if (session('status'))
|
||||
<div class="bg-green-100 text-green-700 p-4 rounded-xl mb-6">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<circle cx="18.5" cy="18.5" r="3.5" stroke="#2563eb"/>
|
||||
<path d="M18.5 17v3M17 18.5h3" stroke="#2563eb"/>
|
||||
</svg>
|
||||
<form method="POST" action="{{ route('password.email') }}">
|
||||
@csrf
|
||||
|
||||
<div class="mb-6">
|
||||
<label class="block mb-2 font-medium text-gray-700">
|
||||
Email
|
||||
</label>
|
||||
|
||||
<input
|
||||
type="email"
|
||||
name="email"
|
||||
class="w-full border rounded-xl px-4 py-3 focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
placeholder="contoh@email.com"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
|
||||
<!-- TITLE -->
|
||||
<h1 class="title">
|
||||
Lupa Password?
|
||||
</h1>
|
||||
<button
|
||||
type="submit"
|
||||
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 rounded-xl transition"
|
||||
>
|
||||
Kirim Link Reset
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="subtitle">
|
||||
Untuk keamanan akun, pengaturan ulang password hanya dapat dilakukan
|
||||
<br>
|
||||
<span>oleh Administrator.</span>
|
||||
</p>
|
||||
|
||||
<!-- INFO -->
|
||||
<div class="info-box">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="34"
|
||||
height="34"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<path d="M12 16v-4"/>
|
||||
<path d="M12 8h.01"/>
|
||||
|
||||
</svg>
|
||||
|
||||
<p>
|
||||
Silakan hubungi Administrator sistem untuk memperbarui password akun Anda.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- SECTION TITLE -->
|
||||
<div class="section-title">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="40"
|
||||
height="40"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M17 20h5V4H2v16h5"/>
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M9 20h6"/>
|
||||
<circle cx="12" cy="8" r="3"/>
|
||||
<path d="M7 16c1.333-2 3-3 5-3s3.667 1 5 3"/>
|
||||
|
||||
</svg>
|
||||
|
||||
<h2>Cara Memperbarui Password</h2>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- STEP -->
|
||||
<div class="step">
|
||||
|
||||
<div class="step-number">1</div>
|
||||
|
||||
<div class="step-content">
|
||||
<h3>Hubungi Administrator</h3>
|
||||
<p>
|
||||
Sampaikan kepada Administrator bahwa Anda lupa password akun SENTARA.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
|
||||
<div class="step-number">2</div>
|
||||
|
||||
<div class="step-content">
|
||||
<h3>Verifikasi Identitas</h3>
|
||||
<p>
|
||||
Administrator akan memverifikasi identitas Anda sebagai pengguna sistem.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
|
||||
<div class="step-number">3</div>
|
||||
|
||||
<div class="step-content">
|
||||
<h3>Password Baru</h3>
|
||||
<p>
|
||||
Administrator akan membuat password baru dan memberikannya kepada Anda.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- CONTACT -->
|
||||
<div class="contact-box">
|
||||
|
||||
<div class="contact-header">
|
||||
|
||||
<div class="contact-icon">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="38"
|
||||
height="38"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M18 10c0 3.866-3.582 7-8 7a8.841 8.841 0 01-4-.917L2 17l1.083-3.25A6.963 6.963 0 012 10c0-3.866 3.582-7 8-7s8 3.134 8 7z"/>
|
||||
|
||||
<path d="M15 8h.01"/>
|
||||
<path d="M9 8h.01"/>
|
||||
<path d="M8 12c1 1 2 1.5 4 1.5s3-.5 4-1.5"/>
|
||||
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>Kontak Administrator</h3>
|
||||
<p>
|
||||
Silakan hubungi administrator melalui kontak resmi berikut:
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="contact-list">
|
||||
|
||||
<!-- PHONE -->
|
||||
<div class="contact-item">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="26"
|
||||
height="26"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M3 5a2 2 0 012-2h2.28a2 2 0 011.94 1.515l.57 2.28a2 2 0 01-.45 1.91l-1.27 1.27a16 16 0 006.59 6.59l1.27-1.27a2 2 0 011.91-.45l2.28.57A2 2 0 0121 16.72V19a2 2 0 01-2 2h-1C9.163 21 3 14.837 3 7V5z"/>
|
||||
|
||||
</svg>
|
||||
|
||||
0881-0267-1527
|
||||
|
||||
</div>
|
||||
|
||||
<!-- EMAIL -->
|
||||
<div class="contact-item">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
width="26"
|
||||
height="26"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="#2563eb"
|
||||
stroke-width="2">
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M4 4h16v16H4z"/>
|
||||
|
||||
<path stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
d="M22 6l-10 7L2 6"/>
|
||||
|
||||
</svg>
|
||||
|
||||
e31231226@student.polije.ac.id
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- FOOTER -->
|
||||
<div class="footer">
|
||||
<div>© 2025 SENTARA. All rights reserved.</div>
|
||||
<div>Dinas Pariwisata Jember</div>
|
||||
<div class="mt-6 text-center">
|
||||
<a href="{{ route('login') }}" class="text-blue-600 hover:underline">
|
||||
Kembali ke Login
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -288,6 +288,19 @@
|
|||
<img src="{{ asset('images/logo-sentara.png') }}">
|
||||
</div>
|
||||
|
||||
@if ($errors->any())
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Login Gagal',
|
||||
text: 'Email atau password yang dimasukkan salah.',
|
||||
confirmButtonColor: '#2d5be3'
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
|
||||
<div class="title">
|
||||
Selamat Datang <span>Kembali!</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,39 +1,183 @@
|
|||
<x-guest-layout>
|
||||
<form method="POST" action="{{ route('password.store') }}">
|
||||
@csrf
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- Password Reset Token -->
|
||||
<input type="hidden" name="token" value="{{ $request->route('token') }}">
|
||||
<title>Reset Password - SENTARA</title>
|
||||
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
<style>
|
||||
body{
|
||||
background:#f5f7fb;
|
||||
}
|
||||
|
||||
.left-panel{
|
||||
background: linear-gradient(180deg,#0f3fb9,#1546cf);
|
||||
}
|
||||
|
||||
.input-box{
|
||||
width:100%;
|
||||
border:1px solid #dbe3ef;
|
||||
border-radius:10px;
|
||||
padding:14px 16px;
|
||||
outline:none;
|
||||
}
|
||||
|
||||
.input-box:focus{
|
||||
border-color:#2563eb;
|
||||
box-shadow:0 0 0 3px rgba(37,99,235,.15);
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body class="min-h-screen flex items-center justify-center p-6">
|
||||
|
||||
<div class="bg-white rounded-3xl shadow-xl overflow-hidden max-w-5xl w-full grid md:grid-cols-2">
|
||||
|
||||
<!-- LEFT -->
|
||||
<div class="left-panel text-white p-10 flex flex-col justify-between">
|
||||
|
||||
<!-- Email Address -->
|
||||
<div>
|
||||
<x-input-label for="email" :value="__('Email')" />
|
||||
<x-text-input id="email" class="block mt-1 w-full" type="email" name="email" :value="old('email', $request->email)" required autofocus autocomplete="username" />
|
||||
<x-input-error :messages="$errors->get('email')" class="mt-2" />
|
||||
|
||||
<img src="{{ asset('images/logo-sentara.png') }}"
|
||||
class="w-56 mb-10"
|
||||
alt="logo">
|
||||
|
||||
<h1 class="text-3xl font-bold mb-4">
|
||||
Buat Password Baru
|
||||
</h1>
|
||||
|
||||
<p class="text-blue-100 leading-7">
|
||||
Masukkan password baru Anda
|
||||
pada form di samping.
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password" :value="__('Password')" />
|
||||
<x-text-input id="password" class="block mt-1 w-full" type="password" name="password" required autocomplete="new-password" />
|
||||
<x-input-error :messages="$errors->get('password')" class="mt-2" />
|
||||
<div class="text-center mt-12 text-8xl">
|
||||
🔐
|
||||
</div>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<div class="mt-4">
|
||||
<x-input-label for="password_confirmation" :value="__('Confirm Password')" />
|
||||
</div>
|
||||
|
||||
<x-text-input id="password_confirmation" class="block mt-1 w-full"
|
||||
type="password"
|
||||
name="password_confirmation" required autocomplete="new-password" />
|
||||
<!-- RIGHT -->
|
||||
<div class="p-10">
|
||||
|
||||
<x-input-error :messages="$errors->get('password_confirmation')" class="mt-2" />
|
||||
</div>
|
||||
<h2 class="text-4xl font-bold text-slate-800 mb-3">
|
||||
Reset Password
|
||||
</h2>
|
||||
|
||||
<div class="flex items-center justify-end mt-4">
|
||||
<x-primary-button>
|
||||
{{ __('Reset Password') }}
|
||||
</x-primary-button>
|
||||
</div>
|
||||
</form>
|
||||
</x-guest-layout>
|
||||
<p class="text-slate-500 mb-8">
|
||||
Masukkan password baru untuk akun Anda.
|
||||
</p>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="bg-red-100 text-red-600 p-3 rounded-xl mb-5">
|
||||
{{ $errors->first() }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('custom.password.update') }}">
|
||||
|
||||
@csrf
|
||||
|
||||
|
||||
<input type="hidden"
|
||||
name="token"
|
||||
value="{{ $token ?? request()->route('token') }}">
|
||||
|
||||
<input type="hidden"
|
||||
name="email"
|
||||
value="{{ $email ?? request()->email }}">
|
||||
|
||||
<!-- PASSWORD -->
|
||||
|
||||
{{-- Password Baru --}}
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
||||
Password Baru
|
||||
</label>
|
||||
|
||||
<div class="relative">
|
||||
<input
|
||||
id="password"
|
||||
type="password"
|
||||
name="password"
|
||||
placeholder="Masukkan password baru"
|
||||
required
|
||||
class="w-full border rounded-lg px-4 py-3 pr-12 focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="togglePassword('password','eye1')"
|
||||
class="absolute right-4 top-1/2 -translate-y-1/2 text-gray-500"
|
||||
>
|
||||
<span id="eye1">👁️</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
Minimal 8 karakter
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
{{-- Konfirmasi Password --}}
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-medium text-gray-700 mb-2">
|
||||
Konfirmasi Password
|
||||
</label>
|
||||
|
||||
<div class="relative">
|
||||
<input
|
||||
id="password_confirmation"
|
||||
type="password"
|
||||
name="password_confirmation"
|
||||
placeholder="Konfirmasi password baru"
|
||||
required
|
||||
class="w-full border rounded-lg px-4 py-3 pr-12 focus:ring-2 focus:ring-blue-500 outline-none"
|
||||
>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onclick="togglePassword('password_confirmation','eye2')"
|
||||
class="absolute right-4 top-1/2 -translate-y-1/2 text-gray-500"
|
||||
>
|
||||
<span id="eye2">👁️</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="w-full bg-blue-600 hover:bg-blue-700 transition text-white py-4 rounded-xl font-semibold shadow-lg">
|
||||
|
||||
🔒 Reset Password
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function togglePassword(inputId, eyeId) {
|
||||
const input = document.getElementById(inputId);
|
||||
const eye = document.getElementById(eyeId);
|
||||
|
||||
if (input.type === "password") {
|
||||
input.type = "text";
|
||||
eye.innerHTML = "🙈";
|
||||
} else {
|
||||
input.type = "password";
|
||||
eye.innerHTML = "👁️";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Password Berhasil Direset</title>
|
||||
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</head>
|
||||
<body class="bg-[#f5f7fb] min-h-screen flex items-center justify-center px-4">
|
||||
|
||||
<div class="w-full max-w-md bg-white rounded-2xl shadow-lg p-8 text-center">
|
||||
|
||||
<div class="flex justify-center mb-5">
|
||||
<div class="w-20 h-20 rounded-full bg-green-100 flex items-center justify-center">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="text-2xl font-bold text-[#1e3a8a] mb-3">
|
||||
Password Berhasil Direset
|
||||
</h2>
|
||||
|
||||
<p class="text-gray-500 mb-6">
|
||||
Password akun Anda berhasil diperbarui. Silakan login kembali menggunakan password baru.
|
||||
</p>
|
||||
|
||||
<a
|
||||
href="{{ url('/login') }}"
|
||||
class="inline-block bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-xl font-semibold transition duration-200"
|
||||
>
|
||||
Kembali ke Login
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -63,11 +63,14 @@ class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]">
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div x-data="{ tab: new URLSearchParams(window.location.search).get('tab') || 'dashboard' }" class="mb-6">
|
||||
|
||||
<div x-data="{ tab: new URLSearchParams(window.location.search).get('tab') || 'dashboard' }"
|
||||
x-init="$nextTick(() => { if (tab === 'dashboard') renderAllCharts() })"
|
||||
class="mb-6">
|
||||
|
||||
<!-- TAB -->
|
||||
<div class="bg-blue-700 rounded-xl p-1 flex space-x-2 shadow mb-6">
|
||||
<button @click="tab='dashboard'"
|
||||
<button @click="tab='dashboard'; $nextTick(() => renderAllCharts())"
|
||||
:class="tab==='dashboard' ? 'bg-white text-blue-700 shadow' : 'text-white hover:bg-blue-600'"
|
||||
class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
||||
Dashboard Sentara
|
||||
|
|
@ -167,19 +170,31 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
{{-- SCRIPTS --}}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
<script>
|
||||
const pieData = @json($chartSentimen);
|
||||
const destinationData = @json($chartDestinasi);
|
||||
const text = @json($allText);
|
||||
|
||||
function renderAllCharts() {
|
||||
// PIE CHART
|
||||
const pieData = JSON.parse('{!! json_encode($chartSentimen) !!}');
|
||||
const pieCanvas = document.getElementById('pieChart');
|
||||
if (window.pieChartInstance) window.pieChartInstance.destroy();
|
||||
window.pieChartInstance = new Chart(pieCanvas, {
|
||||
const pieCanvas = document.getElementById('pieChart');
|
||||
if (pieCanvas) {
|
||||
if (window.pieChartInstance) {
|
||||
window.pieChartInstance.destroy();
|
||||
window.pieChartInstance = null;
|
||||
}
|
||||
|
||||
// Reset canvas dengan clone agar benar-benar bersih
|
||||
const newPie = pieCanvas.cloneNode(false);
|
||||
pieCanvas.parentNode.replaceChild(newPie, pieCanvas);
|
||||
|
||||
window.pieChartInstance = new Chart(newPie, { // <-- newPie, bukan pieCanvas
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: pieData.map(i => i.sentimen),
|
||||
datasets: [{
|
||||
data: pieData.map(i => i.total),
|
||||
data: pieData.map(i => Number(i.total)),
|
||||
backgroundColor: ['#3B82F6', '#EF4444', '#F59E0B']
|
||||
}]
|
||||
},
|
||||
|
|
@ -189,12 +204,15 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
animation: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// BAR CHART SENTIMEN PER DESTINASI
|
||||
const destinationData = @json($chartDestinasi);
|
||||
// BAR CHART
|
||||
const destinationCanvas = document.getElementById('destinationChart');
|
||||
if (destinationCanvas) {
|
||||
if (window.destinationChartInstance) window.destinationChartInstance.destroy();
|
||||
if (window.destinationChartInstance) {
|
||||
window.destinationChartInstance.destroy();
|
||||
window.destinationChartInstance = null;
|
||||
}
|
||||
window.destinationChartInstance = new Chart(destinationCanvas, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
|
|
@ -234,12 +252,7 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
legend: {
|
||||
position: 'top',
|
||||
align: 'center',
|
||||
labels: {
|
||||
boxWidth: 38,
|
||||
boxHeight: 10,
|
||||
color: '#4B5563',
|
||||
font: { size: 12 },
|
||||
},
|
||||
labels: { boxWidth: 38, boxHeight: 10, color: '#4B5563', font: { size: 12 } },
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
|
|
@ -250,19 +263,11 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
scales: {
|
||||
x: {
|
||||
grid: { color: 'rgba(156, 163, 175, 0.22)' },
|
||||
ticks: {
|
||||
color: '#4B5563',
|
||||
maxRotation: 14,
|
||||
minRotation: 14,
|
||||
font: { size: 12 },
|
||||
},
|
||||
ticks: { color: '#4B5563', maxRotation: 14, minRotation: 14, font: { size: 12 } },
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
color: '#4B5563',
|
||||
precision: 0,
|
||||
},
|
||||
ticks: { color: '#4B5563', precision: 0 },
|
||||
grid: { color: 'rgba(156, 163, 175, 0.28)' },
|
||||
},
|
||||
},
|
||||
|
|
@ -272,8 +277,7 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
});
|
||||
}
|
||||
|
||||
// WORD CLOUD tanpa library eksternal agar tetap tampil stabil.
|
||||
const text = @json($allText);
|
||||
// WORD CLOUD
|
||||
const wordCloud = document.getElementById('wordCloud');
|
||||
const stopwords = new Set([
|
||||
'yang','dan','dari','untuk','dengan','ini','itu','tidak','ada','juga',
|
||||
|
|
@ -304,10 +308,10 @@ class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
|||
}).join('');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,196 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Reset Password SENTARA</title>
|
||||
|
||||
<style>
|
||||
body{
|
||||
margin:0;
|
||||
padding:0;
|
||||
background:#f4f7ff;
|
||||
font-family:Arial, sans-serif;
|
||||
}
|
||||
|
||||
.wrapper{
|
||||
width:100%;
|
||||
padding:40px 15px;
|
||||
}
|
||||
|
||||
.card{
|
||||
max-width:650px;
|
||||
margin:auto;
|
||||
background:white;
|
||||
border-radius:20px;
|
||||
overflow:hidden;
|
||||
box-shadow:0 10px 30px rgba(0,0,0,.08);
|
||||
}
|
||||
|
||||
.header{
|
||||
background:linear-gradient(135deg,#3B82F6,#4F46E5);
|
||||
padding:35px;
|
||||
text-align:center;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.logo{
|
||||
font-size:34px;
|
||||
font-weight:bold;
|
||||
letter-spacing:2px;
|
||||
}
|
||||
|
||||
.subtitle{
|
||||
margin-top:10px;
|
||||
opacity:.9;
|
||||
}
|
||||
|
||||
.content{
|
||||
padding:40px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.icon{
|
||||
font-size:70px;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
.title{
|
||||
font-size:34px;
|
||||
font-weight:bold;
|
||||
color:#1e293b;
|
||||
}
|
||||
|
||||
.desc{
|
||||
color:#64748b;
|
||||
line-height:1.7;
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
.btn{
|
||||
display:inline-block;
|
||||
margin-top:30px;
|
||||
background:#3B82F6;
|
||||
color:white !important;
|
||||
text-decoration:none;
|
||||
padding:15px 40px;
|
||||
border-radius:10px;
|
||||
font-weight:bold;
|
||||
font-size:16px;
|
||||
}
|
||||
|
||||
.info-box{
|
||||
margin-top:35px;
|
||||
background:#eef4ff;
|
||||
padding:20px;
|
||||
border-radius:12px;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.info-box strong{
|
||||
color:#2563eb;
|
||||
}
|
||||
|
||||
.footer{
|
||||
padding:25px;
|
||||
text-align:center;
|
||||
color:#94a3b8;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
.link-box{
|
||||
margin-top:25px;
|
||||
background:#0f172a;
|
||||
color:white;
|
||||
padding:20px;
|
||||
border-radius:12px;
|
||||
word-break:break-all;
|
||||
font-size:13px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="wrapper">
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="header">
|
||||
|
||||
<div class="logo">
|
||||
SENTARA
|
||||
</div>
|
||||
|
||||
<div class="subtitle">
|
||||
Sistem Analisis Sentimen Pariwisata Jember
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="content">
|
||||
|
||||
<div class="icon">
|
||||
🔐
|
||||
</div>
|
||||
|
||||
<div class="title">
|
||||
Reset Password
|
||||
</div>
|
||||
|
||||
<p class="desc">
|
||||
|
||||
Halo,<br><br>
|
||||
|
||||
Kami menerima permintaan reset password untuk akun Anda.
|
||||
Klik tombol di bawah untuk membuat password baru.
|
||||
|
||||
</p>
|
||||
|
||||
<a class="btn" href="{{ $actionUrl }}">
|
||||
Reset Password
|
||||
</a>
|
||||
|
||||
<div class="info-box">
|
||||
|
||||
⏰ Link reset password akan kadaluarsa dalam
|
||||
<strong>60 menit</strong>.
|
||||
|
||||
<br><br>
|
||||
|
||||
Jika Anda tidak meminta reset password,
|
||||
abaikan email ini.
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="link-box">
|
||||
|
||||
Jika tombol tidak berfungsi, salin link berikut:
|
||||
|
||||
<br><br>
|
||||
|
||||
{{ $actionUrl }}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="footer">
|
||||
|
||||
© {{ date('Y') }} SENTARA <br>
|
||||
|
||||
Email otomatis — jangan membalas email ini.
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -229,6 +229,11 @@ class="text-slate-400 hover:text-slate-700 text-2xl leading-none ml-4 flex-shrin
|
|||
|
||||
<form method="POST" id="editForm">
|
||||
@csrf
|
||||
@if ($errors->any())
|
||||
<div class="mb-4 rounded-2xl bg-red-50 border border-red-200 text-red-600 px-4 py-3 text-sm">
|
||||
{{ $errors->first() }}
|
||||
</div>
|
||||
@endif
|
||||
@method('PUT')
|
||||
|
||||
<div class="mb-4">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,376 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{ $judulLaporan }}</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
||||
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f1f5f9;
|
||||
color: #1f2937;
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* ── Sticky action bar pojok kanan atas ── */
|
||||
.action-bar {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 24px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 9px 18px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
||||
transition: opacity .2s;
|
||||
}
|
||||
.btn:hover { opacity: .85; }
|
||||
.btn-primary { background: #1d4ed8; color: white; }
|
||||
.btn-secondary { background: white; color: #374151; border: 1px solid #d1d5db; }
|
||||
|
||||
.container {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
padding: 28px;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
/* LOGO */
|
||||
.logo { font-size: 26px; font-weight: 800; color: #1e3a8a; margin-bottom: 20px; }
|
||||
|
||||
/* HERO */
|
||||
.hero {
|
||||
border: 1px solid #dbeafe;
|
||||
background: linear-gradient(135deg, #eff6ff, #f7f8ff);
|
||||
border-radius: 12px;
|
||||
padding: 22px 24px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.hero-title { font-size: 22px; font-weight: 800; color: #132b70; line-height: 1.3; }
|
||||
.hero-sub { margin-top: 6px; color: #374151; font-size: 13px; }
|
||||
|
||||
.hero-right {
|
||||
min-width: 160px;
|
||||
border: 1px solid #dbeafe;
|
||||
border-radius: 10px;
|
||||
padding: 14px 16px;
|
||||
background: white;
|
||||
font-size: 13px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
/* SECTION TITLE */
|
||||
.section-title {
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
color: #1e3a8a;
|
||||
letter-spacing: .5px;
|
||||
margin: 24px 0 14px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* CARDS */
|
||||
.cards { display: flex; gap: 12px; margin-bottom: 24px; }
|
||||
|
||||
.card {
|
||||
flex: 1;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.card .card-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
|
||||
.card .card-value { font-size: 26px; font-weight: 800; margin: 0; }
|
||||
.card .card-unit { font-size: 12px; color: #9ca3af; margin-top: 4px; }
|
||||
|
||||
.blue { background: #eff6ff; border-color: #bfdbfe; }
|
||||
.green { background: #f0fdf4; border-color: #bbf7d0; }
|
||||
.yellow { background: #fffbeb; border-color: #fde68a; }
|
||||
.purple { background: #faf5ff; border-color: #e9d5ff; }
|
||||
|
||||
/* CHARTS */
|
||||
.chart-row { display: flex; gap: 16px; margin-bottom: 24px; align-items: flex-start; }
|
||||
|
||||
.box-pie {
|
||||
width: 260px;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.box-bar {
|
||||
flex: 1;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.box-pie h4, .box-bar h4 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
color: #1e3a8a;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .4px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* TABLE */
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
|
||||
table th { background: #f8fafc; font-size: 12px; font-weight: 600; }
|
||||
table th, table td { border: 1px solid #e5e7eb; padding: 9px 11px; font-size: 12px; }
|
||||
|
||||
.badge {
|
||||
background: #dcfce7;
|
||||
color: #15803d;
|
||||
border-radius: 20px;
|
||||
padding: 3px 10px;
|
||||
font-weight: 600;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* KESIMPULAN */
|
||||
.kesimpulan {
|
||||
border: 1px solid #dbeafe;
|
||||
background: #eff6ff;
|
||||
border-radius: 10px;
|
||||
padding: 16px 18px;
|
||||
margin-top: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
.footer {
|
||||
margin-top: 24px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
/* Sembunyikan action bar saat print */
|
||||
@media print {
|
||||
body { background: white; padding: 0; }
|
||||
.action-bar { display: none !important; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{-- ── ACTION BAR pojok kanan atas ── --}}
|
||||
<div class="action-bar" id="actionBar">
|
||||
<button class="btn btn-secondary" onclick="cetakHalaman()">🖨️ Cetak</button>
|
||||
</div>
|
||||
|
||||
<div class="container" id="isiLaporan">
|
||||
|
||||
{{-- LOGO --}}
|
||||
<div class="logo">SENTARA</div>
|
||||
|
||||
{{-- HERO --}}
|
||||
<div class="hero">
|
||||
<div class="hero-left">
|
||||
<div class="hero-title">LAPORAN ANALISIS SENTIMEN<br>PER BULAN</div>
|
||||
<div class="hero-sub">SISTEM ANALISIS SENTIMEN WISATA JEMBER</div>
|
||||
</div>
|
||||
<div class="hero-right">
|
||||
<b>Periode</b><br>
|
||||
{{ $periode->nama ?? '-' }}<br><br>
|
||||
<b>Tanggal Cetak</b><br>
|
||||
{{ now()->format('d M Y H:i') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- RINGKASAN --}}
|
||||
<div class="section-title">Ringkasan</div>
|
||||
|
||||
<div class="cards">
|
||||
<div class="card blue">
|
||||
<div class="card-label">Total Ulasan</div>
|
||||
<p class="card-value">{{ $totalUlasanKotor }}</p>
|
||||
<div class="card-unit">Ulasan Masuk</div>
|
||||
</div>
|
||||
<div class="card green">
|
||||
<div class="card-label">Hasil Analisis</div>
|
||||
<p class="card-value">{{ $totalUlasan }}</p>
|
||||
<div class="card-unit">Data Bersih</div>
|
||||
</div>
|
||||
<div class="card yellow">
|
||||
<div class="card-label">Wisata Dibahas</div>
|
||||
<p class="card-value">{{ count($perWisata) }}</p>
|
||||
<div class="card-unit">Destinasi</div>
|
||||
</div>
|
||||
<div class="card purple">
|
||||
<div class="card-label">Akurasi Analisis</div>
|
||||
<p class="card-value">{{ number_format(($evaluasi->accuracy ?? 0) * 100, 2) }}%</p>
|
||||
<div class="card-unit">Model</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- CHARTS --}}
|
||||
<div class="section-title">Visualisasi</div>
|
||||
|
||||
<div class="chart-row">
|
||||
<div class="box-pie">
|
||||
<h4>Distribusi Sentimen</h4>
|
||||
<canvas id="pieChart" width="220" height="220"></canvas>
|
||||
</div>
|
||||
<div class="box-bar">
|
||||
<h4>Sentimen per Destinasi</h4>
|
||||
<canvas id="barChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- TABEL --}}
|
||||
<div class="section-title">Top Wisata Berdasarkan Sentimen Positif</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Wisata</th>
|
||||
<th>Total</th>
|
||||
<th>Positif</th>
|
||||
<th>Netral</th>
|
||||
<th>Negatif</th>
|
||||
<th>% Positif</th>
|
||||
</tr>
|
||||
@foreach($perWisata as $i => $w)
|
||||
<tr>
|
||||
<td>{{ $i + 1 }}</td>
|
||||
<td>{{ $w->wisata }}</td>
|
||||
<td>{{ $w->total }}</td>
|
||||
<td>{{ $w->positif }}</td>
|
||||
<td>{{ $w->netral }}</td>
|
||||
<td>{{ $w->negatif }}</td>
|
||||
<td><span class="badge">{{ $w->total > 0 ? round(($w->positif / $w->total) * 100, 2) : 0 }}%</span></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
||||
{{-- KESIMPULAN --}}
|
||||
<div class="kesimpulan">
|
||||
<b>KESIMPULAN</b>
|
||||
<p style="margin:8px 0 0">
|
||||
Pada periode <b>{{ $periode->nama ?? '' }}</b>,
|
||||
terdapat <b>{{ $totalUlasanKotor }}</b> ulasan masuk dengan
|
||||
<b>{{ $totalUlasan }}</b> data berhasil dianalisis.
|
||||
Sentimen positif mendominasi dengan persentase <b>{{ $persen['positif'] ?? 0 }}%</b>,
|
||||
diikuti netral <b>{{ $persen['netral'] ?? 0 }}%</b>
|
||||
dan negatif <b>{{ $persen['negatif'] ?? 0 }}%</b>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{-- FOOTER --}}
|
||||
<div class="footer">
|
||||
<div>SENTARA — Sistem Analisis Sentimen Wisata Jember</div>
|
||||
<div>Dicetak oleh: Admin | {{ now()->format('d M Y H:i') }}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// ── PIE / DOUGHNUT CHART ──
|
||||
new Chart(document.getElementById('pieChart'), {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Positif', 'Netral', 'Negatif'],
|
||||
datasets: [{
|
||||
data: [{{ $totalPositif }}, {{ $totalNetral }}, {{ $totalNegatif }}],
|
||||
backgroundColor: ['#22c55e', '#f59e0b', '#ef4444'],
|
||||
borderWidth: 2,
|
||||
borderColor: '#fff'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: false,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: { position: 'bottom', labels: { font: { size: 11 }, padding: 10 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── BAR CHART SENTIMEN PER DESTINASI ──
|
||||
const wisataLabels = @json($perWisata->pluck('wisata'));
|
||||
const wisataPos = @json($perWisata->pluck('positif'));
|
||||
const wisataNet = @json($perWisata->pluck('netral'));
|
||||
const wisataNeg = @json($perWisata->pluck('negatif'));
|
||||
|
||||
new Chart(document.getElementById('barChart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: wisataLabels,
|
||||
datasets: [
|
||||
{ label: 'Positif', data: wisataPos, backgroundColor: '#22c55e' },
|
||||
{ label: 'Netral', data: wisataNet, backgroundColor: '#f59e0b' },
|
||||
{ label: 'Negatif', data: wisataNeg, backgroundColor: '#ef4444' }
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: { position: 'bottom', labels: { font: { size: 11 } } }
|
||||
},
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { font: { size: 11 } } },
|
||||
x: { ticks: { font: { size: 10 } } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── CETAK ──
|
||||
function cetakHalaman() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
// ── SIMPAN PDF ──
|
||||
function simpanPDF() {
|
||||
const el = document.getElementById('isiLaporan');
|
||||
const bar = document.getElementById('actionBar');
|
||||
bar.style.display = 'none';
|
||||
|
||||
html2pdf().set({
|
||||
margin: 10,
|
||||
filename: 'Laporan-{{ Str::slug($periode->nama ?? "bulanan") }}.pdf',
|
||||
image: { type: 'jpeg', quality: 0.98 },
|
||||
html2canvas: { scale: 2, useCORS: true },
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||
}).from(el).save().then(() => {
|
||||
bar.style.display = 'flex';
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,605 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Laporan Tahunan</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f3f5fb;
|
||||
padding: 24px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
/* ACTION BAR */
|
||||
.action-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
max-width: 960px;
|
||||
margin: 0 auto 16px;
|
||||
}
|
||||
|
||||
.logo-text {
|
||||
font-size: 22px;
|
||||
font-weight: 900;
|
||||
color: #1e3a8a;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
.logo-text span { color: #ef4444; }
|
||||
|
||||
.btn-group { display: flex; gap: 8px; }
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 9px 18px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,0.12);
|
||||
}
|
||||
.btn-blue { background: #1d4ed8; color: white; }
|
||||
.btn-white { background: white; color: #374151; border: 1px solid #d1d5db; }
|
||||
.btn:hover { opacity: .88; }
|
||||
|
||||
/* CONTAINER */
|
||||
.container {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
padding: 24px;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.07);
|
||||
}
|
||||
|
||||
/* HERO */
|
||||
.hero {
|
||||
border: 1px solid #dbeafe;
|
||||
background: linear-gradient(135deg, #eff6ff, #f7f8ff);
|
||||
border-radius: 12px;
|
||||
padding: 18px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.hero-left { display: flex; gap: 16px; align-items: center; }
|
||||
|
||||
.hero-icon {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
background: #1d4ed8;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.hero-icon svg { width: 28px; height: 28px; fill: white; }
|
||||
|
||||
.hero-title { font-size: 18px; font-weight: 900; color: #132b70; line-height: 1.3; }
|
||||
.hero-sub { font-size: 11px; color: #6b7280; margin-top: 4px; }
|
||||
|
||||
.hero-right { font-size: 12px; text-align: right; line-height: 1.8; }
|
||||
.hero-right .year { font-size: 22px; font-weight: 800; color: #1e3a8a; }
|
||||
|
||||
/* SECTION TITLE */
|
||||
.section-title {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .6px;
|
||||
margin: 20px 0 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.section-title::before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 14px;
|
||||
background: #1d4ed8;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* CARDS */
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.card {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 14px 16px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.card-info .card-label { font-size: 11px; color: #6b7280; margin-bottom: 4px; }
|
||||
.card-info .card-value { font-size: 28px; font-weight: 800; line-height: 1; }
|
||||
.card-info .card-unit { font-size: 11px; color: #9ca3af; margin-top: 4px; }
|
||||
.card-icon {
|
||||
width: 36px; height: 36px;
|
||||
border-radius: 8px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.blue { background: #eff6ff; border-color: #bfdbfe; }
|
||||
.green { background: #f0fdf4; border-color: #bbf7d0; }
|
||||
.yellow { background: #fffbeb; border-color: #fde68a; }
|
||||
.purple { background: #faf5ff; border-color: #e9d5ff; }
|
||||
|
||||
.blue .card-icon { background: #dbeafe; }
|
||||
.green .card-icon { background: #dcfce7; }
|
||||
.yellow .card-icon { background: #fef3c7; }
|
||||
.purple .card-icon { background: #ede9fe; }
|
||||
|
||||
/* REKAP + DONUT ROW */
|
||||
.grid2 {
|
||||
display: grid;
|
||||
grid-template-columns: 1.4fr 1fr;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
/* TABLE */
|
||||
.table-box {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
table thead tr { background: #f8fafc; }
|
||||
table th { padding: 10px 12px; font-size: 11px; font-weight: 700; color: #374151; text-align: left; }
|
||||
table td { padding: 9px 12px; font-size: 11px; border-top: 1px solid #f1f5f9; }
|
||||
table tbody tr:hover { background: #fafafa; }
|
||||
|
||||
.tfoot-row td { background: #f8fafc; font-weight: 700; border-top: 2px solid #e5e7eb; }
|
||||
|
||||
.pos { color: #16a34a; font-weight: 600; }
|
||||
.net { color: #d97706; font-weight: 600; }
|
||||
.neg { color: #dc2626; font-weight: 600; }
|
||||
|
||||
.badge-green {
|
||||
background: #dcfce7;
|
||||
color: #15803d;
|
||||
border-radius: 20px;
|
||||
padding: 2px 8px;
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* DONUT BOX */
|
||||
.donut-box {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.donut-box h4 {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.donut-wrap {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.donut-center {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
.donut-center .dc-num { font-size: 20px; font-weight: 800; color: #1e3a8a; }
|
||||
.donut-center .dc-label { font-size: 9px; color: #6b7280; }
|
||||
|
||||
/* TREND BOX */
|
||||
.trend-box {
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.trend-box h4 {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .4px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* BOTTOM GRID */
|
||||
.bottom-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* KESIMPULAN */
|
||||
.kesimpulan-box {
|
||||
border: 1px solid #dbeafe;
|
||||
background: #eff6ff;
|
||||
border-radius: 12px;
|
||||
padding: 16px 18px;
|
||||
font-size: 12px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
.kesimpulan-box h4 {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
color: #1e3a8a;
|
||||
margin-bottom: 8px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #f1f5f9;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body { background: white; padding: 0; }
|
||||
.action-bar { display: none !important; }
|
||||
.container { box-shadow: none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{{-- ACTION BAR --}}
|
||||
<div class="action-bar no-print" id="actionBar">
|
||||
<div></div>
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-white" onclick="window.print()">🖨 Cetak</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container" id="isiLaporan">
|
||||
|
||||
{{-- HERO --}}
|
||||
<div class="hero">
|
||||
<div class="hero-left">
|
||||
<div class="hero-icon">
|
||||
<svg viewBox="0 0 24 24"><path d="M9 12h6m-6 4h6M7 4H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V6a2 2 0 00-2-2h-2M9 4a2 2 0 002 2h2a2 2 0 002-2M9 4a2 2 0 012-2h2a2 2 0 012 2" stroke="white" stroke-width="2" stroke-linecap="round" fill="none"/></svg>
|
||||
</div>
|
||||
<div>
|
||||
{{-- Logo kecil di atas judul --}}
|
||||
<div style="display:inline-flex;align-items:center;gap:5px;background:#1e3a8a;border-radius:6px;padding:3px 10px;margin-bottom:7px;">
|
||||
<span style="color:#fff;font-size:11px;font-weight:900;letter-spacing:1px;">-SENTARA-</span>
|
||||
<span style="color:#93c5fd;font-size:9px;letter-spacing:2px;">JEMBER</span>
|
||||
</div>
|
||||
<div class="hero-title">LAPORAN ANALISIS SENTIMEN<br>PER TAHUN</div>
|
||||
<div class="hero-sub">SISTEM ANALISIS SENTIMEN WISATA JEMBER</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hero-right">
|
||||
<div style="color:#6b7280;font-size:11px;">Tahun</div>
|
||||
<div class="year">{{ $tahun }}</div>
|
||||
<div style="color:#6b7280;font-size:11px;margin-top:6px;">Tanggal Cetak</div>
|
||||
<div style="font-weight:600;">{{ now()->format('d M Y H:i') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- RINGKASAN --}}
|
||||
<div class="section-title">Ringkasan Tahunan</div>
|
||||
|
||||
<div class="cards">
|
||||
<div class="card blue">
|
||||
<div class="card-info">
|
||||
<div class="card-label">Total Ulasan</div>
|
||||
<div class="card-value">{{ $totalUlasan }}</div>
|
||||
<div class="card-unit">Ulasan</div>
|
||||
</div>
|
||||
<div class="card-icon">💬</div>
|
||||
</div>
|
||||
<div class="card green">
|
||||
<div class="card-info">
|
||||
<div class="card-label">Rata-rata Akurasi</div>
|
||||
<div class="card-value" style="font-size:20px;">{{ $akurasi }}%</div>
|
||||
<div class="card-unit">Akurasi</div>
|
||||
</div>
|
||||
<div class="card-icon">✅</div>
|
||||
</div>
|
||||
<div class="card yellow">
|
||||
<div class="card-info">
|
||||
<div class="card-label">Total Wisata Dibahas</div>
|
||||
<div class="card-value">{{ $totalWisata }}</div>
|
||||
<div class="card-unit">Wisata</div>
|
||||
</div>
|
||||
<div class="card-icon">📍</div>
|
||||
</div>
|
||||
<div class="card purple">
|
||||
<div class="card-info">
|
||||
<div class="card-label">Bulan Dianalisis</div>
|
||||
<div class="card-value">{{ count($rekapBulanan) }}</div>
|
||||
<div class="card-unit">Bulan</div>
|
||||
</div>
|
||||
<div class="card-icon">📅</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- REKAP + DONUT --}}
|
||||
<div class="section-title">Rekap Sentimen per Bulan</div>
|
||||
|
||||
<div class="grid2">
|
||||
<div class="table-box">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Bulan</th>
|
||||
<th>Total Ulasan</th>
|
||||
<th>Positif</th>
|
||||
<th>Netral</th>
|
||||
<th>Negatif</th>
|
||||
<th>Persentase Positif</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php $totP=0; $totN=0; $totNt=0; $totAll=0; @endphp
|
||||
@foreach($rekapBulanan as $r)
|
||||
@php $totP+=$r->positif; $totN+=$r->negatif; $totNt+=$r->netral; $totAll+=$r->total; @endphp
|
||||
<tr>
|
||||
<td>{{ $r->bulan }}</td>
|
||||
<td>{{ $r->total }}</td>
|
||||
<td class="pos">{{ $r->positif }}</td>
|
||||
<td class="net">{{ $r->netral }}</td>
|
||||
<td class="neg">{{ $r->negatif }}</td>
|
||||
<td><span class="badge-green">{{ number_format(($r->positif/max($r->total,1))*100,2) }}%</span></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="tfoot-row">
|
||||
<td>TOTAL / RATA-RATA</td>
|
||||
<td>{{ $totAll }}</td>
|
||||
<td class="pos">{{ $totP }}</td>
|
||||
<td class="net">{{ $totNt }}</td>
|
||||
<td class="neg">{{ $totN }}</td>
|
||||
<td><span class="badge-green">{{ $totAll > 0 ? number_format(($totP/$totAll)*100,2) : 0 }}%</span></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="donut-box">
|
||||
<h4>Distribusi Sentimen Tahun {{ $tahun }}</h4>
|
||||
<div class="donut-wrap" style="height:220px;">
|
||||
<canvas id="donut"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- TREND --}}
|
||||
<div class="section-title">Trend Sentimen per Bulan ({{ $tahun }})</div>
|
||||
|
||||
<div class="trend-box">
|
||||
<canvas id="trend" height="90"></canvas>
|
||||
</div>
|
||||
|
||||
{{-- WISATA + KESIMPULAN --}}
|
||||
<div class="section-title">Wisata Serpopuler & Kesimpulan</div>
|
||||
|
||||
<div class="bottom-grid">
|
||||
<div class="table-box">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Wisata</th>
|
||||
<th>Total Ulasan</th>
|
||||
<th>Persentase Positif</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($wisataPopuler as $i => $w)
|
||||
<tr>
|
||||
<td>{{ $i+1 }}</td>
|
||||
<td>{{ $w->wisata }}</td>
|
||||
<td>{{ $w->jumlah }}</td>
|
||||
<td><span class="badge-green">{{ $w->persen }}%</span></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="kesimpulan-box">
|
||||
<h4>Kesimpulan Tahunan</h4>
|
||||
<p>
|
||||
Secara umum, sentimen positif mendominasi tahun <b>{{ $tahun }}</b>
|
||||
dengan rata-rata <b>{{ $persenPositif }}%</b>.
|
||||
@if(isset($wisataPopuler[0]))
|
||||
{{ $wisataPopuler[0]->wisata }} menjadi destinasi paling populer
|
||||
dengan sentimen positif tertinggi.
|
||||
@endif
|
||||
Diperlukan peningkatan pada aspek fasilitas, kebersihan, dan pelayanan
|
||||
untuk menekan sentimen negatif.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- FOOTER --}}
|
||||
<div class="footer">
|
||||
<div>SENTARA - Sistem Analisis Sentimen Wisata Jember</div>
|
||||
<div>Dicetak oleh: {{ auth()->user()->name }} ({{ ucfirst(auth()->user()->role ?? 'Admin') }})</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// ── DONUT ──
|
||||
const donutCtx = document.getElementById('donut');
|
||||
const totalUlasan = {{ $totalUlasan > 0 ? $totalUlasan : 1 }};
|
||||
const donutData = [{{ $positif }}, {{ $netral }}, {{ $negatif }}];
|
||||
|
||||
// Plugin: angka total di tengah (tidak numpuk)
|
||||
const centerTextPlugin = {
|
||||
id: 'centerText',
|
||||
beforeDraw(chart) {
|
||||
const { ctx, chartArea: { left, top, right, bottom } } = chart;
|
||||
const cx = (left + right) / 2;
|
||||
const cy = (top + bottom) / 2;
|
||||
ctx.save();
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
ctx.fillStyle = '#1e3a8a';
|
||||
ctx.font = 'bold 22px Arial';
|
||||
ctx.fillText(totalUlasan, cx, cy - 8);
|
||||
ctx.fillStyle = '#9ca3af';
|
||||
ctx.font = '11px Arial';
|
||||
ctx.fillText('Total Ulasan', cx, cy + 12);
|
||||
ctx.restore();
|
||||
}
|
||||
};
|
||||
|
||||
new Chart(donutCtx, {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Positif', 'Netral', 'Negatif'],
|
||||
datasets: [{
|
||||
data: donutData,
|
||||
backgroundColor: ['#22c55e', '#f59e0b', '#ef4444'],
|
||||
borderWidth: 3,
|
||||
borderColor: '#fff',
|
||||
hoverOffset: 6,
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
animation: false,
|
||||
cutout: '62%',
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'bottom',
|
||||
labels: {
|
||||
font: { size: 11 },
|
||||
padding: 10,
|
||||
generateLabels(chart) {
|
||||
const d = chart.data;
|
||||
return d.labels.map((lbl, i) => {
|
||||
const val = d.datasets[0].data[i];
|
||||
const pct = Math.round(val / totalUlasan * 1000) / 10;
|
||||
return {
|
||||
text: `${lbl} ${val} (${pct}%)`,
|
||||
fillStyle: d.datasets[0].backgroundColor[i],
|
||||
strokeStyle: '#fff',
|
||||
lineWidth: 2,
|
||||
index: i,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label(ctx) {
|
||||
const pct = Math.round(ctx.parsed / totalUlasan * 1000) / 10;
|
||||
return ` ${ctx.label}: ${ctx.parsed} (${pct}%)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [centerTextPlugin]
|
||||
});
|
||||
|
||||
// ── TREND LINE ──
|
||||
new Chart(document.getElementById('trend'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: [
|
||||
@foreach($rekapBulanan as $r)
|
||||
'{{ $r->bulan }}',
|
||||
@endforeach
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Positif',
|
||||
data: [@foreach($rekapBulanan as $r){{ $r->positif }},@endforeach],
|
||||
borderColor: '#22c55e',
|
||||
backgroundColor: 'rgba(34,197,94,0.08)',
|
||||
tension: 0.4, fill: true, pointRadius: 4, pointBackgroundColor: '#22c55e'
|
||||
},
|
||||
{
|
||||
label: 'Netral',
|
||||
data: [@foreach($rekapBulanan as $r){{ $r->netral }},@endforeach],
|
||||
borderColor: '#f59e0b',
|
||||
backgroundColor: 'rgba(245,158,11,0.05)',
|
||||
tension: 0.4, fill: false, pointRadius: 4, pointBackgroundColor: '#f59e0b',
|
||||
borderDash: [4,3]
|
||||
},
|
||||
{
|
||||
label: 'Negatif',
|
||||
data: [@foreach($rekapBulanan as $r){{ $r->negatif }},@endforeach],
|
||||
borderColor: '#ef4444',
|
||||
backgroundColor: 'rgba(239,68,68,0.05)',
|
||||
tension: 0.4, fill: false, pointRadius: 4, pointBackgroundColor: '#ef4444'
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: { position: 'bottom', labels: { font: { size: 11 }, padding: 12 } }
|
||||
},
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { font: { size: 10 } }, grid: { color: '#f1f5f9' } },
|
||||
x: { ticks: { font: { size: 10 } }, grid: { display: false } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── SIMPAN PDF ──
|
||||
function simpanPDF() {
|
||||
const el = document.getElementById('isiLaporan');
|
||||
const bar = document.getElementById('actionBar');
|
||||
bar.style.display = 'none';
|
||||
|
||||
html2pdf().set({
|
||||
margin: 8,
|
||||
filename: 'Laporan-Tahunan-{{ $tahun }}.pdf',
|
||||
image: { type: 'jpeg', quality: 0.98 },
|
||||
html2canvas: { scale: 2, useCORS: true, windowWidth: 960 },
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||
}).from(el).save().then(() => {
|
||||
bar.style.display = 'flex';
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<body class="bg-gray-100 overflow-x-hidden">
|
||||
|
||||
<div class="min-h-screen flex">
|
||||
<div class="h-auto ">
|
||||
|
||||
<!-- SIDEBAR -->
|
||||
<aside id="sidebar"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
$totalDestinasiAnalisis ??= 0;
|
||||
$totalDestinasiBerkeluhan ??= 0;
|
||||
$totalNegatif ??= 0;
|
||||
$totalPositif ??= 0;
|
||||
$totalNetral ??= 0;
|
||||
$totalUlasan ??= 0;
|
||||
$persenNegatif ??= 0;
|
||||
$tingkatKepuasan ??= 0;
|
||||
|
|
@ -15,6 +17,37 @@
|
|||
$prioritas ??= [];
|
||||
@endphp
|
||||
|
||||
@php
|
||||
// $persenPositif, $persenNetral, $isuNegatif, $isuNetral, $isuPositif sudah dikirim dari controller
|
||||
// Icon map untuk prioritas cards
|
||||
$iconMap = [
|
||||
'harga' => '🎫',
|
||||
'tiket' => '🎫',
|
||||
'kebersihan'=> '🧹',
|
||||
'parkir' => '🚗',
|
||||
'fasilitas' => '🏗️',
|
||||
'keramaian' => '👥',
|
||||
'akses' => '🛣️',
|
||||
'jalan' => '🛣️',
|
||||
'default' => '⚙️',
|
||||
];
|
||||
@endphp
|
||||
|
||||
<style>
|
||||
.gauge-ring {
|
||||
transform: rotate(-90deg);
|
||||
transform-origin: center;
|
||||
}
|
||||
.gauge-wrap { position: relative; display: inline-block; }
|
||||
.gauge-inner {
|
||||
position: absolute;
|
||||
top: 50%; left: 50%;
|
||||
transform: translate(-50%, -30%);
|
||||
text-align: center;
|
||||
line-height: 1.1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
{{-- HEADER --}}
|
||||
|
|
@ -22,7 +55,7 @@
|
|||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">Rekomendasi Layanan</h2>
|
||||
<p class="text-sm text-gray-500">
|
||||
Rekomendasi dibuat dari ulasan negatif agar saran perbaikan fokus pada keluhan pengunjung.
|
||||
Rekomendasi dibuat dari hasil analisis sentimen untuk perbaikan layanan destinasi wisata.
|
||||
</p>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
{{ $totalDestinasiAnalisis }} destinasi dianalisis, {{ $totalDestinasiBerkeluhan }} destinasi memiliki ulasan negatif.
|
||||
|
|
@ -32,7 +65,10 @@
|
|||
{{-- FILTER DESTINASI — submit ke /dashboard agar tab tidak reset --}}
|
||||
<form method="GET" action="{{ route('dashboard') }}" class="flex gap-3">
|
||||
<input type="hidden" name="tab" value="rekomendasi">
|
||||
<input type="hidden" name="periode_id" value="{{ $periodeAktif->id ?? request('periode_id') }}">
|
||||
<input type="hidden" name="periode_id" value="{{ $periodeId ?? $periodeAktif->id ?? request('periode_id') }}">
|
||||
@if(request('periode_bulan'))
|
||||
<input type="hidden" name="periode_bulan" value="{{ request('periode_bulan') }}">
|
||||
@endif
|
||||
<select name="destinasi" onchange="this.form.submit()"
|
||||
class="border rounded-lg pl-3 pr-9 py-2 text-sm min-w-[220px] focus:outline-none focus:ring-2 focus:ring-blue-400">
|
||||
<option value="">Semua Destinasi</option>
|
||||
|
|
@ -45,174 +81,238 @@ class="border rounded-lg pl-3 pr-9 py-2 text-sm min-w-[220px] focus:outline-none
|
|||
</form>
|
||||
</div>
|
||||
|
||||
{{-- SUMMARY CARDS --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-5">
|
||||
{{-- SUMMARY CARDS — 3 gauge cards seperti di screenshot --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center gap-4">
|
||||
<div class="bg-blue-100 text-blue-600 p-3 rounded-full text-xl">📍</div>
|
||||
{{-- Tingkat Positif --}}
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm text-gray-500">Destinasi Dianalisis</p>
|
||||
<h3 class="text-xl font-bold">{{ $totalDestinasiAnalisis }}</h3>
|
||||
<p class="text-xs text-gray-500">{{ $totalDestinasiBerkeluhan }} punya keluhan</p>
|
||||
<p class="text-sm font-semibold text-green-600">Tingkat Positif</p>
|
||||
<h3 class="text-4xl font-bold text-green-600 mt-1">{{ $persenPositif }}%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-green-100 text-green-700 font-medium">Positif</span>
|
||||
<p class="text-xs text-gray-400 mt-2">{{ $totalPositif }} ulasan</p>
|
||||
</div>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#e5e7eb" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#22c55e" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="{{ round($persenPositif * 1.099) }} 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😊</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center gap-4">
|
||||
<div class="bg-red-100 text-red-500 p-3 rounded-full text-xl">😟</div>
|
||||
{{-- Tingkat Negatif --}}
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm text-gray-500">Total Ulasan Negatif</p>
|
||||
<h3 class="text-xl font-bold">{{ $totalNegatif }}</h3>
|
||||
<p class="text-xs text-red-500">{{ $persenNegatif }}% dari total</p>
|
||||
<p class="text-sm font-semibold text-red-500">Tingkat Negatif</p>
|
||||
<h3 class="text-4xl font-bold text-red-500 mt-1">{{ $persenNegatif }}%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-red-100 text-red-600 font-medium">Negatif</span>
|
||||
<p class="text-xs text-gray-400 mt-2">{{ $totalNegatif }} ulasan</p>
|
||||
</div>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#fee2e2" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#ef4444" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="{{ round($persenNegatif * 1.099) }} 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😟</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center gap-4">
|
||||
<div class="bg-green-100 text-green-600 p-3 rounded-full text-xl">😊</div>
|
||||
{{-- Tingkat Netral --}}
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm text-gray-500">Tingkat Kepuasan</p>
|
||||
<h3 class="text-xl font-bold">{{ $tingkatKepuasan }}%</h3>
|
||||
<span class="text-xs px-2 py-1 rounded
|
||||
{{ $labelKepuasan === 'Baik' ? 'bg-green-100 text-green-700' :
|
||||
($labelKepuasan === 'Sedang' ? 'bg-yellow-100 text-yellow-700' :
|
||||
'bg-red-100 text-red-700') }}">
|
||||
{{ $labelKepuasan }}
|
||||
</span>
|
||||
<p class="text-sm font-semibold text-gray-500">Tingkat Netral</p>
|
||||
<h3 class="text-4xl font-bold text-gray-600 mt-1">{{ $persenNetral }}%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-gray-100 text-gray-600 font-medium">Netral</span>
|
||||
<p class="text-xs text-gray-400 mt-2">{{ $totalNetral }} ulasan</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center gap-4">
|
||||
<div class="bg-purple-100 text-purple-600 p-3 rounded-full text-xl">❗</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500">Isu Dominan</p>
|
||||
<h3 class="text-xl font-bold">{{ $isuDominan }}</h3>
|
||||
<p class="text-xs text-gray-500">{{ $isuDominanPersen }}% dari total isu</p>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#e5e7eb" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#9ca3af" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="{{ round($persenNetral * 1.099) }} 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😐</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- GRID ANALISIS --}}
|
||||
|
||||
|
||||
{{-- TABEL ISU 3 KOLOM (Negatif / Netral / Positif) --}}
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
|
||||
{{-- ISU UTAMA --}}
|
||||
{{-- ISU NEGATIF UTAMA --}}
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-gray-700">Isu Utama (Top 5)</h3>
|
||||
<h3 class="font-semibold mb-4 text-red-600">Isu Negatif Utama (Top 5)</h3>
|
||||
|
||||
@forelse ($isuUtama as $i => $isu)
|
||||
@php
|
||||
$warnaClass = match($isu['color']) {
|
||||
'red' => 'bg-red-500',
|
||||
'orange' => 'bg-orange-500',
|
||||
'yellow' => 'bg-yellow-400',
|
||||
'green' => 'bg-green-500',
|
||||
default => 'bg-blue-500',
|
||||
};
|
||||
@endphp
|
||||
@forelse ($isuNegatif as $i => $isu)
|
||||
@if($i >= 5) @break @endif
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span>{{ $i + 1 }}. {{ $isu['nama'] }}</span>
|
||||
<span class="font-semibold">{{ $isu['persen'] }}%</span>
|
||||
<span class="text-gray-700">{{ $i + 1 }}. {{ $isu['nama'] }}</span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
{{ $isu['persen'] }}%
|
||||
@if(isset($isu['jumlah'])) ({{ $isu['jumlah'] }}) @endif
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-red-100 h-2 rounded">
|
||||
<div class="h-2 rounded bg-red-500" style="width: {{ $isu['persen'] }}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu negatif.</p>
|
||||
@endforelse
|
||||
|
||||
<p class="text-xs text-red-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan negatif ({{ $totalNegatif }} ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{-- ISU NETRAL UTAMA --}}
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-gray-600">Isu Netral Utama (Top 5)</h3>
|
||||
|
||||
@forelse ($isuNetral as $i => $isu)
|
||||
@if($i >= 5) @break @endif
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span class="text-gray-700">{{ $i + 1 }}. {{ $isu['nama'] }}</span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
{{ $isu['persen'] }}%
|
||||
@if(isset($isu['jumlah'])) ({{ $isu['jumlah'] }}) @endif
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 h-2 rounded">
|
||||
<div class="h-2 rounded {{ $warnaClass }}" style="width: {{ $isu['persen'] }}%"></div>
|
||||
<div class="h-2 rounded bg-gray-500" style="width: {{ $isu['persen'] }}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu.</p>
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu netral.</p>
|
||||
@endforelse
|
||||
|
||||
<p class="text-xs text-gray-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan netral ({{ $totalNetral }} ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{-- KATA KUNCI DOMINAN --}}
|
||||
{{-- ASPEK POSITIF UTAMA --}}
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-gray-700">Kata Kunci Dominan</h3>
|
||||
<h3 class="font-semibold mb-4 text-green-600">Aspek Positif Utama (Top 5)</h3>
|
||||
|
||||
@php $maxFreq = !empty($kataDominan) ? max($kataDominan) : 1; @endphp
|
||||
|
||||
@forelse (array_slice($kataDominan, 0, 5, true) as $kata => $jumlah)
|
||||
<div class="mb-3">
|
||||
<div class="flex justify-between text-sm">
|
||||
<span>{{ $kata }}</span>
|
||||
<span class="font-semibold text-blue-600">{{ $jumlah }}x</span>
|
||||
@forelse ($isuPositif as $i => $isu)
|
||||
@if($i >= 5) @break @endif
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span class="text-gray-700">{{ $i + 1 }}. {{ $isu['nama'] }}</span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
{{ $isu['persen'] }}%
|
||||
@if(isset($isu['jumlah'])) ({{ $isu['jumlah'] }}) @endif
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 h-2 rounded mt-1">
|
||||
<div class="bg-blue-500 h-2 rounded" style="width: {{ round(($jumlah / $maxFreq) * 100) }}%"></div>
|
||||
<div class="w-full bg-green-100 h-2 rounded">
|
||||
<div class="h-2 rounded bg-green-500" style="width: {{ $isu['persen'] }}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada kata kunci.</p>
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu positif.</p>
|
||||
@endforelse
|
||||
</div>
|
||||
|
||||
{{-- SARAN PERBAIKAN --}}
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-gray-700">Saran Perbaikan</h3>
|
||||
|
||||
<div class="space-y-4 text-sm">
|
||||
@forelse ($saranPerbaikan as $saran)
|
||||
<div class="flex gap-3">
|
||||
<div class="text-xl">{{ $saran['icon'] }}</div>
|
||||
<div>
|
||||
<p class="font-semibold">{{ $saran['nama'] }}</p>
|
||||
<p class="text-gray-600">{{ $saran['tip'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada saran.</p>
|
||||
@endforelse
|
||||
</div>
|
||||
<p class="text-xs text-green-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan positif ({{ $totalPositif }} ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- PRIORITAS REKOMENDASI --}}
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-800 mb-1">Prioritas Rekomendasi Perbaikan Layanan</h3>
|
||||
<p class="text-sm text-gray-500 mb-4">Prioritas disusun berdasarkan frekuensi isu negatif dan dampaknya terhadap kepuasan pengunjung.</p>
|
||||
|
||||
@forelse ($prioritas as $p)
|
||||
@php
|
||||
$border = match($p['color']) {
|
||||
'red' => 'border-red-300',
|
||||
'orange' => 'border-orange-300',
|
||||
'yellow' => 'border-yellow-300',
|
||||
'green' => 'border-green-300',
|
||||
default => 'border-blue-300',
|
||||
};
|
||||
$title = match($p['color']) {
|
||||
'red' => 'text-red-600',
|
||||
'orange' => 'text-orange-500',
|
||||
'yellow' => 'text-yellow-600',
|
||||
'green' => 'text-green-600',
|
||||
default => 'text-blue-600',
|
||||
};
|
||||
$dampak = match($p['color']) {
|
||||
'red' => 'bg-red-100 text-red-600',
|
||||
'orange' => 'bg-orange-100 text-orange-600',
|
||||
'yellow' => 'bg-yellow-100 text-yellow-600',
|
||||
'green' => 'bg-green-100 text-green-700',
|
||||
default => 'bg-blue-100 text-blue-600',
|
||||
};
|
||||
@endphp
|
||||
<div class="border {{ $border }} rounded-xl p-5 bg-white">
|
||||
<h4 class="font-semibold {{ $title }} mb-2">Prioritas {{ $p['rank'] }}</h4>
|
||||
<h3 class="text-lg font-bold mb-3">{{ $p['nama'] }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
|
||||
<ul class="text-sm space-y-2 mb-4">
|
||||
@foreach ($p['actions'] as $action)
|
||||
<li class="flex items-center gap-2">
|
||||
<span class="text-blue-500">✔</span> {{ $action }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@forelse ($prioritas as $p)
|
||||
@php
|
||||
$border = match($p['color']) {
|
||||
'red' => 'border-red-200',
|
||||
'orange' => 'border-orange-200',
|
||||
'yellow' => 'border-yellow-200',
|
||||
'green' => 'border-green-200',
|
||||
default => 'border-blue-200',
|
||||
};
|
||||
$title = match($p['color']) {
|
||||
'red' => 'text-red-600',
|
||||
'orange' => 'text-orange-500',
|
||||
'yellow' => 'text-yellow-600',
|
||||
'green' => 'text-green-600',
|
||||
default => 'text-blue-600',
|
||||
};
|
||||
$dampak = match($p['color']) {
|
||||
'red' => 'bg-red-50 text-red-500 border border-red-200',
|
||||
'orange' => 'bg-orange-50 text-orange-500 border border-orange-200',
|
||||
'yellow' => 'bg-yellow-50 text-yellow-600 border border-yellow-200',
|
||||
'green' => 'bg-green-50 text-green-700 border border-green-200',
|
||||
default => 'bg-blue-50 text-blue-600 border border-blue-200',
|
||||
};
|
||||
$badgeBg = match($p['color']) {
|
||||
'red' => 'bg-red-500',
|
||||
'orange' => 'bg-orange-400',
|
||||
'yellow' => 'bg-yellow-400',
|
||||
'green' => 'bg-green-500',
|
||||
default => 'bg-blue-500',
|
||||
};
|
||||
$namaLower = strtolower($p['nama']);
|
||||
$icon = '⚙️';
|
||||
foreach ($iconMap as $key => $val) {
|
||||
if (str_contains($namaLower, $key)) { $icon = $val; break; }
|
||||
}
|
||||
@endphp
|
||||
<div class="border {{ $border }} rounded-xl p-5 bg-white">
|
||||
<div class="flex items-start gap-4 mb-3">
|
||||
<div class="{{ $badgeBg }} text-white rounded-full w-8 h-8 flex items-center justify-center font-bold text-sm flex-shrink-0">
|
||||
{{ $p['rank'] }}
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs font-semibold {{ $title }}">
|
||||
Prioritas {{ $p['rank'] === 1 ? 'Utama' : ($p['rank'] === 2 ? 'Kedua' : 'Ketiga') }}
|
||||
</p>
|
||||
<h3 class="text-base font-bold text-gray-800">{{ $p['nama'] }}</h3>
|
||||
</div>
|
||||
<div class="ml-auto text-3xl">{{ $icon }}</div>
|
||||
</div>
|
||||
|
||||
<div class="text-xs {{ $dampak }} p-2 rounded">
|
||||
Dampak: {{ $p['dampak'] }}
|
||||
<ul class="text-sm space-y-2 mb-4">
|
||||
@foreach ($p['actions'] as $action)
|
||||
<li class="flex items-start gap-2 text-gray-700">
|
||||
<span class="text-blue-500 mt-0.5">✔</span> {{ $action }}
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
|
||||
<div class="text-xs {{ $dampak }} p-2 rounded-lg">
|
||||
Alasan: {{ $p['dampak'] }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-span-3 text-center text-gray-400 text-sm py-6">
|
||||
Belum ada data rekomendasi. Pastikan analisis sentimen sudah dijalankan.
|
||||
</div>
|
||||
@endforelse
|
||||
@empty
|
||||
<div class="col-span-3 text-center text-gray-400 text-sm py-6">
|
||||
Belum ada data rekomendasi. Pastikan analisis sentimen sudah dijalankan.
|
||||
</div>
|
||||
@endforelse
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- FOOTER NOTE --}}
|
||||
<div class="bg-blue-50 border border-blue-100 rounded-xl px-5 py-3 flex items-start gap-3 text-sm text-gray-600">
|
||||
<span class="text-blue-500 mt-0.5">ℹ️</span>
|
||||
<span>Rekomendasi dihasilkan secara otomatis berdasarkan hasil analisis sentimen dan kata kunci dominan dari ulasan wisatawan.</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -5,17 +5,64 @@
|
|||
<div class="max-w-7xl mx-auto space-y-6">
|
||||
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">Riwayat Analisis</h2>
|
||||
<h2 class="text-2xl font-bold text-gray-800">
|
||||
Riwayat Analisis
|
||||
</h2>
|
||||
|
||||
<p class="text-sm text-gray-500">
|
||||
Periode tersimpan otomatis setiap kali Ambil Data dijalankan.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<a href="{{ route('ulasan.index') }}"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm shadow text-center">
|
||||
Ambil Data Baru
|
||||
</a>
|
||||
{{-- TAMBAHAN BUTTON CETAK TAHUNAN --}}
|
||||
{{-- TAMBAHAN BUTTON CETAK TAHUNAN --}}
|
||||
<form
|
||||
action="{{ route('laporan.tahunan') }}"
|
||||
method="GET"
|
||||
class="flex items-center gap-3">
|
||||
|
||||
<div class="relative">
|
||||
|
||||
<select
|
||||
name="tahun"
|
||||
required
|
||||
class="appearance-none
|
||||
border-2 border-blue-500
|
||||
rounded-2xl
|
||||
pl-4 pr-9
|
||||
py-2.5
|
||||
text-sm font-medium
|
||||
bg-white
|
||||
shadow-sm
|
||||
cursor-pointer
|
||||
focus:outline-none
|
||||
focus:ring-2
|
||||
focus:ring-blue-300">
|
||||
|
||||
@for($tahun = date('Y'); $tahun >= 2024; $tahun--)
|
||||
<option value="{{ $tahun }}">{{ $tahun }}</option>
|
||||
@endfor
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-600
|
||||
hover:bg-blue-700
|
||||
text-white
|
||||
px-5 py-2.5
|
||||
rounded-2xl
|
||||
text-sm font-medium
|
||||
shadow">
|
||||
Cetak Tahunan
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@if(session('success'))
|
||||
|
|
@ -23,6 +70,7 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm sha
|
|||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(session('error'))
|
||||
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded whitespace-pre-line">
|
||||
{{ session('error') }}
|
||||
|
|
@ -30,23 +78,46 @@ class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm sha
|
|||
@endif
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-6">
|
||||
<h3 class="font-semibold text-gray-800 mb-1">Import Data Lama dari CSV</h3>
|
||||
|
||||
<h3 class="font-semibold text-gray-800 mb-1">
|
||||
Import Data Lama dari CSV
|
||||
</h3>
|
||||
|
||||
<p class="text-sm text-gray-500 mb-4">
|
||||
Gunakan untuk memasukkan ulasan historis. Kolom wajib: wisata, rating, ulasan, tanggal. Kolom reviewer boleh ada.
|
||||
Gunakan untuk memasukkan ulasan historis. Kolom wajib:
|
||||
wisata, rating, ulasan, tanggal.
|
||||
Kolom reviewer boleh ada.
|
||||
</p>
|
||||
|
||||
<form action="{{ route('riwayat.import') }}" method="POST" enctype="multipart/form-data"
|
||||
<form
|
||||
action="{{ route('riwayat.import') }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
class="grid grid-cols-1 md:grid-cols-[180px_1fr_auto] gap-3 md:items-center">
|
||||
|
||||
@csrf
|
||||
<input type="month" name="periode_bulan" value="{{ now()->format('Y-m') }}"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]" required>
|
||||
|
||||
<input type="file" name="file" accept=".csv,.txt"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-0" required>
|
||||
<input
|
||||
type="month"
|
||||
name="periode_bulan"
|
||||
value="{{ now()->format('Y-m') }}"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]"
|
||||
required>
|
||||
|
||||
<input
|
||||
type="file"
|
||||
name="file"
|
||||
accept=".csv,.txt"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-0"
|
||||
required>
|
||||
|
||||
<button
|
||||
class="bg-green-600 hover:bg-green-700 text-white px-5 py-2 rounded-lg text-sm shadow">
|
||||
|
||||
<button class="bg-green-600 hover:bg-green-700 text-white px-5 py-2 rounded-lg text-sm shadow">
|
||||
Import CSV
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
@if($errors->any())
|
||||
|
|
@ -54,64 +125,207 @@ class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-0" required>
|
|||
{{ $errors->first() }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow overflow-hidden">
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
|
||||
<table class="w-full text-sm">
|
||||
|
||||
<thead class="bg-gray-100 text-left">
|
||||
|
||||
<tr>
|
||||
<th class="px-4 py-3">Periode</th>
|
||||
<th class="px-4 py-3 text-center">Total Ulasan</th>
|
||||
<th class="px-4 py-3 text-center">Hasil Analisis</th>
|
||||
<th class="px-4 py-3 text-center">Wisata</th>
|
||||
<th class="px-4 py-3">Terakhir Analisis</th>
|
||||
<th class="px-4 py-3 text-center">Aksi</th>
|
||||
|
||||
<th class="px-4 py-3">
|
||||
Periode
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Total Ulasan
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Hasil Analisis
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Wisata
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3">
|
||||
Terakhir Analisis
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Aksi
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y">
|
||||
|
||||
@forelse($riwayat as $item)
|
||||
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 font-semibold text-gray-800">{{ $item->nama }}</td>
|
||||
<td class="px-4 py-3 text-center">{{ $item->total_ulasan }}</td>
|
||||
<td class="px-4 py-3 text-center">{{ $item->total_hasil }}</td>
|
||||
<td class="px-4 py-3 text-center">{{ $item->total_wisata }}</td>
|
||||
|
||||
<td class="px-4 py-3 font-semibold text-gray-800">
|
||||
{{ $item->nama }}
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
{{ $item->total_ulasan }}
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
{{ $item->total_hasil }}
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
{{ $item->total_wisata }}
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-gray-500">
|
||||
{{ $item->terakhir_analisis ? \Carbon\Carbon::parse($item->terakhir_analisis)->format('d M Y H:i') : '-' }}
|
||||
|
||||
{{ $item->terakhir_analisis
|
||||
? \Carbon\Carbon::parse(
|
||||
$item->terakhir_analisis
|
||||
)->format('d M Y H:i')
|
||||
: '-' }}
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3">
|
||||
|
||||
<div class="flex flex-wrap justify-center gap-2">
|
||||
<a href="{{ route('dashboard', ['periode_id' => $item->id]) }}"
|
||||
class="px-3 py-1 rounded-lg bg-blue-50 text-blue-600 hover:bg-blue-100">
|
||||
Dashboard
|
||||
</a>
|
||||
<a href="{{ route('dashboard', ['periode_id' => $item->id, 'tab' => 'analisis']) }}"
|
||||
class="px-3 py-1 rounded-lg bg-green-50 text-green-600 hover:bg-green-100">
|
||||
|
||||
<a
|
||||
href="{{ route('dashboard',
|
||||
['periode_id'=>$item->id,
|
||||
'tab'=>'analisis']) }}"
|
||||
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-green-50 text-green-600
|
||||
hover:bg-green-100">
|
||||
|
||||
Analisis
|
||||
|
||||
</a>
|
||||
<a href="{{ route('ulasan.index', ['periode_id' => $item->id]) }}"
|
||||
class="px-3 py-1 rounded-lg bg-gray-100 text-gray-700 hover:bg-gray-200">
|
||||
|
||||
<a
|
||||
href="{{ route('ulasan.index',
|
||||
['periode_id'=>$item->id]) }}"
|
||||
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-gray-100 text-gray-700
|
||||
hover:bg-gray-200">
|
||||
|
||||
Ulasan
|
||||
|
||||
</a>
|
||||
|
||||
{{-- TAMBAHAN CETAK BULANAN --}}
|
||||
<a
|
||||
href="{{ route('laporan.bulanan', $item->id) }}"
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-blue-50 text-blue-600
|
||||
hover:bg-blue-100">
|
||||
Cetak Laporan
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@empty
|
||||
|
||||
<tr>
|
||||
<td colspan="6" class="px-4 py-8 text-center text-gray-400">
|
||||
Belum ada riwayat analisis. Jalankan Ambil Data terlebih dahulu.
|
||||
|
||||
<td
|
||||
colspan="6"
|
||||
class="px-4 py-8 text-center text-gray-400">
|
||||
|
||||
Belum ada riwayat analisis.
|
||||
Jalankan Ambil Data terlebih dahulu.
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@endforelse
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
@if($riwayat->hasPages())
|
||||
<div class="p-4">
|
||||
{{ $riwayat->links() }}
|
||||
{{-- ================= PAGINATION ================= --}}
|
||||
|
||||
@if($riwayat->hasPages())
|
||||
@php
|
||||
$current = $riwayat->currentPage();
|
||||
$last = $riwayat->lastPage();
|
||||
$query = http_build_query(request()->except('page'));
|
||||
$window = collect(range(max(1, $current - 2), min($last, $current + 2)));
|
||||
@endphp
|
||||
|
||||
<div class="px-6 py-4 border-t border-gray-100 flex items-center justify-between text-sm text-gray-600">
|
||||
|
||||
{{-- Info --}}
|
||||
<p>Menampilkan {{ $riwayat->firstItem() }} – {{ $riwayat->lastItem() }} dari {{ $riwayat->total() }} data</p>
|
||||
|
||||
{{-- Tombol --}}
|
||||
<div class="flex items-center gap-1">
|
||||
|
||||
{{-- « --}}
|
||||
@if($riwayat->onFirstPage())
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-gray-100 text-gray-400 cursor-not-allowed">«</span>
|
||||
@else
|
||||
<a href="{{ $riwayat->previousPageUrl() }}&{{ $query }}" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">«</a>
|
||||
@endif
|
||||
|
||||
{{-- Halaman 1 --}}
|
||||
@if(!$window->contains(1))
|
||||
<a href="{{ $riwayat->url(1) }}&{{ $query }}" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">1</a>
|
||||
@if($window->min() > 2)
|
||||
<span class="px-2 py-1.5 text-gray-400">...</span>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
{{-- Window --}}
|
||||
@foreach($window as $page)
|
||||
@if($page == $current)
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-blue-600 text-white font-semibold">{{ $page }}</span>
|
||||
@else
|
||||
<a href="{{ $riwayat->url($page) }}&{{ $query }}" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">{{ $page }}</a>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
{{-- Halaman terakhir --}}
|
||||
@if(!$window->contains($last))
|
||||
@if($window->max() < $last - 1)
|
||||
<span class="px-2 py-1.5 text-gray-400">...</span>
|
||||
@endif
|
||||
<a href="{{ $riwayat->url($last) }}&{{ $query }}" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">{{ $last }}</a>
|
||||
@endif
|
||||
|
||||
{{-- » --}}
|
||||
@if($riwayat->hasMorePages())
|
||||
<a href="{{ $riwayat->nextPageUrl() }}&{{ $query }}" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">»</a>
|
||||
@else
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-gray-100 text-gray-400 cursor-not-allowed">»</span>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
use App\Http\Controllers\Auth\ConfirmablePasswordController;
|
||||
use App\Http\Controllers\Auth\EmailVerificationNotificationController;
|
||||
use App\Http\Controllers\Auth\EmailVerificationPromptController;
|
||||
use App\Http\Controllers\Auth\NewPasswordController;
|
||||
use App\Http\Controllers\Auth\PasswordController;
|
||||
use App\Http\Controllers\Auth\PasswordResetLinkController;
|
||||
use App\Http\Controllers\Auth\RegisteredUserController;
|
||||
use App\Http\Controllers\Auth\VerifyEmailController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware('guest')->group(function () {
|
||||
|
||||
Route::get('register', [RegisteredUserController::class, 'create'])
|
||||
->name('register');
|
||||
|
||||
|
|
@ -22,20 +21,15 @@
|
|||
|
||||
Route::post('login', [AuthenticatedSessionController::class, 'store']);
|
||||
|
||||
Route::get('forgot-password', [PasswordResetLinkController::class, 'create'])
|
||||
->name('password.request');
|
||||
|
||||
Route::post('forgot-password', [PasswordResetLinkController::class, 'store'])
|
||||
->name('password.email');
|
||||
|
||||
Route::get('reset-password/{token}', [NewPasswordController::class, 'create'])
|
||||
->name('password.reset');
|
||||
|
||||
Route::post('reset-password', [NewPasswordController::class, 'store'])
|
||||
->name('password.store');
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RESET PASSWORD BAWAAN DIHAPUS
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
});
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
|
||||
Route::get('verify-email', EmailVerificationPromptController::class)
|
||||
->name('verification.notice');
|
||||
|
||||
|
|
@ -43,17 +37,31 @@
|
|||
->middleware(['signed', 'throttle:6,1'])
|
||||
->name('verification.verify');
|
||||
|
||||
Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store'])
|
||||
->middleware('throttle:6,1')
|
||||
->name('verification.send');
|
||||
Route::post(
|
||||
'email/verification-notification',
|
||||
[EmailVerificationNotificationController::class, 'store']
|
||||
)
|
||||
->middleware('throttle:6,1')
|
||||
->name('verification.send');
|
||||
|
||||
Route::get('confirm-password', [ConfirmablePasswordController::class, 'show'])
|
||||
->name('password.confirm');
|
||||
Route::get(
|
||||
'confirm-password',
|
||||
[ConfirmablePasswordController::class, 'show']
|
||||
)
|
||||
->name('password.confirm');
|
||||
|
||||
Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']);
|
||||
Route::post(
|
||||
'confirm-password',
|
||||
[ConfirmablePasswordController::class, 'store']
|
||||
);
|
||||
|
||||
Route::put('password', [PasswordController::class, 'update'])->name('password.update');
|
||||
Route::put(
|
||||
'password',
|
||||
[PasswordController::class, 'update']
|
||||
)->name('password.update');
|
||||
|
||||
Route::post('logout', [AuthenticatedSessionController::class, 'destroy'])
|
||||
->name('logout');
|
||||
Route::post(
|
||||
'logout',
|
||||
[AuthenticatedSessionController::class, 'destroy']
|
||||
)->name('logout');
|
||||
});
|
||||
|
|
@ -7,14 +7,33 @@
|
|||
use App\Http\Controllers\AnalisisController;
|
||||
use App\Http\Controllers\RekomendasiController;
|
||||
use App\Http\Controllers\UserController;
|
||||
use App\Http\Controllers\Auth\ForgotPasswordController;
|
||||
use App\Http\Controllers\Auth\ResetPasswordController;
|
||||
use App\Http\Controllers\LaporanController;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ROUTE AWAL
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Route::get('/forgot-password',
|
||||
[ForgotPasswordController::class, 'showLinkRequestForm'])
|
||||
->name('password.request');
|
||||
|
||||
Route::post('/forgot-password',
|
||||
[ForgotPasswordController::class, 'sendResetLinkEmail'])
|
||||
->name('password.email');
|
||||
|
||||
Route::get('/reset-password/{token}',
|
||||
[ResetPasswordController::class, 'showResetForm'])
|
||||
->name('password.reset');
|
||||
|
||||
Route::post('/reset-password-custom',
|
||||
[ResetPasswordController::class, 'reset'])
|
||||
->name('custom.password.update');
|
||||
|
||||
Route::get('/', function () {
|
||||
return redirect('/login');
|
||||
});
|
||||
|
|
@ -105,6 +124,21 @@
|
|||
[UlasanController::class, 'kosongkanPeriode']
|
||||
)->name('ulasan.kosongkan-periode');
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| LAPORAN
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
Route::get('/laporan/bulanan/{periode}',
|
||||
[LaporanController::class, 'downloadBulanan']
|
||||
)->name('laporan.bulanan');
|
||||
|
||||
Route::get('/laporan/tahunan',
|
||||
[LaporanController::class, 'downloadTahunan']
|
||||
)->name('laporan.tahunan');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PROSES ANALISIS
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,295 @@
|
|||
from flask import Flask, request, jsonify
|
||||
import pickle
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import nltk
|
||||
from nltk.corpus import stopwords
|
||||
from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
|
||||
|
||||
# =========================
|
||||
# LOAD MODEL
|
||||
# =========================
|
||||
|
||||
with open('model/model_sentiment.pkl', 'rb') as file:
|
||||
model = pickle.load(file)
|
||||
|
||||
with open('model/tfidf_vectorizer.pkl', 'rb') as file:
|
||||
tfidf = pickle.load(file)
|
||||
|
||||
# =========================
|
||||
# PREPROCESSING
|
||||
# =========================
|
||||
|
||||
nltk.download('stopwords')
|
||||
|
||||
stop_words = set(stopwords.words('indonesian'))
|
||||
|
||||
factory = StemmerFactory()
|
||||
stemmer = factory.create_stemmer()
|
||||
|
||||
def preprocess_text(text):
|
||||
|
||||
text = str(text).lower()
|
||||
|
||||
# normalisasi huruf berulang
|
||||
text = re.sub(r'(.)\1+', r'\1', text)
|
||||
|
||||
# hapus angka
|
||||
text = re.sub(r'\d+', '', text)
|
||||
|
||||
# hapus simbol
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
|
||||
# hapus spasi berlebih
|
||||
text = re.sub(r'\s+', ' ', text).strip()
|
||||
|
||||
# tokenizing
|
||||
words = text.split()
|
||||
|
||||
# slang normalization
|
||||
slang_dict = {
|
||||
'gk': 'tidak',
|
||||
'ga': 'tidak',
|
||||
'nggak': 'tidak',
|
||||
'bgt': 'banget',
|
||||
'bgtt': 'banget',
|
||||
'bangett': 'banget',
|
||||
'bgus': 'bagus',
|
||||
'baguss': 'bagus',
|
||||
'tmpt': 'tempat',
|
||||
'jln': 'jalan',
|
||||
'sy': 'saya',
|
||||
'yg': 'yang',
|
||||
'udh': 'sudah'
|
||||
}
|
||||
|
||||
words = [
|
||||
slang_dict[word] if word in slang_dict else word
|
||||
for word in words
|
||||
]
|
||||
|
||||
# stopword removal
|
||||
words = [
|
||||
word for word in words
|
||||
if word not in stop_words
|
||||
]
|
||||
|
||||
# stemming
|
||||
words = [stemmer.stem(word) for word in words]
|
||||
|
||||
return ' '.join(words)
|
||||
|
||||
# lowercase
|
||||
text = text.lower()
|
||||
|
||||
# hapus angka
|
||||
text = re.sub(r'\d+', '', text)
|
||||
|
||||
# hapus simbol
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
|
||||
# hapus spasi berlebih
|
||||
text = re.sub(r'\s+', ' ', text).strip()
|
||||
|
||||
# tokenizing
|
||||
words = text.split()
|
||||
|
||||
# stopword removal
|
||||
words = [word for word in words if word not in stop_words]
|
||||
|
||||
# stemming
|
||||
words = [stemmer.stem(word) for word in words]
|
||||
|
||||
return ' '.join(words)
|
||||
|
||||
# lowercase
|
||||
text = text.lower()
|
||||
|
||||
# hapus angka
|
||||
text = re.sub(r'\d+', '', text)
|
||||
|
||||
# hapus simbol
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
|
||||
# hapus spasi berlebih
|
||||
text = re.sub(r'\s+', ' ', text).strip()
|
||||
|
||||
# tokenizing
|
||||
words = text.split()
|
||||
|
||||
# stopword removal
|
||||
words = [word for word in words if word not in stop_words]
|
||||
|
||||
# stemming
|
||||
words = [stemmer.stem(word) for word in words]
|
||||
|
||||
return ' '.join(words)
|
||||
|
||||
# =========================
|
||||
# FLASK APP
|
||||
# =========================
|
||||
|
||||
app = Flask(__name__)
|
||||
@app.route('/scraping', methods=['POST'])
|
||||
def scraping():
|
||||
|
||||
try:
|
||||
|
||||
data = request.get_json()
|
||||
|
||||
wisata = data.get('wisata', '')
|
||||
|
||||
result = subprocess.run(
|
||||
['python', 'scraping_pipeline.py', wisata],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': result.stderr
|
||||
}), 500
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': result.stdout
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
|
||||
try:
|
||||
|
||||
result = subprocess.run(
|
||||
['python', 'scraping_pipeline.py'],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': result.stderr
|
||||
}), 500
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': result.stdout
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
|
||||
# ======================================
|
||||
# PREDICT 1 REVIEW
|
||||
# ======================================
|
||||
|
||||
@app.route('/predict', methods=['POST'])
|
||||
def predict():
|
||||
|
||||
data = request.get_json()
|
||||
|
||||
review = data['review']
|
||||
|
||||
# preprocessing
|
||||
clean_review = preprocess_text(review)
|
||||
|
||||
# tfidf transform
|
||||
vector = tfidf.transform([clean_review])
|
||||
|
||||
# prediksi
|
||||
prediction = model.predict(vector)[0]
|
||||
|
||||
# probabilitas
|
||||
probability = model.predict_proba(vector).max()
|
||||
|
||||
return jsonify({
|
||||
'review': review,
|
||||
'clean_review': clean_review,
|
||||
'sentiment': prediction,
|
||||
'probability': round(float(probability), 4)
|
||||
})
|
||||
|
||||
# ======================================
|
||||
# PROSES ANALISIS SEMUA DATA
|
||||
# ======================================
|
||||
|
||||
@app.route('/proses-analisis', methods=['POST'])
|
||||
def proses_analisis():
|
||||
|
||||
try:
|
||||
|
||||
data = request.get_json()
|
||||
|
||||
periode_id = str(data.get('periode_id'))
|
||||
|
||||
result = subprocess.run(
|
||||
['python', 'analisis.py', periode_id],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': result.stderr
|
||||
}), 500
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': result.stdout
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
|
||||
try:
|
||||
|
||||
result = subprocess.run(
|
||||
['python', 'analisis.py'],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': result.stderr
|
||||
}), 500
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'message': result.stdout
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'error': str(e)
|
||||
}), 500
|
||||
|
||||
# =========================
|
||||
# RUN APP
|
||||
# =========================
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=False)
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,193 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
redistribute_periode.py
|
||||
-----------------------
|
||||
Memisahkan ulasan 2025 yang salah masuk ke periode Mei 2026,
|
||||
lalu memindahkan ke periode yang benar berdasarkan kolom `tanggal`.
|
||||
|
||||
Jalankan dari root project Laravel:
|
||||
python scripts/redistribute_periode.py
|
||||
|
||||
Atau dengan --dry-run untuk preview tanpa mengubah data:
|
||||
python scripts/redistribute_periode.py --dry-run
|
||||
"""
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
|
||||
# ── path setup ──────────────────────────────────────────────────────────────
|
||||
BASE_DIR = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
# re-use helper dari scraping_pipeline
|
||||
from scraping_pipeline import (
|
||||
db_config,
|
||||
make_connection,
|
||||
prepare_sql,
|
||||
execute,
|
||||
is_sqlite_connection,
|
||||
)
|
||||
|
||||
NAMA_BULAN = [
|
||||
"Januari", "Februari", "Maret", "April", "Mei", "Juni",
|
||||
"Juli", "Agustus", "September", "Oktober", "November", "Desember",
|
||||
]
|
||||
|
||||
|
||||
def log(level, msg):
|
||||
print(f"[{level}] {msg}", flush=True)
|
||||
|
||||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument(
|
||||
"--dry-run",
|
||||
action="store_true",
|
||||
help="Preview perubahan tanpa benar-benar mengubah database.",
|
||||
)
|
||||
p.add_argument(
|
||||
"--tahun",
|
||||
type=int,
|
||||
default=2025,
|
||||
help="Tahun ulasan yang akan dipisah. Default: 2025.",
|
||||
)
|
||||
return p.parse_args()
|
||||
|
||||
|
||||
def get_or_create_periode(cursor, conn, bulan, tahun, dry_run):
|
||||
"""Ambil id periode yang ada, atau buat baru jika belum ada."""
|
||||
execute(
|
||||
cursor, conn,
|
||||
"SELECT id FROM periode_analisis WHERE bulan = %s AND tahun = %s LIMIT 1",
|
||||
(bulan, tahun),
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
return row[0]
|
||||
|
||||
nama = f"{NAMA_BULAN[bulan - 1]} {tahun}"
|
||||
if dry_run:
|
||||
log("DRY-RUN", f"Akan buat periode baru: {nama}")
|
||||
return None # belum ada id nyata
|
||||
|
||||
execute(
|
||||
cursor, conn,
|
||||
"""
|
||||
INSERT INTO periode_analisis (nama, bulan, tahun, created_at, updated_at)
|
||||
VALUES (%s, %s, %s, NOW(), NOW())
|
||||
""",
|
||||
(nama, bulan, tahun),
|
||||
)
|
||||
conn.commit()
|
||||
new_id = cursor.lastrowid
|
||||
log("OK", f"Periode baru dibuat: {nama} (id={new_id})")
|
||||
return new_id
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
dry_run = args.dry_run
|
||||
tahun = args.tahun
|
||||
|
||||
if dry_run:
|
||||
log("INFO", "Mode DRY-RUN — tidak ada perubahan yang disimpan.")
|
||||
|
||||
config = db_config()
|
||||
conn = make_connection(config)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# ── 1. Ambil semua ulasan tahun target yang periode-nya salah ───────────
|
||||
# "Salah" = bulan/tahun di kolom tanggal tidak cocok dengan periode_analisis
|
||||
if is_sqlite_connection(conn):
|
||||
sql_fetch = """
|
||||
SELECT u.id, u.tanggal, u.wisata, u.periode_id,
|
||||
p.bulan AS p_bulan, p.tahun AS p_tahun
|
||||
FROM ulasan u
|
||||
JOIN periode_analisis p ON u.periode_id = p.id
|
||||
WHERE strftime('%Y', u.tanggal) = ?
|
||||
AND (
|
||||
CAST(strftime('%m', u.tanggal) AS INTEGER) != p.bulan
|
||||
OR CAST(strftime('%Y', u.tanggal) AS INTEGER) != p.tahun
|
||||
)
|
||||
"""
|
||||
cursor.execute(sql_fetch, (str(tahun),))
|
||||
else:
|
||||
sql_fetch = """
|
||||
SELECT u.id, u.tanggal, u.wisata, u.periode_id,
|
||||
p.bulan AS p_bulan, p.tahun AS p_tahun
|
||||
FROM ulasan u
|
||||
JOIN periode_analisis p ON u.periode_id = p.id
|
||||
WHERE YEAR(u.tanggal) = %s
|
||||
AND (
|
||||
MONTH(u.tanggal) != p.bulan
|
||||
OR YEAR(u.tanggal) != p.tahun
|
||||
)
|
||||
"""
|
||||
cursor.execute(sql_fetch, (tahun,))
|
||||
|
||||
rows = cursor.fetchall()
|
||||
log("INFO", f"Ditemukan {len(rows)} ulasan {tahun} dengan periode tidak sesuai tanggal.")
|
||||
|
||||
if not rows:
|
||||
log("OK", "Tidak ada data yang perlu dipindahkan.")
|
||||
conn.close()
|
||||
return
|
||||
|
||||
# ── 2. Kelompokkan per bulan ─────────────────────────────────────────────
|
||||
from collections import defaultdict
|
||||
grouped = defaultdict(list) # (bulan, tahun) → [id, ...]
|
||||
|
||||
for row in rows:
|
||||
ulasan_id, tanggal, wisata, periode_id, p_bulan, p_tahun = row
|
||||
try:
|
||||
if isinstance(tanggal, str):
|
||||
dt = datetime.strptime(tanggal[:10], "%Y-%m-%d")
|
||||
else:
|
||||
dt = tanggal
|
||||
grouped[(dt.month, dt.year)].append(ulasan_id)
|
||||
except Exception as e:
|
||||
log("WARNING", f"Skip id={ulasan_id} tanggal='{tanggal}': {e}")
|
||||
|
||||
# ── 3. Preview ───────────────────────────────────────────────────────────
|
||||
log("INFO", "Rencana pemindahan:")
|
||||
for (bulan, thn), ids in sorted(grouped.items()):
|
||||
nama = f"{NAMA_BULAN[bulan - 1]} {thn}"
|
||||
log("INFO", f" → {nama}: {len(ids)} ulasan")
|
||||
|
||||
if dry_run:
|
||||
log("DRY-RUN", "Selesai preview. Jalankan tanpa --dry-run untuk terapkan perubahan.")
|
||||
conn.close()
|
||||
return
|
||||
|
||||
# ── 4. Terapkan pemindahan ───────────────────────────────────────────────
|
||||
total_moved = 0
|
||||
for (bulan, thn), ids in sorted(grouped.items()):
|
||||
periode_id = get_or_create_periode(cursor, conn, bulan, thn, dry_run=False)
|
||||
if periode_id is None:
|
||||
continue
|
||||
|
||||
# Update per batch
|
||||
placeholders = ",".join(["%s"] * len(ids))
|
||||
if is_sqlite_connection(conn):
|
||||
placeholders = ",".join(["?"] * len(ids))
|
||||
|
||||
cursor.execute(
|
||||
f"UPDATE ulasan SET periode_id = %s, updated_at = NOW() WHERE id IN ({placeholders})".replace(
|
||||
"%s", "?" if is_sqlite_connection(conn) else "%s"
|
||||
),
|
||||
[periode_id] + ids,
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
nama = f"{NAMA_BULAN[bulan - 1]} {thn}"
|
||||
log("OK", f"{nama}: {len(ids)} ulasan dipindahkan ke periode_id={periode_id}")
|
||||
total_moved += len(ids)
|
||||
|
||||
log("OK", f"Selesai. Total {total_moved} ulasan berhasil dipindahkan ke periode yang benar.")
|
||||
conn.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
import argparse
|
||||
import os
|
||||
import tempfile
|
||||
import hashlib
|
||||
|
||||
from networkx import config
|
||||
import undetected_chromedriver as uc
|
||||
|
|
@ -114,7 +115,7 @@ def db_config():
|
|||
"connection": connection,
|
||||
"host": env_value(env, "DB_HOST", "127.0.0.1"),
|
||||
"port": int(env_value(env, "DB_PORT", "3306")),
|
||||
"database": env_value(env, "DB_DATABASE", "sentara"),
|
||||
"database": env_value(env, "DB_DATABASE", "sistem_analisis"),
|
||||
"user": env_value(env, "DB_USERNAME", "root"),
|
||||
"password": env_value(env, "DB_PASSWORD", ""),
|
||||
}
|
||||
|
|
@ -277,10 +278,10 @@ def get_or_create_period(cursor, conn, start_date, end_date):
|
|||
|
||||
|
||||
DESTINATIONS = {
|
||||
"Pantai Papuma": "https://www.google.com/maps/search/?api=1&query=Pantai%20Papuma%20Jember",
|
||||
"Pantai Watu Ulo": "https://www.google.com/maps/search/?api=1&query=Pantai%20Watu%20Ulo%20Jember",
|
||||
"Teluk Love": "https://www.google.com/maps/search/?api=1&query=Teluk%20Love%20Jember",
|
||||
"Kebun Teh Gunung Gambir": "https://www.google.com/maps/search/?api=1&query=Kebun%20Teh%20Gunung%20Gambir%20Jember",
|
||||
"Pantai Papuma": "https://www.google.com/maps/place/Pantai+Papuma/@-8.4310054,113.5508204,16z/data=!4m7!3m6!1s0x2dd682a6a4b5cd8d:0xb9c242f3a09e2d2e!4b1!8m2!3d-8.4300871!4d113.5536464!16s%2Fg%2F11bwy_gg5k?authuser=0&entry=ttu&g_ep=EgoyMDI2MDUxMy4wIKXMDSoASAFQAw%3D%3D",
|
||||
"Pantai Watu Ulo": "https://www.google.com/maps/place/Pantai+Watu+Ulo/@-8.4252967,113.5515972,15z/data=!4m8!3m7!1s0x2dd69d2fffffffff:0x6f3d7097accf3209!8m2!3d-8.425297!4d113.561897!9m1!1b1!16s%2Fg%2F120m19h0?authuser=0&entry=ttu&g_ep=EgoyMDI2MDUxMy4wIKXMDSoASAFQAw%3D%3D",
|
||||
"Teluk Love": "https://www.google.com/maps/place/Teluk+Love/@-8.4410549,113.581323,17z/data=!3m1!4b1!4m6!3m5!1s0x2dd6942520c45715:0x3cabb1f5dd90a01b!8m2!3d-8.4410549!4d113.5838979!16s%2Fg%2F11ckkqq_1b?authuser=0&entry=ttu&g_ep=EgoyMDI2MDUxMy4wIKXMDSoASAFQAw%3D%3D",
|
||||
"Kebun Teh Gunung Gambir": "https://www.google.com/maps/place/Wisata+kebun+teh+gunung+gambir/@-8.0351906,113.4389961,17z/data=!4m7!3m6!1s0x2dd6f551f90c0c8f:0x3d1a62be1e269d12!4b1!8m2!3d-8.0351906!4d113.441571!16s%2Fg%2F11tjmzk404?authuser=0&entry=ttu&g_ep=EgoyMDI2MDUxMy4wIKXMDSoASAFQAw%3D%3D",
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -303,6 +304,7 @@ def selected_destinations(wisata_name):
|
|||
|
||||
def build_chrome_options(config):
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
import tempfile
|
||||
|
||||
options = Options()
|
||||
# options = uc.ChromeOptions()
|
||||
|
|
@ -310,7 +312,6 @@ def build_chrome_options(config):
|
|||
|
||||
options.add_argument("--lang=id")
|
||||
options.add_argument("--accept-language=id-ID,id")
|
||||
options.add_argument("--window-size=1366,900")
|
||||
options.add_argument("--disable-blink-features=AutomationControlled")
|
||||
options.add_argument("--disable-dev-shm-usage")
|
||||
options.add_argument("--no-sandbox")
|
||||
|
|
@ -326,8 +327,12 @@ def build_chrome_options(config):
|
|||
|
||||
options.add_argument(f"--user-data-dir={tempfile.mkdtemp()}")
|
||||
|
||||
if config["headless"]:
|
||||
# User agent supaya dianggap browser asli
|
||||
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
|
||||
|
||||
if config.get("headless"):
|
||||
options.add_argument("--headless=new")
|
||||
options.add_argument("--window-size=1920,1080")
|
||||
else:
|
||||
options.add_argument("--start-maximized")
|
||||
|
||||
|
|
@ -405,7 +410,7 @@ def click_first_search_result_if_needed(driver):
|
|||
for result in results:
|
||||
if result.is_displayed():
|
||||
driver.execute_script("arguments[0].click();", result)
|
||||
time.sleep(5)
|
||||
time.sleep(10)
|
||||
log("INFO", "Hasil pencarian Google Maps pertama dibuka.")
|
||||
return True
|
||||
except Exception as exc:
|
||||
|
|
@ -669,22 +674,31 @@ def click_reviews_tab(driver, wait, wisata, manual_login_timeout=0):
|
|||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
|
||||
candidates = [
|
||||
"//div[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan')]",
|
||||
"//div[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review')]",
|
||||
"//button[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan')]",
|
||||
"//button[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review')]",
|
||||
"//button[contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan') and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'tulis')) and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'write'))]",
|
||||
"//button[contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review') and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'write'))]",
|
||||
# candidates = [
|
||||
# "//div[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan')]",
|
||||
# "//div[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review')]",
|
||||
# "//button[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan')]",
|
||||
# "//button[@role='tab'][contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review')]",
|
||||
# "//button[contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'ulasan') and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'tulis')) and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'write'))]",
|
||||
# "//button[contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'review') and not(contains(translate(@aria-label, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), 'write'))]",
|
||||
# ]
|
||||
|
||||
possible_xpaths = [
|
||||
"//button[contains(@aria-label, 'Ulasan untuk')]",
|
||||
"//button[contains(., 'Ulasan')]",
|
||||
"//div[@role='tab'][contains(., 'Ulasan')]",
|
||||
"//button[contains(@aria-label, 'Reviews')]"
|
||||
]
|
||||
|
||||
try:
|
||||
wait.until(EC.presence_of_all_elements_located((By.XPATH, "//button | //div[@role='tab']")))
|
||||
# wait.until(EC.presence_of_all_elements_located((By.XPATH, "//button | //div[@role='tab']")))
|
||||
all_btns = driver.find_elements(By.XPATH, "//button | //div[@role='tab']")
|
||||
time.sleep(3)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def try_click_reviews_tab():
|
||||
for xpath in candidates:
|
||||
for xpath in possible_xpaths:
|
||||
try:
|
||||
elements = driver.find_elements(By.XPATH, xpath)
|
||||
for element in elements:
|
||||
|
|
@ -739,6 +753,12 @@ def find_reviews_scroll_container(driver, wait):
|
|||
"//div[.//div[@data-review-id]]",
|
||||
]
|
||||
|
||||
# xpaths = [
|
||||
# "//div[contains(@class, 'm6U624-v79jQ-le0U9b')]", # Class kontainer ulasan umum
|
||||
# "//div[@role='main' and contains(@aria-label, 'Ulasan')]",
|
||||
# "//div[contains(@aria-label, 'Ulasan untuk')]"
|
||||
# ]
|
||||
|
||||
for xpath in xpaths:
|
||||
try:
|
||||
return wait.until(EC.presence_of_element_located((By.XPATH, xpath)))
|
||||
|
|
@ -749,7 +769,6 @@ def find_reviews_scroll_container(driver, wait):
|
|||
|
||||
|
||||
def scrape_with_selenium(cursor, conn, periode_id, start_date, end_date, config, destinations):
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
|
@ -772,8 +791,10 @@ def scrape_with_selenium(cursor, conn, periode_id, start_date, end_date, config,
|
|||
# options=build_chrome_options(config)
|
||||
# )
|
||||
|
||||
|
||||
service = Service(r"C:\Users\Mufrida Farah\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe")
|
||||
driver = webdriver.Chrome(service=service, options=build_chrome_options(config))
|
||||
opts = build_chrome_options(config)
|
||||
driver = webdriver.Chrome(service=service, options=opts)
|
||||
|
||||
total_saved = 0
|
||||
total_skipped_duplicate = 0
|
||||
|
|
@ -826,6 +847,7 @@ def scrape_with_selenium(cursor, conn, periode_id, start_date, end_date, config,
|
|||
|
||||
last_height = 0
|
||||
|
||||
driver.execute_script("arguments[0].focus();", scrollable_div)
|
||||
for i in range(config["scroll_limit"]):
|
||||
try:
|
||||
driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", scrollable_div)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,151 @@
|
|||
import pandas as pd
|
||||
import re
|
||||
import nltk
|
||||
import pickle
|
||||
|
||||
from Sastrawi.Stemmer.StemmerFactory import StemmerFactory
|
||||
from nltk.corpus import stopwords
|
||||
|
||||
# Download stopword nltk
|
||||
nltk.download('stopwords')
|
||||
|
||||
# =========================
|
||||
# LOAD DATASET
|
||||
# =========================
|
||||
|
||||
df = pd.read_excel('dataset/Labeled_LawangSewu_ReviewData.xlsx')
|
||||
|
||||
# Ambil kolom penting
|
||||
df = df[['Text', 'Label']]
|
||||
|
||||
# Rename kolom
|
||||
df.columns = ['review', 'label']
|
||||
|
||||
# Lowercase label
|
||||
df['label'] = df['label'].str.lower()
|
||||
|
||||
# Hapus label tidak relevan
|
||||
df = df[df['label'] != 'tidak relevan']
|
||||
|
||||
# Hapus data kosong
|
||||
df = df.dropna()
|
||||
|
||||
# Hapus duplicate
|
||||
df = df.drop_duplicates(subset=['review'])
|
||||
|
||||
# =========================
|
||||
# PREPROCESSING
|
||||
# =========================
|
||||
|
||||
# Stopword Indonesia
|
||||
stop_words = set(stopwords.words('indonesian'))
|
||||
|
||||
# Stemmer Indonesia
|
||||
factory = StemmerFactory()
|
||||
stemmer = factory.create_stemmer()
|
||||
|
||||
def preprocess_text(text):
|
||||
|
||||
# lowercase
|
||||
text = text.lower()
|
||||
|
||||
# hapus angka
|
||||
text = re.sub(r'\d+', '', text)
|
||||
|
||||
# hapus simbol
|
||||
text = re.sub(r'[^\w\s]', '', text)
|
||||
|
||||
# hapus spasi berlebih
|
||||
text = re.sub(r'\s+', ' ', text).strip()
|
||||
|
||||
# tokenizing
|
||||
words = text.split()
|
||||
|
||||
# stopword removal
|
||||
words = [word for word in words if word not in stop_words]
|
||||
|
||||
# stemming
|
||||
words = [stemmer.stem(word) for word in words]
|
||||
|
||||
return ' '.join(words)
|
||||
|
||||
# Terapkan preprocessing
|
||||
df['clean_review'] = df['review'].apply(preprocess_text)
|
||||
|
||||
# =========================
|
||||
# HASIL
|
||||
# =========================
|
||||
|
||||
print(df[['review', 'clean_review', 'label']].head())
|
||||
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.feature_extraction.text import TfidfVectorizer
|
||||
from sklearn.naive_bayes import MultinomialNB
|
||||
from sklearn.metrics import classification_report, accuracy_score
|
||||
|
||||
# =========================
|
||||
# TF-IDF
|
||||
# =========================
|
||||
|
||||
X = df['clean_review']
|
||||
y = df['label']
|
||||
|
||||
tfidf = TfidfVectorizer(
|
||||
max_features=5000,
|
||||
ngram_range=(1,2),
|
||||
min_df=3,
|
||||
max_df=0.9,
|
||||
sublinear_tf=True
|
||||
)
|
||||
|
||||
X_tfidf = tfidf.fit_transform(X)
|
||||
|
||||
# =========================
|
||||
# SPLIT DATA
|
||||
# =========================
|
||||
|
||||
X_train, X_test, y_train, y_test = train_test_split(
|
||||
X_tfidf,
|
||||
y,
|
||||
test_size=0.2,
|
||||
random_state=42,
|
||||
stratify=y
|
||||
)
|
||||
|
||||
# =========================
|
||||
# TRAIN MODEL
|
||||
# =========================
|
||||
|
||||
model = MultinomialNB(fit_prior=False)
|
||||
|
||||
model.fit(X_train, y_train)
|
||||
|
||||
# =========================
|
||||
# PREDIKSI
|
||||
# =========================
|
||||
|
||||
y_pred = model.predict(X_test)
|
||||
|
||||
# =========================
|
||||
# EVALUASI
|
||||
# =========================
|
||||
|
||||
accuracy = accuracy_score(y_test, y_pred)
|
||||
|
||||
print("\n=== HASIL EVALUASI MODEL ===")
|
||||
print(f"Akurasi: {accuracy:.4f}")
|
||||
|
||||
print("\nClassification Report:")
|
||||
print(classification_report(y_test, y_pred))
|
||||
|
||||
# =========================
|
||||
# SIMPAN MODEL
|
||||
# =========================
|
||||
|
||||
with open('model/model_sentiment.pkl', 'wb') as file:
|
||||
pickle.dump(model, file)
|
||||
|
||||
with open('model/tfidf_vectorizer.pkl', 'wb') as file:
|
||||
pickle.dump(tfidf, file)
|
||||
|
||||
print("\nModel berhasil disimpan!")
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?php if($paginator->hasPages()): ?>
|
||||
<nav role="navigation" aria-label="<?php echo e(__('Pagination Navigation')); ?>" class="flex items-center justify-between">
|
||||
<div class="flex justify-between flex-1 sm:hidden">
|
||||
<?php if($paginator->onFirstPage()): ?>
|
||||
<span class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md dark:text-gray-600 dark:bg-gray-800 dark:border-gray-600">
|
||||
<?php echo __('pagination.previous'); ?>
|
||||
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($paginator->previousPageUrl()); ?>" class="relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300">
|
||||
<?php echo __('pagination.previous'); ?>
|
||||
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($paginator->hasMorePages()): ?>
|
||||
<a href="<?php echo e($paginator->nextPageUrl()); ?>" class="relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-500 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-300 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300">
|
||||
<?php echo __('pagination.next'); ?>
|
||||
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="relative inline-flex items-center px-4 py-2 ml-3 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 rounded-md dark:text-gray-600 dark:bg-gray-800 dark:border-gray-600">
|
||||
<?php echo __('pagination.next'); ?>
|
||||
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<p class="text-sm text-gray-700 leading-5 dark:text-gray-400">
|
||||
<?php echo __('Showing'); ?>
|
||||
|
||||
<?php if($paginator->firstItem()): ?>
|
||||
<span class="font-medium"><?php echo e($paginator->firstItem()); ?></span>
|
||||
<?php echo __('to'); ?>
|
||||
|
||||
<span class="font-medium"><?php echo e($paginator->lastItem()); ?></span>
|
||||
<?php else: ?>
|
||||
<?php echo e($paginator->count()); ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php echo __('of'); ?>
|
||||
|
||||
<span class="font-medium"><?php echo e($paginator->total()); ?></span>
|
||||
<?php echo __('results'); ?>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<span class="relative z-0 inline-flex rtl:flex-row-reverse shadow-sm rounded-md">
|
||||
|
||||
<?php if($paginator->onFirstPage()): ?>
|
||||
<span aria-disabled="true" aria-label="<?php echo e(__('pagination.previous')); ?>">
|
||||
<span class="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default rounded-l-md leading-5 dark:bg-gray-800 dark:border-gray-600" aria-hidden="true">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($paginator->previousPageUrl()); ?>" rel="prev" class="relative inline-flex items-center px-2 py-2 text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-l-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:active:bg-gray-700 dark:focus:border-blue-800" aria-label="<?php echo e(__('pagination.previous')); ?>">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $__currentLoopData = $elements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $element): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
<?php if(is_string($element)): ?>
|
||||
<span aria-disabled="true">
|
||||
<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 cursor-default leading-5 dark:bg-gray-800 dark:border-gray-600"><?php echo e($element); ?></span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(is_array($element)): ?>
|
||||
<?php $__currentLoopData = $element; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page => $url): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php if($page == $paginator->currentPage()): ?>
|
||||
<span aria-current="page">
|
||||
<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5 dark:bg-gray-800 dark:border-gray-600"><?php echo e($page); ?></span>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($url); ?>" class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 leading-5 hover:text-gray-500 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-700 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-400 dark:hover:text-gray-300 dark:active:bg-gray-700 dark:focus:border-blue-800" aria-label="<?php echo e(__('Go to page :page', ['page' => $page])); ?>">
|
||||
<?php echo e($page); ?>
|
||||
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
|
||||
<?php if($paginator->hasMorePages()): ?>
|
||||
<a href="<?php echo e($paginator->nextPageUrl()); ?>" rel="next" class="relative inline-flex items-center px-2 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 rounded-r-md leading-5 hover:text-gray-400 focus:z-10 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-500 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:active:bg-gray-700 dark:focus:border-blue-800" aria-label="<?php echo e(__('pagination.next')); ?>">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span aria-disabled="true" aria-label="<?php echo e(__('pagination.next')); ?>">
|
||||
<span class="relative inline-flex items-center px-2 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default rounded-r-md leading-5 dark:bg-gray-800 dark:border-gray-600" aria-hidden="true">
|
||||
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php /**PATH C:\laragon\www\SistemAnalisisSentimen\vendor\laravel\framework\src\Illuminate\Pagination/resources/views/tailwind.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,377 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php echo e($judulLaporan); ?></title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
||||
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background: #f1f5f9;
|
||||
color: #1f2937;
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* ── Sticky action bar pojok kanan atas ── */
|
||||
.action-bar {
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
right: 24px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 9px 18px;
|
||||
border-radius: 8px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
|
||||
transition: opacity .2s;
|
||||
}
|
||||
.btn:hover { opacity: .85; }
|
||||
.btn-primary { background: #1d4ed8; color: white; }
|
||||
.btn-secondary { background: white; color: #374151; border: 1px solid #d1d5db; }
|
||||
|
||||
.container {
|
||||
max-width: 960px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
padding: 28px;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
|
||||
}
|
||||
|
||||
/* LOGO */
|
||||
.logo { font-size: 26px; font-weight: 800; color: #1e3a8a; margin-bottom: 20px; }
|
||||
|
||||
/* HERO */
|
||||
.hero {
|
||||
border: 1px solid #dbeafe;
|
||||
background: linear-gradient(135deg, #eff6ff, #f7f8ff);
|
||||
border-radius: 12px;
|
||||
padding: 22px 24px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.hero-title { font-size: 22px; font-weight: 800; color: #132b70; line-height: 1.3; }
|
||||
.hero-sub { margin-top: 6px; color: #374151; font-size: 13px; }
|
||||
|
||||
.hero-right {
|
||||
min-width: 160px;
|
||||
border: 1px solid #dbeafe;
|
||||
border-radius: 10px;
|
||||
padding: 14px 16px;
|
||||
background: white;
|
||||
font-size: 13px;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
/* SECTION TITLE */
|
||||
.section-title {
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
color: #1e3a8a;
|
||||
letter-spacing: .5px;
|
||||
margin: 24px 0 14px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* CARDS */
|
||||
.cards { display: flex; gap: 12px; margin-bottom: 24px; }
|
||||
|
||||
.card {
|
||||
flex: 1;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.card .card-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
|
||||
.card .card-value { font-size: 26px; font-weight: 800; margin: 0; }
|
||||
.card .card-unit { font-size: 12px; color: #9ca3af; margin-top: 4px; }
|
||||
|
||||
.blue { background: #eff6ff; border-color: #bfdbfe; }
|
||||
.green { background: #f0fdf4; border-color: #bbf7d0; }
|
||||
.yellow { background: #fffbeb; border-color: #fde68a; }
|
||||
.purple { background: #faf5ff; border-color: #e9d5ff; }
|
||||
|
||||
/* CHARTS */
|
||||
.chart-row { display: flex; gap: 16px; margin-bottom: 24px; align-items: flex-start; }
|
||||
|
||||
.box-pie {
|
||||
width: 260px;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.box-bar {
|
||||
flex: 1;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.box-pie h4, .box-bar h4 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 12px;
|
||||
color: #1e3a8a;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: .4px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* TABLE */
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
|
||||
table th { background: #f8fafc; font-size: 12px; font-weight: 600; }
|
||||
table th, table td { border: 1px solid #e5e7eb; padding: 9px 11px; font-size: 12px; }
|
||||
|
||||
.badge {
|
||||
background: #dcfce7;
|
||||
color: #15803d;
|
||||
border-radius: 20px;
|
||||
padding: 3px 10px;
|
||||
font-weight: 600;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* KESIMPULAN */
|
||||
.kesimpulan {
|
||||
border: 1px solid #dbeafe;
|
||||
background: #eff6ff;
|
||||
border-radius: 10px;
|
||||
padding: 16px 18px;
|
||||
margin-top: 20px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* FOOTER */
|
||||
.footer {
|
||||
margin-top: 24px;
|
||||
padding-top: 14px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
/* Sembunyikan action bar saat print */
|
||||
@media print {
|
||||
body { background: white; padding: 0; }
|
||||
.action-bar { display: none !important; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="action-bar" id="actionBar">
|
||||
<button class="btn btn-secondary" onclick="cetakHalaman()">🖨️ Cetak</button>
|
||||
</div>
|
||||
|
||||
<div class="container" id="isiLaporan">
|
||||
|
||||
|
||||
<div class="logo">SENTARA</div>
|
||||
|
||||
|
||||
<div class="hero">
|
||||
<div class="hero-left">
|
||||
<div class="hero-title">LAPORAN ANALISIS SENTIMEN<br>PER BULAN</div>
|
||||
<div class="hero-sub">SISTEM ANALISIS SENTIMEN WISATA JEMBER</div>
|
||||
</div>
|
||||
<div class="hero-right">
|
||||
<b>Periode</b><br>
|
||||
<?php echo e($periode->nama ?? '-'); ?><br><br>
|
||||
<b>Tanggal Cetak</b><br>
|
||||
<?php echo e(now()->format('d M Y H:i')); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-title">Ringkasan</div>
|
||||
|
||||
<div class="cards">
|
||||
<div class="card blue">
|
||||
<div class="card-label">Total Ulasan</div>
|
||||
<p class="card-value"><?php echo e($totalUlasanKotor); ?></p>
|
||||
<div class="card-unit">Ulasan Masuk</div>
|
||||
</div>
|
||||
<div class="card green">
|
||||
<div class="card-label">Hasil Analisis</div>
|
||||
<p class="card-value"><?php echo e($totalUlasan); ?></p>
|
||||
<div class="card-unit">Data Bersih</div>
|
||||
</div>
|
||||
<div class="card yellow">
|
||||
<div class="card-label">Wisata Dibahas</div>
|
||||
<p class="card-value"><?php echo e(count($perWisata)); ?></p>
|
||||
<div class="card-unit">Destinasi</div>
|
||||
</div>
|
||||
<div class="card purple">
|
||||
<div class="card-label">Akurasi Analisis</div>
|
||||
<p class="card-value"><?php echo e(number_format(($evaluasi->accuracy ?? 0) * 100, 2)); ?>%</p>
|
||||
<div class="card-unit">Model</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-title">Visualisasi</div>
|
||||
|
||||
<div class="chart-row">
|
||||
<div class="box-pie">
|
||||
<h4>Distribusi Sentimen</h4>
|
||||
<canvas id="pieChart" width="220" height="220"></canvas>
|
||||
</div>
|
||||
<div class="box-bar">
|
||||
<h4>Sentimen per Destinasi</h4>
|
||||
<canvas id="barChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-title">Top Wisata Berdasarkan Sentimen Positif</div>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Wisata</th>
|
||||
<th>Total</th>
|
||||
<th>Positif</th>
|
||||
<th>Netral</th>
|
||||
<th>Negatif</th>
|
||||
<th>% Positif</th>
|
||||
</tr>
|
||||
<?php $__currentLoopData = $perWisata; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $w): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<tr>
|
||||
<td><?php echo e($i + 1); ?></td>
|
||||
<td><?php echo e($w->wisata); ?></td>
|
||||
<td><?php echo e($w->total); ?></td>
|
||||
<td><?php echo e($w->positif); ?></td>
|
||||
<td><?php echo e($w->netral); ?></td>
|
||||
<td><?php echo e($w->negatif); ?></td>
|
||||
<td><span class="badge"><?php echo e($w->total > 0 ? round(($w->positif / $w->total) * 100, 2) : 0); ?>%</span></td>
|
||||
</tr>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="kesimpulan">
|
||||
<b>KESIMPULAN</b>
|
||||
<p style="margin:8px 0 0">
|
||||
Pada periode <b><?php echo e($periode->nama ?? ''); ?></b>,
|
||||
terdapat <b><?php echo e($totalUlasanKotor); ?></b> ulasan masuk dengan
|
||||
<b><?php echo e($totalUlasan); ?></b> data berhasil dianalisis.
|
||||
Sentimen positif mendominasi dengan persentase <b><?php echo e($persen['positif'] ?? 0); ?>%</b>,
|
||||
diikuti netral <b><?php echo e($persen['netral'] ?? 0); ?>%</b>
|
||||
dan negatif <b><?php echo e($persen['negatif'] ?? 0); ?>%</b>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="footer">
|
||||
<div>SENTARA — Sistem Analisis Sentimen Wisata Jember</div>
|
||||
<div>Dicetak oleh: Admin | <?php echo e(now()->format('d M Y H:i')); ?></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// ── PIE / DOUGHNUT CHART ──
|
||||
new Chart(document.getElementById('pieChart'), {
|
||||
type: 'doughnut',
|
||||
data: {
|
||||
labels: ['Positif', 'Netral', 'Negatif'],
|
||||
datasets: [{
|
||||
data: [<?php echo e($totalPositif); ?>, <?php echo e($totalNetral); ?>, <?php echo e($totalNegatif); ?>],
|
||||
backgroundColor: ['#22c55e', '#f59e0b', '#ef4444'],
|
||||
borderWidth: 2,
|
||||
borderColor: '#fff'
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: false,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: { position: 'bottom', labels: { font: { size: 11 }, padding: 10 } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── BAR CHART SENTIMEN PER DESTINASI ──
|
||||
const wisataLabels = <?php echo json_encode($perWisata->pluck('wisata'), 15, 512) ?>;
|
||||
const wisataPos = <?php echo json_encode($perWisata->pluck('positif'), 15, 512) ?>;
|
||||
const wisataNet = <?php echo json_encode($perWisata->pluck('netral'), 15, 512) ?>;
|
||||
const wisataNeg = <?php echo json_encode($perWisata->pluck('negatif'), 15, 512) ?>;
|
||||
|
||||
new Chart(document.getElementById('barChart'), {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: wisataLabels,
|
||||
datasets: [
|
||||
{ label: 'Positif', data: wisataPos, backgroundColor: '#22c55e' },
|
||||
{ label: 'Netral', data: wisataNet, backgroundColor: '#f59e0b' },
|
||||
{ label: 'Negatif', data: wisataNeg, backgroundColor: '#ef4444' }
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: true,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: { position: 'bottom', labels: { font: { size: 11 } } }
|
||||
},
|
||||
scales: {
|
||||
y: { beginAtZero: true, ticks: { font: { size: 11 } } },
|
||||
x: { ticks: { font: { size: 10 } } }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ── CETAK ──
|
||||
function cetakHalaman() {
|
||||
window.print();
|
||||
}
|
||||
|
||||
// ── SIMPAN PDF ──
|
||||
function simpanPDF() {
|
||||
const el = document.getElementById('isiLaporan');
|
||||
const bar = document.getElementById('actionBar');
|
||||
bar.style.display = 'none';
|
||||
|
||||
html2pdf().set({
|
||||
margin: 10,
|
||||
filename: 'Laporan-<?php echo e(Str::slug($periode->nama ?? "bulanan")); ?>.pdf',
|
||||
image: { type: 'jpeg', quality: 0.98 },
|
||||
html2canvas: { scale: 2, useCORS: true },
|
||||
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
|
||||
}).from(el).save().then(() => {
|
||||
bar.style.display = 'flex';
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/laporan/bulanan.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,442 @@
|
|||
<?php $__env->startSection('content'); ?>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
|
||||
<?php if(session('success')): ?>
|
||||
<div class="bg-green-50 border border-green-200 text-green-700 px-5 py-4 rounded-2xl">
|
||||
<?php echo e(session('success')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(session('error')): ?>
|
||||
<div class="bg-red-50 border border-red-200 text-red-700 px-5 py-4 rounded-2xl">
|
||||
<?php echo e(session('error')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-slate-800">Kelola Pengguna</h1>
|
||||
<p class="text-slate-500 mt-1">Kelola akun pengguna sistem SENTARA.</p>
|
||||
</div>
|
||||
|
||||
<!-- BUTTON TAMBAH -->
|
||||
<button
|
||||
onclick="openTambahModal()"
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-5 py-3 rounded-2xl text-sm font-semibold shadow transition">
|
||||
+ Tambah Pengguna
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- CARD -->
|
||||
<div class="bg-white rounded-3xl shadow-sm border border-slate-100 p-5">
|
||||
|
||||
<!-- TABLE -->
|
||||
<div class="overflow-x-auto mt-6">
|
||||
|
||||
<table class="w-full text-sm min-w-[900px]">
|
||||
|
||||
<thead>
|
||||
<tr class="text-slate-500 border-b">
|
||||
<th class="py-4 text-left">No</th>
|
||||
<th class="py-4 text-left">Nama</th>
|
||||
<th class="py-4 text-left">Email</th>
|
||||
<th class="py-4 text-left">Role</th>
|
||||
<th class="py-4 text-left">Status</th>
|
||||
<th class="py-4 text-left">Terakhir Aktif</th>
|
||||
<th class="py-4 text-center">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="text-slate-700">
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
|
||||
<tr class="border-b hover:bg-slate-50 transition">
|
||||
|
||||
<td class="py-4"><?php echo e($loop->iteration); ?></td>
|
||||
|
||||
<td class="py-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-full bg-slate-200 flex items-center justify-center text-xs font-bold text-slate-600">
|
||||
<?php echo e(strtoupper(substr($user->name, 0, 2))); ?>
|
||||
|
||||
</div>
|
||||
<span class="font-medium"><?php echo e($user->name); ?></span>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="py-4"><?php echo e($user->email); ?></td>
|
||||
|
||||
<td class="py-4">
|
||||
<?php if($user->role == 'admin'): ?>
|
||||
<span class="bg-purple-100 text-purple-700 px-3 py-1 rounded-full text-xs font-semibold">Admin</span>
|
||||
<?php else: ?>
|
||||
<span class="bg-blue-100 text-blue-700 px-3 py-1 rounded-full text-xs font-semibold">Staff</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
||||
<td class="py-4">
|
||||
<span class="bg-green-100 text-green-700 px-3 py-1 rounded-full text-xs font-semibold">Aktif</span>
|
||||
</td>
|
||||
|
||||
<td class="py-4"><?php echo e($user->updated_at->format('d M Y, H:i')); ?></td>
|
||||
|
||||
<td class="py-4">
|
||||
<div class="flex justify-center gap-2">
|
||||
|
||||
<button
|
||||
onclick="openEditModal('<?php echo e($user->id); ?>', '<?php echo e(addslashes($user->name)); ?>', '<?php echo e($user->email); ?>', '<?php echo e($user->role); ?>')"
|
||||
class="w-11 h-11 rounded-2xl border border-blue-200 text-blue-600 hover:bg-blue-50 flex items-center justify-center transition"
|
||||
title="Edit Pengguna">✏️</button>
|
||||
|
||||
<button
|
||||
onclick="openPasswordModal('<?php echo e($user->id); ?>')"
|
||||
class="w-11 h-11 rounded-2xl border border-amber-200 text-amber-500 hover:bg-amber-50 flex items-center justify-center transition"
|
||||
title="Reset Password">🔒</button>
|
||||
|
||||
<button
|
||||
onclick="openDeleteModal('<?php echo e($user->id); ?>', '<?php echo e($user->role); ?>')"
|
||||
class="w-11 h-11 rounded-2xl border border-red-200 text-red-500 hover:bg-red-50 flex items-center justify-center transition"
|
||||
title="Hapus Pengguna">🗑️</button>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
|
||||
<tr>
|
||||
<td colspan="7" class="py-10 text-center text-slate-400">
|
||||
Data pengguna belum tersedia.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- PAGINATION -->
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4 mt-6">
|
||||
<p class="text-sm text-slate-500">
|
||||
Menampilkan <?php echo e($users->firstItem() ?? 0); ?> - <?php echo e($users->lastItem() ?? 0); ?>
|
||||
|
||||
dari <?php echo e($users->total()); ?> pengguna
|
||||
</p>
|
||||
<?php echo e($users->links()); ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= MODAL TAMBAH PENGGUNA ================= -->
|
||||
<div id="tambahModal"
|
||||
class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center px-4">
|
||||
|
||||
<div class="bg-white rounded-3xl p-6 shadow-2xl w-full" style="max-width: 480px;">
|
||||
|
||||
<div class="flex items-start justify-between mb-5">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-slate-800">Tambah Pengguna</h2>
|
||||
<p class="text-slate-500 text-sm mt-1">Buat akun pengguna baru untuk sistem SENTARA.</p>
|
||||
</div>
|
||||
<button onclick="closeTambahModal()"
|
||||
class="text-slate-400 hover:text-slate-700 text-2xl leading-none ml-4 flex-shrink-0">×</button>
|
||||
</div>
|
||||
|
||||
|
||||
<form method="POST" action="/kelola-pengguna" id="tambahForm">
|
||||
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Nama Pengguna</label>
|
||||
<input type="text" name="name" placeholder="Masukkan nama lengkap"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Email</label>
|
||||
<input type="email" name="email" placeholder="contoh@email.com"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Role Pengguna</label>
|
||||
<select name="role"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||
<option value="staff">Staff</option>
|
||||
<option value="admin">Admin</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Password</label>
|
||||
<input type="password" name="password" placeholder="Minimal 8 karakter"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Konfirmasi Password</label>
|
||||
<input type="password" name="password_confirmation" placeholder="Ulangi password"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none" required>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="button" onclick="closeTambahModal()"
|
||||
class="flex-1 py-3 rounded-2xl border border-slate-200 text-slate-600 text-sm font-medium hover:bg-slate-100 transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="flex-1 py-3 rounded-2xl bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold transition">
|
||||
Tambah
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= MODAL EDIT ================= -->
|
||||
<div id="editModal"
|
||||
class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center px-4">
|
||||
|
||||
<div class="bg-white rounded-3xl p-6 shadow-2xl w-full" style="max-width: 480px;">
|
||||
|
||||
<div class="flex items-start justify-between mb-5">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-slate-800">Edit Pengguna</h2>
|
||||
<p class="text-slate-500 text-sm mt-1">Perbarui informasi akun pengguna SENTARA.</p>
|
||||
</div>
|
||||
<button onclick="closeEditModal()"
|
||||
class="text-slate-400 hover:text-slate-700 text-2xl leading-none ml-4 flex-shrink-0">×</button>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="editForm">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php if($errors->any()): ?>
|
||||
<div class="mb-4 rounded-2xl bg-red-50 border border-red-200 text-red-600 px-4 py-3 text-sm">
|
||||
<?php echo e($errors->first()); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php echo method_field('PUT'); ?>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Nama Pengguna</label>
|
||||
<input type="text" name="name" id="editName"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Email</label>
|
||||
<input type="email" name="email" id="editEmail"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Role Pengguna</label>
|
||||
<select name="role" id="editRole"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none">
|
||||
<option value="admin">Admin</option>
|
||||
<option value="staff">Staff</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="button" onclick="closeEditModal()"
|
||||
class="flex-1 py-3 rounded-2xl border border-slate-200 text-slate-600 text-sm font-medium hover:bg-slate-100 transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="flex-1 py-3 rounded-2xl bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold transition">
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= MODAL RESET PASSWORD ================= -->
|
||||
<div id="passwordModal"
|
||||
class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center px-4">
|
||||
|
||||
<div class="bg-white rounded-3xl p-6 shadow-2xl w-full" style="max-width: 480px;">
|
||||
|
||||
<div class="flex items-start justify-between mb-5">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-slate-800">Reset Password</h2>
|
||||
<p class="text-slate-500 text-sm mt-1">Buat password baru pengguna.</p>
|
||||
</div>
|
||||
<button onclick="closePasswordModal()"
|
||||
class="text-slate-400 hover:text-slate-700 text-2xl leading-none ml-4 flex-shrink-0">×</button>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 bg-amber-50 border border-amber-200 rounded-2xl p-4">
|
||||
<p class="text-sm text-amber-700 leading-relaxed">
|
||||
Password minimal 8 karakter dan harus kombinasi huruf besar, huruf kecil, dan angka.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form method="POST" id="passwordForm">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php echo method_field('PUT'); ?>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Password Baru</label>
|
||||
<input type="password" name="password"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-amber-400 focus:outline-none">
|
||||
</div>
|
||||
|
||||
<div class="mb-6">
|
||||
<label class="block text-sm font-semibold text-slate-700 mb-2">Konfirmasi Password</label>
|
||||
<input type="password" name="password_confirmation"
|
||||
class="w-full rounded-2xl border border-slate-200 px-4 py-3 text-sm focus:ring-2 focus:ring-amber-400 focus:outline-none">
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="button" onclick="closePasswordModal()"
|
||||
class="flex-1 py-3 rounded-2xl border border-slate-200 text-slate-600 text-sm font-medium hover:bg-slate-100 transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="flex-1 py-3 rounded-2xl bg-amber-500 hover:bg-amber-600 text-white text-sm font-semibold transition">
|
||||
Reset
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= MODAL DELETE ================= -->
|
||||
<div id="deleteModal"
|
||||
class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center px-4">
|
||||
|
||||
<div class="bg-white rounded-3xl p-6 shadow-2xl w-full text-center" style="max-width: 400px;">
|
||||
|
||||
<div class="w-16 h-16 mx-auto rounded-full bg-red-100 flex items-center justify-center text-3xl mb-4">🗑️</div>
|
||||
<h2 class="text-2xl font-bold text-slate-800">Hapus Pengguna?</h2>
|
||||
<p class="text-slate-500 text-sm mt-2 leading-relaxed">
|
||||
Data pengguna akan dihapus permanen dan tidak dapat dikembalikan.
|
||||
</p>
|
||||
|
||||
<form method="POST" id="deleteForm" class="mt-6">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php echo method_field('DELETE'); ?>
|
||||
<div class="flex gap-3">
|
||||
<button type="button" onclick="closeDeleteModal()"
|
||||
class="flex-1 py-3 rounded-2xl border border-slate-200 text-slate-600 text-sm font-medium hover:bg-slate-100 transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="flex-1 py-3 rounded-2xl bg-red-500 hover:bg-red-600 text-white text-sm font-semibold transition">
|
||||
Hapus
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= MODAL ADMIN TIDAK BISA DIHAPUS ================= -->
|
||||
<div id="adminAlertModal"
|
||||
class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center px-4">
|
||||
|
||||
<div class="bg-white rounded-3xl p-6 shadow-2xl w-full text-center" style="max-width: 400px;">
|
||||
|
||||
<div class="w-16 h-16 mx-auto rounded-full bg-amber-100 flex items-center justify-center text-3xl mb-4">⚠️</div>
|
||||
<h2 class="text-2xl font-bold text-slate-800">Akses Ditolak</h2>
|
||||
<p class="text-slate-500 text-sm mt-2 leading-relaxed">
|
||||
Akun administrator tidak dapat dihapus demi menjaga keamanan sistem.
|
||||
</p>
|
||||
|
||||
<button onclick="closeAdminAlertModal()"
|
||||
class="w-full mt-6 py-3 rounded-2xl bg-blue-600 hover:bg-blue-700 text-white text-sm font-semibold transition">
|
||||
Mengerti
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ================= SCRIPT ================= -->
|
||||
<script>
|
||||
|
||||
/* ---- TAMBAH ---- */
|
||||
function openTambahModal() {
|
||||
document.getElementById('tambahModal').classList.remove('hidden');
|
||||
document.getElementById('tambahForm').reset();
|
||||
}
|
||||
function closeTambahModal() {
|
||||
document.getElementById('tambahModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
/* ---- EDIT ---- */
|
||||
function openEditModal(id, name, email, role) {
|
||||
document.getElementById('editModal').classList.remove('hidden');
|
||||
document.getElementById('editName').value = name;
|
||||
document.getElementById('editEmail').value = email;
|
||||
document.getElementById('editRole').value = role;
|
||||
document.getElementById('editForm').action = '/kelola-pengguna/' + id;
|
||||
}
|
||||
function closeEditModal() {
|
||||
document.getElementById('editModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
/* ---- RESET PASSWORD ---- */
|
||||
function openPasswordModal(id) {
|
||||
document.getElementById('passwordModal').classList.remove('hidden');
|
||||
document.getElementById('passwordForm').action =
|
||||
'/kelola-pengguna/' + id + '/reset-password';
|
||||
}
|
||||
function closePasswordModal() {
|
||||
document.getElementById('passwordModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
/* ---- DELETE ---- */
|
||||
function openDeleteModal(id, role) {
|
||||
if (role === 'admin') {
|
||||
document.getElementById('adminAlertModal').classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
document.getElementById('deleteModal').classList.remove('hidden');
|
||||
document.getElementById('deleteForm').action = '/kelola-pengguna/' + id;
|
||||
}
|
||||
function closeDeleteModal() {
|
||||
document.getElementById('deleteModal').classList.add('hidden');
|
||||
}
|
||||
function closeAdminAlertModal() {
|
||||
document.getElementById('adminAlertModal').classList.add('hidden');
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?php $__env->stopSection(); ?>
|
||||
<?php echo $__env->make('layouts.sentara', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/kelolauser/index.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
<?php
|
||||
$destinasiList ??= collect([]);
|
||||
$totalDestinasiAnalisis ??= 0;
|
||||
$totalDestinasiBerkeluhan ??= 0;
|
||||
$totalNegatif ??= 0;
|
||||
$totalPositif ??= 0;
|
||||
$totalNetral ??= 0;
|
||||
$totalUlasan ??= 0;
|
||||
$persenNegatif ??= 0;
|
||||
$tingkatKepuasan ??= 0;
|
||||
$labelKepuasan ??= 'Kurang';
|
||||
$isuDominan ??= '-';
|
||||
$isuDominanPersen ??= 0;
|
||||
$isuUtama ??= [];
|
||||
$kataDominan ??= [];
|
||||
$saranPerbaikan ??= [];
|
||||
$prioritas ??= [];
|
||||
?>
|
||||
|
||||
<?php
|
||||
// $persenPositif, $persenNetral, $isuNegatif, $isuNetral, $isuPositif sudah dikirim dari controller
|
||||
// Icon map untuk prioritas cards
|
||||
$iconMap = [
|
||||
'harga' => '🎫',
|
||||
'tiket' => '🎫',
|
||||
'kebersihan'=> '🧹',
|
||||
'parkir' => '🚗',
|
||||
'fasilitas' => '🏗️',
|
||||
'keramaian' => '👥',
|
||||
'akses' => '🛣️',
|
||||
'jalan' => '🛣️',
|
||||
'default' => '⚙️',
|
||||
];
|
||||
?>
|
||||
|
||||
<style>
|
||||
.gauge-ring {
|
||||
transform: rotate(-90deg);
|
||||
transform-origin: center;
|
||||
}
|
||||
.gauge-wrap { position: relative; display: inline-block; }
|
||||
.gauge-inner {
|
||||
position: absolute;
|
||||
top: 50%; left: 50%;
|
||||
transform: translate(-50%, -30%);
|
||||
text-align: center;
|
||||
line-height: 1.1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">Rekomendasi Layanan</h2>
|
||||
<p class="text-sm text-gray-500">
|
||||
Rekomendasi dibuat dari hasil analisis sentimen untuk perbaikan layanan destinasi wisata.
|
||||
</p>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
<?php echo e($totalDestinasiAnalisis); ?> destinasi dianalisis, <?php echo e($totalDestinasiBerkeluhan); ?> destinasi memiliki ulasan negatif.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<form method="GET" action="<?php echo e(route('dashboard')); ?>" class="flex gap-3">
|
||||
<input type="hidden" name="tab" value="rekomendasi">
|
||||
<input type="hidden" name="periode_id" value="<?php echo e($periodeId ?? $periodeAktif->id ?? request('periode_id')); ?>">
|
||||
<?php if(request('periode_bulan')): ?>
|
||||
<input type="hidden" name="periode_bulan" value="<?php echo e(request('periode_bulan')); ?>">
|
||||
<?php endif; ?>
|
||||
<select name="destinasi" onchange="this.form.submit()"
|
||||
class="border rounded-lg pl-3 pr-9 py-2 text-sm min-w-[220px] focus:outline-none focus:ring-2 focus:ring-blue-400">
|
||||
<option value="">Semua Destinasi</option>
|
||||
<?php $__currentLoopData = $destinasiList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $destinasi): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($destinasi); ?>" <?php echo e(request('destinasi') == $destinasi ? 'selected' : ''); ?>>
|
||||
<?php echo e($destinasi); ?>
|
||||
|
||||
</option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-semibold text-green-600">Tingkat Positif</p>
|
||||
<h3 class="text-4xl font-bold text-green-600 mt-1"><?php echo e($persenPositif); ?>%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-green-100 text-green-700 font-medium">Positif</span>
|
||||
<p class="text-xs text-gray-400 mt-2"><?php echo e($totalPositif); ?> ulasan</p>
|
||||
</div>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#e5e7eb" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#22c55e" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="<?php echo e(round($persenPositif * 1.099)); ?> 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😊</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-semibold text-red-500">Tingkat Negatif</p>
|
||||
<h3 class="text-4xl font-bold text-red-500 mt-1"><?php echo e($persenNegatif); ?>%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-red-100 text-red-600 font-medium">Negatif</span>
|
||||
<p class="text-xs text-gray-400 mt-2"><?php echo e($totalNegatif); ?> ulasan</p>
|
||||
</div>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#fee2e2" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#ef4444" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="<?php echo e(round($persenNegatif * 1.099)); ?> 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😟</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5 flex items-center justify-between">
|
||||
<div>
|
||||
<p class="text-sm font-semibold text-gray-500">Tingkat Netral</p>
|
||||
<h3 class="text-4xl font-bold text-gray-600 mt-1"><?php echo e($persenNetral); ?>%</h3>
|
||||
<span class="inline-block mt-2 text-xs px-3 py-1 rounded-full bg-gray-100 text-gray-600 font-medium">Netral</span>
|
||||
<p class="text-xs text-gray-400 mt-2"><?php echo e($totalNetral); ?> ulasan</p>
|
||||
</div>
|
||||
<div class="gauge-wrap">
|
||||
<svg width="90" height="70" viewBox="0 0 90 70">
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#e5e7eb" stroke-width="8" stroke-linecap="round"/>
|
||||
<path d="M 10 65 A 35 35 0 0 1 80 65" fill="none" stroke="#9ca3af" stroke-width="8" stroke-linecap="round"
|
||||
stroke-dasharray="<?php echo e(round($persenNetral * 1.099)); ?> 110"
|
||||
style="transition: stroke-dasharray 0.8s ease"/>
|
||||
</svg>
|
||||
<div style="position:absolute;bottom:6px;left:50%;transform:translateX(-50%);font-size:1.5rem;">😐</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-red-600">Isu Negatif Utama (Top 5)</h3>
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $isuNegatif; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $isu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<?php if($i >= 5): ?> <?php break; ?> <?php endif; ?>
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span class="text-gray-700"><?php echo e($i + 1); ?>. <?php echo e($isu['nama']); ?></span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
<?php echo e($isu['persen']); ?>%
|
||||
<?php if(isset($isu['jumlah'])): ?> (<?php echo e($isu['jumlah']); ?>) <?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-red-100 h-2 rounded">
|
||||
<div class="h-2 rounded bg-red-500" style="width: <?php echo e($isu['persen']); ?>%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu negatif.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="text-xs text-red-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan negatif (<?php echo e($totalNegatif); ?> ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-gray-600">Isu Netral Utama (Top 5)</h3>
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $isuNetral; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $isu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<?php if($i >= 5): ?> <?php break; ?> <?php endif; ?>
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span class="text-gray-700"><?php echo e($i + 1); ?>. <?php echo e($isu['nama']); ?></span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
<?php echo e($isu['persen']); ?>%
|
||||
<?php if(isset($isu['jumlah'])): ?> (<?php echo e($isu['jumlah']); ?>) <?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-200 h-2 rounded">
|
||||
<div class="h-2 rounded bg-gray-500" style="width: <?php echo e($isu['persen']); ?>%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu netral.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="text-xs text-gray-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan netral (<?php echo e($totalNetral); ?> ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<h3 class="font-semibold mb-4 text-green-600">Aspek Positif Utama (Top 5)</h3>
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $isuPositif; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $isu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<?php if($i >= 5): ?> <?php break; ?> <?php endif; ?>
|
||||
<div class="mb-4">
|
||||
<div class="flex justify-between text-sm mb-1">
|
||||
<span class="text-gray-700"><?php echo e($i + 1); ?>. <?php echo e($isu['nama']); ?></span>
|
||||
<span class="font-semibold text-gray-800">
|
||||
<?php echo e($isu['persen']); ?>%
|
||||
<?php if(isset($isu['jumlah'])): ?> (<?php echo e($isu['jumlah']); ?>) <?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="w-full bg-green-100 h-2 rounded">
|
||||
<div class="h-2 rounded bg-green-500" style="width: <?php echo e($isu['persen']); ?>%"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<p class="text-sm text-gray-400 text-center py-4">Belum ada data isu positif.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="text-xs text-green-400 mt-2">
|
||||
Persentase berdasarkan dari total ulasan positif (<?php echo e($totalPositif); ?> ulasan)
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-gray-800 mb-1">Prioritas Rekomendasi Perbaikan Layanan</h3>
|
||||
<p class="text-sm text-gray-500 mb-4">Prioritas disusun berdasarkan frekuensi isu negatif dan dampaknya terhadap kepuasan pengunjung.</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $prioritas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<?php
|
||||
$border = match($p['color']) {
|
||||
'red' => 'border-red-200',
|
||||
'orange' => 'border-orange-200',
|
||||
'yellow' => 'border-yellow-200',
|
||||
'green' => 'border-green-200',
|
||||
default => 'border-blue-200',
|
||||
};
|
||||
$title = match($p['color']) {
|
||||
'red' => 'text-red-600',
|
||||
'orange' => 'text-orange-500',
|
||||
'yellow' => 'text-yellow-600',
|
||||
'green' => 'text-green-600',
|
||||
default => 'text-blue-600',
|
||||
};
|
||||
$dampak = match($p['color']) {
|
||||
'red' => 'bg-red-50 text-red-500 border border-red-200',
|
||||
'orange' => 'bg-orange-50 text-orange-500 border border-orange-200',
|
||||
'yellow' => 'bg-yellow-50 text-yellow-600 border border-yellow-200',
|
||||
'green' => 'bg-green-50 text-green-700 border border-green-200',
|
||||
default => 'bg-blue-50 text-blue-600 border border-blue-200',
|
||||
};
|
||||
$badgeBg = match($p['color']) {
|
||||
'red' => 'bg-red-500',
|
||||
'orange' => 'bg-orange-400',
|
||||
'yellow' => 'bg-yellow-400',
|
||||
'green' => 'bg-green-500',
|
||||
default => 'bg-blue-500',
|
||||
};
|
||||
$namaLower = strtolower($p['nama']);
|
||||
$icon = '⚙️';
|
||||
foreach ($iconMap as $key => $val) {
|
||||
if (str_contains($namaLower, $key)) { $icon = $val; break; }
|
||||
}
|
||||
?>
|
||||
<div class="border <?php echo e($border); ?> rounded-xl p-5 bg-white">
|
||||
<div class="flex items-start gap-4 mb-3">
|
||||
<div class="<?php echo e($badgeBg); ?> text-white rounded-full w-8 h-8 flex items-center justify-center font-bold text-sm flex-shrink-0">
|
||||
<?php echo e($p['rank']); ?>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs font-semibold <?php echo e($title); ?>">
|
||||
Prioritas <?php echo e($p['rank'] === 1 ? 'Utama' : ($p['rank'] === 2 ? 'Kedua' : 'Ketiga')); ?>
|
||||
|
||||
</p>
|
||||
<h3 class="text-base font-bold text-gray-800"><?php echo e($p['nama']); ?></h3>
|
||||
</div>
|
||||
<div class="ml-auto text-3xl"><?php echo e($icon); ?></div>
|
||||
</div>
|
||||
|
||||
<ul class="text-sm space-y-2 mb-4">
|
||||
<?php $__currentLoopData = $p['actions']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $action): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<li class="flex items-start gap-2 text-gray-700">
|
||||
<span class="text-blue-500 mt-0.5">✔</span> <?php echo e($action); ?>
|
||||
|
||||
</li>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</ul>
|
||||
|
||||
<div class="text-xs <?php echo e($dampak); ?> p-2 rounded-lg">
|
||||
Alasan: <?php echo e($p['dampak']); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<div class="col-span-3 text-center text-gray-400 text-sm py-6">
|
||||
Belum ada data rekomendasi. Pastikan analisis sentimen sudah dijalankan.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-blue-50 border border-blue-100 rounded-xl px-5 py-3 flex items-start gap-3 text-sm text-gray-600">
|
||||
<span class="text-blue-500 mt-0.5">ℹ️</span>
|
||||
<span>Rekomendasi dihasilkan secara otomatis berdasarkan hasil analisis sentimen dan kata kunci dominan dari ulasan wisatawan.</span>
|
||||
</div>
|
||||
|
||||
</div><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/rekomendasi/index.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,340 @@
|
|||
<?php $__env->startSection('content'); ?>
|
||||
|
||||
<div class="max-w-7xl mx-auto space-y-6">
|
||||
|
||||
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">
|
||||
Riwayat Analisis
|
||||
</h2>
|
||||
|
||||
<p class="text-sm text-gray-500">
|
||||
Periode tersimpan otomatis setiap kali Ambil Data dijalankan.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<form
|
||||
action="<?php echo e(route('laporan.tahunan')); ?>"
|
||||
method="GET"
|
||||
class="flex items-center gap-3">
|
||||
|
||||
<div class="relative">
|
||||
|
||||
<select
|
||||
name="tahun"
|
||||
required
|
||||
class="appearance-none
|
||||
border-2 border-blue-500
|
||||
rounded-2xl
|
||||
pl-4 pr-9
|
||||
py-2.5
|
||||
text-sm font-medium
|
||||
bg-white
|
||||
shadow-sm
|
||||
cursor-pointer
|
||||
focus:outline-none
|
||||
focus:ring-2
|
||||
focus:ring-blue-300">
|
||||
|
||||
<?php for($tahun = date('Y'); $tahun >= 2024; $tahun--): ?>
|
||||
<option value="<?php echo e($tahun); ?>"><?php echo e($tahun); ?></option>
|
||||
<?php endfor; ?>
|
||||
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-600
|
||||
hover:bg-blue-700
|
||||
text-white
|
||||
px-5 py-2.5
|
||||
rounded-2xl
|
||||
text-sm font-medium
|
||||
shadow">
|
||||
Cetak Tahunan
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if(session('success')): ?>
|
||||
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 rounded">
|
||||
<?php echo e(session('success')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if(session('error')): ?>
|
||||
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 rounded whitespace-pre-line">
|
||||
<?php echo e(session('error')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-6">
|
||||
|
||||
<h3 class="font-semibold text-gray-800 mb-1">
|
||||
Import Data Lama dari CSV
|
||||
</h3>
|
||||
|
||||
<p class="text-sm text-gray-500 mb-4">
|
||||
Gunakan untuk memasukkan ulasan historis. Kolom wajib:
|
||||
wisata, rating, ulasan, tanggal.
|
||||
Kolom reviewer boleh ada.
|
||||
</p>
|
||||
|
||||
<form
|
||||
action="<?php echo e(route('riwayat.import')); ?>"
|
||||
method="POST"
|
||||
enctype="multipart/form-data"
|
||||
class="grid grid-cols-1 md:grid-cols-[180px_1fr_auto] gap-3 md:items-center">
|
||||
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<input
|
||||
type="month"
|
||||
name="periode_bulan"
|
||||
value="<?php echo e(now()->format('Y-m')); ?>"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]"
|
||||
required>
|
||||
|
||||
<input
|
||||
type="file"
|
||||
name="file"
|
||||
accept=".csv,.txt"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-0"
|
||||
required>
|
||||
|
||||
<button
|
||||
class="bg-green-600 hover:bg-green-700 text-white px-5 py-2 rounded-lg text-sm shadow">
|
||||
|
||||
Import CSV
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php if($errors->any()): ?>
|
||||
<div class="mt-3 text-sm text-red-600">
|
||||
<?php echo e($errors->first()); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl shadow overflow-hidden">
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
|
||||
<table class="w-full text-sm">
|
||||
|
||||
<thead class="bg-gray-100 text-left">
|
||||
|
||||
<tr>
|
||||
|
||||
<th class="px-4 py-3">
|
||||
Periode
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Total Ulasan
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Hasil Analisis
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Wisata
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3">
|
||||
Terakhir Analisis
|
||||
</th>
|
||||
|
||||
<th class="px-4 py-3 text-center">
|
||||
Aksi
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y">
|
||||
|
||||
<?php $__empty_1 = true; $__currentLoopData = $riwayat; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
|
||||
<tr class="hover:bg-gray-50">
|
||||
|
||||
<td class="px-4 py-3 font-semibold text-gray-800">
|
||||
<?php echo e($item->nama); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
<?php echo e($item->total_ulasan); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
<?php echo e($item->total_hasil); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-center">
|
||||
<?php echo e($item->total_wisata); ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-gray-500">
|
||||
|
||||
<?php echo e($item->terakhir_analisis
|
||||
? \Carbon\Carbon::parse(
|
||||
$item->terakhir_analisis
|
||||
)->format('d M Y H:i')
|
||||
: '-'); ?>
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3">
|
||||
|
||||
<div class="flex flex-wrap justify-center gap-2">
|
||||
|
||||
<a
|
||||
href="<?php echo e(route('dashboard',
|
||||
['periode_id'=>$item->id,
|
||||
'tab'=>'analisis'])); ?>"
|
||||
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-green-50 text-green-600
|
||||
hover:bg-green-100">
|
||||
|
||||
Analisis
|
||||
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="<?php echo e(route('ulasan.index',
|
||||
['periode_id'=>$item->id])); ?>"
|
||||
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-gray-100 text-gray-700
|
||||
hover:bg-gray-200">
|
||||
|
||||
Ulasan
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
<a
|
||||
href="<?php echo e(route('laporan.bulanan', $item->id)); ?>"
|
||||
class="px-3 py-1 rounded-lg
|
||||
bg-blue-50 text-blue-600
|
||||
hover:bg-blue-100">
|
||||
Cetak Laporan
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
|
||||
<tr>
|
||||
|
||||
<td
|
||||
colspan="6"
|
||||
class="px-4 py-8 text-center text-gray-400">
|
||||
|
||||
Belum ada riwayat analisis.
|
||||
Jalankan Ambil Data terlebih dahulu.
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php if($riwayat->hasPages()): ?>
|
||||
<?php
|
||||
$current = $riwayat->currentPage();
|
||||
$last = $riwayat->lastPage();
|
||||
$query = http_build_query(request()->except('page'));
|
||||
$window = collect(range(max(1, $current - 2), min($last, $current + 2)));
|
||||
?>
|
||||
|
||||
<div class="px-6 py-4 border-t border-gray-100 flex items-center justify-between text-sm text-gray-600">
|
||||
|
||||
|
||||
<p>Menampilkan <?php echo e($riwayat->firstItem()); ?> – <?php echo e($riwayat->lastItem()); ?> dari <?php echo e($riwayat->total()); ?> data</p>
|
||||
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
|
||||
|
||||
<?php if($riwayat->onFirstPage()): ?>
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-gray-100 text-gray-400 cursor-not-allowed">«</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($riwayat->previousPageUrl()); ?>&<?php echo e($query); ?>" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">«</a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(!$window->contains(1)): ?>
|
||||
<a href="<?php echo e($riwayat->url(1)); ?>&<?php echo e($query); ?>" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">1</a>
|
||||
<?php if($window->min() > 2): ?>
|
||||
<span class="px-2 py-1.5 text-gray-400">...</span>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $__currentLoopData = $window; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php if($page == $current): ?>
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-blue-600 text-white font-semibold"><?php echo e($page); ?></span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($riwayat->url($page)); ?>&<?php echo e($query); ?>" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition"><?php echo e($page); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
|
||||
<?php if(!$window->contains($last)): ?>
|
||||
<?php if($window->max() < $last - 1): ?>
|
||||
<span class="px-2 py-1.5 text-gray-400">...</span>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo e($riwayat->url($last)); ?>&<?php echo e($query); ?>" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition"><?php echo e($last); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($riwayat->hasMorePages()): ?>
|
||||
<a href="<?php echo e($riwayat->nextPageUrl()); ?>&<?php echo e($query); ?>" class="px-3 py-1.5 rounded-lg border hover:bg-blue-50 text-blue-600 transition">»</a>
|
||||
<?php else: ?>
|
||||
<span class="px-3 py-1.5 rounded-lg border bg-gray-100 text-gray-400 cursor-not-allowed">»</span>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php $__env->stopSection(); ?>
|
||||
<?php echo $__env->make('layouts.sentara', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/ulasan/riwayat.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SENTARA Dashboard</title>
|
||||
|
||||
<?php echo app('Illuminate\Foundation\Vite')(['resources/css/app.css','resources/js/app.js']); ?>
|
||||
|
||||
<!-- FEATHER ICON -->
|
||||
<script src="https://unpkg.com/feather-icons"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-100 overflow-x-hidden">
|
||||
|
||||
<div class="h-auto ">
|
||||
|
||||
<!-- SIDEBAR -->
|
||||
<aside id="sidebar"
|
||||
class="fixed top-0 left-0 h-full w-64
|
||||
bg-gradient-to-b from-blue-900 to-blue-700
|
||||
text-white flex flex-col
|
||||
transform -translate-x-full md:translate-x-0
|
||||
transition duration-300 z-50">
|
||||
|
||||
<!-- LOGO -->
|
||||
<div class="flex justify-center mt-6 mb-8">
|
||||
<img src="<?php echo e(asset('images/tulisan-sentara.png')); ?>"
|
||||
class="w-44"
|
||||
alt="Logo SENTARA">
|
||||
</div>
|
||||
|
||||
<!-- MENU -->
|
||||
<nav class="flex-1 px-6 space-y-3 text-sm font-medium">
|
||||
|
||||
<!-- DASHBOARD -->
|
||||
<a href="<?php echo e(route('dashboard')); ?>"
|
||||
class="flex items-center gap-4 px-4 py-3 rounded-xl hover:bg-blue-800 transition">
|
||||
|
||||
<div class="w-10 h-10 flex items-center justify-center bg-blue-800 rounded-lg">
|
||||
<i data-feather="grid" class="w-5 h-5"></i>
|
||||
</div>
|
||||
|
||||
<span class="text-[15px] leading-5">
|
||||
Dashboard Sentimen
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<!-- DATA ULASAN -->
|
||||
<a href="<?php echo e(route('ulasan.index')); ?>"
|
||||
class="flex items-center gap-4 px-4 py-3 rounded-xl hover:bg-blue-800 transition">
|
||||
|
||||
<div class="w-10 h-10 flex items-center justify-center bg-blue-800 rounded-lg">
|
||||
<i data-feather="file-text" class="w-5 h-5"></i>
|
||||
</div>
|
||||
|
||||
<span class="text-[15px] leading-5">
|
||||
Data Ulasan
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<!-- RIWAYAT -->
|
||||
<a href="<?php echo e(route('riwayat.index')); ?>"
|
||||
class="flex items-center gap-4 px-4 py-3 rounded-xl hover:bg-blue-800 transition">
|
||||
|
||||
<div class="w-10 h-10 flex items-center justify-center bg-blue-800 rounded-lg">
|
||||
<i data-feather="clock" class="w-5 h-5"></i>
|
||||
</div>
|
||||
|
||||
<span class="text-[15px] leading-5">
|
||||
Riwayat Analisis
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<!-- KHUSUS ADMIN -->
|
||||
<?php if(auth()->user()->role == 'admin'): ?>
|
||||
|
||||
<a href="<?php echo e(route('kelola-pengguna.index')); ?>"
|
||||
class="flex items-center gap-4 px-4 py-3 rounded-xl hover:bg-blue-800 transition">
|
||||
|
||||
<div class="w-10 h-10 flex items-center justify-center bg-blue-800 rounded-lg">
|
||||
<i data-feather="users" class="w-5 h-5"></i>
|
||||
</div>
|
||||
|
||||
<span class="text-[15px] leading-5">
|
||||
Kelola Pengguna
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</nav>
|
||||
|
||||
<!-- USER -->
|
||||
<div class="px-6 pb-6">
|
||||
|
||||
<div class="relative">
|
||||
|
||||
<!-- USER BUTTON -->
|
||||
<button onclick="toggleUserMenu()"
|
||||
class="w-full flex items-center gap-3
|
||||
bg-blue-800 hover:bg-blue-900
|
||||
px-4 py-3 rounded-2xl transition">
|
||||
|
||||
<!-- ICON -->
|
||||
<div class="w-11 h-11 rounded-full bg-blue-700
|
||||
flex items-center justify-center">
|
||||
|
||||
<i data-feather="user"
|
||||
class="w-5 h-5"></i>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TEXT -->
|
||||
<div class="text-left flex-1">
|
||||
|
||||
<p class="text-sm font-semibold capitalize">
|
||||
<?php echo e(auth()->user()->name); ?>
|
||||
|
||||
</p>
|
||||
|
||||
<p class="text-xs text-blue-200 capitalize">
|
||||
<?php echo e(auth()->user()->role); ?>
|
||||
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ARROW -->
|
||||
<i data-feather="chevron-up"
|
||||
class="w-4 h-4 text-blue-200"></i>
|
||||
|
||||
</button>
|
||||
|
||||
<!-- DROPDOWN -->
|
||||
<div id="userMenu"
|
||||
class="hidden absolute bottom-16 left-0 w-full
|
||||
bg-white text-gray-700 rounded-2xl shadow-2xl overflow-hidden">
|
||||
|
||||
<!-- PROFILE -->
|
||||
<a href="<?php echo e(route('profile')); ?>"
|
||||
class="flex items-center gap-3 px-4 py-4 text-sm hover:bg-gray-100 transition">
|
||||
|
||||
<i data-feather="user"
|
||||
class="w-4 h-4"></i>
|
||||
|
||||
Profile
|
||||
|
||||
</a>
|
||||
|
||||
<!-- LOGOUT -->
|
||||
<form id="logoutForm"
|
||||
method="POST"
|
||||
action="<?php echo e(route('logout')); ?>">
|
||||
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<button type="submit"
|
||||
class="w-full flex items-center gap-3 px-4 py-4 text-sm hover:bg-gray-100 transition text-left">
|
||||
|
||||
<i data-feather="log-out"
|
||||
class="w-4 h-4"></i>
|
||||
|
||||
Logout
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</aside>
|
||||
|
||||
<!-- CONTENT -->
|
||||
<div class="flex-1 p-4 md:p-6 md:ml-64">
|
||||
|
||||
<!-- MOBILE BUTTON -->
|
||||
<button onclick="toggleSidebar()"
|
||||
class="md:hidden mb-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow">
|
||||
|
||||
☰
|
||||
|
||||
</button>
|
||||
|
||||
<?php echo $__env->yieldContent('content'); ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- MODAL LOGOUT -->
|
||||
<div id="logoutModal"
|
||||
class="hidden fixed inset-0 bg-black/40 flex items-center justify-center z-50 px-4">
|
||||
|
||||
<div class="bg-white rounded-2xl p-6 w-96 text-center shadow-2xl">
|
||||
|
||||
<!-- ICON -->
|
||||
<div class="w-16 h-16 rounded-full
|
||||
flex items-center justify-center mx-auto mb-5">
|
||||
|
||||
<i data-feather="log-out"
|
||||
class="w-7 h-7 text-red-500"></i>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- TITLE -->
|
||||
<h3 class="text-xl font-bold text-gray-800 mb-2">
|
||||
Konfirmasi Logout
|
||||
</h3>
|
||||
|
||||
<!-- TEXT -->
|
||||
<p class="text-sm text-gray-500 mb-6">
|
||||
Apakah Anda ingin keluar dari sistem?
|
||||
</p>
|
||||
|
||||
<!-- BUTTON -->
|
||||
<div class="flex justify-center gap-3">
|
||||
|
||||
<button onclick="closeModal()"
|
||||
class="px-5 py-2 rounded-xl bg-gray-200 hover:bg-gray-300 transition">
|
||||
|
||||
Tidak
|
||||
|
||||
</button>
|
||||
|
||||
<button onclick="submitLogout()"
|
||||
class="px-5 py-2 rounded-xl bg-red-500 hover:bg-red-600 text-white transition">
|
||||
|
||||
Ya
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- SCRIPT -->
|
||||
<script>
|
||||
|
||||
function toggleSidebar() {
|
||||
document.getElementById('sidebar')
|
||||
.classList.toggle('-translate-x-full');
|
||||
}
|
||||
|
||||
function toggleUserMenu() {
|
||||
document.getElementById('userMenu')
|
||||
.classList.toggle('hidden');
|
||||
}
|
||||
|
||||
function confirmLogout() {
|
||||
document.getElementById('logoutModal')
|
||||
.classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
document.getElementById('logoutModal')
|
||||
.classList.add('hidden');
|
||||
}
|
||||
|
||||
function submitLogout() {
|
||||
document.getElementById('logoutForm').submit();
|
||||
}
|
||||
|
||||
/* CLOSE DROPDOWN KETIKA KLIK LUAR */
|
||||
window.addEventListener('click', function(e){
|
||||
|
||||
const button = e.target.closest('button');
|
||||
const menu = document.getElementById('userMenu');
|
||||
|
||||
if(!e.target.closest('#userMenu') &&
|
||||
!e.target.closest('[onclick="toggleUserMenu()"]')) {
|
||||
|
||||
menu.classList.add('hidden');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
feather.replace();
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/layouts/sentara.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,354 @@
|
|||
<?php $__env->startSection('content'); ?>
|
||||
|
||||
<div class="max-w-7xl mx-auto">
|
||||
|
||||
|
||||
<?php if(session('success')): ?>
|
||||
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-6 rounded">
|
||||
<?php echo e(session('success')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if(session('error')): ?>
|
||||
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-6 rounded whitespace-pre-line">
|
||||
<?php echo e(session('error')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($noDataPesan ?? null): ?>
|
||||
<div class="bg-blue-50 border-l-4 border-blue-400 text-blue-700 p-4 mb-6 rounded flex items-center gap-2">
|
||||
<span>📅</span> <span><?php echo e($noDataPesan); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($periodeAktif && !$hasAnalisis): ?>
|
||||
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mb-6 rounded">
|
||||
Data ulasan sudah tersedia, tetapi belum dilakukan analisis sentimen.
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-sm text-gray-600 font-medium">
|
||||
Periode aktif: <?php echo e($periodeAktif->nama ?? 'Belum ada data'); ?>
|
||||
|
||||
</span>
|
||||
<a href="<?php echo e(route('riwayat.index')); ?>" class="text-sm text-blue-600 hover:underline">
|
||||
Lihat riwayat
|
||||
</a>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<?php if($periodeAktif): ?>
|
||||
<span class="text-xs text-gray-400">
|
||||
Terakhir update: <?php echo e($lastUpdate ? \Carbon\Carbon::parse($lastUpdate)->format('d M Y H:i') : '-'); ?>
|
||||
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<form method="GET"
|
||||
action="<?php echo e(route('dashboard')); ?>"
|
||||
class="flex flex-col md:flex-row gap-3 md:items-center">
|
||||
|
||||
|
||||
|
||||
<input type="month"
|
||||
name="periode_bulan"
|
||||
value="<?php echo e(request('periode_bulan', now()->format('Y-m'))); ?>"
|
||||
max="<?php echo e(now()->format('Y-m')); ?>"
|
||||
onchange="this.form.submit()"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]">
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div x-data="{ tab: new URLSearchParams(window.location.search).get('tab') || 'dashboard' }"
|
||||
x-init="$nextTick(() => { if (tab === 'dashboard') renderAllCharts() })"
|
||||
class="mb-6">
|
||||
|
||||
<!-- TAB -->
|
||||
<div class="bg-blue-700 rounded-xl p-1 flex space-x-2 shadow mb-6">
|
||||
<button @click="tab='dashboard'; $nextTick(() => renderAllCharts())"
|
||||
:class="tab==='dashboard' ? 'bg-white text-blue-700 shadow' : 'text-white hover:bg-blue-600'"
|
||||
class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
||||
Dashboard Sentara
|
||||
</button>
|
||||
<button @click="tab='analisis'"
|
||||
:class="tab==='analisis' ? 'bg-white text-blue-700 shadow' : 'text-white hover:bg-blue-600'"
|
||||
class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
||||
Hasil Analisis Sentimen
|
||||
</button>
|
||||
<button @click="tab='rekomendasi'"
|
||||
:class="tab==='rekomendasi' ? 'bg-white text-blue-700 shadow' : 'text-white hover:bg-blue-600'"
|
||||
class="flex-1 py-3 rounded-lg text-sm font-medium transition">
|
||||
Rekomendasi Layanan
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- ================= DASHBOARD ================= -->
|
||||
<div x-show="tab === 'dashboard'">
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-8">
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<p class="text-gray-500 text-sm">Total Ulasan</p>
|
||||
<h3 class="text-2xl font-bold mt-2 text-gray-900"><?php echo e($stats['total']); ?></h3>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<p class="text-gray-500 text-sm">Sentimen Positif</p>
|
||||
<h3 class="text-2xl font-bold mt-2 text-green-600"><?php echo e($stats['positif_persen']); ?>%</h3>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<p class="text-gray-500 text-sm">Sentimen Negatif</p>
|
||||
<h3 class="text-2xl font-bold mt-2 text-red-600"><?php echo e($stats['negatif_persen']); ?>%</h3>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow p-5">
|
||||
<p class="text-gray-500 text-sm">Sentimen Netral</p>
|
||||
<h3 class="text-2xl font-bold mt-2 text-yellow-500"><?php echo e($stats['netral_persen']); ?>%</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-6">
|
||||
<h3 class="font-semibold mb-4 text-gray-700">Distribusi Sentimen</h3>
|
||||
<div style="height:300px;">
|
||||
<canvas id="pieChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-6">
|
||||
<h3 class="font-semibold mb-4 text-gray-700">Sentimen per Destinasi</h3>
|
||||
<div class="h-[300px]">
|
||||
<canvas id="destinationChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
||||
<div class="bg-white rounded-xl shadow p-6 h-[320px]">
|
||||
<h3 class="font-semibold mb-6 text-gray-700">Total Data per Destinasi</h3>
|
||||
<div class="space-y-4 text-sm text-gray-600">
|
||||
<?php $__currentLoopData = $totalPerWisata; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<div class="flex justify-between border-b pb-3">
|
||||
<span><?php echo e($item->wisata); ?></span>
|
||||
<span class="font-semibold text-gray-800"><?php echo e($item->total); ?> ulasan</span>
|
||||
</div>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl shadow p-6 h-[320px]">
|
||||
<h3 class="font-semibold mb-6 text-gray-700">Word Cloud</h3>
|
||||
<div id="wordCloud" class="w-full h-[240px] overflow-hidden flex flex-wrap content-center justify-center gap-3 text-center">
|
||||
<p class="text-sm text-gray-400">Belum ada kata dominan.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ================= ANALISIS ================= -->
|
||||
<div x-show="tab === 'analisis'" id="analisis-content">
|
||||
<?php echo $__env->make('analisis.index', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
|
||||
</div>
|
||||
|
||||
<!-- ================= REKOMENDASI ================= -->
|
||||
<div x-show="tab === 'rekomendasi'" id="rekomendasi-content">
|
||||
<?php echo $__env->make('rekomendasi.index', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
const pieData = <?php echo json_encode($chartSentimen, 15, 512) ?>;
|
||||
const destinationData = <?php echo json_encode($chartDestinasi, 15, 512) ?>;
|
||||
const text = <?php echo json_encode($allText, 15, 512) ?>;
|
||||
|
||||
function renderAllCharts() {
|
||||
// PIE CHART
|
||||
const pieCanvas = document.getElementById('pieChart');
|
||||
if (pieCanvas) {
|
||||
if (window.pieChartInstance) {
|
||||
window.pieChartInstance.destroy();
|
||||
window.pieChartInstance = null;
|
||||
}
|
||||
|
||||
// Reset canvas dengan clone agar benar-benar bersih
|
||||
const newPie = pieCanvas.cloneNode(false);
|
||||
pieCanvas.parentNode.replaceChild(newPie, pieCanvas);
|
||||
|
||||
window.pieChartInstance = new Chart(newPie, { // <-- newPie, bukan pieCanvas
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: pieData.map(i => i.sentimen),
|
||||
datasets: [{
|
||||
data: pieData.map(i => Number(i.total)),
|
||||
backgroundColor: ['#3B82F6', '#EF4444', '#F59E0B']
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
animation: false
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// BAR CHART
|
||||
const destinationCanvas = document.getElementById('destinationChart');
|
||||
if (destinationCanvas) {
|
||||
if (window.destinationChartInstance) {
|
||||
window.destinationChartInstance.destroy();
|
||||
window.destinationChartInstance = null;
|
||||
}
|
||||
window.destinationChartInstance = new Chart(destinationCanvas, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: destinationData.map(item => item.wisata),
|
||||
datasets: [
|
||||
{
|
||||
label: 'Positif',
|
||||
data: destinationData.map(item => Number(item.positif || 0)),
|
||||
backgroundColor: 'rgba(96, 165, 250, 0.88)',
|
||||
borderColor: '#3B82F6',
|
||||
borderWidth: 1,
|
||||
borderRadius: 3,
|
||||
},
|
||||
{
|
||||
label: 'Negatif',
|
||||
data: destinationData.map(item => Number(item.negatif || 0)),
|
||||
backgroundColor: 'rgba(248, 113, 113, 0.9)',
|
||||
borderColor: '#EF4444',
|
||||
borderWidth: 1,
|
||||
borderRadius: 3,
|
||||
},
|
||||
{
|
||||
label: 'Netral',
|
||||
data: destinationData.map(item => Number(item.netral || 0)),
|
||||
backgroundColor: 'rgba(251, 191, 36, 0.72)',
|
||||
borderColor: '#F59E0B',
|
||||
borderWidth: 1,
|
||||
borderRadius: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
position: 'top',
|
||||
align: 'center',
|
||||
labels: { boxWidth: 38, boxHeight: 10, color: '#4B5563', font: { size: 12 } },
|
||||
},
|
||||
tooltip: {
|
||||
callbacks: {
|
||||
label: context => `${context.dataset.label}: ${context.parsed.y} ulasan`,
|
||||
},
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
grid: { color: 'rgba(156, 163, 175, 0.22)' },
|
||||
ticks: { color: '#4B5563', maxRotation: 14, minRotation: 14, font: { size: 12 } },
|
||||
},
|
||||
y: {
|
||||
beginAtZero: true,
|
||||
ticks: { color: '#4B5563', precision: 0 },
|
||||
grid: { color: 'rgba(156, 163, 175, 0.28)' },
|
||||
},
|
||||
},
|
||||
categoryPercentage: 0.72,
|
||||
barPercentage: 0.82,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// WORD CLOUD
|
||||
const wordCloud = document.getElementById('wordCloud');
|
||||
const stopwords = new Set([
|
||||
'yang','dan','dari','untuk','dengan','ini','itu','tidak','ada','juga',
|
||||
'sangat','lebih','sudah','bisa','tapi','karena','pada','atau','saya',
|
||||
'kami','mereka','nya','jadi','kalau','dalam','akan','saat','tempat'
|
||||
]);
|
||||
|
||||
if (wordCloud && text.trim().length > 0) {
|
||||
const wordCount = {};
|
||||
text.toLowerCase().split(/\s+/).forEach(word => {
|
||||
const cleanWord = word.replace(/[^a-z]/g, '');
|
||||
if (cleanWord.length > 3 && !stopwords.has(cleanWord)) {
|
||||
wordCount[cleanWord] = (wordCount[cleanWord] || 0) + 1;
|
||||
}
|
||||
});
|
||||
|
||||
const words = Object.entries(wordCount)
|
||||
.sort((a, b) => b[1] - a[1])
|
||||
.slice(0, 28);
|
||||
|
||||
if (words.length > 0) {
|
||||
const max = words[0][1] || 1;
|
||||
const colors = ['text-blue-700', 'text-green-600', 'text-red-500', 'text-yellow-600', 'text-indigo-600'];
|
||||
wordCloud.innerHTML = words.map(([word, count], index) => {
|
||||
const size = 13 + Math.round((count / max) * 20);
|
||||
const weight = count === max ? 800 : 600;
|
||||
return `<span class="${colors[index % colors.length]} inline-block" style="font-size:${size}px;font-weight:${weight}" title="${count}x">${word}</span>`;
|
||||
}).join('');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const container = document.getElementById('analisis-content');
|
||||
|
||||
// FILTER AJAX
|
||||
document.addEventListener('submit', function(e){
|
||||
if(e.target.id === 'filter-form'){
|
||||
e.preventDefault();
|
||||
const params = new URLSearchParams(new FormData(e.target)).toString();
|
||||
fetch('/dashboard?' + params)
|
||||
.then(res => res.text())
|
||||
.then(html => {
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
container.innerHTML = doc.getElementById('analisis-content').innerHTML;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// PAGINATION AJAX
|
||||
document.addEventListener('click', function(e){
|
||||
const link = e.target.closest('a');
|
||||
if(link && link.href.includes('page=')){
|
||||
e.preventDefault();
|
||||
fetch(link.href)
|
||||
.then(res => res.text())
|
||||
.then(html => {
|
||||
const doc = new DOMParser().parseFromString(html, 'text/html');
|
||||
container.innerHTML = doc.getElementById('analisis-content').innerHTML;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php $__env->stopSection(); ?>
|
||||
<?php echo $__env->make('layouts.sentara', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/dashboard.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Login - SENTARA</title>
|
||||
|
||||
<link rel="icon" type="image/png" href="<?php echo e(asset('favicon.png')); ?>">
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
*{
|
||||
margin:0;
|
||||
padding:0;
|
||||
box-sizing:border-box;
|
||||
font-family:'Poppins',sans-serif;
|
||||
}
|
||||
|
||||
body{
|
||||
background:#f3f5fb;
|
||||
min-height:100vh;
|
||||
display:flex;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
padding:40px;
|
||||
}
|
||||
|
||||
/* CONTAINER */
|
||||
.container{
|
||||
width:1350px;
|
||||
max-width:100%;
|
||||
height:720px;
|
||||
background:#fff;
|
||||
border-radius:25px;
|
||||
display:flex;
|
||||
overflow:hidden;
|
||||
box-shadow:0 30px 80px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
/* LEFT */
|
||||
.left{
|
||||
width:50%;
|
||||
padding:60px 80px;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
justify-content:center;
|
||||
}
|
||||
|
||||
/* LOGO */
|
||||
.logo{
|
||||
text-align:center;
|
||||
margin-bottom:25px;
|
||||
}
|
||||
|
||||
.logo img{
|
||||
width:200px;
|
||||
}
|
||||
|
||||
/* TITLE */
|
||||
.title{
|
||||
text-align:center;
|
||||
font-size:28px;
|
||||
font-weight:600;
|
||||
}
|
||||
|
||||
.title span{
|
||||
color:#ff5c8d;
|
||||
}
|
||||
|
||||
.subtitle{
|
||||
text-align:center;
|
||||
font-size:14px;
|
||||
color:#777;
|
||||
margin:12px 0 35px;
|
||||
}
|
||||
|
||||
/* FORM */
|
||||
.form-group{
|
||||
margin-bottom:20px;
|
||||
}
|
||||
|
||||
label{
|
||||
font-size:13px;
|
||||
font-weight:500;
|
||||
}
|
||||
|
||||
input{
|
||||
width:100%;
|
||||
padding:14px;
|
||||
border-radius:12px;
|
||||
border:1px solid #ddd;
|
||||
margin-top:6px;
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
.input-group{
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.toggle{
|
||||
position:absolute;
|
||||
right:12px;
|
||||
top:14px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.forgot{
|
||||
text-align:right;
|
||||
margin-top:6px;
|
||||
}
|
||||
|
||||
.forgot a{
|
||||
font-size:12px;
|
||||
color:#2d5be3;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
/* BUTTON */
|
||||
.btn{
|
||||
width:100%;
|
||||
padding:14px;
|
||||
border:none;
|
||||
border-radius:12px;
|
||||
background:linear-gradient(90deg,#2d5be3,#4c7dff);
|
||||
color:#fff;
|
||||
font-weight:500;
|
||||
margin-top:20px;
|
||||
cursor:pointer;
|
||||
transition:0.3s;
|
||||
}
|
||||
|
||||
.btn:hover{
|
||||
opacity:0.9;
|
||||
}
|
||||
|
||||
.right{
|
||||
width:50%;
|
||||
position:relative;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
/* GAMBAR */
|
||||
.right img{
|
||||
position:absolute;
|
||||
top:0;
|
||||
right:0;
|
||||
width:100%;
|
||||
height:100%;
|
||||
object-fit:cover;
|
||||
|
||||
/* SHAPE DIPERBAIKI */
|
||||
clip-path: ellipse(120% 100% at 100% 50%);
|
||||
}
|
||||
|
||||
/* OVERLAY */
|
||||
.overlay{
|
||||
position:absolute;
|
||||
width:100%;
|
||||
height:100%;
|
||||
display:flex;
|
||||
flex-direction:column;
|
||||
align-items:center;
|
||||
justify-content:center;
|
||||
text-align:center;
|
||||
color:#fff;
|
||||
background:rgba(0,0,0,0.25);
|
||||
padding:20px;
|
||||
z-index:2; /* DI ATAS */
|
||||
}
|
||||
|
||||
/* QUOTE */
|
||||
.quote{
|
||||
font-size:42px;
|
||||
color:#ff5c8d;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
/* TEXT */
|
||||
.overlay p{
|
||||
font-size:30px;
|
||||
font-weight:500;
|
||||
line-height:1.5;
|
||||
max-width:420px;
|
||||
}
|
||||
|
||||
.overlay span{
|
||||
color:#ff5c8d;
|
||||
font-weight:600;
|
||||
}
|
||||
|
||||
/* GARIS */
|
||||
.line{
|
||||
width:70px;
|
||||
height:3px;
|
||||
background:#fff;
|
||||
border-radius:10px;
|
||||
margin-top:18px;
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.line::after{
|
||||
content:'';
|
||||
position:absolute;
|
||||
width:12px;
|
||||
height:12px;
|
||||
border:2px solid #fff;
|
||||
border-left:none;
|
||||
border-top:none;
|
||||
transform:rotate(-45deg);
|
||||
right:-12px;
|
||||
top:-5px;
|
||||
}
|
||||
|
||||
/* MOBILE */
|
||||
@media(max-width:900px){
|
||||
.container{
|
||||
flex-direction:column;
|
||||
height:auto;
|
||||
}
|
||||
|
||||
.left{
|
||||
width:100%;
|
||||
padding:40px;
|
||||
}
|
||||
|
||||
.right{
|
||||
width:100%;
|
||||
height:260px;
|
||||
}
|
||||
|
||||
.overlay p{
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
.logo img{
|
||||
width:150px;
|
||||
}
|
||||
}
|
||||
|
||||
@media(max-width:900px){
|
||||
.container{
|
||||
flex-direction:column;
|
||||
height:auto;
|
||||
}
|
||||
|
||||
.left{
|
||||
width:100%;
|
||||
padding:40px;
|
||||
}
|
||||
|
||||
.right{
|
||||
width:100%;
|
||||
height:260px;
|
||||
}
|
||||
|
||||
.overlay p{
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
.logo img{
|
||||
width:150px;
|
||||
}
|
||||
}
|
||||
|
||||
/* HILANGKAN ICON PASSWORD BAWAAN BROWSER */
|
||||
input[type="password"]::-ms-reveal,
|
||||
input[type="password"]::-ms-clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input::-ms-reveal,
|
||||
input::-ms-clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- LEFT -->
|
||||
<div class="left">
|
||||
|
||||
<div class="logo">
|
||||
<img src="<?php echo e(asset('images/logo-sentara.png')); ?>">
|
||||
</div>
|
||||
|
||||
<?php if($errors->any()): ?>
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<script>
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Login Gagal',
|
||||
text: 'Email atau password yang dimasukkan salah.',
|
||||
confirmButtonColor: '#2d5be3'
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="title">
|
||||
Selamat Datang <span>Kembali!</span>
|
||||
</div>
|
||||
|
||||
<div class="subtitle">
|
||||
Login untuk mengakses Dashboard Analisis Sentimen Wisata Jember
|
||||
</div>
|
||||
|
||||
<form method="POST" action="<?php echo e(route('login')); ?>">
|
||||
<?php echo csrf_field(); ?>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Email</label>
|
||||
<input type="email" name="email" placeholder="Masukkan email Anda" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Password</label>
|
||||
<div class="input-group">
|
||||
<input type="password" id="password" name="password" placeholder="Masukkan password Anda" required>
|
||||
<span class="toggle" onclick="togglePass()">👁</span>
|
||||
</div>
|
||||
|
||||
<div class="forgot">
|
||||
<a href="<?php echo e(route('password.request')); ?>">Lupa password?</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn">Login</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- RIGHT -->
|
||||
<div class="right">
|
||||
|
||||
<img src="<?php echo e(asset('images/papuma.jpg')); ?>" alt="bg">
|
||||
|
||||
<div class="overlay">
|
||||
|
||||
<p>
|
||||
Memahami opini,<br>
|
||||
meningkatkan <span>pariwisata</span><br>
|
||||
Jember.
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function togglePass(){
|
||||
let x = document.getElementById("password");
|
||||
x.type = x.type === "password" ? "text" : "password";
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/auth/login.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
<?php $__env->startSection('content'); ?>
|
||||
|
||||
<div class="max-w-7xl mx-auto px-4 md:px-0 space-y-6">
|
||||
|
||||
<!-- HEADER -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">Data Ulasan</h2>
|
||||
<p class="text-sm text-gray-500">
|
||||
Periode aktif: <?php echo e($periodeAktif->nama ?? 'Belum ada data'); ?>
|
||||
|
||||
<a href="<?php echo e(route('riwayat.index')); ?>" class="text-blue-600 hover:underline ml-2">Lihat riwayat</a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-col md:flex-row gap-3 md:items-center">
|
||||
<form action="<?php echo e(route('ulasan.ambil')); ?>" method="POST" class="flex flex-col md:flex-row gap-3 md:items-center">
|
||||
<?php echo csrf_field(); ?>
|
||||
<input type="hidden" name="redirect_to" value="ulasan">
|
||||
<input type="month" name="periode_bulan" value="<?php echo e($periodeAktif
|
||||
? $periodeAktif->tahun . '-' . str_pad($periodeAktif->bulan, 2, '0', STR_PAD_LEFT)
|
||||
: now()->format('Y-m')); ?>"
|
||||
class="border rounded-lg px-3 py-2 text-sm bg-white shadow-sm min-w-[150px]">
|
||||
<select name="wisata" class="border rounded-lg pl-3 pr-9 py-2 text-sm bg-white shadow-sm min-w-[220px]">
|
||||
<option value="">Semua Lokasi</option>
|
||||
<?php $__currentLoopData = ($scraperDestinations ?? []); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $scraperDestination): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($scraperDestination); ?>"><?php echo e($scraperDestination); ?></option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
</select>
|
||||
<button class="border border-blue-500 text-blue-600 px-5 py-2.5 rounded-full hover:bg-blue-50 transition">
|
||||
Ambil Data
|
||||
</button>
|
||||
</form>
|
||||
<form action="<?php echo e(route('proses.analisis')); ?>" method="POST">
|
||||
<?php echo csrf_field(); ?>
|
||||
<input type="hidden" name="periode_id" value="<?php echo e($periodeId); ?>">
|
||||
<button
|
||||
<?php echo e($totalUlasan <= 0 ? 'disabled' : ''); ?>
|
||||
|
||||
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2.5 rounded-full shadow-md transition disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
Proses Analisis
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- SUMMARY -->
|
||||
<div class="bg-white rounded-3xl shadow p-6 mb-6 mt-5">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="bg-blue-100 text-blue-600 p-3 rounded-full">📄</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Total Ulasan</p>
|
||||
<p class="font-bold text-lg"><?php echo e($totalUlasan); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="bg-green-100 text-green-600 p-3 rounded-full">📍</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Total Wisata</p>
|
||||
<p class="font-bold text-lg"><?php echo e($totalWisata); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="bg-orange-100 text-orange-600 p-3 rounded-full">📅</div>
|
||||
<div>
|
||||
<p class="text-xs text-gray-500">Terakhir Update</p>
|
||||
<p class="text-sm font-semibold">
|
||||
<?php echo e($lastUpdate ? \Carbon\Carbon::parse($lastUpdate)->format('d M Y H:i') : '-'); ?>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ALERT -->
|
||||
<?php if(session('success')): ?>
|
||||
<div class="bg-green-100 text-green-700 px-4 py-2 rounded-lg text-sm">
|
||||
<?php echo e(session('success')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if(session('error')): ?>
|
||||
<div class="bg-red-100 text-red-700 px-4 py-2 rounded-lg text-sm whitespace-pre-line">
|
||||
<?php echo e(session('error')); ?>
|
||||
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- SEARCH -->
|
||||
<form method="GET" action="<?php echo e(route('ulasan.index')); ?>" class="flex flex-col md:flex-row gap-3 items-center">
|
||||
<?php if(request('periode_id')): ?>
|
||||
<input type="hidden" name="periode_id" value="<?php echo e(request('periode_id')); ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<input type="text" name="search" value="<?php echo e(request('search')); ?>"
|
||||
placeholder="Cari ulasan atau wisata..."
|
||||
class="flex-1 border px-3 py-2 rounded-lg text-sm">
|
||||
|
||||
<button class="bg-blue-500 text-white px-4 py-2 rounded-lg text-sm">Cari</button>
|
||||
|
||||
<button type="button"
|
||||
onclick="if (confirm('Reset akan mengosongkan semua ulasan dan hasil analisis untuk periode ini. Lanjutkan?')) document.getElementById('resetPeriodeForm').submit();"
|
||||
class="bg-gray-200 px-4 py-2 rounded-lg text-sm">
|
||||
Reset
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php if($periodeId): ?>
|
||||
<form id="resetPeriodeForm" action="<?php echo e(route('ulasan.kosongkan-periode')); ?>" method="POST" class="hidden">
|
||||
<?php echo csrf_field(); ?>
|
||||
<?php echo method_field('DELETE'); ?>
|
||||
<input type="hidden" name="periode_id" value="<?php echo e($periodeId); ?>">
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- TABLE -->
|
||||
<div class="bg-white rounded-xl shadow overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-100">
|
||||
<tr>
|
||||
<th class="px-4 py-3 w-[5%]">No</th>
|
||||
<th class="px-4 py-3 w-[20%]">Nama Wisata</th>
|
||||
<th class="px-4 py-3 w-[10%] text-center">Rating</th>
|
||||
<th class="px-4 py-3 w-[45%]">Ulasan</th>
|
||||
<th class="px-4 py-3 w-[20%] text-center">Tanggal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y">
|
||||
<?php $__empty_1 = true; $__currentLoopData = $mentah; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3"><?php echo e($mentah->firstItem() + $i); ?></td>
|
||||
<td class="px-4 py-3 font-medium"><?php echo e($item->wisata); ?></td>
|
||||
<td class="px-4 py-3 text-center text-yellow-500">
|
||||
<?php echo e(str_repeat('★', round($item->rating))); ?>
|
||||
|
||||
<span class="text-gray-500 ml-1"><?php echo e($item->rating); ?></span>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="line-clamp-2 text-gray-600"><?php echo e($item->ulasan); ?></div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-center text-gray-500">
|
||||
<?php
|
||||
try {
|
||||
$tanggalUlasan = $item->tanggal
|
||||
? \Carbon\Carbon::parse($item->tanggal)->format('d M Y')
|
||||
: '-';
|
||||
} catch (\Throwable $e) {
|
||||
$tanggalUlasan = $item->tanggal ?: '-';
|
||||
}
|
||||
?>
|
||||
<?php echo e($tanggalUlasan); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-6 text-gray-400">Belum ada data</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="p-4 flex flex-col md:flex-row gap-3 justify-between items-center text-sm text-gray-500">
|
||||
<div>
|
||||
Menampilkan <?php echo e($mentah->firstItem() ?? 0); ?> - <?php echo e($mentah->lastItem() ?? 0); ?>
|
||||
|
||||
dari <?php echo e($mentah->total()); ?> data
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<?php if($mentah->onFirstPage()): ?>
|
||||
<span class="px-3 py-1 bg-gray-200 rounded-lg">«</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($mentah->previousPageUrl()); ?>" class="px-3 py-1 bg-gray-100 rounded-lg">«</a>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php for($i = 1; $i <= $mentah->lastPage(); $i++): ?>
|
||||
<?php if($i == $mentah->currentPage()): ?>
|
||||
<span class="px-3 py-1 bg-blue-600 text-white rounded-lg"><?php echo e($i); ?></span>
|
||||
<?php elseif($i <= 3 || $i > $mentah->lastPage() - 2 || abs($i - $mentah->currentPage()) <= 1): ?>
|
||||
<a href="<?php echo e($mentah->url($i)); ?>" class="px-3 py-1 bg-gray-100 rounded-lg"><?php echo e($i); ?></a>
|
||||
<?php elseif($i == 4 || $i == $mentah->lastPage() - 3): ?>
|
||||
<span class="px-2">...</span>
|
||||
<?php endif; ?>
|
||||
<?php endfor; ?>
|
||||
|
||||
<?php if($mentah->hasMorePages()): ?>
|
||||
<a href="<?php echo e($mentah->nextPageUrl()); ?>" class="px-3 py-1 bg-gray-100 rounded-lg">»</a>
|
||||
<?php else: ?>
|
||||
<span class="px-3 py-1 bg-gray-200 rounded-lg">»</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $__env->stopSection(); ?>
|
||||
|
||||
<?php echo $__env->make('layouts.sentara', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/ulasan/index.blade.php ENDPATH**/ ?>
|
||||
|
|
@ -0,0 +1,222 @@
|
|||
<?php if($standalone ?? false): ?>
|
||||
|
||||
<?php $__env->startSection('content'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$totalHasilAnalisis ??= $hasil->total() ?? 0;
|
||||
$jumlahKelasAnalisis ??= 0;
|
||||
$evaluasiTersedia = $evaluasi && $jumlahKelasAnalisis >= 2;
|
||||
?>
|
||||
|
||||
<div class="space-y-4">
|
||||
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold">Hasil Analisis Sentimen</h2>
|
||||
|
||||
<?php if($totalHasilAnalisis > 0 && !$evaluasiTersedia): ?>
|
||||
<p class="text-sm text-yellow-700 bg-yellow-50 border border-yellow-200 rounded-lg px-3 py-2 mt-3">
|
||||
Semua hasil hanya memiliki <?php echo e($jumlahKelasAnalisis); ?> kelas sentimen. Precision, recall, F1, dan akurasi tidak dihitung karena evaluasi klasifikasi membutuhkan minimal 2 kelas. Detail hasil analisis tetap ditampilkan di bawah.
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">Precision</p>
|
||||
<h3 class="text-2xl font-bold text-blue-600">
|
||||
<?php echo e($evaluasiTersedia ? number_format($evaluasi->precision ?? 0, 2) : '-'); ?>
|
||||
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">Recall</p>
|
||||
<h3 class="text-2xl font-bold text-green-600">
|
||||
<?php echo e($evaluasiTersedia ? number_format($evaluasi->recall ?? 0, 2) : '-'); ?>
|
||||
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">F1 Score</p>
|
||||
<h3 class="text-2xl font-bold text-purple-600">
|
||||
<?php echo e($evaluasiTersedia ? number_format($evaluasi->f1_score ?? 0, 2) : '-'); ?>
|
||||
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="bg-white p-5 rounded-xl shadow">
|
||||
<p class="text-gray-500 text-sm">Akurasi</p>
|
||||
<h3 class="text-2xl font-bold text-indigo-600">
|
||||
<?php echo e($evaluasiTersedia ? number_format($evaluasi->accuracy ?? 0, 2) : '-'); ?>
|
||||
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="flex items-end gap-3 mb-4">
|
||||
|
||||
<form id="filter-form"
|
||||
method="GET"
|
||||
action="<?php echo e(route('dashboard')); ?>"
|
||||
class="flex items-end gap-2">
|
||||
|
||||
<input type="hidden" name="tab" value="analisis">
|
||||
<input type="hidden" name="periode_id"
|
||||
value="<?php echo e($periodeAktif->id ?? ''); ?>">
|
||||
|
||||
<select
|
||||
name="wisata"
|
||||
class="border rounded px-3 py-2 h-[46px]">
|
||||
|
||||
<option value="">Semua Destinasi</option>
|
||||
|
||||
<?php $__currentLoopData = $wisataList; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<option value="<?php echo e($item); ?>"
|
||||
<?php echo e(request('wisata') == $item ? 'selected' : ''); ?>>
|
||||
<?php echo e($item); ?>
|
||||
|
||||
</option>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
</select>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="bg-blue-600 text-white px-4 rounded h-[46px]">
|
||||
Filter
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="bg-white rounded-xl shadow p-4 h-fit">
|
||||
|
||||
<h3 class="font-semibold mb-4">Detail Hasil Analisis Sentimen</h3>
|
||||
|
||||
<table class="w-full text-sm">
|
||||
<thead class="border-b text-left">
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Wisata</th>
|
||||
<th>Ulasan Asli</th>
|
||||
<th>Ulasan Bersih</th>
|
||||
<th>Sentimen</th>
|
||||
<th>Probabilitas</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php $__empty_1 = true; $__currentLoopData = $hasil; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
|
||||
<tr class="border-b">
|
||||
<td><?php echo e(($hasil->currentPage() - 1) * $hasil->perPage() + $loop->iteration); ?></td>
|
||||
<td><?php echo e($item->wisata); ?></td>
|
||||
<td class="text-gray-500"><?php echo e(Str::limit($item->ulasan_asli ?? '-', 80)); ?></td>
|
||||
<td><?php echo e(Str::limit($item->hasil_preprocessing ?? '-', 80)); ?></td>
|
||||
<td>
|
||||
<span class="px-2 py-1 rounded text-xs
|
||||
<?php echo e(strtolower($item->sentimen) == 'positif' ? 'bg-green-100 text-green-600' : ''); ?>
|
||||
|
||||
<?php echo e(strtolower($item->sentimen) == 'negatif' ? 'bg-red-100 text-red-600' : ''); ?>
|
||||
|
||||
<?php echo e(strtolower($item->sentimen) == 'netral' ? 'bg-yellow-100 text-yellow-600' : ''); ?>
|
||||
|
||||
">
|
||||
<?php echo e(ucfirst($item->sentimen)); ?>
|
||||
|
||||
</span>
|
||||
</td>
|
||||
<td><?php echo e(number_format($item->probabilitas ?? 0, 2)); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center py-4 text-gray-500">Tidak ada data</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<?php if($hasil->hasPages()): ?>
|
||||
<?php
|
||||
$current = $hasil->currentPage();
|
||||
$last = $hasil->lastPage();
|
||||
$query = http_build_query(request()->except('page'));
|
||||
// Window 2 halaman kiri & kanan dari current
|
||||
$window = collect(range(max(1, $current - 2), min($last, $current + 2)));
|
||||
?>
|
||||
|
||||
<div class="mt-4 flex items-center justify-between text-sm text-gray-600">
|
||||
|
||||
|
||||
<p>Menampilkan <?php echo e($hasil->firstItem()); ?> - <?php echo e($hasil->lastItem()); ?> dari <?php echo e($hasil->total()); ?> data</p>
|
||||
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
|
||||
|
||||
<?php if($hasil->onFirstPage()): ?>
|
||||
<span class="px-3 py-1 rounded border bg-gray-100 text-gray-400 cursor-not-allowed">«</span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($hasil->previousPageUrl()); ?>&<?php echo e($query); ?>" class="px-3 py-1 rounded border hover:bg-blue-50 text-blue-600">«</a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if(!$window->contains(1)): ?>
|
||||
<a href="<?php echo e($hasil->url(1)); ?>&<?php echo e($query); ?>" class="px-3 py-1 rounded border hover:bg-blue-50 text-blue-600">1</a>
|
||||
<?php if($window->min() > 2): ?>
|
||||
<span class="px-2 py-1 text-gray-400">...</span>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $__currentLoopData = $window; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
|
||||
<?php if($page == $current): ?>
|
||||
<span class="px-3 py-1 rounded border bg-blue-600 text-white font-semibold"><?php echo e($page); ?></span>
|
||||
<?php else: ?>
|
||||
<a href="<?php echo e($hasil->url($page)); ?>&<?php echo e($query); ?>" class="px-3 py-1 rounded border hover:bg-blue-50 text-blue-600"><?php echo e($page); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
|
||||
|
||||
|
||||
<?php if(!$window->contains($last)): ?>
|
||||
<?php if($window->max() < $last - 1): ?>
|
||||
<span class="px-2 py-1 text-gray-400">...</span>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo e($hasil->url($last)); ?>&<?php echo e($query); ?>" class="px-3 py-1 rounded border hover:bg-blue-50 text-blue-600"><?php echo e($last); ?></a>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if($hasil->hasMorePages()): ?>
|
||||
<a href="<?php echo e($hasil->nextPageUrl()); ?>&<?php echo e($query); ?>" class="px-3 py-1 rounded border hover:bg-blue-50 text-blue-600">»</a>
|
||||
<?php else: ?>
|
||||
<span class="px-3 py-1 rounded border bg-gray-100 text-gray-400 cursor-not-allowed">»</span>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if($standalone ?? false): ?>
|
||||
<?php $__env->stopSection(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $__env->make('layouts.sentara', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\SistemAnalisisSentimen\resources\views/analisis/index.blade.php ENDPATH**/ ?>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue