<?php
echo "
<div class='col-lg-12'>
<div class='panel panel-yellow'>
<div class='panel-heading'>
<h3 class='panel-title'>Requirements</h3>
</div>
<div class='panel-body'>
<form method='post'>
<div class='col-lg-2'>
<select name='schoolyear' class='form-control'>";

$cm=date("Y");
$cm2=date("y");

echo "<option value=".$cm2.">".$cm."</option>
<option value='22'>2022</option>
<option value='23'>2023</option>
<option value='24'>2024</option>
<option value='25'>2025</option>
<option value='26'>2026</option>
</select>
</div>

<div class='col-lg-2'>
<select name='term' class='form-control'>
<option value=''>Term</option>
<option value='t1'>Term 1</option>
<option value='t2'>Term 2</option>
<option value='t3'>Term 3</option>
</select>
</div>
<div class='col-lg-2'>
<input type='submit' class='btn btn-sm btn-primary' name='item_filter' value='Filter'>
</div> 
</form>";

include("connect.php");

if(isset($_POST["item_filter"])){
$schoolyear=$_POST["schoolyear"];
$term=$_POST["term"];

$yeartotake="schoolyear='$schoolyear'";
$termtotake=$term;
}else{
    $cy=date("y");
$yeartotake="schoolyear='$cy'";


$cm = date("m");
if ($cm>='1' and $cm<='4'){$termtotake="t1";}
elseif ($cm>='5' and $cm<='8'){$termtotake="t2";}
elseif ($cm>='9' and $cm<='12'){$termtotake="t3";}
}


echo "
<table class='table table-bordered table-hover table-striped sortable'>
<tr>
<th>Item</th>
<th>Expected</th>
<th>Collected</th>
<th>Achievement (%)</th>
</tr>";
$result_scrap=$dbh->query("SELECT * from scrap where type='fsitem'");
$row_scrap=$result_scrap->fetchObject();
$count_scrap=$result_scrap->rowcount();

if ($count_scrap>0){
do {
    
echo "
<tr>
<td>".$row_scrap->item2."</td>
<td></td>
<td></td>
</tr>";

}while($row_scrap=$result_scrap->fetchObject());
}
echo "</table>

</div>
</div>
</div>";
?>