183 lines
7.5 KiB
PHP
183 lines
7.5 KiB
PHP
<?php
|
|
include('includes/config/config.php');
|
|
include('includes/functions.php');
|
|
|
|
$ohc = mysqli_real_escape_string($conn, $_POST['pohcid']);
|
|
$program_name = mysqli_real_escape_string($conn, $_POST['program_name']);
|
|
$activity_name = mysqli_real_escape_string($conn, $_POST['activity_name']);
|
|
$role_type = mysqli_real_escape_string($conn, $_POST['center_type']);
|
|
$from_date1 = date('Y-m-d', strtotime($_POST['procurement_date1']));
|
|
$from_date2 = date('Y-m-d', strtotime($_POST['procurement_date2']));
|
|
?>
|
|
|
|
<body>
|
|
<table width="100%">
|
|
<tr align="right">
|
|
<td style="font-size: 12px">
|
|
<strong>Selected Location: <?php if ($ohc == 'All') {
|
|
echo 'All';
|
|
} else {
|
|
echo htmlspecialchars(getFieldFromTable('ohc_type_name', 'ohc_type', 'ohc_type_id', $ohc));
|
|
} ?></strong>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<table width="100%">
|
|
<tr>
|
|
<td style="font-size: 15px;">
|
|
<strong style="margin-left: 500px">Indent Report - <?php echo $role_type ?></strong>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" style="font-size: 12px">
|
|
<strong>
|
|
From Date: <?= date("d-M-Y", strtotime($from_date1)) ?>
|
|
To Date: <?= date("d-M-Y", strtotime($from_date2)) ?>
|
|
</strong>
|
|
</td>
|
|
<td align="right" style="font-size: 15px">
|
|
<button id="printPageButton" class="btn btn-success" onclick="window.print();">Print</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<br>
|
|
<table border="1" width="100%" cellspacing="0">
|
|
<tr bgcolor="#eeeeee">
|
|
<td align="left" width="2%">Sr.</td>
|
|
<td align="left" width="12%">Location</td>
|
|
<td align="left" width="12%">Item Name</td>
|
|
<td align="left" width="12%">Specifications</td>
|
|
<td align="left" width="12%">Make</td>
|
|
<td align="left" width="12%">Indent Ref No</td>
|
|
<td align="left" width="10%">Indent Date</td>
|
|
<td align="left" width="8%">Indent Qty</td>
|
|
<td align="left" width="8%">Item Rate</td>
|
|
<td align="left" width="10%">RFQ No</td>
|
|
<td align="left" width="10%">PO Ref No</td>
|
|
<td align="left" width="10%">PO Date</td>
|
|
<td align="left" width="10%">Payment Terms</td>
|
|
<td align="left" width="10%">Vendor Name</td>
|
|
<td align="left" width="13%">GRN Ref No</td>
|
|
|
|
</tr>
|
|
<?php
|
|
$ohc_filter = ($ohc == 'All') ? '' : "ohc_type_id = '$ohc' AND";
|
|
$sql = "SELECT * FROM indent_master WHERE $ohc_filter role_type = '$role_type' AND indent_date BETWEEN '$from_date1' AND '$from_date2' ORDER BY indent_date DESC";
|
|
$result = mysqli_query($conn, $sql);
|
|
$count = 1;
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
|
|
|
$items_sql = "SELECT item_id,indent_qty FROM indent_items WHERE indent_id = '" . $row['indent_id'] . "'";
|
|
$items_result = mysqli_query($conn, $items_sql);
|
|
|
|
while ($item_row = mysqli_fetch_assoc($items_result)) {
|
|
$item_name = getFieldFromTable('item_name', 'tbl_items', 'item_id', $item_row['item_id']);
|
|
$specifications = getFieldFromTable('specifications', 'tbl_items', 'item_id', $item_row['item_id']);
|
|
$make = getFieldFromTable('make', 'tbl_items', 'item_id', $item_row['item_id']);
|
|
$indent_qty = $item_row['indent_qty'];
|
|
|
|
|
|
$po_sql = "SELECT DISTINCT pm.po_date, pm.po_no, pi.vendor_id, pi.item_id
|
|
FROM po_master pm
|
|
JOIN po_items pi ON pm.po_id = pi.po_id
|
|
WHERE pm.indent_id = '" . $row['indent_id'] . "'
|
|
AND pi.item_id = '" . $item_row['item_id'] . "'";
|
|
|
|
error_log($po_sql . " dipak mali");
|
|
|
|
$po_result = mysqli_query($conn, $po_sql);
|
|
$pos = "";
|
|
$po_date = "";
|
|
$vendor_name = "";
|
|
$vendor_id = "";
|
|
|
|
while ($po_row = mysqli_fetch_assoc($po_result)) {
|
|
$pos .= $po_row['po_no'] . " ";
|
|
$po_date = $po_row['po_date'];
|
|
|
|
$vendor_id = $po_row['vendor_id'];
|
|
}
|
|
|
|
|
|
|
|
$grn_sql = "SELECT DISTINCT gm.vendor_id, gm.item_grn_no, gi.vendor_rate, gi.item_id
|
|
FROM grn_master gm
|
|
JOIN grn_items gi ON gm.grn_id = gi.grn_id
|
|
WHERE gm.indent_id = '" . $row['indent_id'] . "'
|
|
AND gi.item_id = '" . $item_row['item_id'] . "'";
|
|
|
|
$grn_result = mysqli_query($conn, $grn_sql);
|
|
$grns = "";
|
|
|
|
$vendor_name = "";
|
|
|
|
while ($grn_row = mysqli_fetch_assoc($grn_result)) {
|
|
$grns .= $grn_row['item_grn_no'] . " ";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$rfq_sql = "SELECT DISTINCT(rfq_no) FROM quotation_list WHERE indent_id = '" . $row['indent_id'] . "'";
|
|
$rfq_result = mysqli_query($conn, $rfq_sql);
|
|
$rfqs = "";
|
|
while ($rfq_row = mysqli_fetch_assoc($rfq_result)) {
|
|
$rfqs .= $rfq_row['rfq_no'] . " ";
|
|
}
|
|
|
|
$vendor_rates = '';
|
|
|
|
|
|
$rate_sql = "SELECT vendor_rate,payment_terms,rfq_qty,per_unit_rate FROM quotation_list
|
|
WHERE indent_id = '" . $row['indent_id'] . "'
|
|
AND item_id = '" . $item_row['item_id'] . "'
|
|
AND vendor_id = '$vendor_id'
|
|
ORDER BY quotation_id DESC LIMIT 1";
|
|
error_log($rate_sql . "dushant mali");
|
|
|
|
$rate_result = mysqli_query($conn, $rate_sql);
|
|
if ($rate_row = mysqli_fetch_assoc($rate_result)) {
|
|
$raw_rate = $rate_row['vendor_rate'] / $rate_row['rfq_qty'];
|
|
|
|
|
|
$vendor_rates = round($raw_rate, 3);
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
<tr>
|
|
<td><?= $count ?></td>
|
|
<?php $indent_location = getFieldFromTable('ohc_type_id', 'indent_master', 'indent_ref_no', $row['indent_ref_no']); ?>
|
|
<td><?= getFieldFromTable('ohc_type_name', 'ohc_type', 'ohc_type_id', $indent_location) ?></td>
|
|
<td><?= htmlspecialchars($item_name) ?></td>
|
|
<td><?= htmlspecialchars($specifications) ?></td>
|
|
<td><?= htmlspecialchars($make) ?></td>
|
|
<td><?= htmlspecialchars($row['indent_ref_no']) ?></td>
|
|
<td><?= date("d-m-Y", strtotime($row['indent_date'])) ?></td>
|
|
<td><?= $indent_qty ?></td>
|
|
<td><?= $vendor_rates ?></td>
|
|
<td><?= $rfqs ?></td>
|
|
<td><?= $pos ?></td>
|
|
<td><?php if ($po_date) {
|
|
echo date("d-m-Y", strtotime($po_date));
|
|
} ?></td>
|
|
<td><?php echo $rate_row['payment_terms'] ?></td>
|
|
<td><?= getFieldFromTable('employer_contractor_name', 'employer_contractor', 'id', $vendor_id) ?></td>
|
|
<td><?= $grns ?></td>
|
|
|
|
</tr>
|
|
<?php
|
|
$count++;
|
|
}
|
|
}
|
|
?>
|
|
</table>
|
|
<div style="text-align: center; margin-top: 20px;">
|
|
<button id="printPageButton" class="btn btn-success" onclick="window.print();">Print</button>
|
|
</div>
|
|
</body>
|