ESH/asset_procurement_excel.php
2024-10-23 18:28:06 +05:30

162 lines
6.7 KiB
PHP

<?php
header("Content-type:application/octet-stream");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=asset_management_report.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>
<?php include('excel_ohc_header.php'); ?>
<table width="100%">
<tr>
<td colspan="1"></td>
<td colspan="2" align='center'><strong style="margin-left: 120px;text-decoration: underline;">Asset
Management
Report</strong>
</td>
</tr>
</table>
<?php
if ($_REQUEST['asset_procurement_date1'] && $_REQUEST['asset_procurement_date2'] ) {
echo "<h5>From Date : ". $_REQUEST['asset_procurement_date1']. " To Date : " . $_REQUEST['asset_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 a.procurement_id, a.procurement_refno,a.procurement_date from procurement a left join procurement_items b on a.procurement_id=b.procurement_id where b.item_id in (select item_id from tbl_items where cat='8') and date_format(date(a.procurement_date),'%Y-%m-%d') between str_to_date('" . trim($_POST["asset_procurement_date1"]) . "','%d-%m-%Y') and str_to_date('" . trim($_POST["asset_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>
</body>