180 lines
6.4 KiB
PHP
180 lines
6.4 KiB
PHP
<?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;
|
|
|
|
$procurement_date1 = $_POST['procurement_date1'];
|
|
$procurement_date2 = $_POST['procurement_date2'];
|
|
$ohc_type_id = $_POST['pohcid'];
|
|
|
|
$agency = $_POST['agency'];
|
|
?>
|
|
|
|
|
|
|
|
<body>
|
|
<table width="100%">
|
|
|
|
|
|
<tr>
|
|
|
|
<td colspan="2" align='center'><strong style="margin-left: 120px;text-decoration: underline;">Procurement
|
|
Report</strong>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
|
|
<td colspan="2" align='center'><strong style="margin-left: 120px;text-decoration: underline;">Agency : <?php echo getFieldFromTable('agency_name','agency','id',$agency); ?></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>";}
|
|
?>
|
|
|
|
|
|
|
|
<br>
|
|
|
|
|
|
<table border="1 black" width="100%">
|
|
<?php
|
|
$procurement_date1 = $_POST['procurement_date1'];
|
|
$procurement_date2 = $_POST['procurement_date2'];
|
|
$ohc_type_id = $_POST['pohcid'];
|
|
|
|
$agency = $_POST['agency'];
|
|
$sql = "SELECT DISTINCT procurement.procurement_id,
|
|
procurement.procurement_refno,
|
|
procurement.procurement_date
|
|
FROM procurement
|
|
INNER JOIN procurement_items
|
|
ON procurement.procurement_id = procurement_items.procurement_id
|
|
INNER JOIN tbl_items
|
|
ON procurement_items.item_id = tbl_items.item_id
|
|
WHERE DATE_FORMAT(procurement.procurement_date, '%Y-%m-%d')
|
|
BETWEEN STR_TO_DATE('$procurement_date1', '%d-%m-%Y')
|
|
AND STR_TO_DATE('$procurement_date2', '%d-%m-%Y')
|
|
AND procurement.ohc_type_id = '$ohc_type_id'
|
|
AND tbl_items.agency = '$agency'
|
|
ORDER BY procurement.procurement_id";
|
|
|
|
|
|
$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="12%">Procurement Reference No.</td>
|
|
<td align="left" width="9%">Procurement Date</td>
|
|
<td width="30%">Item name</td>
|
|
<td width="5%" align="left">Quantity</td>
|
|
<td width="8%" align="left">Per Unit Rate</td>
|
|
<td align="left" width="10%">Amount</td>
|
|
<td align="left" width="15%">Item Remarks</td>
|
|
</strong>
|
|
</tr>
|
|
|
|
<?php
|
|
$srNo = 0;
|
|
while ($row1 = mysqli_fetch_array($result)) {
|
|
$srNo++;
|
|
$sql_procure_items = "
|
|
SELECT
|
|
pi.*,
|
|
ti.item_name
|
|
FROM
|
|
procurement_items pi
|
|
INNER JOIN
|
|
tbl_items ti
|
|
ON
|
|
pi.item_id = ti.item_id
|
|
WHERE
|
|
pi.procurement_id = '" . $row1['procurement_id'] . "'
|
|
AND ti.agency = '$agency'
|
|
ORDER BY
|
|
pi.procurement_id";
|
|
error_log($sql_procure_items."dipak mali");
|
|
$results_procure_items = mysqli_query($conn, $sql_procure_items);
|
|
$rows_count = mysqli_num_rows($results_procure_items);
|
|
|
|
?><tr>
|
|
<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 = $row_procure_items['item_name'];
|
|
$item_qty = $row_procure_items['qty'];
|
|
$item_rate = $row_procure_items['net_value'];
|
|
$item_remarks = $row_procure_items['remarks'];
|
|
$total_cost += number_format((float)$item_rate, 2, '.', '');
|
|
?>
|
|
<td><?php echo $item_desc ?></td>
|
|
<td><?php echo $row_procure_items['qty'] ?></td>
|
|
<td><?php echo number_format((float)$item_rate, 2, '.', '') / $row_procure_items['qty'] ?></td>
|
|
<td><?php echo number_format((float)$item_rate, 2, '.', '') ?></td>
|
|
<td><?php echo $item_remarks ?></td>
|
|
<?php } else {
|
|
$item_desc = $row_procure_items['item_name'];
|
|
$item_qty = $row_procure_items['qty'];
|
|
$item_rate = $row_procure_items['net_value'];
|
|
|
|
$item_remarks = $row_procure_items['remarks'];
|
|
$total_cost += number_format((float)$item_rate, 2, '.', '');
|
|
$item_qty += number_format((float)$item_qty, 2, '.', '');
|
|
?>
|
|
</tr>
|
|
<tr>
|
|
<td><?php echo $item_desc ?></td>
|
|
<td><?php echo $row_procure_items['qty'] ?></td>
|
|
<td><?php echo number_format((float)$item_rate, 2, '.', '') / $row_procure_items['qty'] ?></td>
|
|
<td><?php 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="6">Total Amount</td>
|
|
<td align="left" colspan="2"><?= number_format((float)$total_cost, 2, '.', '') ?></td>
|
|
</tr>
|
|
</table>
|