<?php include ('header1f.php');?>
<?php 
ob_start();   
session_start();
include ('connection.php') ;

  if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
	date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/Y");
$today3 = date("Y-m-d");
$today1 = date("d/m");


function getAmPm($time) {
    // Convert the time string to a DateTime object
    $dateTime = DateTime::createFromFormat('H:i', $time);

    // Check if the conversion was successful
    if ($dateTime === false) {
        return "Invalid time format";
    }

    // Format the DateTime object to get the AM/PM value
    $amPm = $dateTime->format('A');

    return $amPm;
}

?>

<div class="content-page">
<div class="content">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View All Book An Appointment </h3>
</div>
<div class="panel-body">
<table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr class="ligth">
<th>Sr No.</th>
<th>App Dt &amp; Time </th>
<th>First Name </th>
<th>Age</th>
<th>Mobile No </th>
<th>City</th>
<th>Your Health Issues</th>
<th>Reference</th>
<th>How to Consult&nbsp;</th>
<th>Signature</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$query1a = "select * from kanakveda_registration where prescription_status!='DONE'";
$result1a = mysqli_query($conn,$query1a);
//echo $query1a;
//exit();
while($row=mysqli_fetch_array($result1a))
{		
$ibp_id = $row['ibp_id'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$age = $row['age'];
$mobile_no = $row['mobile_no'];
$city = $row['city'];
$health_issue = $row['health_issue'];
$reference = $row['reference'];
$signature = $row['signature'];
$date = $row['date'];
$how_to_consult = $row['how_to_consult'];
$registration_id = $row['registration_id'];
$call_follow_up_id = $row['call_follow_up_id'];
$appointment = $row['appointment'];
$prescription_status = $row['prescription_status'];


$patient_name = $first_name.' '.$last_name;


$sql = "SELECT * FROM appointment_details WHERE appointment_id = '$appointment'"; // Adjust your table and column names accordingly
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Fetch the row
    $row = $result->fetch_assoc();
    $time = $row['appointment_time'];
	$appointment_date = $row['appointment_date'];

    // Determine AM/PM
    $amPm = getAmPm($time);
    $time . " is in the " . $amPm . "\n";
} else {
    "No time value found.";
}


 ?>
<tr>
<td>
<?php if($appointment!=''){?>
<?php if($prescription_status=='START'){?>

<a href="prescription.php?program_name=Kanakveda Registration&&patient_name=<?php echo $patient_name?>&&tablename=kanakveda_registration&&program_id=<?php echo $ibp_id?>&&registration_id=<?php echo $registration_id?>&&appointment=<?php echo $appointment?>" class="btn btn-danger btn-xs waves-effect waves-light">PRESCRIPTION</a>
<?php }else{ ?>
<a href="prescription_reg_step1.php?program_name=Kanakveda Registration&&patient_name=<?php echo $patient_name?>&&tablename=kanakveda_registration&&program_id=<?php echo $ibp_id?>&&registration_id=<?php echo $registration_id?>&&appointment=<?php echo $appointment?>" class="btn btn-dark btn-xs waves-effect waves-light">RECEPTION</a><?php } ?>

<?php }else{?>
<a href="follow_up.php?program_id=<?php echo $ibp_id?>&&program_name=Kanakveda Registration&&patient_name=<?php echo $patient_name?>&&tablename=kanakveda_registration&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Follow-up</a><?php }?></td>
<td><?php echo $appointment_date?><br /><?php echo $time?> <?php echo$amPm ?></td>
<td><?php echo $first_name?>&nbsp; <?php echo $last_name?></td>
<td><?php echo $age?></td>
<td><?php echo $mobile_no?></td>
<td><?php echo $city?></td>
<td><?php echo $health_issue?></td>
<td><?php echo $reference?></td>
<td><?php echo $how_to_consult?></td>
<td><?php if($signature!=''){?><img src="https://crmsahavas.co.in/kanakveda/<?php echo $signature?>" width="100" height="auto"/><?php } ?></td>
<td><?php echo $date?></td>
</tr>
<?php  }?>
</tbody>
</table>
</div>
</div>
</div>
</div>


<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View All Immunity Booster Program Registrartion</h3>
</div>
<div class="panel-body">
<table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr class="ligth">
<th>Sr No.</th>
<th>Parent Name</th>
<th>Child Name</th>
<th>Age</th>
<th>Height</th>
<th>Email</th>
<th>Mobile No </th>
<th>City</th>
<th>Program&nbsp;</th>
<th>Courier Charges</th>
<th>Reference</th>
<th>How to Consult&nbsp;</th>
<th>Signature</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$query1a = "select * from immunity_booster_program";
$result1a = mysqli_query($conn,$query1a);
//echo $query1a;
//exit();
while($row=mysqli_fetch_array($result1a))
{		
$ibp_id = $row['ibp_id'];
$parent_first_name = $row['parent_first_name'];
$parent_last_name= $row['parent_last_name'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$age = $row['age'];
$child_height = $row['child_height'];
$email = $row['email'];
$mobile_no = $row['mobile_no'];
$city = $row['city'];
$health_issue = $row['health_issue'];
$monthly_program = $row['monthly_program'];
$signature01 = $row['signature'];
$date = $row['date'];
$how_to_consult = $row['how_to_consult'];
$courier_charges = $row['courier_charges'];
$registration_id = $row['registration_id'];
$call_follow_up_id = $row['call_follow_up_id'];
$prescription_status = $row['prescription_status'];

$appointment = $row['appointment'];

$qry4z = "select * from appointment_details where  appointment_id='$appointment' and case_id!=''" ;
$re4z= mysqli_query($conn,$qry4z);
$rowcount=mysqli_num_rows($re4z);
while($row=mysqli_fetch_array($re4z))
{  
$case_id = $row['case_id'];
}


$patient_name = $first_name.' '.$last_name;

 ?>
<tr>
<td>

<?php if($appointment!=''){?>
<?php if($prescription_status=='START'){?>

<a href="prescription_ibp.php?program_name=Immunity Booster Program Registrartion&&patient_name=<?php echo $patient_name?>&&tablename=immunity_booster_program&&program_id=<?php echo $ibp_id?>&&registration_id=<?php echo $registration_id?>&&appointment=<?php echo $appointment?>" class="btn btn-danger btn-xs waves-effect waves-light">PRESCRIPTION</a>
<?php }else{ ?>
<a href="prescription_reg_step1.php?program_name=Immunity Booster Program Registrartion&&patient_name=<?php echo $patient_name?>&&tablename=immunity_booster_program&&program_id=<?php echo $ibp_id?>&&registration_id=<?php echo $registration_id?>&&appointment=<?php echo $appointment?>" class="btn btn-dark btn-xs waves-effect waves-light">RECEPTION</a><?php } ?>

<?php }else{?>
<a href="follow_up.php?program_id=<?php echo $ibp_id?>&&program_name=Immunity Booster Program Registrartion&&patient_name=<?php echo $patient_name?>&&tablename=immunity_booster_program&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Follow-up</a><?php }?>




</td>
<td><?php echo $parent_first_name?>&nbsp; <?php echo $parent_last_name?></td>
<td><?php echo $first_name?>&nbsp; <?php echo $last_name?></td>
<td><?php echo $age?></td>
<td><?php echo $child_height?></td>
<td><?php echo $email?></td>
<td><?php echo $mobile_no?></td>
<td><?php echo $city?></td>
<td><?php echo $monthly_program?></td>
<td><?php echo $courier_charges?></td>
<td><?php echo $reference?></td>
<td><?php echo $how_to_consult?></td>
<td><?php if($signature01!=''){?><img src="https://crmsahavas.co.in/kanakveda/<?php echo $signature01?>" width="100" height="auto"/><?php } ?></td>
<td><?php echo $date?></td>
</tr>
<?php  }?>
</tbody>
</table>
</div>
</div>
</div>
</div>


<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View All GROW WELL (Height Increasing Program) Registrartion</h3>
</div>
<div class="panel-body">
<table id="datatable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr class="ligth">
<th>Sr No.</th>
<th>Parent Name</th>
<th>Child Name</th>
<th>Age</th>
<th>Height</th>
<th>Email</th>
<th>Mobile No </th>
<th>City</th>
<th>Program&nbsp;</th>
<th>Courier Charges</th>
<th>Reference</th>
<th>How to Consult&nbsp;</th>
<th>Signature</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$query1a = "select * from  height_Increasing_program";
$result1a = mysqli_query($conn,$query1a);
//echo $query1a;
//exit();
while($row=mysqli_fetch_array($result1a))
{		
$ibp_id = $row['ibp_id'];
$parent_first_name = $row['parent_first_name'];
$parent_last_name= $row['parent_last_name'];
$parent_middle_name = $row['parent_middle_name'];
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$age = $row['age'];
$child_height = $row['child_height'];
$email = $row['email'];
$mobile_no = $row['mobile_no'];
$city = $row['city'];
$health_issue = $row['health_issue'];
$monthly_program = $row['monthly_program'];
$signature02 = $row['signature'];
$date = $row['date'];
$how_to_consult = $row['how_to_consult'];
$courier_charges = $row['courier_charges'];
$registration_id = $row['registration_id'];
$patient_name = $first_name.' '.$last_name;
$call_follow_up_id = $row['call_follow_up_id'];
$prescription_status = $row['prescription_status'];

$appointment = $row['appointment'];

$qry4z = "select * from appointment_details where  appointment_id='$appointment' and case_id!=''" ;
$re4z= mysqli_query($conn,$qry4z);
$rowcount=mysqli_num_rows($re4z);
while($row=mysqli_fetch_array($re4z))
{  
$case_id = $row['case_id'];
}


 ?>
<tr>
<td>

<?php if($appointment!=''){?>

<?php if($prescription_status=='START'){?>


<?php if($rowcount>='1'){?>

<a href="view_case_study.php?appointment=<?php echo $appointment?>&&call_follow_up_id=<?php echo $call_follow_up_id?>&&case_id=<?php echo $case_id?>&&program_id=<?php echo $ibp_id?>&&program_name=Height Increasing Program&&tablename=height_Increasing_program&&registration_id=<?php echo $registration_id?>" class="btn btn-danger btn-xs waves-effect waves-light">View Case-Study</a>

<?php }else{ ?>
<a href="case_study_whatapp.php?appointment=<?php echo $appointment?>&&program_name=Height Increasing Program&&patient_name=<?php echo $patient_name?>&&tablename=height_Increasing_program&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>&&mobile_no=<?php echo $mobile_no?>&&program_id=<?php echo $ibp_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Case-Study Form</a><?php } ?>



<?php }else{ ?>
<a href="prescription_reg_step1.php?program_name=Height Increasing Program&&patient_name=<?php echo $patient_name?>&&tablename=height_Increasing_program&&program_id=<?php echo $ibp_id?>&&registration_id=<?php echo $registration_id?>&&appointment=<?php echo $appointment?>" class="btn btn-dark btn-xs waves-effect waves-light">RECEPTION</a><?php } ?>











<?php }else{?>
<a href="follow_up.php?program_id=<?php echo $ibp_id?>&&program_name=Height Increasing Program&&patient_name=<?php echo $patient_name?>&&tablename=height_Increasing_program&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Follow-up</a><?php }?>



</td>
<td><?php echo $parent_first_name?>&nbsp;<?php echo $parent_middle_name?>&nbsp; <?php echo $parent_last_name?></td>
<td><?php echo $first_name?>&nbsp; <?php echo $last_name?></td>
<td><?php echo $age?></td>
<td><?php echo $child_height?></td>
<td><?php echo $email?></td>
<td><?php echo $mobile_no?></td>
<td><?php echo $city?></td>
<td><?php echo $monthly_program?></td>
<td><?php echo $courier_charges?></td>
<td><?php echo $reference?></td>
<td><?php echo $how_to_consult?></td>
<td><?php if($signature02!=''){?><img src="https://crmsahavas.co.in/kanakveda/<?php echo $signature02?>" width="100" height="auto"/><?php } ?></td>
<td><?php echo $date?></td>
</tr>
<?php  }?>
</tbody>
</table>
</div>
</div>
</div>
</div>


<div class="row">
<div class="col-md-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">View All Event</h3>
</div>
<div class="panel-body">
<table id="datatable-keytable" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
<thead>
<tr class="ligth">
<th>Sr No.</th>
<th>Event Name </th>
<th>Name</th>
<th>Mobile</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$query1a1 = "select * from  event_more";
$result1a1 = mysqli_query($conn,$query1a1);
while($row=mysqli_fetch_array($result1a1))
{		
$event_name = $row['event_name'];
$first_name = $row['first_name'];
$last_name= $row['last_name'];
$mobile_no = $row['mobile_no'];
$eventID = $row['eventID'];

$qry4z = "select * from event_master where  eventID='$eventID'" ;
$re4z= mysqli_query($conn,$qry4z);
$rowcount=mysqli_num_rows($re4z);
while($row=mysqli_fetch_array($re4z))
{  
$Edate = $row['Edate'];
}


 ?>
<tr>
<td>

<?php if($appointment!=''){?>
<?php if($rowcount>='1'){?>

<a href="view_case_study.php?appointment=<?php echo $appointment?>&&call_follow_up_id=<?php echo $call_follow_up_id?>&&case_id=<?php echo $case_id?>" class="btn btn-danger btn-xs waves-effect waves-light">View Case-Study</a>

<?php }else{ ?>
<a href="case_study_whatapp.php?appointment=<?php echo $appointment?>&&program_name=Kanakveda Registration&&patient_name=<?php echo $patient_name?>&&tablename=kanakveda_registration&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>&&mobile_no=<?php echo $mobile_no?>&&program_id=<?php echo $ibp_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Case-Study Form</a><?php } ?>

<?php }else{?>
<a href="follow_up.php?program_id=<?php echo $ibp_id?>&&program_name=Kanakveda Registration&&patient_name=<?php echo $patient_name?>&&tablename=kanakveda_registration&&registration_id=<?php echo $registration_id?>&&call_follow_up_id=<?php echo $call_follow_up_id?>" class="btn btn-danger btn-xs waves-effect waves-light">Follow-up</a><?php }?></td>
<td><?php echo $event_name?></td>
<td><?php echo $first_name?>&nbsp;<?php echo $last_name?></td>
<td><?php echo $mobile_no?></td>
<td><?php echo $Edate?></td>
</tr>
<?php  }?>
</tbody>
</table>
</div>
</div>
</div>
</div>


</div>
</div>
<?php include 'footer1a.php';?>
