ESH/driver_vision_report_excel.php

187 lines
7.5 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php //include('pdf_header_reverse.php');
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=driver_vision_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
$checkup_type_id = $_REQUEST['checkup_type_id_m'];
error_log("checkup_type_id " . $checkup_type_id);
$start_date_excel = $_REQUEST['start_date_excel'];
$end_date_excel = $_REQUEST['end_date_excel'];
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
.btn {
background-color: #4CAF50;
border-radius: 5%;
/* Green */
border: none;
color: white;
padding: 5px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 4px 2px;
cursor: pointer;
}
@media print {
#printPageButton {
display: none;
}
}
</style>
<body>
<?php include('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td style="font-size: 15px;"><strong style="margin-left: 400px">Driver Vision Report
<?php if($only_referral=='Y'){echo "(Referral)";}?> </strong></td>
</tr>
<tr>
<td align="left" style="font-size: 12px"><strong>For Date:
<? echo date("d-M-Y", strtotime($start_date_excel))." - ".date("d-M-Y", strtotime($end_date_excel)); ?>
</strong></td>
<td align="right" style="font-size: 15px"><button align="center" id="printPageButton"
class="btn btn-success" onClick="window.print();">Print</button></td>
</tr>
</table>
<br>
<?php
$designation_id=getTableFieldValue("designation","designation_id","designation_name","'DRIVER'");
$dates = "and date(checkup_date) >= '" . $start_date_excel . "' and date(checkup_date) <= '" . $end_date_excel . "'";
$sql210 = "select * from checkup_type where checkup_type_id='" . $checkup_type_id . "'";
error_log("sql210" . $sql210);
$result210 = @mysqli_query($conn, $sql210);
while ($row210 = mysqli_fetch_array($result210)) {
// $checkup = $row210['checkup_form_section_ids'];
$checkup=(71);
}
$sql = 'select distinct section_id,section_name,count(*) as count from (select* from checkup_form_section where Status="Active"and section_id in (' . $checkup . ') ) as c left JOIN checkup_parameter on checkup_parameter.checkup_form_section_id=c.section_id and enabled="Y" group by section_id ';
error_log("sql 1st" . $sql);
$result = mysqli_query($conn, $sql);
$sql1 = 'select parameter_value,input_type,section_id,column_order,checkup_parameter_id,parameter_name,column_name from (select checkup_form_section_id,column_order,checkup_parameter_id ,parameter_name,input_type,column_name,parameter_value from checkup_parameter WHERE enabled="Y" and checkup_form_section_id in (' . $checkup . ')) as c inner JOIN checkup_form_section on checkup_form_section.section_id=c.checkup_form_section_id and Status="Active" order by checkup_form_section_id,column_order';
$result1 = mysqli_query($conn, $sql1);
error_log("heading query " . $sql1);
$sql2 = "select c.*,p.* from checkup_form c left join patient_master p on c.emp_id = p.id where p.designation_id='".$designation_id."' and c.checkup_type_id='" . $checkup_type_id . "' and (c.current_status='DRA') $dates";
$result2 = mysqli_query($conn, $result2);
error_log("Fetched result Value " . $sql2);
?>
<table border="1">
<thead>
<tr>
<th rowspan="2">Examination date </th>
<th rowspan="2">Examination Type</th>
<th colspan="11">Patient details</th>
<?php
while ($row1 = mysqli_fetch_array($result)) {
?>
<th colspan="<?= $row1['count'] ?>">
<?= $row1['section_name'] ?>
</th>
<?php
}
?>
</tr>
<tr>
<th>Employee Code</th>
<th>Patient name</th>
<th>Father name</th>
<th>DOB</th>
<th>Ticket No</th>
<th>Gender</th>
<th>Blood Group</th>
<th>Designation</th>
<th>Department</th>
<th>Adhaar Number</th>
<th>Phone</th>
<?php
mysqli_free_result($result1);
$result1 = mysqli_query($conn, $sql1);
while ($row2 = mysqli_fetch_array($result1)) {
?>
<th><?= $row2['parameter_name'] ?></th>
<?php
}
?>
</tr>
</thead>
<?php
mysqli_free_result($result2);
$result2 = mysqli_query($conn, $sql2);
while ($row3 = mysqli_fetch_assoc($result2)) {
?>
<tr>
<td><?= $row3['checkup_date'] ?></td>
<td><?= getFieldFromTable('checkup_type_name', 'checkup_type', 'checkup_type_id', $checkup_type_id) ?></td>
<td><?= $row3['emp_code'] ?></td>
<td><?= $row3['patient_name'] ?></td>
<td><?= $row3['father_name'] ?></td>
<td><?= $row3['dob'] ?></td>
<td><?= $row3['ticket_no'] ?></td>
<td><?= $row3['gender'] ?></td>
<td><?= $row3['blood_group'] ?></td>
<td><?= getFieldFromTable('designation_name', 'designation', 'designation_id', $row3['designation_id']) ?>
</td>
<td><?= getFieldFromTable('dept_name', 'department', 'dept_id', $row3['dept_id']) ?></td>
<td><?= $row3['aadhar_no'] ?></td>
<td><?= $row3['primary_phone'] ?></td>
<?php
$data = "select distinct cf.checkup_form_key,cf.checkup_form_value,cf.checkup_form_id,c.* ,cp.input_type from checkup_form c left join checkup_form_key_value cf on c.checkup_id=cf.checkup_form_id left join checkup_parameter cp on cp.`column_name`=cf.checkup_form_key where checkup_form_section_id in (" . $checkup . ") and c.checkup_type_id='" . $checkup_type_id . "' and emp_id='" . $row3['emp_id'] . "' and c.checkup_id='" . $row3['checkup_id'] . "' and c.checkup_type_id='" . $checkup_type_id . "' and enabled='Y' $dates order by checkup_form_section_id,column_order";
error_log("data query " . $data);
$result3 = mysqli_query($conn, $data);
while ($row_data = mysqli_fetch_assoc($result3)) {
?>
<?php
if ($row_data['input_type'] == 'select') {
?>
<td><?= getFieldFromTable('parameter_value_name', 'checkup_parameter_value', 'parameter_value_id', $row_data['checkup_form_value']) ?>
</td>
<?php
} else if ($row_data['input_type'] == 'multiselect') {
?>
<td><?= getCommaSeperatedValuesForInClause("select parameter_value_name from checkup_parameter_value", 'parameter_value_id', $row_data['checkup_form_value']) ?>
</td>
<?php
} else {
?>
<td>
<?= $row_data['checkup_form_value'] ?>
</td>
<?php
}
}
?>
</tr>
<?php
}
?>
</table>
</body>