clqms-server/app/Views/report_spesific_range.php
2025-08-15 09:45:16 +07:00

142 lines
4.5 KiB
PHP

<?php
$currentMonth = date('m');
?>
<?= $this->extend('layouts/main.php') ?>
<?= $this->section('content') ?>
<main id="main" class="main">
<?php
if(isset($validation)) {
?>
<div class='alert alert-danger alert-dismissible'>
<?= $validation->listErrors(); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <span
aria-hidden="true"></span> </button>
</div>
<?php
}
?>
<div class="card">
<div class="card-header py-0 mb-3">
<div class="d-flex justify-content-between">
<div class="">
<h5 class="card-title my-0">Spesific Range Data</h5>
</div>
<div class="">
<h5 class="card-title my-0"><i class="bi bi-pc-display-horizontal"></i></h5>
</div>
</div>
</div>
<div class='p-4 pt-2'>
<form method="get" class="row g-3 mb-1">
<div class="col-md-3">
<label for="first_month" class="form-label">Start Month :</label>
<select name="first_month" class="form-select">
<?php for ($m = 1; $m <= 12; $m++): ?>
<option value="<?= str_pad($m, 2, '0', STR_PAD_LEFT) ?>"
<?= @$_GET['first_month'] == str_pad($m, 2, '0', STR_PAD_LEFT) ? 'selected' : '' ?>>
<?= date('F', mktime(0, 0, 0, $m, 1)) ?>
</option>
<?php endfor ?>
</select>
</div>
<div class="col-md-3">
<label for="last_month" class="form-label">Last Month :</label>
<select name="last_month" class="form-select">
<?php for ($m = 1; $m <= 12; $m++):
$val = str_pad($m, 2, '0', STR_PAD_LEFT);
$selected = (@$_GET['last_month'] ?? $currentMonth) == $val ? 'selected' : '';
?>
<option value="<?= $val ?>" <?= $selected ?>><?= date('F', mktime(0, 0, 0, $m, 1)) ?></option>
<?php endfor; ?>
</select>
</div>
<div class="col-md-3">
<label for="option" class="form-label">Instrument :</label>
<select class="form-select" id="option" name="option">
<!-- <option value="" disabled <?= empty($_GET['enddate']) ? 'selected' : '' ?>>-</option> -->
<option value="1" <?= @$_GET['enddate'] == '1' ? 'selected' : '' ?>>TMS 30i</option>
<option value="2" <?= @$_GET['enddate'] == '2' ? 'selected' : '' ?> disabled>TMS 1024i</option>
<option value="2" <?= @$_GET['enddate'] == '2' ? 'selected' : '' ?> disabled>TMS 24i Premium
</option>
<option value="2" <?= @$_GET['enddate'] == '2' ? 'selected' : '' ?> disabled>TMS 50i Superior
</option>
</select>
</div>
<div class="col-md-3 align-self-end">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
<div class="card-body p-2">
<?php if (!empty($pivot)): ?>
<div class="table-responsive">
<h4>Data counter semua tahun hanya untuk bulan <?=$name_first_month?> - <?=$name_last_month?></h4>
<table class="table table-bordered table-striped table-sm text-center align-middle">
<thead class="table-dark align-middle">
<tr>
<th>SN#</th>
<th>SITE</th>
<?php foreach ($yearRange as $year): ?>
<th><?= esc($year) ?></th>
<?php endforeach; ?>
<?php for ($i = 1; $i < count($yearRange); $i++): ?>
<th><?= $yearRange[$i - 1] ?> v <?= $yearRange[$i] ?></th>
<?php endfor; ?>
</tr>
</thead>
<tbody>
<?php foreach ($pivot as $eid => $data): ?>
<tr>
<td><code><?= esc($eid) ?></code></td>
<td class="text-start"><strong><?= esc($siteNames[$eid] ?? 'Unknown') ?></strong></td>
<?php foreach ($yearRange as $year): ?>
<td><?= esc($data[$year]) ?></td>
<?php endforeach; ?>
<?php for ($i = 1; $i < count($yearRange); $i++): ?>
<?php
$key = $yearRange[$i - 1] . '-' . $yearRange[$i];
$percent = $growth[$eid][$key] ?? '-';
if ($percent === '-') {
$colorClass = 'text-secondary';
$symbol = '';
} elseif (strpos($percent, '-') !== false) {
$colorClass = 'text-danger fw-bold';
$symbol = '<i class="bi bi-chevron-down"></i> ';
} else {
$colorClass = 'text-success fw-bold';
$symbol = '<i class="bi bi-chevron-up"></i> ';
}
?>
<td class="<?= $colorClass ?>"><?= $symbol . esc($percent) ?></td>
<?php endfor; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</main>
<?= $this->endSection() ?>
<?= $this->section('script') ?>
<script>
</script>
<?= $this->endSection() ?>