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

128 lines
4.1 KiB
PHP

<?= $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">All 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="startdate" class="form-label">Start Date :</label>
<input type="date" class="form-control" id="startdate" name="startdate"
value="<?= esc($_GET['startdate'] ?? date('Y-m-d')) ?>">
</div>
<div class="col-md-3">
<label for="enddate" class="form-label">End Date :</label>
<input type="date" class="form-control" id="enddate" name="enddate"
value="<?= esc($_GET['enddate'] ?? date('Y-m-d')) ?>">
</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 TMS30i Periode : <?= date('j M Y', strtotime($_GET['startdate']))?> -
<?= date('j M Y', strtotime($_GET['enddate']))?></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() ?>