<?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 = $_POST['id'];
$fullname = $_POST['idd2'];

$GET_VISIT_HISTORY = array(
  'METHOD' => urlencode('GET_VISIT_HISTORY'),
  'APIKEY' => $apikey,
  'USERNAME' => $username,
  'PASSWORD' => $password,
  'PROVIDERID' => $providerId,
  'MEMBER_NO' => $member_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 - <?php echo $fullname ?>
   </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>
      <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:6%; color: black; font-weight: 900px;">No.</td>
                      <td style="width:10%; color: black; font-weight: 900px;">Date</td>
                      <td style="width:22%; color: black; font-weight: 900px;">Process Claim No.</td>
                      <td style="width:21%; color: black; font-weight: 900px;">Type of Visit</td>
                      <td style="width:13%; color: black; font-weight: 900px;">Attending Officer</td>
                      <td style="width:10%; 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){
                        $date_of_consultation = $savedRecords['date_of_consultation'];
                        $process_claim_no = $savedRecords['process_claim_no'];
                        $type_of_visit = $savedRecords['type_of_visit'];
                        $attending_officer = $savedRecords['attending_officer'];
                        $totalClaim = $savedRecords['totalClaim'];
                        $count ++;

                        ?>

                        <tr style="cursor: pointer;" onclick="getstep2('visit_history_details', '<?php echo $process_claim_no ?>','<?php echo $date_of_consultation."@@".$totalClaim."@@".$fullname ?>')">
                          <td>
                            <?php echo strtoupper($count) ?>
                          </td>
                          <td>
                            <?php echo strtoupper(date("jS F Y ", strtotime($date_of_consultation))) ?>
                          </td>
                          <td><?php echo strtoupper($process_claim_no) ?></td>
                          <td>
                               <span style="color: white; height: 25px;" class="<?php if ($type_of_visit == "Out-Patient") { echo "kt-badge kt-badge--inline kt-badge--brand"; }else if($type_of_visit == "In-Patient"){echo "kt-badge kt-badge--inline kt-badge--warning";} ?> " >
                                <?php echo strtoupper($type_of_visit); ?>
                                </span>
                          </td>
                          <td>
                            <?php echo strtoupper($attending_officer) ?>
                          </td>
                          <td class="kt-align-right kt-font-brand kt-font-bold"><?php echo'GHC'.' '.strtoupper(number_format($totalClaim, 2)) ?></td>
                        </tr>
                      <?php } }?>




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

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

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