ohctech_p8/procurement_pdf.php
2024-10-16 19:18:52 +05:30

177 lines
6.3 KiB
PHP

<?php session_start();
include('includes/config/config.php');
include_once("includes/functions.php");
include_once("log_entry.php");
mysqli_query($conn, 'SET character_set_results=utf8');
error_reporting(0);
$query = "select * from company_profile where company_id = 5";
$result = mysqli_query($conn, $query);
$row_for_company = mysqli_fetch_array($result);
@extract($row_for_company);
?>
<!doctype html>
<html lang="en">
<head>
<title>Procurement data</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
u {
border-bottom: 1px dotted #000;
text-decoration: none;
}
.print {
position: absolute;
right: 11%;
}
@media print {
footer {
page-break-after: always;
}
#printPageButton {
display: none;
}
}
body {
font-family: Arial, Helvetica, sans-serif
}
table {
border-collapse: collapse;
}
.canteen {
background-color: #8E44AD;
/* position: relative; */
left: 20%;
text-align: center;
padding-left: 10%;
padding-right: 10%;
color: white;
}
</style>
</head>
<?php
include('pdf_header.php');
include('pdf_ohc_header.php');
?>
<H2 align='center' style="text-decoration: underline;">Procurement Report <button id="printPageButton"
class="btn btn-success print" onClick="window.print();">Print</button>
</H2>
<br>
<table border="1 black" width="100%">
<?php
// $sql = "select procurement.procurement_id, procurement.procurement_refno,procurement.procurement_date from procurement order by procurement.procurement_id";
//echo
$sql = "select procurement.procurement_id, procurement.procurement_refno,procurement.procurement_date from procurement where date_format(date(procurement_date),'%Y-%m-%d') between str_to_date('" . trim($_POST["procurement_date1"]) . "','%d-%m-%Y') and str_to_date('" . trim($_POST["procurement_date2"]) . "','%d-%m-%Y') ";
$result = mysqli_query($conn, $sql);
error_log("filter:".$sql);
?><strong>
<tr bgcolor="#eeeeee">
<td valign="top" align="left" width="2%">Sr No.</td>
<td align="left" width="15%">Procurement Reference No.</td>
<td align="left" width="10%">Procurement Date</td>
<td valign="top" align="left" width="30%">Item name</td>
<td valign="top" width="5%" align="left">Quantity</td>
<!-- <td width="5%" valign="top" align="left">Batch</td> -->
<!-- <td valign="top" width="10%" align="left">Expiry</td> -->
<td valign="top" align="left" width="10%">Amount</td>
<td valign="top" align="left" width="15%">Item Remarks</td>
</strong>
</tr>
<?php
$srNo=0;
while ($row1 = mysqli_fetch_array($result)) {
$srNo++;
$sql_procure_items = "select * from procurement_items where procurement_id='" . $row1['procurement_id'] . "'";
$results_procure_items = mysqli_query($conn, $sql_procure_items);
$item_desc = "";
$item_qty = "";
$item_batch = "";
$item_expiry_date = "";
$item_rate = "";
$rows_count = mysqli_num_rows($results_procure_items);
?><tr>
<!-- <td rowspan="<?php echo $rows_count ?>"><?php echo $row1['procurement_id'];
?></td> -->
<td rowspan="<?php echo $rows_count ?>"><?php echo $srNo;;
?></td>
<td rowspan="<?php echo $rows_count ?>"><?php echo $row1['procurement_refno'] ?>
</td>
<td rowspan="<?php echo $rows_count ?>"><?php echo $row1['procurement_date'] ?>
</td><?php
$count = 0;
while ($row_procure_items = mysqli_fetch_assoc($results_procure_items)) {
++$count;
if ($count == 1) {
$item_desc = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row_procure_items['item_id']);
$item_qty = $row_procure_items['qty'];
// $item_batch = $row_procure_items['batch'];
// $item_expiry_date = date_format(date_create($row_procure_items['expiry']), "d-M-Y ");
$item_rate = $row_procure_items['net_value'];
$item_remarks = $row_procure_items['remarks'];
?><td><?php echo $item_desc ?></td>
<td><?php echo $item_qty ?></td>
<!-- <td><?php echo $item_batch ?></td> -->
<!-- <td><?php echo $item_expiry_date ?></td> -->
<td><?php $total_cost+=number_format((float)$item_rate, 2, '.', '');
echo number_format((float)$item_rate, 2, '.', '')?></td>
<td><?php echo $item_remarks ?></td>
<?php } else {
$item_desc = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row_procure_items['item_id']);
$item_qty = $row_procure_items['qty'];
// $item_batch = $row_procure_items['batch'];
// $item_expiry_date = date_format(date_create($row_procure_items['expiry']), "d-M-Y ");
$item_rate = $row_procure_items['net_value'];
$item_remarks = $row_procure_items['remarks'];
?>
</tr>
<tr>
<td><?php echo $item_desc ?></td>
<td><?php echo $item_qty ?></td>
<!-- <td><?php echo $item_batch ?></td> -->
<!-- <td><?php echo $item_expiry_date ?></td> -->
<td><?php $total_cost+=number_format((float)$item_rate, 2, '.', '');
echo number_format((float)$item_rate, 2, '.', '')?></td>
<td><?php echo $item_remarks ?></td>
</tr>
<?php }
}
if ($rows_count == 1) {
?></tr><?php
}
}
?>
<tr>
<td align="right" colspan="5">Total Amount</td>
<td align="left" colspan="2"><?=number_format((float)$total_cost, 2, '.', '')?></td>
</tr>
</table>
<!-- <style></style>
<?php
// include('pdf_footer.php');
?>