<?php
include_once('../libs/functions.php'); 
    if($_REQUEST['type'] == 'billable')
    {
        $type = "Billable";
        $type_url = "billablelist.php";
    }else if($_REQUEST['type'] == 'patientbillable'){
        $type = "Patient";
        $type_url = "patientbillablelist.php";
    }

if($billableappointmentDetails && $billableappointmentDetails > 0 )
{ 
    foreach ($billableappointmentDetails as $key => $value)
    { 

        ?>
        <div class="breadcrumb">
            <h1><?php echo $type; ?> Appointment</h1>
            <ul>
                <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>/<?php echo $type_url; ?>">Dashboard</a></li>
                <li> Appointment Details</li>
            </ul>
        </div>
        <div class="text-sm-right">
               <span><a href="<?php echo $type_url; ?>">Back</a></span>       
        </div>
        <div class="separator-breadcrumb border-top"></div>
        <div class="row">
           <div class="col-md-12">
               <div class="card">
                <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade show active" id="invoice" role="tabpanel" aria-labelledby="invoice-tab">
                        <div id="print-area">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <b>IP Address</b> : <?php echo $value->appointment_ip;  ?></b><br/><br/>
                                            <b>Appointment Billing Status</b> : <?php echo $value->appointment_billingStatus; ?></b><br/>
                                        </div>
                                        <div class="col-md-6 text-sm-right">
                                            <p><b>Appointment Created</b> : <?php echo $value->appointment_created_at; ?></p>
                                            <p><b>Appointment Updated</b> : <?php echo $value->appointment_updated_at; ?></p>
                                        </div>
                                    </div>
                                    <div class="mt-3 mb-4 border-top"></div>
                                    <?php 
                                    //print_r($appointmentDetails);exit;
                                 
                                    $all_requestdata = json_decode($value->appointment_requestData,1);
                                    $all_metadata = json_decode($value->appointment_metadata,1);
                                    $all_billingdata = json_decode($value->appointment_billingdata,1);
                                    //echo  $all_requestdata['address']['locality'];exit;
                                    ?>
                                    <div class="row mb-5">
                                        <div class="col-md-4 mb-3 mb-sm-0">
                                            <?php if($all_requestdata && $all_requestdata > 0){ ?>
                                            <h5 class="font-weight-bold">Appoitment RequestData</h5>
                                            <?php   
                                                echo  $value->appointment_requestData;
                                            ?>
                                            <?php } ?>
                                            <br/>

                                            <p></p>
                                        </div>
                                        
                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Appoitment MetaData</h5>
                                            <?php
                                            //print_r($all_metadata);exit;
                                            if($all_metadata && $all_metadata > 0 )
                                            { 
                                                foreach ($all_metadata as $key => $row_metadata) 
                                                {
                                                    
                                                    if(is_array($row_metadata))
                                                    {
                                                        echo "<b>".$key."</b>".'<br/>';
                                                        /*array_walk_recursive( $row_metadata, function($value, $key) {
                                                               echo "$key : $value"."<br/>"; 
                                                            });*/
                                                        recursive($row_metadata); 

                                                    }else{
                                                        echo "<b>".$key."</b>".":".$row_metadata."<br/>";
                                                    }
                                                }
                                            }
                                            ?>
                                            
                                        </div>

                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Appoitment BillingData</h5>
                                            <?php  if($all_billingdata && $all_billingdata > 0 ){
                                                //print_r($all_billingdata);exit;
                                                foreach ($all_billingdata as $key => $row_billingdata) 
                                                {

                                                    if(is_array($row_billingdata))
                                                    {
                                                        echo "<b>".$key."</b>".'<br/>';
                                                        /*array_walk_recursive( $row_billingdata, function($value, $key) {
                                                               echo "$key : $value"."<br/>"; 
                                                            });*/
                                                        recursive($row_billingdata);

                                                    }else{
                                                        echo "<b>".$key."</b>".":".$row_billingdata."<br/>";
                                                    }
                                                }
                                            ?>
                                            <?php } ?>
                                        </div>   
                                    </div>
                        </div>
                    </div>
                </div>
            </div>
           </div> 
        </div>
<?php
    }  
} ?>