ESH/procurement_excel.php

210 lines
8.5 KiB
PHP
Raw Normal View History

2024-10-23 18:28:06 +05:30
<?php
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=excel_procurement.xls");
header("Pragma: no-cache");
header("Expires: 0");
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
?>
<?php
include('includes/config/config.php');
include('includes/functions.php');
//include('pop_up_top.php');
error_reporting(E_ERROR | E_PARSE);
error_log("error" . $_REQUEST['appointment_id_pdf']);
$unitMap = getKeyValueMap('unit_master', 'unit_id', 'unit_name');
$queryc = "select * from company_profile ";
// echo $query;
error_log("APPOINTMENT ID PDF::" . $_REQUEST['appointment_id_pdf']);
$resultc = mysqli_query($conn, $queryc);
$row_company = mysqli_fetch_array($resultc);
@extract($row_company);
$total_cost=0;
?>
<body>
<table width="100%">
<tr>
<td width="40%">
<?php if (isset($row_company['company_logo']) && $row_company['company_logo'] != null) { ?>
<img src="data:<?php echo $row_company['image_type'] ?>;base64,<?php echo base64_encode($row_company['company_logo']) ?>"
style="width: 150px; height: 60px; margin: 0px; padding: 0px;">
<?php } ?>
</td>
<td width="90%" align="center">
<div style="margin-left: 20px;">
<strong style="margin-right: 110px ;font-size: 15px ;text-align: center;">
<?php echo $row_company['company_name'] ?>
<br>
<pre style="margin-top: 0px; font-size:10px;"><?php echo $row_company['address'] ?></pre>
</strong>
</div>
</td>
<?php if (isset($row_company['right_com_logo']) && $row_company['right_com_logo'] != null) { ?>
<td width="20%" align="right"><img
src="data:<?php echo $row_company['right_image_type'] ?>;base64,<?php echo base64_encode($row_company['right_com_logo']) ?>"
style="width: 150px; height: 60px; margin: 0px; padding: 0px;">
</td>
<?php } ?>
<td width="40%">
<!-- <strong>OHC Mob.</strong> -->
<!-- <?php echo $row_company['primary_phone'] ?><br> -->
<pre style="font-size:10px;"><strong><?php echo $row_company['ohc_details'] ?></strong></pre><br>
<!-- <b style="font-size: 12px">Email: </b><span style="font-size: 12px"> -->
<!-- <?php echo strtolower($row_company['primary_email']) ?> -->
<!-- </span> -->
</td>
</tr>
<tr rowspan="2">
<td colspan="1"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2"><strong style="margin-left: 120px;text-decoration: underline;">Procurement List</strong>
</td>
</tr>
</table>
<?php
if ($_REQUEST['procurement_date1'] && $_REQUEST['procurement_date2'] ) {
echo "<h5>From Date : ". $_REQUEST['procurement_date1']. " To Date : " . $_REQUEST['procurement_date2'] . "</h5>";}
?>
<!-- <div style="display: inline-block;">
<h3><?php echo $row_company['company_name'] ?></h3>
<strong style="float: right;">Mob.<?php echo $row_company['primary_phone'] ?></strong>
</div>
<div style="margin-top: -50px;">
<h5 style="text-align: center"><?php echo $row_company['address'] ?></h5>
</div>
<div>
<h5 style="text-align: center;text-decoration: underline;">OPD TICKET</h5>
</div> -->
<!-- -->
<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>