<script
	src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link
	href="https://fonts.googleapis.com/css?family=Hind:400,700&amp;subset=devanagari,latin-ext"
	rel="stylesheet">
<head>
<style>
@page {
	size: auto;
	margin: 20px;
	/* font-size: 100px; */
}

@media print {
	#printPageButton {
		display: none;
	}
}

.tbl1 {
	border: 2px solid black;
	border-collapse: collapse;
	font-weight: 800;
	padding: 15px;
}

.tbl1, tr, td {
	border: 1px solid black !important;
}

.tbl3, tr, td {
	border: 1px solid black !important;
	font-size: 12px;
}

.tbl3 .tg-dvpl {
	border-color: inherit;
	text-align: right;
	vertical-align: top;
}

.btn {
	background-color: #4CAF50;
	border-radius: 10%; /* Green */
	border: none;
	color: white;
	padding: 15px 32px;
	text-align: center;
	text-decoration: none;
	display: inline-block;
	font-size: 16px;
	margin: 4px 2px;
	cursor: pointer;
}
</style>
</head>
<div id="medical_examination_form" style="margin-top: -5px;">
<?php 
include ('includes/config/config.php');
include_once ("includes/functions.php");
include ("log_entry.php");
error_reporting ( 0 );
$query = "select company_logo,image_type from company_profile where company_id =5 ";
// echo $query;
$result = mysqli_query($conn,$query );
$row = mysqli_fetch_array ( $result );
@extract ( $row );
?>
	<table width="100%" class="tbl1" cellspacing="0">
		<tr>
			<td rowspan="4"><img
				src="data:image/jpeg;base64,<?php  echo base64_encode( $row['company_logo'] )?>"
				style="display: block; width: 134px; height: 60px;" /></td>
			<td rowspan="4">MAIHAR IU</td>
			<td>Department</td>
			<td>OCCUPATIONAL HEALTH CENTRE</td>
		</tr>
      <?php 
						echo $sql_patient_physical_parameters = "select a.*,b.id,b.patient_name, b.father_name,b.dob,b.doj,b.designation_id,b.emp_code,b.gender,b.primary_phone,b.blood_group,b.photo,b.email_id,b.personal_phone from medical_examination a inner join patient_master b on b.id=a.patient_id where a.medical_exam_id='" . $_REQUEST ['medical_exam_id'] . "'";
						error_log ( $sql_patient_physical_parameters );
						$result_patient_physical_parameters = mysqli_query($conn,$sql_patient_physical_parameters );
						$row_patient_physical_parameters = mysqli_fetch_assoc ( $result_patient_physical_parameters );
						@extract ( $row_patient_physical_parameters );
						?>
		<tr>
			<td>Document No.</td>
			<td>F-MED-08</td>
		</tr>
		<tr>
			<td>Revision</td>
			<td>0.0</td>
		</tr>
		<tr>
			<td>Implementation Date</td>
			<td>01.04.2016</td>
		</tr>
		<tr>
			<td align="center" colspan="4">Initial Medical Examination Card
				(Short Term)</td>
		</tr>
	</table>
	<br>
	<div style="margin-top: 0px">
	 <?php 
		?><table width="100%" class="tbl2"
			style="border: 1px solid black !important;" cellspacing="0">
			<tr>
				<td width="30%">Serial No</td>
				<td width="50%" colspan="5"><?php  echo $ime_no?></td>
			</tr>
			<tr>
				<td width="30%">Name</td>
				<td width="50%" colspan="3"><?php  echo $patient_name?></td>
				<td width="20%" colspan="2" rowspan="6"></td>
			</tr>
			<tr>
				<td width="20%">Father Name</td>
				<td width="20%" colspan="3"><?php  echo $father_name?></td>
			</tr>
			<tr>
				<td>Age/Sex</td>
				<td colspan="3"><?php 
				$from = new DateTime ( $dob );
				$to = new DateTime ( 'today' );
				echo $from->diff ( $to )->y;
				if ($gender == 'M')
					echo "   Male";
				elseif ($gender == 'F')
					echo "   Female";
				?></td>
			</tr>
			<tr>
				<td>Grade/Post</td>
				<td colspan="3"><?php  echo getTableFieldValue('designation', 'designation_name', 'designation_id',$designation_id)?></td>
			</tr>
			<tr>
				<td>Mobile.No.</td>
				<td colspan="3"><?php  echo $primary_phone?></td>
			</tr>
			<tr>
				<td>Gate pass No./P No</td>
				<td><?php  echo $emp_code?></td>
				<td>Date</td>
				<td><?php  echo date_format(date_create($row_patient_physical_parameters['approval_date']),"d-M-Y ");?></td>
			</tr>
			<tr>
				<td colspan="6"><b>TO BE FILLED IN BY THE CANDIDATE</b></td>
			</tr>
                                              <?php 
																																														$past_present_illness_array = explode ( ',', $past_present_illness );
																																														$result_section = mysqli_query($conn,"SET NAMES utf8" );
																																														$sql_section = "select * from  history_parameter where  param_id in (1,2,3,4,5,6,7,8,9,10,12,13) order by param_id  asc";
																																														$count = 1;
																																														$result_section = mysqli_query($conn,$sql_section );
																																														while ( $row_section = mysqli_fetch_assoc ( $result_section ) ) {
																																															if ($count % 2 != 0) {
																																																?><tr><?php 
																																															}
																																															?>
                                                                  <td
					width="50%" colspan="3"><input type="checkbox"
					id="<?php  echo $row_section['param_name'];  ?>"
					<?php  if(in_array($row_section['param_id'],$past_present_illness_array)) echo "checked"; ?>
					name="history_param"
					value="<?php  echo $row_section['param_id'];  ?>"> <b
					style="margin-top: -10px"> <?php    echo $row_section['param_name'];?></b>
					<span style="margin-left: 20px">
                                                               <?php 
																																															if (! in_array ( $row_section ['param_id'], $past_present_illness_array )) {
																																																echo "             X";
																																															}
																																															?></span></td>
                                                            <?php 
																																															if ($count % 2 == 0) {
																																																?></tr><?php 
																																															}
																																															$count ++;
																																														}
																																														?>
                                                            <tr>
				<td colspan="6"><p>
						</br>Signature /Left Thumb Impression of Candidate
					</p></td>
			</tr>
		</table>
		<br>
		<div style="margin-top: 0px">
			<table width="100%" style="border: 1px solid black !important;"
				class="tbl3" cellspacing="0">
				<tr>
					<td colspan="6">RECORD OF MEDICAL EXAMINATION</td>
				</tr>
				<tr>
					<td colspan="2">Height(cms)</td>
					<td colspan="2"><?php  echo $height ?></td>
					<td colspan="2"><b>CLINICAL EXAMINATION</</b></td>
				</tr>
				<tr>
					<td width="30%" colspan="2">Weight(kgs)</td>
					<td width="20%" colspan="2"><?php  echo $weight ?></td>
					<td width="20%">PALLOR</td>
					<td width="30%"><?php  echo $pallor ?></td>
				</tr>
				<tr>
					<td colspan="2"></td>
					<td colspan="2"></td>
					<td>PULSE</td>
					<td><?php  echo $pulse ?></td>
				</tr>
				<tr>
					<td colspan="4" align="center"><b>Vision</b></td>
					<td>BP</td>
					<td><?php  echo $bp ?>&nbsp;&nbsp;mm of Hg</td>
				</tr>
				<tr>
					<td></td>
					<td></td>
					<td>RT.EYE</td>
					<td>LT.EYE</td>
					<td>CVS</td>
					<td><?php  echo $cvs ?></td>
				</tr>
				<tr>
					<td>Distant Vision</td>
					<td width="30%">Without Glasses</td>
					<td>6/<?php  echo $dis_without_right_eye?></td>
					<td>6/<?php  echo $dis_without_left_eye?></td>
					<td>RS</td>
					<td><?php  echo $rs ?></td>
				</tr>
				<tr>
					<td></td>
					<td>With Glasses</td>
					<td>6/<?php  echo $dis_with_right_eye?></td>
					<td>6/<?php  echo $dis_with_left_eye?></td>
					<td>MUSCULO SKELETAL</td>
					<td><?php  echo $musculo_skeletal ?></td>
				</tr>
				<tr>
					<td>Near Vision</td>
					<td>Without Glasses</td>
					<td>N/<?php  echo $near_without_right_eye?></td>
					<td>N/<?php  echo $near_without_left_eye?></td>
					<td rowspan="3">ANY OTHER RELEVANT FINDING</td>
					<td rowspan="3"><?php  echo $other_relevant_findings ?></td>
				</tr>
				<tr>
					<td></td>
					<td>With Glasses</td>
					<td>N/<?php  echo $near_with_right_eye?></td>
					<td>N/<?php  echo $near_with_right_eye?></td>
				</tr>
				<tr>
					<td colspan="2">IDENTIFICATION OF INDIVIDUAL COLOURS</td>
					<td colspan="2"><?php  echo $ident_of_individual_colors;?></td>
				</tr>
				<tr>
					<td colspan="2">COLOR VISION</td>
					<td colspan="2"><?php  echo $color_vision;?></td>
					<td></td>
					<td></td>
				</tr>
				<tr>
					<td colspan="3">OPINION/ REMARKS (BY MEDICAL ASSISTANT)</td>
					<td colspan="3"><?php  echo $opinion_remarks_medical_assistant;?></td>
				</tr>
				<tr>
					<td colspan="3">OPINION/ REMARKS (BY DOCTOR)</td>
					<td colspan="3"><?php  echo $opinion_remarks;?></td>
				</tr>
				<tr>
					<td rowspan="2" colspan="3">Signature of Medical Assistant</td>
					<td rowspan="2" colspan="3"><?php 
					if ($sign_medical_ass == 'add') {
						$emp_id = getTableFieldValue ( 'tbl_users', 'emp_id', 'user_id', $medical_attend );
						$query_sign = "select * from employee_signature where emp_id='" . $emp_id . "'  ";
						// echo $query_emp_sign;
						if (! $result_sign = @mysqli_query($conn,$query_sign )) {
							die ( mysqli_error($conn) );
						} else {
							$row_sign = @mysqli_fetch_array ( $result_sign );
							@extract ( $row_sign );
						}
					}
					// echo $row_emp_sign['modified_by'];
					?>  
										<span class="profile-picture" style="margin-left: 50px;">
													<?php  if(isset($row_sign['emp_sign']) && $row_sign['emp_sign']!=null){?>
													<img class="editable img-responsive" id="avatar"
							src="data:<?php  echo $row_sign['image_type']?>;base64,<?php  echo base64_encode( $row_sign['emp_sign'] )?>"
							style="display: block; width: 180px; height: 25px;" />
													<?php  }?>
											 </span></td>
				</tr>
				<tr></tr>
											 <?php 
												// if($sign_medical_officer=='add'){
												// $emp_id=getTableFieldValue('tbl_users','emp_id','user_id',$approved_by);
												// $query_emp_sign = "select * from employee_signature where emp_id='" .$emp_id. "' ";
												// if (! $result_emp_sign = @mysqli_query($conn,$query_emp_sign)) {
												// die(mysqli_error($conn));
												// } else {
												// $row_emp_sign = @mysqli_fetch_array($result_emp_sign);
												// @extract($row_emp_sign);
												// }
												// }
												// echo $row_emp_sign['modified_by'];
												?>  
											<tr>
											 <?php 
												$doc_emp_id = getFieldfromTable ( 'emp_id', 'tbl_users', 'user_id', $sign_medical_officer );
												$doctor_name = getFieldfromTable ( 'patient_name', 'patient_master', 'id', $doc_emp_id )?>
											<td class="tg-dvpl" colspan="6"><img
						src="data:<?php  echo $doc_sign_image_type?>;base64,<?php  echo base64_encode( $approving_doc_sign_img)?>"
						style="width: 240px; height: 61px;" /><br> <br>SIGNATURE OF
						MEDICAL OFFICER <br>(WITH STAMP)<br><?php  echo $doctor_name?><br><?php  echo $row_patient_physical_parameters['approving_doc_qualification']?> <br><?php  echo $row_patient_physical_parameters['approving_doc_regd_no']?></td>
				</tr>
				<tr>
			
			</table>
			<div align="center">
				<button align="center" id="printPageButton" class="btn btn-success"
					onClick="window.print();">Print</button>
			</div>
		</div>
	</div>
	<form id="medical_examination_form_pdf" action="" method="POST">
		<input type="hidden" name="htmlText" id="htmlText" />
	</form>
</div>
<script>
   //formSubmit();
	function formSubmit(){
		  $("#htmlText").val($("#medical_examination_form").html());
		 document.forms['medical_examination_form_pdf'].action="pdf_dynamic.php";
			document.forms['medical_examination_form_pdf'].method="post";
			document.forms['medical_examination_form_pdf'].submit();
		}
	</script>