<?php
$errmsg='';
$sucmsg='';
    
  //echo $mydiet;    
    //switch to Pending
    if(isset($_GET["i"]))
    {
      extract($_GET);
      $qi = "update tpcf_application set status='Pending' where id=$i Limit 1";
      $qryi=mysqli_query($con2, $qi);
      
    }


    $q = "Select * from tpcf_application WHERE regSet='$mydiet' order by status Desc"; // and status='Submitted'";
    $qry=mysqli_query($con2, $q);
    //echo mysqli_num_rows($qry);
    
?>

<div class="graph-visual tables-main" id="salscreen" name="salscreen">
<h2 class="inner-tittle">Test of Professional Competence (TPC Full) - <?php echo $mydiet; ?> </h2>
<div class="graph-form">
    <div class="form-body">
		
     <table width="100%" border="1" cellspacing="0" cellpadding="5">
     <?php
     
      	echo "<tr><td align='center'> <b>SN</b> </td><td> <b> Member No. </b> </td><td> <b>Name </b> </td><td align='center'> <b>Sex </b> </td><td> <b> Grade </b> </td><td> <b> Chapter</b> </td><td> <b> Diet </b>  </td><td> <b>Centre</b> </td><td align='center'> <b>PIN</b> </td><td align='center'> <b>Reg. No.</b> </td> <td><b>Status</b> </td></tr>";
      
     $sn=1;
     while($row=mysqli_fetch_assoc($qry))
     {
     	extract($row);
	switch($memberGrade)
	{
		case 1: $memberGrade="FELLOW";
		break;
		
		case 2: $memberGrade="MEMBER";
		break;
		
		case 3: $memberGrade="PROBATIONER";
		break;
		
		case 4: $memberGrade="TECHNICIAN";
		break;
		
		case 5: $memberGrade="STUDENT";
		break;
		
		case 6: $memberGrade="PRACTICING FIRM";
		break;
		
		case 7: $memberGrade="GRADUATE";
		break;
		
		case 8: $memberGrade="STATE CHAPTER";
		break;
		
		case 9: $memberGrade="PAST PRESIDENT";
		break;
		
		default: $memberGrade = "";
		
	}
      	echo "<tr><td align='center'> $sn </td><td> $memberNo </td><td> <a href='https://register.niqs.org.ng/tpcfull/printform.php?i=".$id."' target='_blank'>$memberSurname  $memberOthernames</a> </td><td align='center'> $memberGender </td><td> $memberGrade </td><td> $memberChapter </td><td> $regSet </td><td> $examCentre </td><td align='center'> $password  </td><td align='center'> $uniqueId</td><td> <a href='?page=tpcfull&i=".$id."'>$status</a> </td></tr>";
      	
      	$sn++;
      }
     
     ?>
     </table>
    
    		
    </div>

</div>

<div><button class='btn' id='btn' onClick='printform();'>Print</button> <a href='https://register.niqs.org.ng/admin/inc/tpcfdownload.php?exam=tpcf&t=1&myd=<?php echo $mydiet; ?>' target='_blank'><button class='btn'>Download</button></a> </div>

</div>

<script>
function printform(){    
 
   var originalContents = document.body.innerHTML;
   document.getElementById('btn').style.display="none";
     var printContents = document.getElementById('salscreen').innerHTML;      
   document.body.innerHTML = printContents;   
   window.print();     
   document.body.innerHTML = originalContents;
}
</script>