<?php 
include_once('../libs/functions.php');
if($appointmentDetails && $appointmentDetails > 0 )
{ 
    foreach ($appointmentDetails as $key => $value)
    { 
        if($_REQUEST['type'] == 'all_data')
        {
            $type =  $_REQUEST['type'];    
        }else{
            $type =  $value->appointment_status;
        }
        
        ?>
        <div class="breadcrumb">
            <h1>Appointment</h1>
            <ul>
                <li><a href="<?php echo SITE_URL.ADMIN_DIR ?>/all_app_data.php?type=<?php echo $type; ?>">Dashboard</a></li>
                <li>Appointment <?php echo $value->appointment_status; ?> Details</li>
            </ul>
        </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">Appointment RequestData</h5>
                                            <?php   
                                                echo  $value->appointment_requestData;
                                            ?>
                                            <?php } ?>
                                            <br/>

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

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

                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Appointment BillingData</h5>
                                            <?php  if($all_billingdata && $all_billingdata > 0 ){
                                                
                                                foreach ($all_billingdata as $key => $row_billingdata) 
                                                {
                                                    
                                                    if(is_array($row_billingdata))
                                                    {
                                                         echo "<b>".$key."</b>".'<br/>';
                                                         recursive($row_billingdata);   

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

                                    <div class="mt-3 mb-4 border-top"></div>

                                    <div class="row mb-5">
                                        <div class="col-md-4 mb-3 mb-sm-0">
                                            <h5 class="font-weight-bold">Appointment BillableData</h5>
                                            <?php   
                                                $billableObj = new billable();
                                                $where = array('billable_appointment_id='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $billableDetails = $billableObj->fromFields($data);
                                            ?>

                                            <b>Billable Id</b> : <?php echo $billableDetails->billable_id ?> <br/>

                                            <b>Billable Month</b> : <?php echo $billableDetails->billable_month ?> <br/>

                                            <b>Billable Year</b> : <?php echo $billableDetails->billable_year ?> <br/>

                                            <b>Billable Status</b> : <?php echo $billableDetails->billable_status ?> <br/>

                                            <b>Billable Price</b> : <?php echo $billableDetails->billable_price ?> <br/>

                                            <b>Billable Tax</b> : <?php echo $billableDetails->billable_tax ?> <br/>
                                            <p></p>
                                        </div>
                                        
                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Patient BillableData</h5>
                                            <?php   
                                                $patientbillableObj = new patientbillable();
                                                $where = array('patientbillabl_appointment_id='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $patientbillableDetails = $patientbillableObj->fromFields($data);
                                            ?>
                                            
                                            <b>PatientBillable Id</b> : <?php echo $patientbillableDetails->billable_id ?> <br/>

                                            <b>PatientBillable Month</b> : <?php echo $patientbillableDetails->billable_month ?> <br/>

                                            <b>PatientBillable Year</b> : <?php echo $patientbillableDetails->billable_year ?> <br/>

                                            <b>PatientBillable Status</b> : <?php echo $patientbillableDetails->billable_status ?> <br/>

                                            <b>PatientBillable Total</b> : <?php echo $patientbillableDetails->billable_price ?> <br/>

                                            <p></p>
                                        </div>

                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Emergency Appointment</h5>
                                            <?php   
                                                $emergencyObj = new emergency();
                                                $where = array('emergency_appointment_id='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $emergencyDetails = $emergencyObj->fromFields($data);
                                            ?>

                                            <b>Emergency Id</b> : <?php echo $emergencyDetails->emergency_id ?> <br/>

                                            <b>Subject</b> : <?php echo $emergencyDetails->emergency_subject ?> <br/>

                                            <b>Description</b> : <?php echo $emergencyDetails->emergency_description ?> <br/>

                                            <b>Status</b> : <?php echo $emergencyDetails->emergency_status ?> <br/>

                                            <b>Date</b> : <?php echo $emergencyDetails->emergency_created_at ?> <br/>
                                            <p></p>
                                        </div>   
                                    </div>

                                    <div class="mt-3 mb-4 border-top"></div>

                                    <div class="row mb-5">
                                        <div class="col-md-4 mb-3 mb-sm-0">
                                            <h5 class="font-weight-bold">Appointment Procedure Amount</h5>
                                            <?php   
                                                $appointment_procedureObj = new appointment_procedure();
                                                $where = array('appointment_procedure_aid='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $appointmentprocedureDetails = $appointment_procedureObj->fromFields($data);
                                            ?>

                                            <b>Procedure Id</b> : <?php echo $appointmentprocedureDetails->appointment_procedure_id ?> <br/>

                                            <b>CategoryId</b> : <?php echo $appointmentprocedureDetails->appointment_procedure_category_id ?> <br/>

                                            <b>Code</b> : <?php echo $appointmentprocedureDetails->appointment_procedure_code ?> <br/>

                                            <b>Amount</b> : <?php echo $appointmentprocedureDetails->appointment_procedure_amount ?> <br/>

                                            <b>Procedure Number</b> : <?php echo $appointmentprocedureDetails->appointment_procedure_number ?> <br/>
                                            <p></p>
                                        </div>
                                        
                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Messagecenter Event</h5>
                                            <?php   
                                                $messagecenter_eventObj = new messagecenter_event();
                                                $where = array('appointment_id='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $messagecentereventDetails = $messagecenter_eventObj->getAllRecords($data);
                                                if(count($messagecentereventDetails) > 0)
                                                {
                                                foreach($messagecentereventDetails as $mkey => $msgcenterval)
                                                {
                                            ?>
                                            
                                                <b>Id</b> : <?php echo $msgcenterval->messagecenter_event_id ?> <br/>

                                                <b>Eventname</b> : <?php echo $msgcenterval->eventname ?> <br/>

                                                <b>Email</b> : <?php 
                                                    if($msgcenterval->issentemail == '1')
                                                    {
                                                        echo 'yes';
                                                    }else{
                                                        echo 'no';
                                                    }
                                                 ?> <br/>

                                                <b>SMS</b> : <?php  
                                                if($msgcenterval->issentsms == '1'){
                                                        echo 'yes';
                                                    }else{
                                                        echo 'no';
                                                    } ?> <br/>

                                                <b>Mobile app</b> : <?php if($msgcenterval->issentappnotification == '1'){
                                                    echo 'yes';
                                                }else{
                                                    echo 'no';
                                                } ?> <br/>

                                                <p></p>
                                            <?php } 
                                            }else{ ?>

                                                <b>Id</b> :<br/>
                                                <b>Eventname</b> :<br/>
                                                <b>Email</b> :<br/>
                                                <b>SMS</b> :<br/>
                                                <b>Mobile app</b> :<br/>

                                           <?php  } ?>  
                                        </div>

                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">PMS Appointment</h5>
                                            
                                            <?php   
                                                $pmsappointmentObj = new pmsAppointment();
                                                $where = array('pmsAppointment_xappointmentId='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $pmsappointmentDetails = $pmsappointmentObj->fromFields($data);
                                            ?>

                                            <b>PMS appointmentId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_id ?> <br/>

                                            <b>ClinicId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_clinic_id ?> <br/>

                                            <b>Appointment Sr.No</b> : <?php echo $pmsappointmentDetails->pmsAppointment_sr_no ?> <br/>

                                            <b>PatientId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_patient_id ?> <br/>

                                            <b>ProviderId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_provider_id ?> <br/>

                                            <b>Date</b> : <?php echo $pmsappointmentDetails->pmsAppointment_date ?> <br/>

                                            <b>Time</b> : <?php echo $pmsappointmentDetails->pmsAppointment_time ?> <br/>

                                            <b>Length</b> : <?php echo $pmsappointmentDetails->pmsAppointment_length ?> <br/>

                                            <b>Amount</b> : <?php echo $pmsappointmentDetails->pmsAppointment_amount ?> <br/>

                                            <b>Status</b> : <?php echo $pmsappointmentDetails->pmsAppointment_status ?> <br/>

                                            <b>Opeatory</b> : <?php echo $pmsappointmentDetails->pmsAppointment_operatory ?> <br/>

                                            <b>Last Change Date</b> : <?php echo $pmsappointmentDetails->pmsAppointment_last_changed_date ?> <br/>

                                            <b>Loaded Date</b> : <?php echo $pmsappointmentDetails->pmsAppointment_loadeddate ?> <br/>

                                            <b>PracticeId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_practice_id ?> <br/>

                                            <b>PracticeId</b> : <?php echo $pmsappointmentDetails->pmsAppointment_practice_id ?> <br/>

                                            <b>Procedure code1</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code1 ?> <br/>

                                            <b>Procedure code2</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code2 ?> <br/>

                                            <b>Procedure code3</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code3 ?> <br/>

                                            <b>Procedure code4</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code4 ?> <br/>

                                            <b>Procedure code5</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code5 ?> <br/>

                                            <b>Procedure code6</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code6 ?> <br/>

                                            <b>Procedure code7</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_code7 ?> <br/>

                                            <b>Procedure amount1</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount1 ?> <br/>

                                            <b>Procedure amount2</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount2 ?> <br/>

                                            <b>Procedure amount3</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount3 ?> <br/>

                                            <b>Procedure amount4</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount4 ?> <br/>

                                            <b>Procedure amount5</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount5 ?> <br/>

                                            <b>Procedure amount6</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount6 ?> <br/>

                                            <b>Procedure amount7</b> : <?php echo $pmsappointmentDetails->pmsAppointment_procedure_amount7 ?> <br/>

                                            <b>Appointment schedule</b> : <?php echo $pmsappointmentDetails->pmsAppointment_schedule ?> <br/>

                                            <b>Appointment verified</b> : <?php echo $pmsappointmentDetails->pmsAppointment_verified ?> <br/>

                                            <b>Appointment verified</b> : <?php echo $pmsappointmentDetails->pmsAppointment_verified ?> <br/>
                                            <p></p>


                                        </div>   
                                    </div>

                                    <div class="mt-3 mb-4 border-top"></div>
                                        <div class="col-md-4">
                                            <h5 class="font-weight-bold">Procedure Appointment</h5>
                                            <!-- <b>Category &ensp;&ensp;</b><b>Code &ensp;&ensp;</b><b>Amount</b>
                                            <br/> -->
                                            <?php   
                                                $appointment_procedureObj = new appointment_procedure();
                                                $where = array('appointment_procedure_aid='=>$value->appointment_id);
                                                $data = array('where'=>$where);
                                                $appointment_procedureDetails = $appointment_procedureObj->getAllRecords($data);
                                                foreach($appointment_procedureDetails as $apkey => $procval)
                                                {
                                                
                                            ?>

                                             <?php echo $procval->appointment_procedure_category_id."&nbsp;&nbsp;&nbsp;" ?> 

                                             <?php echo $procval->appointment_procedure_code."&nbsp;&nbsp;&nbsp;" ?> 

                                             <?php echo $procval->appointment_procedure_amount."<br/>" ?> 
                                            <?php } ?>
                                        </div>   
                                    </div>

                        </div>
                    </div>
                </div>
            </div>
           </div> 
        </div>
<?php
    }  
} ?>