<?php
ini_set('max_execution_time', 600);

//require("../database.php");
$con = mysqli_connect('localhost','niqsorgn','{{Xtreme1969}}') or die("Could not Connect My Sql");
mysqli_select_db($con,"niqsorgn_exams")  or die("Could connect to Database");

$con2 = mysqli_connect('localhost','niqsorgn','{{Xtreme1969}}') or die("Could not Connect My Sql");
mysqli_select_db($con2,"niqsorgn_pota1969")  or die("Could connect to Database");


//header("Content-type: application/vnd-ms-excel");
 
// Defines the name of the export file "codelution-export.xls"
 
//header("Content-Disposition: attachment; filename=GDE Referral.xls");

   
if(isset($_GET["t"]))
{   
    if($_GET["t"]=="1"){ $stat = "Submitted"; }else{ $stat = "Pending"; }	//status to fecth
    
    //required table
    $regtbl = $_GET["exam"]."_application";					//reg table 
    $sponsortbl = $_GET["exam"]."_sponsor";					//sponsor 
    $employertbl = $_GET["exam"]."_employer";					//employer
    //$educationtbl = $_GET["exam"]."_education";					//education
    //$bodytbl = $_GET["exam"]."_body";						//professional body
    //$logbooktbl = $_GET["exam"]."_logbook";					//logbook
    //$gdetbl = $_GET["exam"]."_gde";						//gde
    //$experiencetbl = $_GET["exam"]."_experience";				//experience
    $firstregtbl = $_GET["exam"]."_firstreg";					//first ref
    $lastregtbl = $_GET["exam"]."_lastreg";					//last ref
    $currentregtbl = $_GET["exam"]."_currentreg";				//curent entry
    
    
    
    
    $myd = $_GET["myd"];

    //$q = "Select * from $regtbl WHERE regSet='$myd' and status='$stat'";
    $q = "Select * from $regtbl WHERE regSet='$myd'";
    
    $qry=mysqli_query($con2, $q);
    
	
     echo '<table width="100%" border="1" cellspacing="0" cellpadding="5">';
     echo '<tr><td colspan="7"> GDE Referral- '.$myd.'</td></tr>';
    
      	echo "<tr><td align='center'> <b>SN</b> </td><td width='auto'> <b>NAME</b> </td> <td> <b> Member No. </b> </td> <td> <b>EXAM TYPE</b> </td> </td><td> <b>EXAM NO</b> </td><td align='center' width='10%'> <b>PASSPORT</b> </td><td> <b> SIGN</b> </td></tr>";
      
     $sn=1;
     while($row=mysqli_fetch_assoc($qry))
     {
     	extract($row);
     	
     	//print_r($row);
     	//die();
	 
      	echo "<tr><td align='center'> $sn </td><td>$memberSurname  $memberOthernames </td><td> $memberNo </td><td> GDE REF </td><td> exam number </td> <td> "; 
      	$mypassport = "http://www.niqs.org.ng/onlineapplication/gderef/passport/".$memberNo."_".$id.".jpg";
	echo "<img src='".$mypassport."' width='50%'>";

      	echo "</td><td align='center'>  </td> </tr>";
      	
      	$sn++;
	}


}


//echo '<script>window.close();</script>';


//functions
//employer
function getEmployer($id, $tbl, $con)
{
    $qf = "Select * from $tbl WHERE applicant_id=$id";
    $qryf = mysqli_query($con, $qf);
        
    while($rowf = mysqli_fetch_array($qryf))
    {
       extract($rowf);
       
       $details = "<td> ".$employer." </td><td> ".$nature." </td><td> ".$address." </td><td> ".$position." </td><td> ".$employmentDate." </td>";
       return $details;
    }
}



//grade
function getGrade($memberGrade)
{
  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 = "";
		
	}
	
	return $memberGrade;
}




?>
