<?php
include("../db.php");
//     $row = $db->getRow("SELECT MAX(id),admissionno FROM student_entry_pass");

//     $highest_id = $row['id'];
//     $sadmissionno = $row['admissionno'];

//     $rowc = $db->getVal("SELECT admissionno FROM student_entry_pass where id='$highest_id'");
//     $sidno = $rowc['admissionno'];


// $detail1=$db->getVal("SELECT COUNT(*) FROM student_entry_pass");

// print_r($_POST);
// $detail=$db->getRow("select s.admissionno,s.name,s.fname,s.class,s.mobile,s.photo as photo1,e.visitorname,e.relation,e.contact,e.photo,e.date from
// student as s inner join student_entry_pass as e  on s.idno=e.admissionno where e.id='$highest_id'");

// sms(mydetail("mobile",$sidno,"student"),"Dear ".mydetail("fname",$sidno,"student").", Your child ".mydetail("name",$sidno,"student")." is going to home in between of school timing with ".$_POST["name"],"student_attandance");
// echo $db->getErMsg();
// echo sms(mydetail("mobile",$sidno,"student"));

    $detail=$db->getRow("select * from student where idno='$_POST[idno]' ");
    
    $session = $detail['session'];
    
    // $sql = $db->getRow("select * from gatepass where idno='$_POST[idno]' ");
    // if(count($sql) > 1){
    //     $flg = $sql['id'];
    // } else {

                $ary = array(
                "idno" => $_POST['idno'],
                "name" => $_POST['name'],
                "photo" => $_POST['photo'],
                "relation" => $_POST['relation'],
                "contact" => $_POST['contact']
            );
            
          $flg =  $db->insertAry("gatepass", $ary);
          $sql = $db->getRow("select * from gatepass where idno='$_POST[idno]' and id='$flg' ");
    // }
?>

<style>
.table{
	background: royalblue;
	color: whitesmoke;
	font-weight: bold;
	width:700px;
	
}
</style>
<table class="table" border="1">
  <tr>
    <td colspan="2" style="height:100px">
    <div class="headPrint" style="text-align:center;padding: 1px 10px 0px 0px;">
        <img src="<?php echo $LinksDetails["logo"] ?>" style="float:left" height="70px" width="70px">
        <h1><?php echo ucfirst(trim($LinksDetails["site_name"])) ?></h1>
        <div style="margin-top:-15px;"><h4><?php echo ucfirst(trim($LinksDetails["contact_content"])) ?></h4></div><br>
		<div style="float:right; margin-top:-30px;">Date : <?php     echo    date('d-m-Y', strtotime($sql["udate"]));  ?></div>
        <div style="text-decoration:underline; font-size:12px; font-weight:bold; margin-top:-30px;">GATE PASS <?php echo $flg; ?></div>
    </div>
    </td>
  </tr>
  <tr valign="top">
  	<td width="50%">
    <img src="<?php echo URL_ROOT ?>media/photo/<?php echo $detail["photo"] ?>" style="width: 88px; height: 103px; float:left; margin: 0 8px;">
    Admission.No : <?php echo $detail["admissionno"] ?><br>
	Student Name : <?php echo $detail["name"] ?><br>
    Father Name : <?php echo $detail["fname"] ?><br>
    Class Name : <?php echo $detail["class"] ?><br>
	Contact No. : <?php echo $detail["mobile"] ?>
    
    </td>
    <td>
    <img src="<?php echo URL_ROOT ?>uploads/gatepass/<?php echo trim($_POST["photo"]) ?>" style="width: 88px; height: 103px; float:left; margin: 0 8px;">
    Visitor Name : <?php echo $_POST["name"] ?><br>
    Relation : <?php echo $_POST["relation"] ?><br>
	Contact No. : <?php echo $_POST["contact"] ?>
    </td>
  </tr>
  <tr>
  	<td colspan="2">
    <div style="width:25%; text-align:center; float:right">
    ________________<br />
    Principal Sign
    </div>
    <div style="width:25%; text-align:center; float:left">
    ______________________<br />
    Office InchargeSign
    </div>
    
    <div style="width:25%; text-align:center; margin:0 auto">
    ______________________<br />
    Guardian Sign
    </div>
   
    </td>
  </tr>
</table>

<br>
<table class="table" border="1">
  <tr>
    <td colspan="2">
    <div class="headPrint" style="text-align:center;padding: 1px 10px 0px 0px;">
        <img src="<?php echo $LinksDetails["logo"] ?>" style="float:left" height="70px" width="70px">
        <h1><?php echo ucfirst(trim($LinksDetails["site_name"])) ?></h1>
        <div style="margin-top:-15px;"><h4><?php echo ucfirst(trim($LinksDetails["contact_content"])) ?></h4></div><br>
		<div style="float:right; margin-top:-30px;">Date : <?php     echo    date('d-m-Y', strtotime($sql["udate"]));  ?></div>
        <div style="text-decoration:underline; font-size:12px; font-weight:bold; margin-top:-30px;">GATE PASS <?php echo $flg; ?></div>
    </div>
    </td>
  </tr>
  <tr valign="top">
  	<td width="50%">
    <img src="<?php echo URL_ROOT ?>media/photo/<?php echo $detail["photo"] ?>" style="width: 88px; height: 103px; float:left; margin: 0 8px;">
    Admission.No : <?php echo $detail["admissionno"] ?><br>
	Student Name : <?php echo $detail["name"] ?><br>
    Father Name : <?php echo $detail["fname"] ?><br>
    Class Name : <?php echo $detail["class"] ?><br>
	Contact No. : <?php echo $detail["mobile"] ?>
    
    </td>
    <td>
    <img src="<?php echo URL_ROOT ?>uploads/gatepass/<?php echo trim($_POST["photo"]) ?>" style="width: 88px; height: 103px; float:left; margin: 0 8px;">
    Visitor Name : <?php echo $_POST["name"] ?><br>
    Relation : <?php echo $_POST["relation"] ?><br>
	Contact No. : <?php echo $_POST["contact"] ?>
    </td>
  </tr>
  <tr>
  	<td colspan="2">
    <div style="width:25%; text-align:center; float:right">
    ________________<br />
    Principal Sign
    </div>
    <div style="width:25%; text-align:center; float:left">
    ______________________<br />
    Office InchargeSign
    </div>
    
    <div style="width:25%; text-align:center; margin:0 auto">
    ______________________<br />
    Guardian Sign
    </div>
   
    </td>
  </tr>
</table>
<br>

<script>window.print();</script>