<?php include('techsyn_header.php');
include('image_popup.php');
?>
<!-- Main Content Container for side bar and body-->
<div class="main-container ace-save-state" id="main-container">
	<script type="text/javascript">
		try {
			ace.settings.loadState('main-container')
		} catch (e) {}
	</script>
	<?php include('techsyn_sidebar.php'); ?>


	<!--breadcrumb-->
	<div class="main-content">
		<div class="main-content-inner">
			<div class="breadcrumbs ace-save-state" id="breadcrumbs">
				<ul class="breadcrumb">
					<li class="#"><i class="ace-icon fa fa-home home-icon"></i> <a href="#">Home</a>
					</li>
					<li class="">Patient Visit</li>
					<li class="active">Aproved Medical Examination</li>
				</ul>

			</div>
			<!-- End of breadcrumb -->





			<div class="page-content">

				<form name="flex_medical_form" method="post" action="" id="flex_medical_form">
					<div id="flex1" style="width: 100%">
						<input type="hidden" name="medical_exam_id" id="medical_exam_id">
						<input type="hidden" name="emp_id" id="emp_id">
					</div>
				</form>
				<form name="export_form" method="post" id="export_form" action="">

					<input type="hidden" name="pdf_action" id="pdf_action" value="pdf_approved_medical_examination.php" />
					<input type="hidden" name="excel_action" id="excel_action" value="excel_approved_medical_examination.php" />
				</form>



				<form name="f1" method="post" action="" id="flex_form_checkup">

					<div id="flex1" style="width:100%">

					</div>

					<input type="hidden" name="flex_checkup_id" id="flex_checkup_id" />

					<input type="hidden" name="emp_id_history" id="emp_id_history" />

					<input type="hidden" name="checkup_type_id_db" id="checkup_type_id_db" />

					<input type="hidden" name="toPage" id="toPage" />



				</form>
			</div>



		</div>
		<!-- /.page-content -->
	</div>
</div>
<!-- /.main-content -->




<script type="text/javascript">

	$(function() {
		var w = screen.width * .90;

		var h = 0;
		h = (window.innerHeight - ($("#navbar").height() + $(".breadcrumbs").height())) * .75;
		$("#flex1").flexigrid({
			url: 'approved_lab_examination_script.php',
			dataType: 'json',
			colModel: [

				{
					display: 'Sr',
					name: 'count',
					width: w * .04,
					sortable: false,
					align: 'left'
				},
				{
					display: 'Actions',
					name: '',
					width: w * .1,
					sortable: false,
					align: 'left'
				},

				{
					display: 'Examination Date',
					name: 'medical_entry_date',
					width: w * .10,
					sortable: true,
					align: 'left'
				},
				{
					display: 'Ticket No',
					name: 'ticket_no',
					width: w * .09,
					sortable: false,
					align: 'left'
				},
				{
					display: 'Patient Name',
					name: 'patient_name',
					width: w * .08,
					sortable: true,
					align: 'left'
				},
				{
					display: 'Examination Type',
					name: 'checkup_type_id',
					width: w * .1,
					sortable: true,
					align: 'left'
				},
				{
					display: 'Test Categeries',
					name: 'test_cat',
					width: w * .30,
					sortable: true,
					align: 'left'
				},
				{
					display: 'FINAL BILL AMOUNT',
					name: 'amount',
					width: w * .1,
					sortable: true,
					align: 'left'
				},
				{
					display: 'Remarks',
					name: 'remarks',
					width: w * .1,
					sortable: true,
					align: 'left'
				},
				// {
				// 	display: 'Approval Date',
				// 	name: 'approval_date',
				// 	width: w * .10,
				// 	sortable: true,
				// 	align: 'left'
				// },
				// {display: 'Test Status', name: 'test_status', width: w*.10, sortable: true, align: 'left'},

				// {display: 'Pdf Link', name: '', width: w*.04, sortable: false, align: 'left'},
				// {display: 'Form O/ Form 32 /Form 33', name: '', width: w*.1, sortable: false, align: 'left'},
				// {display: 'Doc Upload', name: '', width: w*.1, sortable: false, align: 'left'},
				// {display: 'Download Certificate', name: '', width: w*.15, sortable: false, align: 'left'},

			],
			buttons: [

				{
					name: 'PDF',
					bclass: 'print',
					onpress: pdf
				},
				{
					separator: true
				},
				{
					name: 'Excel',
					bclass: 'print_excel',
					onpress: excel
				},
				// {separator: true},
				// {name: 'Download Template', bclass: 'print_excel', onpress : download_template},	
				//  {separator: true},
				//  {name: 'Upload Excel', bclass: 'print_excel', onpress : upload_excel},
				// {separator: true},
				//   {name: 'Download Excel', bclass: 'print_excel', onpress : download_excel},
			],
			searchitems: [

				{
					display: 'Patient Name',
					name: 'patient_name',
					isdefault: true
				},
				// {display: 'Phone No', name: 'primary_phone', isdefault: true},
				// {display: 'Aadhar Card', name: 'aadhar_no', isdefault: true},
				// {display: 'EMP code', name: 'emp_code', isdefault: true},
				{
					display: 'Examination Date(DD/MM/YYYY)',
					name: 'checkup_date',
					isdefault: true
				},
				{
					display: 'Examination Date Range(DD/MM/YYYY)-(DD/MM/YYYY)',
					name: 'medical_entry_date_between',
					isdefault: true
				},

				// {display: 'Examination Type(annual/pre_employment)', name: 'task', isdefault: true},
				// {display: 'Patient Category', name: 'patient_cat_name'},
				{
					display: 'Approval Date Range(DD/MM/YYYY)-(DD/MM/YYYY)',
					name: 'approval_date_between',
					isdefault: true
				},
				{
					display: 'Approval Date (DD/MM/YYYY)',
					name: 'approval_date'
				}
			],
			sortname: "a.last_modified",
			sortorder: "desc",
			usepager: true, //pagination

			useRp: true,
			rp: 50, //records per page
			showTableToggleBtn: false, //toggle button for the whole table
			resizable: true,
			//width: w,
			height: h,
			singleSelect: true
		});
	});

	function pdf() {
		//window.open('pdf_manage_item.php');

		window.open('ajax_pdf.php', 'Approved Medical Examination List');
	}

	function excel() {
		console.log("click");
		$("#checkup_type_id_m").val("");
		$('#modal-select-checkup-type-dd-ss').modal("show");
	}

	function upload_excel() {
		window.location = 'upload_excel_medical.php';
	}

	function download_template() {
		window.location = 'templates/medical_Report_new.xlsx';
	}

	function form_generation(medical_exam_id, patient_id, task) {


		var selectOptions = "";
		if (task == 'pre_employment') {
			selectOptions = '<select class="form-control"  id="form_generation_type"  style="margin-left:100px;width:60%"><option value="form_32" > Form 33 </option></select>';
		} else {
			selectOptions = '<select class="form-control"  id="form_generation_type"  style="margin-left:100px;width:60%"><option value="form_32_original" > Form 32 </option></select>';
		}

		BootstrapDialog.show({
			title: 'Form Generation',
			message: selectOptions,
			buttons: [{
				label: 'Submit',
				action: function() {

					$(".close").click();
					open_form_generation(medical_exam_id, $("#form_generation_type").val());

				}
			}]
		});



		/*if(medical_exam_id!='' && medical_exam_id!='' && patient_id!=null && patient_id!=''){
			$("#medical_exam_id").val(medical_exam_id);
			$("#flex_medical_form").attr('method', 'POST');
			if(task=='pme'){
				$("#flex_medical_form").attr('action', 'open_patient_physical_parameters_pme.php?medical_exam_id='+medical_exam_id+'');
			}else if(task=='ime_short'){
				$("#flex_medical_form").attr('action', 'open_patient_physical_parameters_ime_short_term.php?medical_exam_id='+medical_exam_id+'');
			}else if(task=='ame_greater_40'){
				$("#flex_medical_form").attr('action', 'open_patient_physical_parameters.php?medical_exam_id='+medical_exam_id+'');
			}else if(task=='semi_annual'){
				$("#flex_medical_form").attr('action', 'open_patient_physical_parameters_ame_below_40.php?medical_exam_id='+medical_exam_id+'');
			}else if(task=='ime_long'){
				$("#flex_medical_form").attr('action', 'open_ime_long_term.php?medical_exam_id='+medical_exam_id+'');
			}
			
			//$("#flex_medical_form").attr('action', 'open_patient_physical_parameters.php?medical_exam_id='+medical_exam_id+'');
			$("#flex_medical_form").submit();
		}*/

		/*$('#form_genaration').modal({
			keyboard : true
		});
		$('#form_genaration').modal("show");*/

	}








	function open_checkup(checkupId, empId, action, checkup_type_id) {



		//window.location = 'checkup.php?checkup_id='+checkupId+'';

		console.log(checkupId + ':' + empId + ' ; ' + action + ' : ' + checkup_type_id);

		if (checkupId != null && checkupId != '') {

			$("#flex_checkup_id").val(checkupId);

			$("#checkup_type_id_db").val(checkup_type_id);

			$("#emp_id_history").val(empId);

			$("#toPage").val(action);

			$("#flex_form_checkup").attr('method', 'POST');

			$("#flex_form_checkup").attr('action', 'checkup_from_before.php');

			$("#flex_form_checkup").submit();

		}



	}


	function delete_checkup(checkupId, empId, action, checkup_type_id){
		if(checkupId != null || checkupId != ''){
			$.ajax({
				url:'delete_checkup_form.php',
				type:'POST',
				data:{
					checkupId:checkupId,
					empId:empId,
					checkup_type_id:checkup_type_id
				},
				success:function(data){
					let result = JSON.parse(data);
					if(result == 1){
						BootstrapDialog.alert("Deleted Successfully");
						$("#flex1").flexReload();
					}
				},
				error:function(data){
					BootstrapDialog.alert("Something Went Wrong Try Again after a while !");
				}
			});
		}
	}


	function form_generation_for_pdf(form_type) {
		var form_generate_type = "";
		var content = "";
		var form_data_array = [];

		if (form_type == 'form_32') {
			form_generate_type = 'Form 33';
			$('#form_32 p').each(function(index) {
				if (index <= 7)
					form_data_array[index] = ($(this).text())
			});

		} else if (form_type = 'form_32_original') {
			form_generate_type = 'Form 32';
			$('#form_32_original p').each(function(index) {
				if (index <= 24)
					form_data_array[index] = ($(this).text())
			});
		} else {
			$('#form_0_pdf p').each(function(index) {
				if (index <= 6)
					form_data_array[index] = ($(this).text())
			});
			form_generate_type = 'Form O';

		}


		BootstrapDialog.show({
			title: 'Form Generation Pdf',
			message: 'Are You Sure To Generate ' + form_generate_type,
			buttons: [{
				label: 'Submit',

				action: function(dialog) {

					dialog.close();
					if (form_type == 'form_32') {

						$.ajax({
							url: 'save_form_generation_type.php',
							type: 'POST',
							data: {
								form_type: $("#form_type").val(),
								medical_exam_id: $("#medical_exam_id").val(),
								serial_no: $("#serial_no").text(),
								identification_mark: $("#identification_mark").text(),
								examination_date: $("#examination_date").text(),
								form33_unfit_reason: $("#form33_unfit_reason").text(),
								prev_certificate_sno: $("#prev_certificate_sno").text(),
								unfit_period: $("#unfit_period").text(),
								sign_and_symptoms: $("#sign_and_symptoms").text(),
								signature: $("#signature").text(),

							},
							success: function(data) {}
						});
						generateFormPdf($("#medical_exam_id").val())
					} else if (form_type == 'form_32_original') {

						$.ajax({
							url: 'save_form_generation_type.php',
							type: 'POST',
							data: {
								form_type: $("#form_type").val(),
								medical_exam_id: $("#medical_exam_id").val(),
								emp_id: emp_id,
								form_data_array: form_data_array,
								department_works: $("#department_works").text(),
								hazardous_process_name: $("#hazardous_process_name").text(),
								dangerous_process_name: $("#dangerous_process_name").text(),
								byproducts_exposedto: $("#byproducts_exposedto").text(),
								leaving_date: $("#leaving_date").text(),
								designation: $("#designation").text(),
								byproducts_exposedto: $("#byproducts_exposedto").text(),
								doj: $("#doj").text(),
								examination_date: $("#examination_date").text(),
								symptoms: $("#symptoms").text(),
								test_nature: $("#test_nature").text(),
								result_fit_unfit: $("#result_fit_unfit").text(),
								widthdrawal_period: $("#widthdrawal_period").text(),
								withdrawal_reason: $("#withdrawal_reason").text(),
								date_declared_unfit: $("#date_declared_unfit").text(),
								certificate_date: $("#certificate_date").text(),
								reason_leaving: $("#reason_leaving").text(),
								signature: $("#signature").text(),

							},
							success: function(data) {

							}

						});
						generateFormPdf32($("#medical_exam_id").val())
					} else {
						$.ajax({
							url: 'save_form_generation_type.php',
							type: 'POST',
							data: {
								form_type: $("#form_type_O").val(),
								medical_exam_id: $("#medical_exam_id_O").val(),
								form_data_array: form_data_array
							},
							success: function(data) {

							}

						});
						generateFormPdfO()
					}


				}
			}, {
				label: 'Close',
				action: function(dialogItself) {
					dialogItself.close();
				}
			}]
		});

	}
	var emp_id = "";
	var function_calling_count = 0;
	var function_calling_count_32 = 0;
	var function_calling_count_o = 0;

	function open_form_generation(medcal_exam_id, form_generation_type) {
		$("#valid_date").html("");
		$("#medical_exam_id").val(medcal_exam_id);
		$("#form_type").val(form_generation_type);
		$("#medical_exam_id_O").val(medcal_exam_id);
		$("#form_type_O").val(form_generation_type);

		$.ajax({
			url: 'get_medical_examination_patient_details.php',
			type: 'POST',
			data: {
				medical_exam_id: medcal_exam_id
			},
			success: function(data) {
				var data = $.parseJSON(data);
				if (data != null) {
					emp_id = data.emp_id;
					if (form_generation_type == 'form_32') {
						var gender = "";
						if (data.gender == 'F')
							gender = 'Female';
						else if (data.gender == 'M')
							gender = 'Male';
						else
							gender = 'Others';
						var content = "";
						if (function_calling_count > 0) {
							$("table[id='header_table'] > tbody > tr:first-child").remove();
							$('#table_body > tbody > tr:first').remove();
							//$("#doc_no").html();
						}

						// $("#doc_no").html(data.document_no);
						// $("#header_table> tbody > tr:first").before("<tr><td >SL NO "+data.serial_no+" </td><td align=\"right\">Date "+data.approval_date+" </td></tr>")
						content = "<tr><td style=\"width:3%;\">1.</td><td style=\"width:30%;\">   	Serial number in the register of adult workers</td><td>  : <p contenteditable=\"true\" id=\"serial_no\">" + data.serial_no + "</p></td></tr>";

						content += " <tr><td>2.</td><td>	Name of the person examined   </td><td>: Shri <p contenteditable=\"true\">" + data.patient_name + "</p></td></tr>"
						content += " <tr><td>3.</td><td>	Father’s Name   </td><td>: Shri <p contenteditable=\"true\">" + data.father_name + "</p></td></tr>"
						content += " <tr><td>4.</td><td>	Sex  </td><td>: <p contenteditable=\"true\">" + data.gender + "</p></td></tr>"
						content += "<tr><td> 5.</td><td>	Residence	</td><td>: <p contenteditable=\"true\"></p></td></tr>"
						content += "<tr><td>6.</td><td>	Date of birth, if available	</td><td>: <p contenteditable=\"true\">" + data.dob + "</p></td></tr>"
						content += "<tr><td>7.</td><td>	Name & address of the factory </td><td>: <p contenteditable=\"true\">" + data.company_name + ", " + data.factoryAddress + "</p></td></tr>"
						content += "<tr><td> 8.</td><td>	The worker is employed / proposed		</td><td>: <p contenteditable=\"true\"></p></td></tr>"
						content += "<tr><td colspan=\"2\">(a)	Hazardous process				</td><td>: <p contenteditable=\"true\"></p></td></tr>"
						content += "<tr><td colspan=\"2\">(b)	Dangerous operation				</td><td>: <p contenteditable=\"true\"></p></td><td  id=\"signature\" contenteditable=\"true\" style=\"display: none;width: 180px;height: 25px;\" ><p  contenteditable=\"true\">" + data.emp_id + "</p></td></tr> ";


						var imageContent = "";
						var stampContent = "";
						imageContent = "<img class=\"editable img-responsive\" id=\"avatar\"  	src=\"data:" + data.image_type + ";base64," + data.emp_sign + "\"  style=\"display: block; width: 180px; height: 25px;\" />"

						//stampContent="<tr><td align=\"right\">Doctor Name :</td></tr><tr><td align=\"right\">Qualification :</td></tr><tr><td align=\"right\">Registration No :</td></tr>";
						/*	if(data.task=='ime_long')
							$("#valid_date").html("<p>Valid Till-"+data.valid_date+"</p>")
						    else if(data.task=='ime_short')
						      $("#valid_date").html("<p contenteditable=\"true\">Valid Till-</p>")*/
						$("#doctor_name").html("<span align=\"right\"></span>Doctor Name : " + data.doctor_name);
						$("#qualification").html("<span align=\"right\"></span>Qualification : " + data.qualification);
						$("#doc_details").html("<span align=\"right\">" + data.doctor_name + "(" + data.qualification + ")</span>");
						$("#registration_no").html("<span align=\"right\"></span>Registration No : " + data.registration_no);
						$("#form33_age").html(data.age);
						function_calling_count++;


						$('#table_body > tbody > tr:first').before(content);

						$("#profile-picture").html(imageContent);
						$("#form33_doc_sign").html(imageContent);
						$('#form_genaration').modal({
							keyboard: true
						});
						$('#form_genaration').modal("show");
					} else if (form_generation_type == 'form_32_original') {
						var gender = "";
						var content = "";
						if (data.gender == 'F')
							gender = 'Female';
						else if (data.gender == 'M')
							gender = 'Male';
						else
							gender = 'Others';

						if (function_calling_count_32 > 0) {
							$("table[id='header_table_32'] > tbody > tr:first-child").remove();


							$('#table_body_32 > tbody > tr:first').remove();
							//$("#doc_no").html();
							$('#vertical_row_header').remove();
							$('#vertical_row_header1').remove();
							$('#vertical_row_header2').remove();
							$('#vertical_row_content').remove();
						}

						// $("#doc_no").html(data.document_no);
						// $("#header_table_32> tbody > tr:first").before("<tr><td >SL NO "+data.serial_no+" </td><td align=\"right\">Date "+data.approval_date+" </td></tr>");
						content = "<tr><br><td colspan=\"17\"> &nbsp;<strong> 1. Serial number in the register of adult workers  : <p contenteditable=\"true\">" + data.serial_no + "</p><br><br>";
						content += " &nbsp; 2.	Name of the Person examined   : Shri <p contenteditable=\"true\">" + data.patient_name + "</p><br><br>";
						content += " &nbsp; 3.	Sex  : <p contenteditable=\"true\">" + data.gender + "</p><br><br>";
						content += " &nbsp; 4.	Date of birth, if available	: <p contenteditable=\"true\">" + data.dob + "</p></strong></td></tr><br>";
						content += " <p contenteditable=\"true\">" + data.none + "</p></p><p contenteditable=\"true\">" + data.none + "</p></p><p contenteditable=\"true\">" + data.none + "</p></p><p contenteditable=\"true\">" + data.none + "</p></p>";

						content += "<tr id='vertical_row_header'><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);transform: rotate(180deg);\">Department Works</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\" >Name of the Hazardous process</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Dangerous process/operation</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\" rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Nature of job or occupation</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Row material products or By-products likely to be exposed to</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Date of posting</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Date of leaving/or transfer/ leaving</td><td rowspan=\"2\" style=\" writing-mode:vertical-lr; width: 50px; transform: rotate(180deg);\">Reason for discharge/ transfer/ leaving</td><td colspan=\"4\">Medical examination Results therefore</td><td colspan=\"4\">If declared unfit for work</td><td rowspan=\"2\">Signature with date of the factory Medical Officer/ the Certifying Surgeon.</td></tr>";

						content += "<tr id='vertical_row_header1'><td style=\"width: 50px;\">Date</td><td>Signs and symptoms Observed during examination</td><td>Nature of tests & results thereof</td><td>Result Fit/Unfit</td><td>Period of temporary Withdrawal from that work</td><td>Reasons for such withdrawal</td><td>Date of declaring him Unfit for that work</td><td>Date of issuing fitness Certificate</tr>";



						content += "<tr id='vertical_row_header2'><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr>";

						content += "<tr id='vertical_row_content'  style=\"height:300px;\">"
						department_works = (data.department_works) ? data.department_works : 'Production/Admin';
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"department_works\" contenteditable=\"true\" ><p>" + department_works + "</p></td>"

						hazardous_process_name = (data.hazardous_process_name) ? data.hazardous_process_name : 'Pharmacutical Industry';

						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" id=\"hazardous_process_name\" contenteditable=\"true\" class=\"vertical_show\"><p contenteditable=\"true\">" + hazardous_process_name + "</p></td>"

						dangerous_process_name = (data.dangerous_process_name) ? data.dangerous_process_name : 'Not Applicable/ Distilation/ Production/ Packing/ EHS/ ETP/ Maintenance Plant/ Maintenance Electrical/ Utilities/ RM Store/ Engineering Store';

						content += "<td  onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" id=\"dangerous_process_name\" contenteditable=\"true\" class=\"vertical_show\"><p contenteditable=\"true\">" + dangerous_process_name + "</p></td>"

						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\"id=\"designation\" contenteditable=\"true\"class=\"vertical_show\"><p contenteditable=\"true\">" + data.designation + "</p></td>"

						byproducts_exposedto = (data.byproducts_exposedto) ? data.byproducts_exposedto : 'Heat/Noise/Solvent/Ammonia/Dust';
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" id=\"byproducts_exposedto\" contenteditable=\"true\"class=\"vertical_show\"><p contenteditable=\"true\">" + byproducts_exposedto + "</p></td>"

						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" id=\"doj\" contenteditable=\"true\"class=\"vertical_show\"><p contenteditable=\"true\">" + data.doj + "</p></td>"

						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\"  id=\"leaving_date\" contenteditable=\"true\"class=\"vertical_show\"><p contenteditable=\"true\">" + data.leaving_date + "</p></td>"

						reason_leaving = (data.reason_leaving) ? data.reason_leaving : 'Not Applicable/Left/Retired';

						content += "<td  onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" id=\"reason_leaving\" contenteditable=\"true\"class=\"vertical_show\"><p contenteditable=\"true\">" + reason_leaving + "</p></td>"

						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"examination_date\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"symptoms\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"test_nature\" contenteditable=\"true\"><p contenteditable=\"true\" ></p> </td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"result_fit_unfit\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"widthdrawal_period\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"withdrawal_reason\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"date_declared_unfit\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td onclick=\"$(this).removeClass('vertical_show').addClass('horizontal_write')\" onblur=\"$(this).removeClass('horizontal_write').addClass('vertical_show')\" class=\"vertical_show\" id=\"certificate_date\" contenteditable=\"true\"><p contenteditable=\"true\" ></p></td>"
						content += "<td  id=\"signature_image\" ><img class=\"editable img-responsive\" id=\"avatar\" src=\"data:" + data.image_type + ";base64," + data.emp_sign + "\"  style=\"display: block;width: 180px;height: 25px;\" /><br>" + data.doctor_name + "<br>" + data.qualification + "<br>Regd No : " + data.registration_no + " </td>"
						content += "<td  id=\"signature\" contenteditable=\"true\" style=\"display: none;width: 180px;height: 25px;\" ><p  contenteditable=\"true\">" + data.emp_id + "</p></td>"
						content += "</tr>";


						function_calling_count_32++;

						// alert(content);
						$('#table_body_32 > tbody > tr:first').before(content);
						//  $("#profile_picture_32").html(imageContent);	
						$('#form_genaration_32').modal({
							keyboard: true
						});
						$('#form_genaration_32').modal("show");
					} else {
						var content = "";
						if (function_calling_count_o > 0) {
							//  $("table[id='header_table'] > tbody > tr:first-child").remove();
							$('#table_body_form_o>tbody> tr:first').remove();
							//$("#doc_no").html();
							$('#form_header>tbody> tr:last').remove();
						}
						content += " <tr><td><p contenteditable=\"true\"> Certified that Shri " + data.patient_name + " "
						content += " Employed as ....  ....   in..............Mine, Form D. No " + data.serial_no + " has been examined "
						content += " for an initial/periodical medical examination. He/she appears to be " + getAge(new Date(data.dob)) + " years of age. The "
						content += "findings of the examining authority are given in the attached sheet. It is considered that </p></td></tr>"
						$('#table_body_form_o> tbody > tr:first').before(content);

						$("#form_header").append("<tr><td colspan=\"2\" align=\"left\">Certificate No " + data.serial_no + "</td></tr>");
						var imageContent = "";
						imageContent = "<img class=\"editable img-responsive\" id=\"avatar\"  	src=\"data:" + data.image_type + ";base64," + data.emp_sign + "\"  style=\"display: block; width: 180px; height: 25px;\" />"

						$("#doctor_name_id").html("Doctor Name : " + data.doctor_name);
						$("#qualification_id").html("Qualification : " + data.qualification);
						$("#registration_no_id").html("Registration No : " + data.registration_no);




						//$("#doc_no_o").html(data.document_no);
						function_calling_count_o++;
						$("#profile-picture1").html(imageContent);
						$('#form_genaration_0').modal({
							keyboard: true
						});
						$('#form_genaration_0').modal("show");

					}





				}
				// BootstrapDialog.alert("Foward Status  Saved Successfully");
			},
			error: function(data) {
				BootstrapDialog.alert(" Error In Saving Foward Status ");
			}
		});



	}
</script>

<?php include('select_checkup_type_approved.php'); ?>

<?php include_once 'form/form_33_gujarat.php'; ?>
<?php include_once 'form_32_original.php'; ?>
<?php include_once 'form/form_o.php'; ?>
<?php include('techsyn_footer.php'); ?>





<style>
	#form_genaration {
		overflow-y: scroll;
	}

	#form_genaration_0 {
		overflow-y: scroll;
	}

	#form_genaration_32 {
		overflow-y: scroll;
	}

	#modal-dialog1 {
		padding: 15px;
		width: 80%;
	}

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

	.tbl1 td {
		font-size: 12px;
		border: 1px solid black;
		border-collapse: collapse;
		padding: 4px
	}

	.tbl4 td {
		font-size: 12px;
		font-weight: 900;
		border-collapse: collapse;
		padding: 4px
	}

	.tbl3 td {
		font-size: 10px;
		/*font-weight:900;*/
		/*border-collapse: collapse;*/
		padding: 5px
	}
</style>

<script>
	function generateFormPdf(medical_exam_id) {

		var content = $("#form_32").html();
		$("#htmlText").val(content);
		$("#flex1").flexReload();
		document.form_pdf.action = "form_32_pdf.php?medical_exam_id=" + medical_exam_id + "";
		document.form_pdf.method = "POST";
		document.getElementById("form_pdf").submit();
	}

	function generateFormPdf32(medical_exam_id) {

		var content = $("#form_32_original_div").html();
		$("#htmlText").val(content);
		// window.open($("#htmlText").val(content));
		document.form_pdf.action = "form32_pdf.php?medical_exam_id=" + medical_exam_id + "";
		document.form_pdf.method = "POST";
		document.getElementById("form_pdf").submit();
		$("#flex1").flexReload();
	}

	function generateFormPdfO() {

		var content = $("#form_0_pdf_body").html();
		$("#htmlText").val(content);
		document.form_pdf.action = "pdf_dynamic.php";
		document.form_pdf.method = "POST";
		document.getElementById("form_pdf").submit();
		$("#flex1").flexReload();

	}
</script>
<style>
	.vertical_show {
		writing-mode: vertical-lr;
		width: 50px;
		transform: rotate(180deg);
		transform: rotate(180deg);
	}

	.horizontal_write {
		writing-mode: horizontal-tb;
		width: 50px;
	}
</style>