<html>
<head>
	<title>Copying term 3</title>
	</head>
	<body>
<?php include("excelout.php"); ?>
<table width='100%' border='1'>
	<tr>
		<th>autoid</th>
		<th>autodate</th>
		<th>cid</th>
		<th>sname</th>
		<th>fname</th>
		<th>schoolyear</th>
		<th>schoolclass</th>
		<th>ownfee</th>
		<th>lastupdated</th>
		<th>feesbalance</th>
		<th>reqsbalance</th>
		<th>uniformpaid</th>
		<th>uniform</th>
		<th>uniformbal</th>
		<th>contribution</th>
		<th>contributionbal</th>
		<th>registration</th>
		<th>registrationbal</th>
		<th>holiday</th>
		<th>holidaybal</th>
		<th>admission</th>
		<th>admissionbal</th>
		<th>transport</th>
		<th>transportbal</th>
		<th>mockfa</th>
		<th>mockfabal</th>
		<th>other1</th>
		<th>other1bal</th>
		<th>other2</th>
		<th>other2bal</th>
		<th>other3</th>
		<th>other3bal</th>
		<th>orgfee</th>
		<th>comment</th>
		<th>status</th>
		<th>active</th>
	</tr>
		<?php
include("connect.php");

$result_scraplevel=$dbh->query("select * from scrap where type='t3copy' and item2='level'");
$row_scraplevel=$result_scraplevel->fetchObject();
$count_scraplevel=$result_scraplevel->rowCount();

if($count_scraplevel>0){
$dalevel="and cid$row_scraplevel->item";
}else{
$dalevel="";
}
$result_t3=$dbh->query("select * from t3 where autoid!='' and comment NOT like '%left%' and active=1 $dalevel");
$row_t3=$result_t3->fetchObject();
$count_t3=$result_t3->rowCount();

if($count_t3>0){
$x=1;
do{

$result_scrap2=$dbh->query("select * from scrap where type='t3copy' and item2='statez'");
$row_scrap2=$result_scrap2->fetchObject();
$count_scrap2=$result_scrap2->rowCount();

if($count_scrap2>0){
if($row_scrap2->item==2){
$ffinalclass=$row_t3->schoolclass + 1;
if($ffinalclass==11){$finalclass=1;}else{$finalclass=$ffinalclass;}

}elseif($row_scrap2->item==1){
$ffinalclass=$row_t3->schoolclass - 1;
if($ffinalclass==0){$finalclass=10;}else{$finalclass=$ffinalclass;}
}

}

$result_child=$dbh->query("select * from children where cid='$row_t3->cid'");
$row_child=$result_child->fetchObject();

echo "
<tr>
<td>".$x++."</td>
<td></td>
<td>".$row_t3->cid."</td>
<td>".$row_child->fname."</td>
<td>".$row_child->sname."</td>
<td>".$row_t3->schoolyear."</td>
<td>".$row_t3->schoolclass."</td>
<td>".$row_t3->ownfee."</td>
<td></td>
<td>".$row_t3->ownfee."</td>
<td>".$row_t3->contribution."</td>
<td></td>
<td></td>
<td></td>
<td>".$row_t3->contribution."</td>
<td>".$row_t3->contribution."</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>".$row_t3->comment."</td>
<td>".$row_t3->status."</td>
<td>".$row_t3->active."</td>
</tr>
";
}while($row_t3=$result_t3->fetchObject());
}

		?>
	</table>
	</body>
</html>