<?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'];
$principal_id = $_SESSION['principal_id'];

$GET_DEPENDANTS = array(
  'METHOD' => urlencode('GET_DEPENDANTS'),
  'APIKEY' => $apikey,
  'USERNAME' => $username,
  'PASSWORD' => $password,
  'PROVIDERID' => $providerId,
  'PRINCIPAL_ID' => $principal_id,

);
$get_saved_record = onlineJohnAPI($GET_DEPENDANTS);
$get_saved_record_json = json_decode($get_saved_record,"true");
$savedRecord = $get_saved_record_json['RESULT'];
?>
<form action="" method="post" id="add_member" enctype="multipart/form-data">
 <div class="kt-portlet">
  <div class="kt-portlet__head">
   <div class="kt-portlet__head-label">
    <h3 class="kt-portlet__head-title" id="adding_user">
     Dependants
   </h3>
 </div>
</div>

<div class="kt-portlet__body">
<div class="row">
   <div class="col-md-12">
    <div class="row">
      <?php 
            if ($get_saved_record_json['STATCODE'] == "200") {
              foreach ($savedRecord as $savedRecords){
                $ins_company = $savedRecords['ins_company'];
                $member_no = $savedRecords['member_no'];
                $member_plan = $savedRecords['member_plan'];
                $surname = $savedRecords['surname'];
                $firstname = $savedRecords['firstname'];
                $othernames = $savedRecords['othernames'];
                $sex = $savedRecords['sex'];
                $date_of_birth = $savedRecords['date_of_birth'];
                $member_id = $savedRecords['member_id'];
                $principal_id = $savedRecords['principal_id'];
                $member_plan_id = $savedRecords['member_plan_id'];
                $fullname = $surname.' '.$firstname;
                $c= date('Y');
                $y= date('Y',strtotime($date_of_birth));
                $age = $c-$y;
                $picpath = "https://rxhealthbeta.com/prosper/GAB_NEW/assets/images/avatar-placeholder.png";
                
                //$picpath = "http://pics.rxhealthclaim.com/".$ins_company."/".$member_id.".jpg";
              ?>
      <div class="col-md-3" style="cursor: pointer;" onclick="getstep2('visit_history', '<?php echo $member_no ?>','<?php echo $fullname ?>')">
        <div class="kt-portlet kt-portlet--height-fluid">
          <div class="kt-portlet__head kt-portlet__head--noborder">
            <div class="kt-portlet__head-label">
              <h3 class="kt-portlet__head-title">
              </h3>
            </div>
            <div class="kt-portlet__head-toolbar">
              <a href="#" class="btn btn-clean btn-icon" data-toggle="dropdown">
                <i class=""></i>
              </a>
            </div>
          </div>
          <div class="kt-portlet__body kt-portlet__body--fit-y kt-margin-b-40">
            <!--begin::Widget -->
              <div class="kt-widget kt-widget--user-profile-4">
                <div class="kt-widget__head">
                  <div class="kt-widget__media">
                    <img class="kt-widget__img kt-hidden-" src="<?php echo $picpath ?>" alt="image">
                    <div class="kt-widget__pic kt-widget__pic--danger kt-font-danger kt-font-boldest kt-hidden">
                      AP
                    </div>
                  </div>
                  <div class="kt-widget__content">
                    <div class="kt-widget__section">
                      <a href="#" class="kt-widget__username">
                        <?php echo strtoupper($fullname) ?>
                      </a>
                      <div class="kt-widget__button">

                        <button type="button" class="btn btn-primary btn-sm"><?php echo ($age > 1) ? $age.' '.'Years' : $age.' '.'Year';  ?></button>

                     
                      </div>
                      
                    </div>
                  </div>
                </div>
              </div>
            
            <!--end::Widget -->
          </div>
        </div>
      </div>
<?php } } ?>

    </div>
  </div>
</div>
</div>
</div>
</form>



