<?php
date_default_timezone_set('Asia/Karachi');
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="description" content="Educational testing & evoluation agency">
		<title>ETEA</title>
		<link rel="stylesheet" type="text/css" href="print-font/open-sans.css">
		<link rel="stylesheet" type="text/css" href="print-css/sheets-of-paper-a3.css">
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <style>
        table{width: 100%;table-layout: fixed;font-size:13px;}
        body{font-size:10px;width: 99%;margin: auto;font-family: 'NanumGothic','????','NanumGothicWeb','?? ??','Malgun Gothic',Dotum}
        #left{text-align: left;padding-left: 1%;}
        #center{padding-left: 0;}
        #box{
                float: left;
    border: 1px solid black;
    height: 50px;
    width: 19%;
    margin-right: -1px;
        }
#border, .border{border-top: 1px solid black;border-right: 1px solid black;font-weight:normal;font-size:13px;}
td,th{padding: 6px;}
th{font-weight: bold !important;}
table.pinfo th,table.pinfo td{height: 48px;padding: 0;}
table.othertable th, table.othertable td{height: 50px; padding: 0;}
    </style>
	</head>                                                                      
    
    <body class="document">
    <?php
    if(isset($_GET['c']))
    {
        $c_id = $_GET['c'];
        $p = $_GET ['p'];
        if( !preg_match('/^[0-9]+$/', $c_id )) exit('The requested page is not available.');
        if( !preg_match('/^[0-9]+$/', $p )) exit('The requested page is not available.');
        if(!is_numeric($c_id) || $c_id == 0)
        {
            exit('The requested page is not available.');
        }
        if( $p == 0 ) exit('The requested page is not available.');
        try
        {
            require('includes/etea_dbase.php');
            $query = 'SELECT * FROM eteaedup_service_comission.available_post WHERE id = ? LIMIT 1';
            $stmt = $connection->prepare($query);
            $stmt->execute(array($p));
            if($stmt->rowCount() < 1)
            {
                exit('<h4 style="font-size:15px;">Sorry This Vacancy No Longer Exist, Thanks for your Patience</h4>');
            }
            $post_info = $stmt->fetch();
            echo '<title>'.$post_info ['designation'].'</title>';
            
            /** ======================== DETERMINE BANK SLIP =============== **/
            
            $bkslipquery = 'SELECT * FROM eteaedup_service_comission.bank_slips';
            $bk = $connection->prepare( $bkslipquery );
            $bk->execute();
            while( $bk_result = $bk->fetch( PDO::FETCH_ASSOC ) )
            {
            
            $post_ids_res = null;
            $post_ids_res = explode( ',', $bk_result ['for_posts'] );
            if( in_array( $p, $post_ids_res ) )
            {
            $bank_slip_name = $bk_result ['slip_picture'];
            break;
            }
            
            }
            
            /** ===================== BANK SLIP END ====================== **/
            
            $candidate_info = 'SELECT * FROM eteaedup_service_comission.candidate_info WHERE id = ? LIMIT 1';
            $ci = $connection->prepare($candidate_info);
            $ci->execute(array($c_id));
            if($ci->rowCount() < 1)
            {
                exit('You are not registed with ETEA please refer to the registration portion');
            }
            $cinfo = $ci->fetch();
            
            $academics = 'SELECT * FROM eteaedup_service_comission.candidate_qualification WHERE candidate_id = ? ORDER BY id ASC';
            $p = $connection->prepare($academics);
            $p->execute(array($c_id));
            $academics_array = array();
            while($academic_values = $p->fetch(PDO::FETCH_ASSOC))
            {
                $academics_array [] = $academic_values;
            }
            
            $exp = 'SELECT * FROM eteaedup_service_comission.candidate_experience WHERE candidate_id = ? ORDER BY id ASC';
            $a = $connection->prepare($exp);
            $a->execute(array($c_id));
            $experience_array = array();
            while($exp_value = $a->fetch(PDO::FETCH_ASSOC))
            {
                $experience_array [] = $exp_value;
            }
            
            /** ======================== **/
            
            $insquery = 'SELECT instruction FROM eteaedup_service_comission.application_instruction';
            $inss = $connection->prepare( $insquery );
            $inss->execute();
            $instructions_result = $inss->fetch();
        }
        catch(PDOExcpeiton $e)
        {
            echo $e->getMessage();
        }
        ?>
        <div class="page" contenteditable="true">
        <table>
        <tr>
            
            <th colspan="3" style="font-size: 30px;
    text-align: left;
    font-family: Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif;">
    <div style="float: left;width: 20%;">
    <img src="etea-logo-print-sm.png" style="height: 100px;"/>
    </div>
    <div style="float: left;width: 78.5%;">
    
    <span style="float: left;margin-top: 22px;">
    KP - Educational Testing &amp; Evaluation Agency (ETEA)
    </span>
    <span style="float: left;
    width: 64%;
    border-bottom: 1px solid grey;
    font-size: 21px;
    margin-top: 5px;
    margin-bottom: 4px;"><?php echo $post_info['post_deptt'] ?></span>
    <span style="float: left;font-size: 13px;">
    <small style="font-size: 14px;font-weight: normal;">Post applied for:</small>
    <span style="font-size: 17px;
    font-weight: bold;text-decoration: underline;"> <?php echo strtoupper($post_info['designation']) ?></span>
    </span>
    </div>
    
    </th>
        </tr>
        <tr style="height: 40px;"></tr>
        <tr>
            <th style="text-align: left;">ETEA ROLL NO:</th>
            <th><div style="padding-left: 38px;overflow: hidden;"><div id="box"></div><div id="box"></div><div id="box"></div><div id="box"></div><div id="box"></div></div><span style="display: block;text-align: center; margin-top: 5px;font-size:11px;">To be issued by ETEA</span></th>
            
            <th style="text-align: right;"><img src="candidate_photos/sc_photos/<?php echo $cinfo['picture'] ?>" style="width: 120px;border: 1px solid gray;"/></th>
        
        </tr>
        <tr style="height: 40px;"></tr>
        <tr>
        <th style="text-align: left;">TOKEN NO: <?php echo $cinfo['id'] ?></th>
        </tr>
        </table>
        <table class="pinfo" cellspacing=0 style="width: 100%;border-bottom: 1px solid black;border-left: 1px solid black;">
        <tr>
        <th colspan="4" class="border">PERSONAL INFORMATION</th>
        </tr>
        <tr>
            <th id="center" class="border">NAME</th>
            <td id="left" colspan="3" class="border"><?php echo ucfirst($cinfo['name']) ?></td>
        </tr>
        <tr>
            <th id="center" class="border">FATHER NAME</th>
            <td id="left" colspan="3" class="border"><?php echo ucfirst($cinfo['father_name']) ?></td>
        </tr>
        <tr>
            <th id="center" class="border">DATE OF BIRTH</th>
            <td id="left" class="border"><?php echo date('d/M/Y', $cinfo['dob']) ?></td>
            <th id="center" class="border">GENDER</th>
            <td id="left" class="border"><?php echo ucfirst($cinfo['gender']) ?></td>
        </tr>
        
        <tr>
            <th id="center" class="border">NIC</th>
            <td id="left" class="border"><?php echo $cinfo['cnic'] ?></td>
            <th id="center" class="border">DOMICILE</th>
            <td id="left" class="border"><?php echo $cinfo['domicile'] ?></td>
        </tr>
        
        <tr>
            <th id="center" class="border">RELIGION</th>
            <td id="left" class="border"><?php echo ucfirst($cinfo['religion']) ?></td>
            <th id="center" class="border">EMAIL</th>
            <td id="left" class="border"><?php echo $cinfo['email'] ?></td>
        </tr>
        <tr>
            <th id="center" class="border">MOBILE</th>
            <td id="left" class="border"><?php echo $cinfo['cell_num'] ?></td>
            <th id="center" class="border">PHONE</th>
            <td id="left" class="border"><?php echo $cinfo['phone'] ?></td>
        </tr>
        <tr>
            <th id="center" class="border">PERMANENT ADDRESS</th>
            <td id="left" colspan="3" class="border"><?php echo ucfirst($cinfo['permanent_address']) ?></td>
        </tr>
        <tr id="border">
            <th id="center" class="border">RESIDENTIAL/POSTAL ADDRESS</th>
            <td id="left" colspan="3" class="border"><?php echo ucfirst($cinfo['postal_address']) ?></td>
        </tr>
        
        
        <tr>
            <th id="center" class="border">AGE RELAXATION</th>
            <td id="left" colspan="3" class="border">
            <?php
            if( $cinfo ['age_relaxation'] != '' )
            {
            echo 'Yes';
            }
            else
            {
            echo 'No';
            }
            ?>
            </td>
        </tr>
        </table>
        </div>
        <div class="page" contenteditable="true">
        <table class="othertable" cellspacing=0 style="width: 100%;border-bottom: 1px solid black;border-left: 1px solid black;margin-top: 30px;">
            <tr><th colspan="6"  id="border">ACADEMIC QUALIFICATION</th></tr>
            <tr>
                <th id="border">DEGREE TITLE</th><th id="border">BOARD / UNIVERSITY</th>
                <th id="border">MARKS OBTAINED </th><th id="border"> TOTAL MARKS</th><th id="border">GRADE / DIVISION</th><th id="border">MAJOR SUBJECT</th>
            </tr>
            <?php
            
            foreach($academics_array as $academic_single)
            {
                echo '<tr>
                <th style="text-align:center;" id="border">'.$academic_single['examination'].'</th>
                <td id="left" class="border">'.ucfirst($academic_single['institute']).'</td>
                <td id="left" class="border" style="text-align:center;">'.$academic_single['marks_obt'].'</td>
                <td id="left" class="border" style="text-align:center;">'.$academic_single['marks_total'].'</td>
                <td id="left" class="border" style="text-align:center;">'.$academic_single['grade'].' / '.$academic_single['division'].'</td><td  id="left" class="border">'.$academic_single['major_subject'].'</td>
                
                </tr>';
            
            }
            
            ?>
        </table><br />
        
            <?php
            
            
            
            $ab = 0;
            foreach($experience_array as $single_exp)
            {
            	if($single_exp['designation'] != ''){
            	if($ab == 0)
            	{
            	?>
            	<table class="othertable" cellspacing=0 style="width: 100%;border-bottom: 1px solid black;border-left: 1px solid black;    margin-top: 30px;">
            <tr><th id="border" colspan="6">RELEVANT  EXPERIENCE </th></tr>
            <tr><th id="border">ORGANIZATION</th><th id="border">DESIGNATION</th><th id="border">PERMANENT / TEMPORARY</th>
            <th  id="border">JOB DURATION</th><td  id="border">DURATION IN MONTH</td><td  id="border">GRADE</td></tr>
            	
            	<?php
            	}
                $to_date = ( $single_exp ['to_date'] == 'Present' ) ? 'Present' : date('d/M/Y', $single_exp['to_date'] );
                echo '<tr><td id="left" class="border">'.$single_exp['organization'].'</td><td id="left" class="border">'.$single_exp['designation'].'</td>
                <td style="text-align:center;" id="left" class="border">'.$single_exp['permanent_temp'].'</td>
                <td style="text-align:center;" id="left" class="border">'.date('d/M/Y', $single_exp['from_date']).' to '.$to_date.'</td>
                <td style="text-align:center;" id="left" class="border">'.$single_exp['duration_months'].'</td>
                <td style="text-align:center;" id="left" class="border">'.$single_exp['grade'].'</td></tr>';
                }
                $ab++;
            }
            ?>
        </table>
        <table style="
    margin-top: 36px;
"><tbody><tr><td></td><td></td><td></td><td colspan="14" style="
    text-align: right;
                        
    font-size: 10px;
">___________________<br>Applicant Signature</td><td></td></tr></tbody></table>
        <div style="width: 99%;margin-top: 5px;border: 1px solid black;padding: 3px;font-size:11px;line-height:21px;">
        
        <b>Instruction:</b><br /> <?php
        echo nl2br($instructions_result['instruction']);
        ?>
        </div>
        
        <?php
    }
    ?>
    
    
    </div>
    
    <div class="page" contenteditable="true">
    
    
    
    <div>
    <img src="bank_slips/<?php echo $bank_slip_name ?>" width="100%"/>
    </div>
    </div>
    </body>
</html>
                            
                            
                            