| Server IP : 103.243.232.44 / Your IP : 216.73.216.237 Web Server : LiteSpeed System : Linux server17213-10344.hostycare.online 5.14.0-687.38.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 12 17:19:12 EDT 2026 x86_64 User : iamakash ( 1400) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/iamakash/public_html/shaurya.meals28.com/ |
Upload File : |
<?php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/includes/auth.php';
requireLogin();
$pdo = getPDO();
$code = trim((string)($_GET['code'] ?? ''));
$baseYear = '2011-12';
if ($code === '') {
header('Location: ' . base_url('browse.php'));
exit;
}
$s = $pdo->prepare('SELECT * FROM commodities WHERE comm_code=? AND base_year=?');
$s->execute([$code, $baseYear]);
$comm = $s->fetch();
if (!$comm) {
http_response_code(404);
$pageTitle = 'Not found';
require __DIR__ . '/includes/header.php';
echo '<div class="alert alert-warning">Commodity <code>' . h($code) . '</code> not found.</div>';
require __DIR__ . '/includes/footer.php';
exit;
}
// Build path
$path = [];
$cur = $comm;
$guard = 0;
while ($cur && $guard++ < 10) {
array_unshift($path, $cur);
if (!$cur['parent_code']) break;
$ps = $pdo->prepare('SELECT * FROM commodities WHERE comm_code=? AND base_year=?');
$ps->execute([$cur['parent_code'], $baseYear]);
$cur = $ps->fetch();
}
// Load all monthly indices for this commodity, ordered
$stmt = $pdo->prepare(
'SELECT period_year, period_month, index_value, is_provisional
FROM monthly_indices
WHERE comm_code=? AND base_year=?
ORDER BY period_year, period_month'
);
$stmt->execute([$code, $baseYear]);
$rows = $stmt->fetchAll();
// Group by year → months for a pivot table
$byYear = [];
foreach ($rows as $r) {
$byYear[(int)$r['period_year']][(int)$r['period_month']] = $r;
}
ksort($byYear);
$monthNames = ['','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
$pageTitle = $comm['comm_name'] . ' — Shaurya Index Factor';
require __DIR__ . '/includes/header.php';
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?= base_url('browse.php') ?>">Root</a></li>
<?php foreach ($path as $p):
$isLast = $p['comm_code'] === $comm['comm_code'];
?>
<li class="breadcrumb-item <?= $isLast?'active':'' ?>">
<?php if (!$isLast): ?>
<a href="<?= base_url('browse.php?parent=' . urlencode($p['comm_code'])) ?>"><?= h($p['comm_name']) ?></a>
<?php else: ?>
<?= h($p['comm_name']) ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
</nav>
<div class="card mb-3"><div class="card-body">
<h4 class="mb-1"><?= h($comm['comm_name']) ?></h4>
<div>
<code class="code-chip"><?= h($comm['comm_code']) ?></code>
· Level <?= (int)$comm['level'] ?>
<?php if ($comm['comm_wt'] !== null): ?>
· weight <?= number_format((float)$comm['comm_wt'],4) ?>
<?php endif; ?>
· base <?= h($comm['base_year']) ?>
</div>
</div></div>
<div class="card"><div class="card-body">
<h5 class="mb-3">Monthly Index History</h5>
<?php if (!$byYear): ?>
<p class="text-muted mb-0">No monthly data for this commodity yet.</p>
<?php else: ?>
<div class="table-responsive">
<table class="table table-sm table-bordered align-middle text-end">
<thead class="table-light">
<tr>
<th class="text-start">Year</th>
<?php for ($m=1;$m<=12;$m++): ?>
<th><?= $monthNames[$m] ?></th>
<?php endfor; ?>
</tr>
</thead>
<tbody>
<?php foreach ($byYear as $y => $months): ?>
<tr>
<td class="text-start fw-semibold"><?= $y ?></td>
<?php for ($m=1;$m<=12;$m++):
$cell = $months[$m] ?? null;
$v = $cell['index_value'] ?? null;
$prov = $cell && (int)$cell['is_provisional'] === 1;
?>
<td<?= $prov ? ' class="table-warning" title="Provisional"' : '' ?>>
<?= $v !== null ? number_format((float)$v, 2) : '—' ?>
</td>
<?php endfor; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="small text-muted mt-2">Yellow cells = provisional (last two reported months).</div>
<?php endif; ?>
</div></div>
<?php require __DIR__ . '/includes/footer.php'; ?>