<?php
if (!isset($_SESSION)) {
  session_start();
}

require_once("Connections/constants.php");
include("function/function.php");
$apikey = $_SESSION['apikey'];
$username = $_SESSION['facility_name'];
$password = $_SESSION['password'];
$providerId = $_SESSION['provider_id'];
$member_no = $_SESSION['member_no'];

$process_claim_no = $_POST['id'];
list($date_of_consultation, $total_claim, $fullname) = explode("@@", $_POST['idd2']);

$GET_VISIT_HISTORY = array(
  'METHOD' => urlencode('GET_VISIT_HISTORY_DETAILS'),
  'APIKEY' => $apikey,
  'USERNAME' => $username,
  'PASSWORD' => $password,
  'PROVIDERID' => $providerId,
  'PROCESS_CLAIM_NO' => $process_claim_no,

);
$get_saved_record = onlineJohnAPI($GET_VISIT_HISTORY);
$get_saved_record_json = json_decode($get_saved_record,"true");
$savedRecord = $get_saved_record_json['RESULT'];

//print_r($get_saved_record);

?>

<form action="" method="post" id="add_member" enctype="multipart/form-data">
 <div class="">
  <div class="kt-portlet__head">
   <div class="kt-portlet__head-label">
    <h3 class="kt-portlet__head-title" id="adding_user">
     Visit History Details -<span style="font-weight: bolder;"> <?php echo $fullname ?></span>
   </h3>
 </div>
</div>

<div class="kt-portlet__body" style="height:auto; overflow-y: auto;">
  <div class="row">
   <div class="col-xl-12 col-lg-12 order-lg-1 order-xl-1">

    <!--begin:: Widgets/Sale Reports-->
    <div class="kt-portlet kt-portlet--tabs kt-portlet--height-fluid">
      <div class="kt-portlet__head">
        <div class="kt-portlet__head-label" style="width: 100%; font-size: 25px !important">


          <div class="row kt-portlet__head-title" style="width: 100%">
            <div class="col-lg-3">

              <button type="button" class="btn btn-primary" data-toggle="kt-popover" data-trigger="focus" title="" data-html="true" data-content="" data-original-title="Popover title"><?php echo strtoupper(date("jS F Y ", strtotime($date_of_consultation))) ?></button>
            </div>
            <div class="col-lg-1">&nbsp;</div>

            <div class="col-lg-3" style="">

              <button type="button" class="btn btn-primary" data-toggle="kt-popover" data-trigger="focus" title="" data-html="true" data-content="" data-original-title="Popover title"><?php echo $process_claim_no ?></button>
            </div>

            <div class="col-lg-1" style="">&nbsp;</div>

            <div class="col-lg-4">

              <button type="button" class="btn btn-primary" data-toggle="kt-popover" data-trigger="focus" title="" data-html="true" data-content="" data-original-title="Popover title">GHC <?php echo number_format($total_claim,2) ?></button>
            </div>
          </div>
        </div>


      </div>
      <div class="kt-portlet__body">
        <div class="tab-content">
          <div class="tab-pane active" id="kt_widget11_tab1_content">
            <div class="kt-widget11">
              <div class="table-responsive">
                <table class="table">
                  <thead>
                    <tr style="font-weight: 600px; color: black">
                      <td style="width:1%; color: black; font-weight: 900px;">No.</td>
                      <td style="width:30%; color: black; font-weight: 900px;">Item</td>
                      <td style="width:19%; color: black; font-weight: 900px;">Item Service</td>
                      <td style="width:15%; color: black; font-weight: 900px;">Quantity</td>
                      <td style="width:15%; color: black; font-weight: 900px;">Unit Price</td>
                      <td style="width:20%; color: black; font-weight: 900px;" class="kt-align-right">Amount</td>
                    </tr>
                  </thead>
                  <tbody>
                    <?php 
                    $count = 0;
                    if ($get_saved_record_json['STATCODE'] == "200") {
                      foreach ($savedRecord as $savedRecords){
                        $item = $savedRecords['item'];
                        $item_service = $savedRecords['item_service'];
                        $qty = $savedRecords['qty'];
                        $unit_price = $savedRecords['unit_price'];
                        $amount = $savedRecords['amount'];
                        $count ++;

                        ?>
                        <tr>
                          <td>
                            <?php echo strtoupper($count) ?>
                          </td>
                          <td>
                           <?php echo strtoupper($item) ?>
                         </td>
                         <td><?php echo strtoupper($item_service) ?></td>
                         <td><?php echo strtoupper($qty) ?></td>
                         <td><?php echo strtoupper($unit_price) ?></td>
                         <td class="kt-align-right kt-font-brand kt-font-bold">
                          <?php echo strtoupper(number_format($amount, 2)) ?>
                        </td>
                      </tr>

                    <?php } } ?>

                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>

        <!--End::Tab Content-->
      </div>
    </div>

    <!--end:: Widgets/Sale Reports-->
  </div>
</div>
</div>
</div>
</form>