csrtechnew.ohctech.in/excel_procurement.php

75 lines
3.2 KiB
PHP
Raw Normal View History

2025-04-14 13:28:09 +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');
?>
<body>
<table border="1" width="100%">
<?php
$sql = "select procurement.procurement_id, procurement.procurement_refno,procurement.procurement_date from procurement WHERE ohc_type_id = '".$_SESSION['current_ohcttype']."' order by procurement.procurement_id";
//echo $sql;
$result = mysqli_query($conn,$sql);
//echo $result;
?><strong><tr bgcolor="#eeeeee"><td valign="top" align="left" width="2%" >Id</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%">Rate</td><td valign="top" align="left" width="15%">Item Remarks</td></strong></tr>
<?php
$cc = 1;
while($row1=mysqli_fetch_array($result)){
$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 $cc++;
?></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=$row_procure_items['expiry'];
$item_rate=$row_procure_items['rate'];
$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 echo $item_rate?></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['rate'];
$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 echo $item_rate?></td><td><?php echo $item_remarks?></td></tr>
<?php }
}
if($rows_count==1){
?></tr><?php
}
}
?>
</table>
</body>