<?php
error_reporting(1);
session_start();

//check authentication
if(isset($_SESSION['valid'])&& $_SESSION['valid'] ==true){}
else{
	echo "Unauthorize Acess!";
	exit;
}

//$base_url = $_SESSION['BASE_URL'];
 $base_url.'../../asset/custom/mpdf/mpdf.php';
// ============
include("../../php_crud/my_class.php");
$obj=new my_class();
// =======================================

//extract($_GET);

$data = base64_decode($_GET['data']);

$get_arr = explode("&",$data);


$medium = $get_arr[0];
$class_id = $get_arr[1];
$department_id = $get_arr[2];
$section_id = $get_arr[3];
$year = $get_arr[4];
$exam_type = $get_arr[5];
$section_name = $get_arr[6];
$class_name = $get_arr[7];
$department_name = $get_arr[8];
$shift_name = $get_arr[9];


$branch_id = $_SESSION['LOGIN_BRANCHES'];

if($branch_id !=''){
        $brans_obj = $obj->View_branch_details_By_Cond($branch_id,'B');
        $inst_name = $brans_obj->insName;
        $ins_code_name = $brans_obj->insCodeName;
        $extablishd_year = $brans_obj->_establish_year ;
        $ins_logo = $brans_obj->_logo_location;
        $ins_address = $brans_obj->_address;
        $inst_thanta = $brans_obj->thana_name ;
        $ins_district = $brans_obj->distrinc_name  ;
        $ins_division = $brans_obj->division_name  ;
        $ins_web = $brans_obj->_web_address !='' ? $brans_obj->_web_address : '' ;
        $ins_email = $brans_obj->_email_add !='' ? '|| '.$brans_obj->_email_add : '' ;
}

require_once('../../asset/custom/mpdf/mpdf.php');
// require_once($base_url.'/asset/custom/mpdf/mpdf.php');
	
$mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); 
 
$mpdf->SetDisplayMode('fullpage');
 
$mpdf->list_indent_first_level = 0;  // 1 or 0 - whether to indent the first level of a list

$contents .='<!DOCTYPE html>
<html>
<head>
    <title>Students Admit Card '.$exam_type.' '.$year.'</title>
    <style>
        *
        {
            margin:0;
            padding:0;
            font-family:Arial;
            color:#000;
        }
        body
        {
            width:100%;
            font-family:Arial;
            font-size:12pt;
            margin:0;
            padding:0;
			/*background-image: url("../../'.$ins_logo.'");
			background-repeat: repeat;*/
        }
         
        p
        {
            margin:0;
            padding:0;
        }
		
		.wrapper{
			background-image: url(admit_template.png);
			padding: 0px;
			margin: 0px;
		}
		 
		#admit_card{
			padding: 27px;
			margin:0 auto;
			/*border: 1px dashed #000000;*/
			border-radius: 20px;
			/*background: url(bglines.png);*/ /* will get clipped */
		}
		
    </style>
</head>
<body>';

$flg=0;

$contents .='<div class="row-fluid" style="margin-top: 15px; padding:5px;">
			<!--<h2 align="center">Students Admit Card of '.$exam_type.' '.$year.' Examination</h2>-->
	<div>';
			
			$table_name = "_pf_std_basic_info,_pf_std_personal_info";
			$column = "_pf_std_personal_info._full_name name,_pf_std_personal_info._section_roll roll";
			$where_cond="_pf_std_basic_info._pid=_pf_std_personal_info._id and _pf_std_basic_info._section_id=$section_id";
			
			foreach($obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond) as $value ){

				$contents .='<br/>
								<div class="wrapper">
								<table width="70%" border="0" id="admit_card">
								<thead>
									<tr>
										<td width="7%"><!--<img src="../../'.$ins_logo.'" style="width:100px;"/>--></td>
										<td align="left" width="93%"><!--<h2>'.$_SESSION['LOGIN_INSTITUTE_NAME'].'</h2>--></td>
									</tr>
									<tr>
										<td colspan="2">
											<br/>
											<br/>
											<br/><br/>
											<br/>
										</td>
									</tr>
									<tr>
										<td colspan="2" align="center"><h4>&nbsp;&nbsp;&nbsp;&nbsp;'.rawurldecode($exam_type).' '.$year.'</h4><br/><br/><br/><br/></td>
									</tr>
									
									<tr>
										<td colspan="2" align="center" valign="top"><br/><span style="border-radius: 9px;padding:5spx;background-color:black;color:white;"><!--<h2>Admit Card</h2>--></span></td>
									</tr>
								</thead>
							
							<tbody>	
								<tr>
									<td colspan="2"><br/></td>
								</tr>
								
																
								<tr>
									<td colspan="2">
										<table width="100%">
											<tr>
												<td width="25%"><b>Name of The Student : </b></td>
												<td  width="33%" style="border-bottom:1px dotted black;">'.$value['name'].'</td>
												<td width="12%"><b> Roll No :</b> </td>
												<td  width="24%" style="border-bottom:1px dotted black;">'.$value['roll'].'</td>
											</tr>
										</table>
										<br/>
									</td>
								</tr>
								
								<tr>
									<td colspan="2">
										<table width="100%">
											<tr>
												<td width="10%"><b>Class : </b></td>
												<td  width="12%" style="border-bottom:1px dotted black;">'.$class_name.'</td>
												<td width="8%"><b> Shift : </b></td>
												<td  width="15%" style="border-bottom:1px dotted black;">'.rawurldecode($shift_name).'</td>
												<td width="12%"><b> Section : </b></td>
												<td  width="15%" style="border-bottom:1px dotted black;">'.$section_name.'</td><td width="12%"> Session : </td>
												<td  width="18%" style="border-bottom:1px dotted black;">'.$year.'</td>
											</tr>
										</table>
										
									</td>
								</tr>
								
								<tr>
									<td colspan="2"><br/><br/></td>
								</tr>
								
								<tr>
									<td width="50%" align="left">
										<img src="../../asset/user/exam_controller.png" height="70" style="margin-bottom:-5px;"><br/>
						-----------------------------------------<br>Controller of Examination<br>Date: '.date('d-m-Y').'</td>
									<td width="50%" align="right">
									<img src="../../asset/user/principal.png" height="70" style="margin-bottom:-5px;"><br/>
									--------------------------<br>Principal<span style="color:white;">-------</span></td>
								</tr>
								
							</tbody>
						</table>
						</div>';
						
						$flg++;
						
						if($flg==2){
							$contents .= "<pagebreak />";
							$flg=0;
						}
						else
							$contents .="<br/><div style='height:10px;border-bottom:1px dashed black;width:100%;'>&nbsp;</div><br/>";
			}
		$contents .='</div>';

//$mpdf->SetWatermarkImage('../../'.$ins_logo);

//$mpdf->showWatermarkImage = true;

$mpdf->WriteHTML($contents);
         
$mpdf->Output();
?>
