Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97274f3635 |
18
assets/css/custom.css
Normal file
18
assets/css/custom.css
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
background-color: #F8F9FA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-brand {
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-gradient {
|
||||||
|
background: linear-gradient(90deg, #0d6efd 0%, #0d6efd 100%);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
// Generated by setup_mariadb_project.sh — edit as needed.
|
// Generated by setup_mariadb_project.sh — edit as needed.
|
||||||
define('DB_HOST', '127.0.0.1');
|
define('DB_HOST', '127.0.0.1');
|
||||||
define('DB_NAME', 'app_35786');
|
define('DB_NAME', 'dbmaster');
|
||||||
define('DB_USER', 'app_35786');
|
define('DB_USER', 'app_35786');
|
||||||
define('DB_PASS', '4caf095d-493c-43bd-bfec-762cae9c6aab');
|
define('DB_PASS', '4caf095d-493c-43bd-bfec-762cae9c6aab');
|
||||||
|
|
||||||
|
|||||||
10
footer.php
Normal file
10
footer.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="container mt-4 text-center text-muted">
|
||||||
|
<p>© <?php echo date("Y"); ?> vipanalisa. Built with Flatlogic. | <a href="public.php" target="_blank">View Public Report</a></p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
45
header.php
Normal file
45
header.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>vipanalisa</title>
|
||||||
|
<meta name="description" content="Built with Flatlogic Generator">
|
||||||
|
<meta name="keywords" content="sales analysis, php mysql, data analytics, sales dashboard, business intelligence, data visualization, flatlogic">
|
||||||
|
<meta property="og:title" content="vipanalisa">
|
||||||
|
<meta property="og:description" content="Built with Flatlogic Generator">
|
||||||
|
<meta property="og:image" content="">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:image" content="">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark header-gradient shadow-sm mb-4">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="index.php">vipanalisa</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'index.php') ? 'active' : ''; ?>" href="index.php">Analisa per Merk</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'sales_analysis.php') ? 'active' : ''; ?>" href="sales_analysis.php">Analisa per Sales</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'import.php') ? 'active' : ''; ?>" href="import.php">Import Data</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
124
import.php
Normal file
124
import.php
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
|
||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$error_message = null;
|
||||||
|
$import_summary = null;
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['csv_file'])) {
|
||||||
|
if ($_FILES['csv_file']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
|
||||||
|
$file = $_FILES['csv_file']['tmp_name'];
|
||||||
|
|
||||||
|
$pdo = db();
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
|
||||||
|
$success_count = 0;
|
||||||
|
$error_count = 0;
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$handle = fopen($file, "r");
|
||||||
|
$header = fgetcsv($handle, 1000, ","); // Read header row
|
||||||
|
|
||||||
|
// Prepare statement for checking duplicates
|
||||||
|
$check_stmt = $pdo->prepare("SELECT COUNT(*) FROM tabelmaster WHERE NO_FAKTUR = ? AND NAMA_SALES = ? AND TANGGAL = ?");
|
||||||
|
|
||||||
|
// Prepare statement for insertion
|
||||||
|
$insert_stmt = $pdo->prepare("INSERT INTO tabelmaster (NAMA_SALES, TANGGAL, NO_FAKTUR, MERK, OUTLET, PRODUK, QTY, HARGA, BULAN, TAHUN, PERIODE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
$row_number = 1;
|
||||||
|
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
||||||
|
$row_number++;
|
||||||
|
if (count($data) !== 11) {
|
||||||
|
$errors[] = "Row {$row_number}: Invalid column count.";
|
||||||
|
$error_count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign variables from CSV data
|
||||||
|
list($nama_sales, $tanggal, $no_faktur, $merk, $outlet, $produk, $qty, $harga, $bulan, $tahun, $periode) = $data;
|
||||||
|
|
||||||
|
// Basic Validation
|
||||||
|
$check_stmt->execute([$no_faktur, $nama_sales, $tanggal]);
|
||||||
|
if ($check_stmt->fetchColumn() > 0) {
|
||||||
|
$errors[] = "Row {$row_number}: Duplicate record found for NO_FAKTUR {$no_faktur}, NAMA_SALES {$nama_sales}, TANGGAL {$tanggal}.";
|
||||||
|
$error_count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data Normalization
|
||||||
|
$harga_numeric = str_replace(['Rp', '.', ','], '', $harga);
|
||||||
|
|
||||||
|
// Insert data
|
||||||
|
$insert_stmt->execute([
|
||||||
|
$nama_sales, $tanggal, $no_faktur, $merk, $outlet, $produk,
|
||||||
|
(int)$qty, $harga_numeric, (int)$bulan, (int)$tahun, $periode
|
||||||
|
]);
|
||||||
|
|
||||||
|
$success_count++;
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
|
||||||
|
$pdo->commit();
|
||||||
|
$import_summary = ['success' => $success_count, 'errors' => $error_count, 'error_details' => $errors];
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
$error_message = "An error occurred during import: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$error_message = "File upload failed. Please try again.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'header.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main class="container">
|
||||||
|
<?php if (isset($error_message)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo htmlspecialchars($error_message); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (isset($import_summary)): ?>
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-header">Import Summary</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="text-success">Successfully imported <strong><?php echo $import_summary['success']; ?></strong> records.</p>
|
||||||
|
<p class="text-danger">Failed to import <strong><?php echo $import_summary['errors']; ?></strong> records.</p>
|
||||||
|
<?php if (!empty($import_summary['error_details'])): ?>
|
||||||
|
<hr>
|
||||||
|
<h5>Error Details:</h5>
|
||||||
|
<ul class="list-group">
|
||||||
|
<?php foreach ($import_summary['error_details'] as $error): ?>
|
||||||
|
<li class="list-group-item list-group-item-danger">- <?php echo htmlspecialchars($error); ?></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
Import Data from CSV
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="import.php" enctype="multipart/form-data">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="csv_file" class="form-label">Select CSV File</label>
|
||||||
|
<input class="form-control" type="file" id="csv_file" name="csv_file" accept=".csv" required>
|
||||||
|
</div>
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<strong>CSV Format:</strong> The file must have 11 columns in the following order: <br>
|
||||||
|
<code>NAMA_SALES, TANGGAL, NO_FAKTUR, MERK, OUTLET, PRODUK, QTY, HARGA, BULAN, TAHUN, PERIODE</code>
|
||||||
|
<br>The first row should be the header and will be skipped.
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary">Upload and Import</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<?php require_once 'footer.php'; ?>
|
||||||
435
index.php
435
index.php
@ -1,150 +1,291 @@
|
|||||||
<?php
|
<?php
|
||||||
declare(strict_types=1);
|
require_once 'db/config.php';
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
$error_message = null;
|
||||||
$now = date('Y-m-d H:i:s');
|
$records = [];
|
||||||
|
$total_pages = 1;
|
||||||
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
||||||
|
$limit = 20; // Records per page for raw data table
|
||||||
|
$offset = ($page - 1) * $limit;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Get distinct values for filters
|
||||||
|
$sales_options_stmt = $pdo->query('SELECT DISTINCT NAMA_SALES FROM tabelmaster WHERE NAMA_SALES IS NOT NULL AND NAMA_SALES != "" ORDER BY NAMA_SALES');
|
||||||
|
$sales_options = $sales_options_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
$periode_options_stmt = $pdo->query('SELECT DISTINCT PERIODE FROM tabelmaster WHERE PERIODE IS NOT NULL AND PERIODE != "" ORDER BY PERIODE DESC');
|
||||||
|
$periode_options = $periode_options_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
// Handle form submission for analysis
|
||||||
|
$analysis_results = [];
|
||||||
|
$chart_labels_json = '[]';
|
||||||
|
$chart_data_json = '[]';
|
||||||
|
$selected_sales = $_POST['nama_sales'] ?? 'all';
|
||||||
|
$selected_periode = $_POST['periode'] ?? 'all';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['run_analysis'])) {
|
||||||
|
$sql = "
|
||||||
|
SELECT
|
||||||
|
MERK,
|
||||||
|
SUM(QTY) as total_qty,
|
||||||
|
SUM(QTY * CAST(REPLACE(HARGA, ",", "") AS DECIMAL(15,2))) as total_omzet,
|
||||||
|
AVG(CAST(REPLACE(HARGA, ",", "") AS DECIMAL(15,2))) as avg_price,
|
||||||
|
COUNT(DISTINCT NO_FAKTUR) as transactions_count
|
||||||
|
FROM
|
||||||
|
tabelmaster
|
||||||
|
WHERE 1=1";
|
||||||
|
|
||||||
|
$params = [];
|
||||||
|
if ($selected_sales !== 'all') {
|
||||||
|
$sql .= ' AND NAMA_SALES = :nama_sales';
|
||||||
|
$params[':nama_sales'] = $selected_sales;
|
||||||
|
}
|
||||||
|
if ($selected_periode !== 'all') {
|
||||||
|
$sql .= ' AND PERIODE = :periode';
|
||||||
|
$params[':periode'] = $selected_periode;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= ' GROUP BY MERK HAVING SUM(QTY) > 0 ORDER BY total_omzet DESC';
|
||||||
|
|
||||||
|
$analysis_stmt = $pdo->prepare($sql);
|
||||||
|
$analysis_stmt->execute($params);
|
||||||
|
$analysis_results = $analysis_stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($analysis_results)) {
|
||||||
|
$chart_labels = [];
|
||||||
|
$chart_data = [];
|
||||||
|
foreach ($analysis_results as $row) {
|
||||||
|
$chart_labels[] = $row['MERK'];
|
||||||
|
$chart_data[] = $row['total_omzet'];
|
||||||
|
}
|
||||||
|
$chart_labels_json = json_encode($chart_labels);
|
||||||
|
$chart_data_json = json_encode($chart_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get total records for raw data pagination
|
||||||
|
$total_stmt = $pdo->query('SELECT COUNT(*) FROM tabelmaster');
|
||||||
|
$total_records = $total_stmt->fetchColumn();
|
||||||
|
$total_pages = ceil($total_records / $limit);
|
||||||
|
|
||||||
|
// Fetch records for the current page of raw data
|
||||||
|
$stmt = $pdo->prepare('SELECT * FROM tabelmaster ORDER BY TANGGAL DESC, NO_FAKTUR DESC LIMIT :limit OFFSET :offset');
|
||||||
|
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
|
||||||
|
$stmt->execute();
|
||||||
|
$records = $stmt->fetchAll();
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'header.php';
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<main class="container">
|
||||||
<head>
|
<?php if (isset($error_message)): ?>
|
||||||
<meta charset="utf-8" />
|
<div class="alert alert-danger" role="alert">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<?php echo htmlspecialchars($error_message); ?>
|
||||||
<title>New Style</title>
|
</div>
|
||||||
<?php
|
<?php endif; ?>
|
||||||
// Read project preview data from environment
|
|
||||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
<!-- Analysis Form -->
|
||||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
<div class="card mb-4">
|
||||||
?>
|
<div class="card-header">
|
||||||
<?php if ($projectDescription): ?>
|
Analisa Penjualan per Merk
|
||||||
<!-- Meta description -->
|
</div>
|
||||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
<div class="card-body">
|
||||||
<!-- Open Graph meta tags -->
|
<form method="POST" action="index.php#analysis-results">
|
||||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<div class="row g-3 align-items-end">
|
||||||
<!-- Twitter meta tags -->
|
<div class="col-md-5">
|
||||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
<label for="nama_sales" class="form-label">Nama Sales</label>
|
||||||
<?php endif; ?>
|
<select name="nama_sales" id="nama_sales" class="form-select">
|
||||||
<?php if ($projectImageUrl): ?>
|
<option value="all">Semua Sales</option>
|
||||||
<!-- Open Graph image -->
|
<?php foreach ($sales_options as $sales): ?>
|
||||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
<option value="<?php echo htmlspecialchars($sales); ?>" <?php echo ($selected_sales === $sales) ? 'selected' : ''; ?> >
|
||||||
<!-- Twitter image -->
|
<?php echo htmlspecialchars($sales); ?>
|
||||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
</option>
|
||||||
<?php endif; ?>
|
<?php endforeach; ?>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
</select>
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
</div>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
<div class="col-md-5">
|
||||||
<style>
|
<label for="periode" class="form-label">Periode</label>
|
||||||
:root {
|
<select name="periode" id="periode" class="form-select">
|
||||||
--bg-color-start: #6a11cb;
|
<option value="all">Semua Periode</option>
|
||||||
--bg-color-end: #2575fc;
|
<?php foreach ($periode_options as $periode): ?>
|
||||||
--text-color: #ffffff;
|
<option value="<?php echo htmlspecialchars($periode); ?>" <?php echo ($selected_periode === $periode) ? 'selected' : ''; ?> >
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
<?php echo htmlspecialchars($periode); ?>
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
</option>
|
||||||
}
|
<?php endforeach; ?>
|
||||||
body {
|
</select>
|
||||||
margin: 0;
|
</div>
|
||||||
font-family: 'Inter', sans-serif;
|
<div class="col-md-2">
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
<button type="submit" name="run_analysis" class="btn btn-primary w-100">Jalankan</button>
|
||||||
color: var(--text-color);
|
</div>
|
||||||
display: flex;
|
</div>
|
||||||
justify-content: center;
|
</form>
|
||||||
align-items: center;
|
</div>
|
||||||
min-height: 100vh;
|
</div>
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
<!-- Analysis Results -->
|
||||||
position: relative;
|
<?php if (!empty($analysis_results)): ?>
|
||||||
}
|
<div class="card mb-4" id="analysis-results">
|
||||||
body::before {
|
<div class="card-header">
|
||||||
content: '';
|
Hasil Analisa
|
||||||
position: absolute;
|
</div>
|
||||||
top: 0;
|
<div class="card-body">
|
||||||
left: 0;
|
<div class="table-responsive">
|
||||||
width: 100%;
|
<table class="table table-bordered table-hover">
|
||||||
height: 100%;
|
<thead class="table-light">
|
||||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
<tr>
|
||||||
animation: bg-pan 20s linear infinite;
|
<th>Merk</th>
|
||||||
z-index: -1;
|
<th>Total Kuantitas</th>
|
||||||
}
|
<th>Total Omzet</th>
|
||||||
@keyframes bg-pan {
|
<th>Harga Rata-rata</th>
|
||||||
0% { background-position: 0% 0%; }
|
<th>Jumlah Transaksi</th>
|
||||||
100% { background-position: 100% 100%; }
|
</tr>
|
||||||
}
|
</thead>
|
||||||
main {
|
<tbody>
|
||||||
padding: 2rem;
|
<?php foreach ($analysis_results as $row): ?>
|
||||||
}
|
<tr>
|
||||||
.card {
|
<td><?php echo htmlspecialchars($row['MERK']); ?></td>
|
||||||
background: var(--card-bg-color);
|
<td><?php echo number_format($row['total_qty']); ?></td>
|
||||||
border: 1px solid var(--card-border-color);
|
<td>Rp <?php echo number_format($row['total_omzet'], 2, ",", "."); ?></td>
|
||||||
border-radius: 16px;
|
<td>Rp <?php echo number_format($row['avg_price'], 2, ",", "."); ?></td>
|
||||||
padding: 2rem;
|
<td><?php echo number_format($row['transactions_count']); ?></td>
|
||||||
backdrop-filter: blur(20px);
|
</tr>
|
||||||
-webkit-backdrop-filter: blur(20px);
|
<?php endforeach; ?>
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
</tbody>
|
||||||
}
|
</table>
|
||||||
.loader {
|
</div>
|
||||||
margin: 1.25rem auto 1.25rem;
|
<div class="mt-4">
|
||||||
width: 48px;
|
<canvas id="merkChart"></canvas>
|
||||||
height: 48px;
|
</div>
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
</div>
|
||||||
border-top-color: #fff;
|
</div>
|
||||||
border-radius: 50%;
|
<?php elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['run_analysis'])): ?>
|
||||||
animation: spin 1s linear infinite;
|
<div class="card mb-4" id="analysis-results">
|
||||||
}
|
<div class="card-header">
|
||||||
@keyframes spin {
|
Hasil Analisa
|
||||||
from { transform: rotate(0deg); }
|
</div>
|
||||||
to { transform: rotate(360deg); }
|
<div class="card-body">
|
||||||
}
|
<div class="alert alert-info">Tidak ada data yang cocok dengan filter yang dipilih.</div>
|
||||||
.hint {
|
</div>
|
||||||
opacity: 0.9;
|
</div>
|
||||||
}
|
<?php endif; ?>
|
||||||
.sr-only {
|
|
||||||
position: absolute;
|
|
||||||
width: 1px; height: 1px;
|
<!-- Raw Data Table -->
|
||||||
padding: 0; margin: -1px;
|
<div class="card">
|
||||||
overflow: hidden;
|
<div class="card-header">
|
||||||
clip: rect(0, 0, 0, 0);
|
Data Master
|
||||||
white-space: nowrap; border: 0;
|
</div>
|
||||||
}
|
<div class="card-body">
|
||||||
h1 {
|
<?php if (empty($records)): ?>
|
||||||
font-size: 3rem;
|
<div class="alert alert-info" role="alert">
|
||||||
font-weight: 700;
|
No records found in the 'tabelmaster'. You can start by importing your data.
|
||||||
margin: 0 0 1rem;
|
</div>
|
||||||
letter-spacing: -1px;
|
<?php else: ?>
|
||||||
}
|
<div class="table-responsive">
|
||||||
p {
|
<table class="table table-striped table-hover">
|
||||||
margin: 0.5rem 0;
|
<thead class="table-light">
|
||||||
font-size: 1.1rem;
|
<tr>
|
||||||
}
|
<th>Nama Sales</th>
|
||||||
code {
|
<th>Tanggal</th>
|
||||||
background: rgba(0,0,0,0.2);
|
<th>No Faktur</th>
|
||||||
padding: 2px 6px;
|
<th>Merk</th>
|
||||||
border-radius: 4px;
|
<th>Outlet</th>
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
<th>Produk</th>
|
||||||
}
|
<th>Qty</th>
|
||||||
footer {
|
<th>Harga</th>
|
||||||
position: absolute;
|
<th>Bulan</th>
|
||||||
bottom: 1rem;
|
<th>Tahun</th>
|
||||||
font-size: 0.8rem;
|
<th>Periode</th>
|
||||||
opacity: 0.7;
|
</tr>
|
||||||
}
|
</thead>
|
||||||
</style>
|
<tbody>
|
||||||
</head>
|
<?php foreach ($records as $row): ?>
|
||||||
<body>
|
<tr>
|
||||||
<main>
|
<td><?php echo htmlspecialchars($row['NAMA_SALES']); ?></td>
|
||||||
<div class="card">
|
<td><?php echo htmlspecialchars($row['TANGGAL']); ?></td>
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<td><?php echo htmlspecialchars($row['NO_FAKTUR']); ?></td>
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<td><?php echo htmlspecialchars($row['MERK']); ?></td>
|
||||||
<span class="sr-only">Loading…</span>
|
<td><?php echo htmlspecialchars($row['OUTLET']); ?></td>
|
||||||
</div>
|
<td><?php echo htmlspecialchars($row['PRODUK']); ?></td>
|
||||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
<td><?php echo htmlspecialchars($row['QTY']); ?></td>
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
<td><?php echo htmlspecialchars($row['HARGA']); ?></td>
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
<td><?php echo htmlspecialchars($row['BULAN']); ?></td>
|
||||||
</div>
|
<td><?php echo htmlspecialchars($row['TAHUN']); ?></td>
|
||||||
</main>
|
<td><?php echo htmlspecialchars($row['PERIODE']); ?></td>
|
||||||
<footer>
|
</tr>
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<?php endforeach; ?>
|
||||||
</footer>
|
</tbody>
|
||||||
</body>
|
</table>
|
||||||
</html>
|
</div>
|
||||||
|
|
||||||
|
<!-- Pagination -->
|
||||||
|
<nav aria-label="Page navigation">
|
||||||
|
<ul class="pagination justify-content-center">
|
||||||
|
<li class="page-item <?php echo ($page <= 1) ? 'disabled' : ''; ?>">
|
||||||
|
<a class="page-link" href="?page=<?php echo $page - 1; ">Previous</a>
|
||||||
|
</li>
|
||||||
|
<li class="page-item <?php echo ($page >= $total_pages) ? 'disabled' : ''; ?>">
|
||||||
|
<a class="page-link" href="?page=<?php echo $page + 1; ">Next</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (typeof Chart !== 'undefined' && <?php echo !empty($analysis_results) ? 'true' : 'false'; ?>) {
|
||||||
|
const ctx = document.getElementById('merkChart');
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: <?php echo $chart_labels_json; ?>,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Total Omzet',
|
||||||
|
data: <?php echo $chart_data_json; ?>,
|
||||||
|
backgroundColor: 'rgba(13, 110, 253, 0.5)',
|
||||||
|
borderColor: 'rgba(13, 110, 253, 1)',
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true,
|
||||||
|
ticks: {
|
||||||
|
callback: function(value, index, values) {
|
||||||
|
return 'Rp ' + new Intl.NumberFormat('id-ID').format(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function(context) {
|
||||||
|
let label = context.dataset.label || '';
|
||||||
|
if (label) {
|
||||||
|
label += ': ';
|
||||||
|
}
|
||||||
|
if (context.parsed.y !== null) {
|
||||||
|
label += 'Rp ' + new Intl.NumberFormat('id-ID').format(context.parsed.y);
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php require_once 'footer.php'; ?>
|
||||||
188
public.php
Normal file
188
public.php
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$error_message = null;
|
||||||
|
$top_brands = [];
|
||||||
|
$sales_by_period = [];
|
||||||
|
$chart_labels_json = '[]';
|
||||||
|
$chart_data_json = '[]';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Query 1: Top 5 Brands by Sales
|
||||||
|
$top_brands_stmt = $pdo->query('
|
||||||
|
SELECT
|
||||||
|
MERK,
|
||||||
|
SUM(QTY * CAST(REPLACE(HARGA, ",", "") AS DECIMAL(15,2))) as total_omzet
|
||||||
|
FROM
|
||||||
|
tabelmaster
|
||||||
|
GROUP BY
|
||||||
|
MERK
|
||||||
|
ORDER BY
|
||||||
|
total_omzet DESC
|
||||||
|
LIMIT 5
|
||||||
|
');
|
||||||
|
$top_brands = $top_brands_stmt->fetchAll();
|
||||||
|
|
||||||
|
// Query 2: Sales per Period for Trend Chart
|
||||||
|
$sales_by_period_stmt = $pdo->query('
|
||||||
|
SELECT
|
||||||
|
PERIODE,
|
||||||
|
SUM(QTY * CAST(REPLACE(HARGA, ",", "") AS DECIMAL(15,2))) as total_omzet
|
||||||
|
FROM
|
||||||
|
tabelmaster
|
||||||
|
WHERE PERIODE IS NOT NULL AND PERIODE != ""
|
||||||
|
GROUP BY
|
||||||
|
PERIODE
|
||||||
|
ORDER BY
|
||||||
|
PERIODE ASC
|
||||||
|
');
|
||||||
|
$sales_by_period = $sales_by_period_stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($sales_by_period)) {
|
||||||
|
$chart_labels = [];
|
||||||
|
$chart_data = [];
|
||||||
|
foreach ($sales_by_period as $row) {
|
||||||
|
$chart_labels[] = $row['PERIODE'];
|
||||||
|
$chart_data[] = $row['total_omzet'];
|
||||||
|
}
|
||||||
|
$chart_labels_json = json_encode($chart_labels);
|
||||||
|
$chart_data_json = json_encode($chart_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Ringkasan Penjualan - vipanalisa</title>
|
||||||
|
<meta name="description" content="Ringkasan laporan penjualan publik.">
|
||||||
|
<meta name="keywords" content="laporan penjualan, ringkasan, sales report, public dashboard">
|
||||||
|
<meta property="og:title" content="Ringkasan Penjualan - vipanalisa">
|
||||||
|
<meta property="og:description" content="Ringkasan laporan penjualan publik.">
|
||||||
|
<meta property="og:image" content="">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:image" content="">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<header class="header-gradient p-3 shadow-sm mb-4">
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="navbar-brand mb-0 h1">Ringkasan Penjualan Publik</h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="container">
|
||||||
|
<?php if (isset($error_message)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo htmlspecialchars($error_message); ?>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="row">
|
||||||
|
<!-- Top 5 Brands -->
|
||||||
|
<div class="col-lg-4 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<div class="card-header">
|
||||||
|
Top 5 Merk Terlaris
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($top_brands)): ?>
|
||||||
|
<p class="text-muted">Data tidak tersedia.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<ul class="list-group list-group-flush">
|
||||||
|
<?php foreach ($top_brands as $brand): ?>
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<?php echo htmlspecialchars($brand['MERK']); ?>
|
||||||
|
<span class="badge bg-primary rounded-pill">Rp <?php echo number_format($brand['total_omzet'], 0, ",", "."); ?></span>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Sales Trend -->
|
||||||
|
<div class="col-lg-8 mb-4">
|
||||||
|
<div class="card h-100">
|
||||||
|
<div class="card-header">
|
||||||
|
Tren Penjualan per Periode
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<?php if (empty($sales_by_period)): ?>
|
||||||
|
<p class="text-muted">Data tren tidak tersedia.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<canvas id="salesTrendChart"></canvas>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="container mt-4 text-center text-muted">
|
||||||
|
<p>© <?php echo date("Y"); ?> vipanalisa. Built with Flatlogic.</p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (typeof Chart !== 'undefined' && <?php echo !empty($sales_by_period) ? 'true' : 'false'; ?>) {
|
||||||
|
const ctx = document.getElementById('salesTrendChart');
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'line',
|
||||||
|
data: {
|
||||||
|
labels: <?php echo $chart_labels_json; ?>,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Total Omzet',
|
||||||
|
data: <?php echo $chart_data_json; ?>,
|
||||||
|
fill: false,
|
||||||
|
borderColor: 'rgba(13, 110, 253, 1)',
|
||||||
|
tension: 0.1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true,
|
||||||
|
ticks: {
|
||||||
|
callback: function(value, index, values) {
|
||||||
|
return 'Rp ' + new Intl.NumberFormat('id-ID').format(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function(context) {
|
||||||
|
let label = context.dataset.label || '';
|
||||||
|
if (label) {
|
||||||
|
label += ': ';
|
||||||
|
}
|
||||||
|
if (context.parsed.y !== null) {
|
||||||
|
label += 'Rp ' + new Intl.NumberFormat('id-ID').format(context.parsed.y);
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
181
sales_analysis.php
Normal file
181
sales_analysis.php
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
<?php
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
$error_message = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
|
||||||
|
// Get distinct values for filters
|
||||||
|
$periode_options_stmt = $pdo->query('SELECT DISTINCT PERIODE FROM tabelmaster WHERE PERIODE IS NOT NULL AND PERIODE != \'\' ORDER BY PERIODE DESC');
|
||||||
|
$periode_options = $periode_options_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
// Handle form submission for analysis
|
||||||
|
$analysis_results = [];
|
||||||
|
$chart_labels_json = '[]';
|
||||||
|
$chart_data_json = '[]';
|
||||||
|
$selected_periode = $_POST['periode'] ?? 'all';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['run_analysis'])) {
|
||||||
|
$sql = "\n SELECT\n NAMA_SALES,\n SUM(QTY) as total_qty,\n SUM(QTY * CAST(REPLACE(HARGA, ',', '') AS DECIMAL(15,2))) as total_omzet,\n AVG(CAST(REPLACE(HARGA, ',', '') AS DECIMAL(15,2))) as avg_price,\n COUNT(DISTINCT NO_FAKTUR) as transactions_count\n FROM\n tabelmaster\n WHERE 1=1";
|
||||||
|
|
||||||
|
$params = [];
|
||||||
|
if ($selected_periode !== 'all') {
|
||||||
|
$sql .= ' AND PERIODE = :periode';
|
||||||
|
$params[':periode'] = $selected_periode;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= ' GROUP BY NAMA_SALES HAVING SUM(QTY) > 0 ORDER BY total_omzet DESC';
|
||||||
|
|
||||||
|
$analysis_stmt = $pdo->prepare($sql);
|
||||||
|
$analysis_stmt->execute($params);
|
||||||
|
$analysis_results = $analysis_stmt->fetchAll();
|
||||||
|
|
||||||
|
if (!empty($analysis_results)) {
|
||||||
|
$chart_labels = [];
|
||||||
|
$chart_data = [];
|
||||||
|
foreach ($analysis_results as $row) {
|
||||||
|
$chart_labels[] = $row['NAMA_SALES'];
|
||||||
|
$chart_data[] = $row['total_omzet'];
|
||||||
|
}
|
||||||
|
$chart_labels_json = json_encode($chart_labels);
|
||||||
|
$chart_data_json = json_encode($chart_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
$error_message = "Database error: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'header.php';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main class="container">
|
||||||
|
<?php if (isset($error_message)): ?>
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<?php echo htmlspecialchars($error_message); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Analysis Form -->
|
||||||
|
<div class="card mb-4">
|
||||||
|
<div class="card-header">
|
||||||
|
Analisa Penjualan per Sales
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form method="POST" action="sales_analysis.php#analysis-results">
|
||||||
|
<div class="row g-3 align-items-end">
|
||||||
|
<div class="col-md-10">
|
||||||
|
<label for="periode" class="form-label">Periode</label>
|
||||||
|
<select name="periode" id="periode" class="form-select">
|
||||||
|
<option value="all">Semua Periode</option>
|
||||||
|
<?php foreach ($periode_options as $periode): ?>
|
||||||
|
<option value="<?php echo htmlspecialchars($periode); ?>" <?php echo ($selected_periode === $periode) ? 'selected' : ''; ?> >
|
||||||
|
<?php echo htmlspecialchars($periode); ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<button type="submit" name="run_analysis" class="btn btn-primary w-100">Jalankan</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Analysis Results -->
|
||||||
|
<?php if (!empty($analysis_results)): ?>
|
||||||
|
<div class="card mb-4" id="analysis-results">
|
||||||
|
<div class="card-header">
|
||||||
|
Hasil Analisa
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-hover">
|
||||||
|
<thead class="table-light">
|
||||||
|
<tr>
|
||||||
|
<th>Nama Sales</th>
|
||||||
|
<th>Total Kuantitas</th>
|
||||||
|
<th>Total Omzet</th>
|
||||||
|
<th>Harga Rata-rata</th>
|
||||||
|
<th>Jumlah Transaksi</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($analysis_results as $row): ?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo htmlspecialchars($row['NAMA_SALES']); ?></td>
|
||||||
|
<td><?php echo number_format($row['total_qty']); ?></td>
|
||||||
|
<td>Rp <?php echo number_format($row['total_omzet'], 2, ",", "."); ?></td>
|
||||||
|
<td>Rp <?php echo number_format($row['avg_price'], 2, ",", "."); ?></td>
|
||||||
|
<td><?php echo number_format($row['transactions_count']); ?></td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="mt-4">
|
||||||
|
<canvas id="salesChart"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php elseif ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['run_analysis'])): ?>
|
||||||
|
<div class="card mb-4" id="analysis-results">
|
||||||
|
<div class="card-header">
|
||||||
|
Hasil Analisa
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="alert alert-info">Tidak ada data yang cocok dengan filter yang dipilih.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
if (typeof Chart !== 'undefined' && <?php echo !empty($analysis_results) ? 'true' : 'false'; ?>) {
|
||||||
|
const ctx = document.getElementById('salesChart');
|
||||||
|
new Chart(ctx, {
|
||||||
|
type: 'bar',
|
||||||
|
data: {
|
||||||
|
labels: <?php echo $chart_labels_json; ?>,
|
||||||
|
datasets: [{
|
||||||
|
label: 'Total Omzet',
|
||||||
|
data: <?php echo $chart_data_json; ?>,
|
||||||
|
backgroundColor: 'rgba(13, 110, 253, 0.5)',
|
||||||
|
borderColor: 'rgba(13, 110, 253, 1)',
|
||||||
|
borderWidth: 1
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
scales: {
|
||||||
|
y: {
|
||||||
|
beginAtZero: true,
|
||||||
|
ticks: {
|
||||||
|
callback: function(value, index, values) {
|
||||||
|
return 'Rp ' + new Intl.NumberFormat('id-ID').format(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function(context) {
|
||||||
|
let label = context.dataset.label || '';
|
||||||
|
if (label) {
|
||||||
|
label += ': ';
|
||||||
|
}
|
||||||
|
if (context.parsed.y !== null) {
|
||||||
|
label += 'Rp ' + new Intl.NumberFormat('id-ID').format(context.parsed.y);
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php require_once 'footer.php'; ?>
|
||||||
Loading…
x
Reference in New Issue
Block a user