<?php session_start();

// error_log($_REQUEST['patient_id']);
// error_log('Abcde');
include('log_entry.php');
include_once("includes/functions.php");
?>

<?php

$queryc = "select * from company_profile ";

//echo $query;

$resultc = mysqli_query($conn, $queryc);

$row_company = mysqli_fetch_array($resultc);

@extract($row_company);

$query = "SELECT * FROM indent_master where indent_id='" . $_REQUEST['flex_indent_id'] . "'";
$result = mysqli_query($conn, $query);
$rows = mysqli_fetch_assoc($result);
error_log("indentid" . $query);

$item_desc = "";
$item_qty = "";
$sql_q = "select * from indent_items where indent_id='" . $_REQUEST['flex_indent_id'] . "'";
error_log("indent sql" . $sql_q);
$result_q = mysqli_query($conn, $sql_q);
while ($row2 = mysqli_fetch_assoc($result_q)) {
    $item_desc = $item_desc . ' <p> ' . getItemWithFormName($row2['item_id']) . '</p>';
    $item_unit_id = getTableFieldValue('tbl_items', 'unit_id', 'item_id', $row2['item_id']);
    $item_unit = getTableFieldValue(' unit_master', 'unit_name', 'unit_id', $item_unit_id);
    $item_qty = $item_qty . ' <p> ' . $row2['indent_qty'] . ' ' . $item_unit . '</p>';
}

?>

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

</head>
<style type="text/css">
    @page {
        margin: 20px;
    }

    .btn {
        background-color: #4CAF50;
        border-radius: 5%;
        /* Green */
        border: none;
        color: white;
        padding: 15px 32px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        margin: 4px 2px;
        cursor: pointer;
    }

    @media print {
        #printPageButton {
            display: none;
        }
</style>

<table cellspacing="0" width="100%">

    <tr>
        <td rowspan="4">
            <img src="data:image/jpeg;base64,<?php echo base64_encode($row_company['company_logo']) ?>" style="width: 120px; height: 120px;" />
        </td>


        <td align="left"><b style="font-size:30px;font-weight: 800;margin-left: 50px">
                <?php echo $row_company['company_name'] ?>
            </b></td>

    </tr>




    <tr>
        <td align="left"><b style="font-weight: 800;margin-left: 130px">MEDICAL DEPARTMENT</b>
            <br><b style="font-weight: 800;margin-left: 123px"><?php echo $row_company['address'] ?></b>
        </td>

    </tr>

</table>
<br>
<br>
<table cellspacing="0" align="center" width="90%">

    <tr>

        <td align="center"><b style="font-size: 20px;font-weight: 800;text-decoration: underline;">INDENT</b></td>

    </tr>

</table>
<br>
<table align="center" width="90%">
    <strong>
        <tr bgcolor="#eeeeee">
            <td align="left" width="10%">Indent Date</td>
            <td align="left" width="10%">Remarks</td>
            <td valign="top" align="left" width="15%">Item Name</td>
            <td valign="top" width="15%" align="left">Purchased Qty</td>
    </strong></tr>
    <tr>
        <td><?php echo date_format(date_create($rows['indent_date']), "d-M-Y ") ?></td>
        <td><?php echo $rows['remarks'] ?></td>
        <td><?php echo $item_desc ?></td>
        <td><?php echo $item_qty ?></td>
    </tr>
</table>
<div align="center">

    <button align="center" id="printPageButton" class="btn btn-success" onClick="window.print();">Print</button>
</div>


<script>
    $(document).ready(function() {
        window.print();

    });
</script>