ESH/generate_barcode.php

96 lines
2.5 KiB
PHP
Raw Permalink Normal View History

2024-10-23 18:28:06 +05:30
<?php
require 'bar_code_new/vendor/autoload.php';
use Picqer\Barcode\BarcodeGenerator;
use Picqer\Barcode\BarcodeGeneratorSVG;
$generator = new BarcodeGeneratorSVG();
include('includes/functions.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$patient_id = $_POST['emp_id'];
$text2 = $_POST['checkup_id'];
$text3 = $_POST['checkup_section_id'];
$tests = implode(',', $_POST['checkup_section_id']);
$second_part = 0;
if (is_array($text3)) {
sort($text3);
$second_part = $text3[0];
} else {
$second_part = $text3[0];
}
$barcodeCount = $_POST['barcode_count'];
error_log("all section ids " . print_r($text3, true) . " second part " . $second_part);
?>
<style type="text/css">
.btn {
background-color: #4CAF50;
border-radius: 5%;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
@media print {
#printPageButton {
display: none;
}
}
</style>
<center>
<div>
<div>
<strong style="font-size:8px"><?php echo getFieldFromTable('patient_name', 'patient_master', 'id', $patient_id). " (" .getFieldFromTable('emp_code', 'patient_master', 'id', $patient_id).")"; ?>
<span>
<?php
$dob = getTableFieldValue('patient_master', 'dob', 'id', $patient_id);
$from = new DateTime($dob);
$to = new DateTime('today');
echo $from->diff($to)->y;
?> Y/ &nbsp;<?php echo getTableFieldValue('patient_master', 'gender', 'id', $patient_id) ?></span>
</strong>
</div>
<div>
<strong>
<span style="font-size:8px;"><?php echo getCommaSeperatedValuesForInClause("select section_name from checkup_form_section", "section_id", $tests); ?></span>
</strong>
</div>
<button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button>
</div>
</center>
<br>
<center>
<div>
<?php
for ($i = 0; $i < $barcodeCount; $i++) {
$dataToEmbed = $text2 . "" . $second_part;
$barcode = $generator->getBarcode($dataToEmbed, $generator::TYPE_CODE_128, 2, 50);
?>
<img src="data:image/svg+xml;base64,<?php echo base64_encode($barcode); ?>" alt="Barcode"> <br>
<h4> <?= $dataToEmbed ?></h4>
<br>
<?php
}
?>
</div>
</center>
<?php
}
?>