<?php
session_start();
include('connectdb.php'); 
include("side_nav.php"); 
include("top_nav.php"); 

if(isset($_GET['testrid'])){
	$testreport_id = mysqli_real_escape_string($con, $_GET['testrid']);
	$sql = mysqli_query($con, "SELECT * FROM testreport WHERE testreport_id = $testreport_id ");
	$row = mysqli_fetch_array($sql);
}

function testName($test_id){
	global $con;
	$query = mysqli_query($con, "SELECT * FROM labtest WHERE test_id = $test_id ");
	$row = mysqli_fetch_array($query);
	$test_name =  $row['test_name'];
	
	return $test_name;
}

function customerName($loyalty_id){
	global $con;
	$query = mysqli_query($con, "SELECT * FROM loyalty WHERE loyalty_id = '$loyalty_id' ");
	$row = mysqli_fetch_array($query);
	$full_name =  $row['first_name'] . ' ' . $row['last_name'];
	
	return $full_name;
}

?>
        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
            <div class="clearfix"></div>
            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Test Report  (Read Only)<small></small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <br />
                    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST" class="form-horizontal form-label-left">

					  <div class="form-group">
					  <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Patient Name <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" name="test_date" value="<?php echo customerName($row['loyalty_id']) ?>" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                      </div>
					  
					  <div class="form-group">
					  <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Test <span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="text" name="test_date" value="<?php echo testName($row['test_id']) ?>" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                      </div>
					  
					  <div class="form-group">
					  <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Test Date <span class="required">*</span>
                        </label>
                        <div class="col-md-3 col-sm-3 col-xs-12">
                          <input type="text" value="<?php echo $row['test_date'] ?>" required="required" class="form-control col-md-7 col-xs-12" disabled>
                        </div>
						
						<label class="control-label col-md-2 col-sm-2 col-xs-12" for="first-name">Report Date <span class="required">*</span>
                        </label>
                        <div class="col-md-3 col-sm-3 col-xs-12">
                          <input type="text" value="<?php echo $row['date_created'] ?>" required="required" class="form-control col-md-7 col-xs-12" disabled>
                        </div>
                      </div>
					  <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Test report <span class="required">*</span>
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                          <textarea name="test_report" class="form-control col-md-7 col-xs-12"><?php echo $row['test_report'] ?></textarea>
                        </div>
                      </div>
					  
                      <div class="ln_solid"></div>
                    </form>
                  </div>
                </div>
              </div>
            </div>
<?php include("footer.php"); ?>         
	<!-- Include Editor JS files. -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/froala-editor/2.7.3/js/froala_editor.pkgd.min.js"></script>
 
    <!-- Initialize the editor. -->
    <script> $(function() { $('textarea').froalaEditor() }); </script>
<script>
    $('.select2').select2();
</script>