<?php
session_start();
// ============ this file shows a detailed payment report for selected school in a pdf format
include("../../asset/theme/css/myfunc.php");
include("../../php_crud/my_class.php");
require_once("../../asset/custom/mpdf/mpdf.php");
$obj=new my_class();
// ============
$branch_id=$_SESSION['LOGIN_BRANCH'];
//$selected_session = $_SESSION['ADMISSION_SESSION'];
$selected_admission_details=addslashes(trim($_GET['admission_details_id']));

$institute_details = $obj->View_branch_details_By_Cond($branch_id,'I');
$institute_name = $institute_details->insName;
$institute_code = $institute_details->insCodeName; 
$institute_logo = $institute_details->_logo_location;
$institute_address = $institute_details->_address;
$institute_thana = $institute_details->thana_name ;
$institute_district = $institute_details->distrinc_name;
$institute_division = $institute_details->division_name;
$$institute_code = $brans_obj->_zip_code;
$institute_web = $institute_details->_web_address !='' ? $institute_details->_web_address : '' ;
$institute_email = $institute_details->_email_add !='' ? '&nbsp;'. $institute_details->_email_add : '' ;


$im='../../'.$institute_logo;
if(file_exists($im)){
		$image = '<img src="../../'.$institute_logo.'" style="height:110px;  margin-top:0px;"  title="logo" alt="" id="image" />';			
}		 
else{
		$image = '<img src="../../asset/custom/shadow.jpg"  />';
}



$shift_id='';
$shift_name='';
$medium_id='';
$medium_name='';
$class_id='';
$class_name='';
$dept_id='';
$dept_name='';

$table_name="_student_admission_details sad LEFT JOIN _student_admission_master sam ON sad._master_id=sam._id";
$column="sad._shift_id,sad._medium_id,sad._class_id,sad._dept_id,sam._session";
$where_cond="sad._id=".$selected_admission_details;
$class_info=$obj->View_column_details_By_Cond($table_name,$column,$where_cond);

$shift_id=$class_info['_shift_id'];
$medium_id=$class_info['_medium_id'];
$class_id=$class_info['_class_id'];
$dept_id=$class_info['_dept_id'];
$selected_session = $class_info['_session'];

$setup_table_name="_int_institute_setup";
//$column="_name";
$where_cond="_id=".$shift_id;
$class_info=$obj->Details_By_Cond($setup_table_name, $where_cond);
$shift_name = $class_info['_name'];

$where_cond="_id=".$medium_id;
$class_info=$obj->Details_By_Cond($setup_table_name, $where_cond);
$medium_name = $class_info['_name'];

$where_cond="_id=".$class_id;
$class_info=$obj->Details_By_Cond($setup_table_name, $where_cond);
$class_name = $class_info['_name'];

$where_cond="_id=".$dept_id;
$class_info=$obj->Details_By_Cond($setup_table_name, $where_cond);
$dept_name = $class_info['_name'];

$table_name="_students_admission_form";
$column="admission_form_id,_candidate_name,_invoice_number,_gender,_mobile_number,_email,_approve_status,_candidate_status";
$where_cond="_class=".$selected_admission_details." ORDER BY admission_form_id ASC";
$can_list=$obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond);
?>
<style type="text/css">
i{
	cursor:pointer;
}
</style>
<?php if($_SESSION['add']=='Y'){ 
$html="<html><head>
				</head><body>
<table style='width: 100%;'>
			<tr style='width: 100%;'>
				<td rowspan='2' style='width: 20%;' >$image</td>
				<td valign='top' style='width: 80%; font-weight: bold;text-align:center;'>
					<h2>".strtoupper($institute_name)."</h2>
					<h4 style='margin-top: 5px;'>
						$institute_address,&nbsp;$institute_thana,&nbsp;$institute_district,&nbsp;$institute_division-&nbsp;$institute_code
					</h4>
				</td>
			</tr>
			<tr style='width: 100%;'>
				<td style='width: 80%; font-weight: bold;text-align:center;'>
					<h3>Admission Candidate List For $selected_session</h3>
				</td>
			</tr>
</table>
<table align='center;' style='width: 100%; margin-top: 20px;'>
<tr style='width: 100%;'><td>Shift:&nbsp;<b>$shift_name</b>&nbsp;&nbsp;</td>
<td>Medium:&nbsp;<b>$medium_name</b>&nbsp;&nbsp;</td>
<td>Class:&nbsp;<b>$class_name</b>&nbsp;&nbsp;</td>
<td>Department:&nbsp;<b>$dept_name</b>&nbsp;&nbsp;</td>
</tr>
</table>
";
	$html.="
		<table id='sample-table-22' align='center;' style='width: 100%; margin-top: 20px; font-family: Tahoma, Geneva, sans-serif; border: 1px solid black; border-collapse: collapse;'>
			<thead>
			<tr>
				<th style='font-size: 13px; width: 50px; border: 1px solid; border-collapse: collapse;'>Sl</th>
				<th style='font-size: 13px; width: 100px; border: 1px solid; border-collapse: collapse;'>Form No</th>
				<th style='font-size: 13px; width: 100px; border: 1px solid; border-collapse: collapse;'>Name</th>
				<th style='font-size: 13px; width: 100px; border: 1px solid border-collapse: collapse;'>Gender</th>
				<th style='font-size: 13px; width: 100px; border: 1px solid; border-collapse: collapse;'>Mobile Number</th>
				<!--<th style='font-size: 13px; width: 100px; border: 1px solid; border-collapse: collapse;'>Email</th>-->
				<th style='font-size: 13px; width: 100px; border: 1px solid; border-collapse: collapse;'>Candidate Status</th>
			</tr>
			</thead>
			<tbody>";
$sl = 1;
foreach ($can_list AS $index1 => $value1) {
	$html.="<tr style='border: 1px solid black; border-collapse: collapse;'>
			<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$sl</td>";
	$sl++;
	$form_no = $value1['admission_form_id'];
	$candidate_name = $value1['_candidate_name'];
	$invoice_number = $value1['_invoice_number'];
	$gender = $value1['_gender'];
	$mobile_number = $value1['_mobile_number'];
	$email = $value1['_email'];
	
	$html.="<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$form_no</td>
		<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$candidate_name</td>
		<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$gender</td>
		<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$mobile_number</td>
		<!--<td style='font-size: 12px; text-align: center; width: 50px; border: 1px solid; border-collapse: collapse;'>$email</td>-->";
	
	if($value1['_candidate_status']=='UP' || $value1['_candidate_status']=='RE'){
		$html.="<td style='font-size: 12px; text-align: center; color:red; width: 50px; border: 1px solid; border-collapse: collapse;'>Disapproved</td>";
	}
	if($value1['_candidate_status']=='PA'){
		$html.="<td style='font-size: 12px; text-align: center; color:blue; width: 50px; border: 1px solid; border-collapse: collapse;'>Approved</td>";
	}
	if($value1['_candidate_status']=='ME'){
		$html.="<td style='font-size: 12px; text-align: center; color:green; width: 50px; border: 1px solid; border-collapse: collapse;'>Merit List</td>";
	}
	if($value1['_candidate_status']=='WA'){
		$html.="<td style='font-size: 12px; text-align: center; color:darkorange; width: 50px; border: 1px solid; border-collapse: collapse;'>Waiting List</td>";
	}
	$html.="</tr>";
}
$html=$html."</tbody></table></body></html>";
$print_date=date("d/m/Y");
$foothtml="<div><table width='100%'>
		<tr>
		<td>Powered by <b>Leotech</b></td>
		<td style='text-align: center;' width='60%;'>{PAGENO} of {nb}</td>
		<td><b>Date:</b>&nbsp;$print_date</td>
		</tr>
		</table></div>";
$mpdf = new mPDF();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetWatermarkImage('../../'.$institute_logo);
$mpdf->showWatermarkImage = true;
$mpdf->setFooter($foothtml);
$mpdf->WriteHTML($html);
$mpdf->Output();
//exit();
}?>