147 lines
5.9 KiB
PHP
147 lines
5.9 KiB
PHP
<?php include('sub_center_header.php'); ?>
|
|
|
|
<?php
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
$records_per_page = 5;
|
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
$offset = ($page - 1) * $records_per_page;
|
|
$search = isset($_GET['search']) ? $_GET['search'] : '';
|
|
|
|
$hari_ohc_id = getFieldFromTable('ohc_type_id', 'ohc_type', 'ohc_code', 'HS');
|
|
|
|
$sql = "SELECT si.*, pm.patient_name
|
|
FROM hari_sub_center_issue si
|
|
LEFT JOIN patient_master pm ON si.beneficiary = pm.id
|
|
WHERE si.issue_ohc_type_id = ? AND si.sub_center = ?
|
|
LIMIT ?, ?";
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->bind_param("iiii", $hari_ohc_id, $sub_c_id, $offset, $records_per_page);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
$total_sql = "SELECT COUNT(*) FROM hari_sub_center_issue WHERE issue_ohc_type_id = ? AND sub_center = ?";
|
|
$total_stmt = $conn->prepare($total_sql);
|
|
$total_stmt->bind_param("ii", $hari_ohc_id, $sub_c_id);
|
|
$total_stmt->execute();
|
|
$total_stmt->bind_result($total_rows);
|
|
$total_stmt->fetch();
|
|
$total_stmt->close();
|
|
|
|
$total_pages = ceil($total_rows / $records_per_page);
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Issue / Sale</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
</head>
|
|
<style>
|
|
.pagination .page-link { color: #007bff; }
|
|
.pagination .page-item.active .page-link {
|
|
background-color: #007bff;
|
|
border-color: #007bff;
|
|
color: white;
|
|
}
|
|
.pagination .page-item .page-link:hover {
|
|
background-color: #f8f9fa;
|
|
color: #007bff;
|
|
}
|
|
</style>
|
|
|
|
<body>
|
|
<div class="container mt-4">
|
|
<h6 class="text-center">Issue / Sale</h6>
|
|
<form method="GET" action="" class="form-inline mb-3">
|
|
<input type="text" name="search" class="form-control mr-2" placeholder="Search..." value="<?php echo htmlspecialchars($search); ?>">
|
|
<button type="submit" class="btn btn-primary">Search</button>
|
|
</form>
|
|
<a href="add_sub_center_item_issue_hariyadi.php" class="btn btn-success mb-3">Item Issue</a>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-hover table-sm">
|
|
<thead class="thead-warning">
|
|
<tr>
|
|
<th>Sr. No</th>
|
|
<th>Issue Ref No</th>
|
|
<th>Issue Date</th>
|
|
<th>Beneficiary</th>
|
|
<th>Issued Items</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if ($result->num_rows > 0) {
|
|
$sr_no = $offset + 1;
|
|
while ($row = $result->fetch_assoc()) {
|
|
$issue_date = ($row['issue_date'] != '0000-00-00') ? date("d-M-Y", strtotime($row['issue_date'])) : '';
|
|
|
|
echo "<tr>";
|
|
echo "<td>" . $sr_no++ . "</td>";
|
|
|
|
echo "<td>
|
|
<form id='issue_form_".$row['stock_issue_id']."' action='sub_center_issue_bill.php' method='POST' target='_blank' style='display:none;'>
|
|
<input type='hidden' name='stock_issue_id' value='".$row['stock_issue_id']."'>
|
|
</form>
|
|
<a href='#' onclick=\"document.getElementById('issue_form_".$row['stock_issue_id']."').submit();\">".$row['issue_ref_no']."</a>
|
|
</td>";
|
|
|
|
echo "<td>" . $issue_date . "</td>";
|
|
echo "<td>" . htmlspecialchars($row['patient_name']) . "</td>";
|
|
|
|
$item_desc = '';
|
|
$sql_issue_items = "SELECT i.item_name, u.unit_name, sii.issue_qty
|
|
FROM hari_sub_center_issue_items sii
|
|
JOIN tbl_items i ON sii.item_id = i.item_id
|
|
JOIN unit_master u ON i.unit_id = u.unit_id
|
|
WHERE sii.stock_issue_id = ?";
|
|
$stmt_items = $conn->prepare($sql_issue_items);
|
|
$stmt_items->bind_param("i", $row['stock_issue_id']);
|
|
$stmt_items->execute();
|
|
$items_result = $stmt_items->get_result();
|
|
while ($row_issue_items = $items_result->fetch_assoc()) {
|
|
$item_desc .= "<p>" . $row_issue_items['item_name'] . " <b>Qty: " . $row_issue_items['issue_qty'] . " " . $row_issue_items['unit_name'] . "</b></p>";
|
|
}
|
|
echo "<td>" . $item_desc . "</td>";
|
|
echo "</tr>";
|
|
}
|
|
} else {
|
|
echo "<tr><td colspan='6'>No records found</td></tr>";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php if ($total_rows > 0) { ?>
|
|
<nav>
|
|
<ul class="pagination justify-content-center">
|
|
<?php
|
|
if ($page > 1) {
|
|
echo '<li class="page-item"><a class="page-link" href="?page=' . ($page - 1) . '&search=' . urlencode($search) . '">Previous</a></li>';
|
|
}
|
|
|
|
for ($i = 1; $i <= $total_pages; $i++) {
|
|
echo '<li class="page-item ' . ($i == $page ? 'active' : '') . '">';
|
|
echo '<a class="page-link" href="?page=' . $i . '&search=' . urlencode($search) . '">' . $i . '</a>';
|
|
echo '</li>';
|
|
}
|
|
|
|
if ($page < $total_pages) {
|
|
echo '<li class="page-item"><a class="page-link" href="?page=' . ($page + 1) . '&search=' . urlencode($search) . '">Next</a></li>';
|
|
}
|
|
?>
|
|
</ul>
|
|
</nav>
|
|
<?php } ?>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
|
</body>
|
|
</html>
|