csrtechnew.ohctech.in/quotation_comp_report_excel.php
2025-04-14 13:28:09 +05:30

132 lines
3.3 KiB
PHP

<?php
include('includes/config/config.php');
include('includes/functions.php');
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=quotation_report_excel.xls");
header("Pragma: no-cache");
header("Expires: 0");
// $date1 = $_REQUEST['date1'];
// $date2 = $_REQUEST['date2'];
// $date1 = date("Y-m-d", strtotime($date1));
// $date2 = date("Y-m-d", strtotime($date2));
$indent_id = $_POST['qt_ind'];
?>
<link href="includes/css-js/admin.css" rel="stylesheet" type="text/css" />
<style>
@page {
margin: 15px;
}
.btn {
background-color: #4CAF50;
border-radius: 5%;
border: none;
color: white;
padding: 5px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 12px;
margin: 4px 2px;
cursor: pointer;
}
@media print {
#printPageButton {
display: none;
}
}
</style>
<?php include('excel_ohc_header.php') ?>
<table width="100%">
<tr>
<td align="center" style="font-size: 15px;"><strong align='center'>Quotation Comparison Report</strong></td>
</tr>
<tr>
<td align="left" ><h4>Indent No: <?php echo getTableFieldValue('indent_master','indent_ref_no','indent_id',$indent_id) ; ?>
<!-- To date: <?php
// echo $date2; ?> -->
</h4> <button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button></td>
</tr>
</table>
<table border="1" width="100%" cellspacing="0">
<tr bgcolor="#eeeeee">
<td align="left" width="2%" rowspan="2" >Sr.</td>
<td align="left" width="10%" >Item Name</td>
<td align="left" width="5%" >Qty</td>
<td align="left" width="5%" >UoM</td>
<?php
function getRate($ind,$ven,$item){
$sql = "SELECT * FROM quotation_list where indent_id='".$ind."' and item_id='".$item."' and vendor_id='".$ven."'";
$result = mysqli_query($GLOBALS['conn'], $sql);
$row = mysqli_fetch_array($result);
return "<td>".round( $row['vendor_rate']/$row['rfq_qty'] ,2)."</td><td>".$row['vendor_rate']."</td>";
}
$sql = "SELECT distinct(vendor_id) FROM quotation_list where indent_id='".$indent_id."'";
$result = mysqli_query($conn, $sql);
$vendor_arr=array();
while ($row1 = mysqli_fetch_array($result)) {
array_push($vendor_arr,$row1['vendor_id']);
?>
<td colspan="2">
<?= getTableFieldValue('employer_contractor','employer_contractor_name','id',$row1['vendor_id'])?>
</td>
<?php }?>
<tr>
<tr bgcolor="#eeeeee">
<td colspan="4"></td>
<?php for($c=0;$c<count($vendor_arr);$c++) {?>
<td>Rate</td><td>Total Price</td>
<?php }?>
</tr>
<?php
$count=1;
$sql_ind = "SELECT * FROM indent_items where indent_id='".$indent_id."'";
$result_ind = mysqli_query($conn, $sql_ind);
while($row_ind = mysqli_fetch_array($result_ind)){?>
<tr>
<td><?=$count?></td>
<td>
<?php echo getItemWithFormName($row_ind['item_id']); ?>
</td>
<td>
<?php echo $row_ind['indent_qty']; ?>
</td>
<td>
<?= getTableFieldValue('unit_master', 'unit_name', 'unit_id',getTableFieldValue('tbl_items', 'unit_id', 'item_id', $row_ind['item_id'])); ?>
</td>
<?php for($c=0;$c<count($vendor_arr);$c++) {
echo getRate($indent_id,$vendor_arr[$c],$row_ind['item_id']);
}?>
</tr>
<?php
$count++;
}?>
</table>
</body>
</html>