csrtechnew.ohctech.in/download_bio_medical_annual_report_pdf.php
2025-04-14 13:28:09 +05:30

79 lines
2.1 KiB
PHP

<style>
.button-container1 {
text-align: right;
margin-right: 4rem;
margin-bottom: 1rem;
}
#saveAsPdfBtn {
background-color: blue;
padding: 10px 20px;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
@media print {
#saveAsPdfBtn {
display: none;
}
}
</style>
<?php
include('includes/config/config.php');
include_once('includes/functions.php');
if (isset($_REQUEST['startDate2']) && isset($_REQUEST['endDate2'])) {
$from_date = $_REQUEST['startDate2'];
$to_date = $_REQUEST['endDate2'];
$from_year = date('Y', strtotime($from_date));
$to_year = date('Y', strtotime($to_date));
if (isset($_REQUEST['plant'])) {
$ohc_type_id = $_REQUEST['plant'];
if ($from_year === $to_year) {
$query = "SELECT form_data FROM bio_waste_form_doc WHERE for_year = ? AND ohc_type_id = ?";
$stmt = mysqli_prepare($conn, $query);
if ($stmt) {
mysqli_stmt_bind_param($stmt, "ss", $from_year, $ohc_type_id);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$html_content = '';
while ($row = mysqli_fetch_assoc($result)) {
$html_content .= $row['form_data'];
}
if (!empty($html_content)) {
echo $html_content;
?>
<div class="button-container1" contenteditable="false" class="text-right m-5">
<button type="button" id="saveAsPdfBtn" onclick="printPage()">Download as PDF</button>
</div>
<script>
function printPage() {
window.print();
}
</script>
<?php
} else {
echo "There is no form data available at this date range.";
}
exit;
}
} else {
echo "Error: Start year and end year are different.";
}
}
}
?>