<?php session_start(); ?> <!-- session start -->
<?php include("../include/config.php"); ?> <!-- database connection -->
<?php include("../include/connect_url.php"); ?> <!-- connection url/link folder -->
<?php include("../include/date_time.php"); ?> <!-- date & time format -->
<?php include("../database/account.php"); ?> <!-- query database account -->
<?php include("../include/lang.php"); ?> <!-- language -->
<?php include("../include/session_login.php"); ?> <!-- session login -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php include("../template/title.php"); ?></title>

<link rel="shortcut icon" href="<?php echo $connect_url_data; ?>/favicon.ico" />

<link href="<?php echo $connect_url_data; ?>/css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="<?php echo $connect_url_data; ?>/css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->
<link rel="stylesheet" href="<?php echo $connect_url_data; ?>/font/font-awesome-4.3.0/css/font-awesome.min.css">

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery183.js"></script> 
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery192.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autosize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.select2.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.de-DE.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.ja-JP.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/bootstrap.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/functions.js"></script>

</head>

<body>

<?php    
$query_transaction2 = mysql_query("SELECT * FROM tbl_transaction WHERE id='$_GET[transaction_id]'"); 
while($row= mysql_fetch_assoc($query_transaction2))
{
    $db_transaction2_id = $row['id'];
    $db_transaction2_transaction_no = $row['transaction_no'];
    $db_transaction2_patient_id = $row['patient_id'];
    $db_transaction2_pt_type_id = $row['pt_type_id'];
    $db_transaction2_remark = $row['remark'];
    $db_transaction2_user_id = $row['user_id'];
    $db_transaction2_date = $row['date'];
    $db_transaction2_time = $row['time'];
    $db_transaction2_a_status = $row['a_status'];
}
?>

<?php    
$query_transaction_consultant2 = mysql_query("SELECT * FROM tbl_transaction_consultant WHERE transaction_id='$db_transaction2_id'");
$numrows_transaction_consultant2 = mysql_numrows($query_transaction_consultant2);
while($row= mysql_fetch_assoc($query_transaction_consultant2))
{
    $db_transaction_consultant2_id = $row['id'];
    $db_transaction_consultant2_consultant_id = $row['consultant_id'];
}
?>



<?php    
$query_consultant2 = mysql_query("SELECT * FROM tbl_consultant WHERE id='$db_transaction_consultant2_consultant_id'"); 
while($row= mysql_fetch_assoc($query_consultant2))
{
    $db_consultant2_id = $row['id'];
    $db_consultant2_consultant_no = $row['consultant_no'];
    $db_consultant2_image = $row['image'];
    $db_consultant2_firstname = $row['firstname'];
    $db_consultant2_middlename = $row['middlename'];
    $db_consultant2_middlename_str = substr($db_consultant2_middlename,0,1);
    $db_consultant2_lastname = $row['lastname'];
    $db_consultant2_birth_date = $row['birth_date'];
    $db_consultant2_gender = $row['gender'];
    $db_consultant2_address = $row['address'];
    $db_consultant2_phone_no = $row['phone_no'];
    $db_consultant2_mobile_no = $row['mobile_no'];
    $db_consultant2_email = $row['email'];
    $db_consultant2_date = $row['date'];
    $db_consultant2_time = $row['time'];
    $db_consultant2_a_status = $row['a_status'];
}
?>


<?php    
$query_transaction_diagnosis2 = mysql_query("SELECT * FROM tbl_transaction_diagnosis WHERE transaction_id='$db_transaction2_id'");
$numrows_transaction_diagnosis2 = mysql_numrows($query_transaction_diagnosis2);
while($row= mysql_fetch_assoc($query_transaction_diagnosis2))
{
    $db_transaction_diagnosis2_id = $row['id'];
    $db_transaction_diagnosis2_admitting_diagnosis = $row['admitting_diagnosis'];
    $db_transaction_diagnosis2_final_diagnosis = $row['final_diagnosis'];
}
?>

<?php    
$query_transaction_file2 = mysql_query("SELECT * FROM tbl_transaction_file WHERE transaction_id='$db_transaction2_id'");
$numrows_transaction_file2 = mysql_numrows($query_transaction_file2);
while($row= mysql_fetch_assoc($query_transaction_file2))
{
    $db_transaction_file2_id = $row['id'];
    $db_transaction_file2_file_name = $row['file_name'];
    $db_transaction_file2_file = $row['file'];
}
?>

<?php    
$query_transaction_type2 = mysql_query("SELECT * FROM tbl_transaction_type WHERE id='$db_transaction2_a_status'"); 
while($row= mysql_fetch_assoc($query_transaction_type2))
{
    $db_transaction_type2_id = $row['id'];
    $db_transaction_type2_transaction_type = $row['transaction_type'];
}
?>


<?php    
$query_patient2 = mysql_query("SELECT * FROM tbl_patient WHERE id='$db_transaction2_patient_id'"); 
while($row= mysql_fetch_assoc($query_patient2))
{
    $db_patient2_id = $row['id'];
    $db_patient2_patient_no = $row['patient_no'];
    $db_patient2_image = $row['image'];
    $db_patient2_firstname = $row['firstname'];
    $db_patient2_middlename = $row['middlename'];
    $db_patient2_middlename_str = substr($db_patient2_middlename,0,1);
    $db_patient2_lastname = $row['lastname'];
    $db_patient2_birth_date = $row['birth_date'];
    $db_patient2_gender = $row['gender'];
    $db_patient2_civil_status_id = $row['civil_status_id'];
    $db_patient2_nationality_id = $row['nationality_id'];
    $db_patient2_address = $row['address'];
    $db_patient2_phone_no = $row['phone_no'];
    $db_patient2_mobile_no = $row['mobile_no'];
    $db_patient2_email = $row['email'];
    $db_patient2_ref_name = $row['ref_name'];
    $db_patient2_ref_relationship_id = $row['ref_relationship_id'];
    $db_patient2_ref_address = $row['ref_address'];
    $db_patient2_ref_phone_no = $row['ref_phone_no'];
    $db_patient2_ref_mobile_no = $row['ref_mobile_no'];
    $db_patient2_date = $row['date'];
    $db_patient2_time = $row['time'];
    $db_patient2_a_status = $row['a_status'];
}
?>

<?php
$query_civil_status2 = mysql_query("SELECT * FROM tbl_civil_status WHERE id='$db_patient2_civil_status_id'");
while($row= mysql_fetch_assoc($query_civil_status2))
{
    $db_civil_status2_id = $row['id'];
    $db_civil_status2_civil_status = $row['civil_status'];
}
?>

<?php
$query_nationality2 = mysql_query("SELECT * FROM tbl_nationality WHERE id='$db_patient2_nationality_id'");
while($row= mysql_fetch_assoc($query_nationality2))
{
    $db_nationality2_id = $row['id'];
    $db_nationality2_nationality = $row['nationality'];
}
?>

<?php
$query_relationship2 = mysql_query("SELECT * FROM tbl_relationship WHERE id='$db_patient2_ref_relationship_id'");
while($row= mysql_fetch_assoc($query_relationship2))
{
    $db_relationship2_id = $row['id'];
    $db_relationship2_relationship = $row['relationship'];
}
?>

<?php
$query_transaction_room2 = mysql_query("SELECT * FROM tbl_transaction_room WHERE transaction_id='$db_transaction2_id'");
while($row= mysql_fetch_assoc($query_transaction_room2))
{
    $db_transaction_room2_id = $row['id'];
    $db_transaction_room2_room_id = $row['room_id'];
    $db_transaction_room2_bed_id = $row['bed_id'];
    $db_transaction_room2_price = $row['price'];
    $db_transaction_room2_price_nf = number_format($db_transaction_room2_price, 2);
    $db_transaction_room2_user_id= $row['user_id'];
    $db_transaction_room2_price = $row['date'];
    $db_transaction_room2_time = $row['time'];
    $db_transaction_room2_a_status = $row['a_status'];
}
?>

<?php
$query_room1= mysql_query("SELECT * FROM tbl_room WHERE id='$db_transaction_room2_room_id'");
while($row= mysql_fetch_assoc($query_room1))
{
$db_room1_id= $row['id'];
$db_room1_room= $row['room'];
}
?>

<?php
$query_bed1= mysql_query("SELECT * FROM tbl_bed WHERE id='$db_transaction_room2_bed_id'");
while($row= mysql_fetch_assoc($query_bed1))
{
$db_bed1_id= $row['id'];
$db_bed1_bed= $row['bed'];
}
?>






<?php
if($_POST)
{
$consultant = $_POST['consultant'];
$remark =mysql_real_escape_string($_POST['remark']);
$admitting_diagnosis = mysql_real_escape_string($_POST['admitting_diagnosis']);
$final_diagnosis = mysql_real_escape_string($_POST['final_diagnosis']);
$a_status = $_POST['a_status'];


$sql = "UPDATE tbl_transaction SET  remark='$remark', a_status='$a_status'  WHERE  id ='$db_transaction2_id '";
$result = mysql_query($sql) or die("Error: Failed to Update!");



if($numrows_transaction_consultant2){
$sql = "UPDATE tbl_transaction_consultant SET  consultant_id='$consultant'  WHERE transaction_id ='$db_transaction2_id '";
$result = mysql_query($sql) or die("Error: Failed to Update!");
}else{
$query_insert = mysql_query("
  INSERT INTO tbl_transaction_consultant VALUES ('','$db_transaction2_id','$consultant','$db_user_id','$date','$time','1');
");    
}

if($numrows_transaction_diagnosis2){
$sql = "UPDATE tbl_transaction_diagnosis SET  admitting_diagnosis='$admitting_diagnosis', final_diagnosis='$final_diagnosis'  WHERE transaction_id ='$db_transaction2_id '";
$result = mysql_query($sql) or die("Error: Failed to Update!");
}else{
$query_insert = mysql_query("
  INSERT INTO tbl_transaction_diagnosis VALUES ('','$db_transaction2_id','$admitting_diagnosis','$final_diagnosis','$db_user_id','$date','$time','1');
");    
}



//file
$file_extension_allowed = array('doc','docx','pdf','');
$file_name = strtolower($_FILES['file']['name']);
$file_extension = strtolower(end(explode('.', $file_name)));
$file_tmp_name  = $_FILES['file']['tmp_name'];
$file_size = $_FILES['file']['size'];
$file_type = $_FILES['file']['type'];
if($file_name)
{

if(in_array($file_extension, $file_extension_allowed)=== false){ 	 
die ("<script>  
alert('File extension for file is not allowed.');
window.location.href='javascript:history.back();';
</script>");
}     

if(!get_magic_quotes_gpc())
	{
		$file_name =addslashes($file_name);
	}
        
if($file_name=="")
{
die("<script>	
alert('ERROR: Please select file.'); 
window.location.href='javascript:history.back();';		
</script> ");
}

$rand_number = rand(1, 1000000);
$file_file_generate = "$db_patient1_id_add_comp$rand_number-$file_name";

if (move_uploaded_file($file_tmp_name, "../file/patient/".$file_file_generate)){
}

$query_insert = mysql_query("
  INSERT INTO tbl_transaction_file VALUES ('','$db_transaction2_id','$file_file_generate','$db_user_id','$date','$time','1');
");    

}
//end if patient_file

die ("<script> alert('Saved.');
window.close();		
</script> ");
}
?>


	

  <form name="form" id="form" action="<?php echo $connect_url_data; ?>/outpatient/e/<?php echo $db_transaction2_id; ?>" class="main" method="POST"  enctype="multipart/form-data">
            <fieldset style="margin-top:-35px;">
                <div class="widget fluid">
                    <div class="whead"><h6><span class="icon-user" style="margin-top:-2px;"></span>&nbsp; <?php echo "$db_patient2_firstname $db_patient2_middlename_str. $db_patient2_lastname"; ?></h6></div>
                    
		    <!-- Tabs -->
		<div class="fluid" >
                <div class="widget grid12" style="margin-top:-0px;">       
                    <div class="tabs">
                        <ul>
                            <li><a href="#tabs-patient"><?php echo $lang['Patient Information']; ?></a></li>
                            <li><a href="#tabs-outpatient"><?php echo $lang['Outpatient Details']; ?></a></li>
                            <li><a href="#tabs-diagnosis"><?php echo $lang['Diagnosis']; ?></a></li>
                            <li><a href="#tabs-file"><?php echo $lang['Patient File']; ?></a></li>
                        </ul>
			
			
			
                <div id="tabs-patient">
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Profile Picture']; ?>:</label> </div>
                            <div class="grid10">
                                <img src="<?php echo $connect_url_data; ?>/images/patient/<?php if($db_patient2_image){ echo $db_patient2_image; }else {echo"avatar.png";}?>" width="100" height="100">
                            </div>
                     </div>
		
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Firstname']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_firstname; ?></div>
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Middlename']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_middlename; ?></div>
                    </div>
		    
		     <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Lastname']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_lastname; ?></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Birth Date']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_birth_date; ?></div>
                    </div>
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Gender']; ?>:</label></div>
                            <div class="grid10"><?php echo $db_patient2_gender; ?></div>             
                    </div>
		    
		     <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Civil Status']; ?>:</label></div>
                            <div class="grid10"><?php echo $db_civil_status2_civil_status; ?></div>             
                    </div>
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Nationality']; ?>:</label></div>
                            <div class="grid10"><?php echo $db_nationality2_nationality; ?></div>             
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Address']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_address; ?> </div>
                    </div>
		      
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Phone No']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_phone_no; ?></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Mobile No']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_mobile_no; ?></div>
                    </div>
		         
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Email']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_email; ?></div>
		    </div>
		       
		       
		   <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Ref. Name']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_ref_name; ?></div>
                    </div>
		    
		    
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Ref. Relationship']; ?>:</label></div>
                            <div class="grid10"><?php echo $db_relationship2_relationship; ?></div>             
                    </div>
		    
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Ref. Address']; ?>:</label></div>
                        <div class="grid10"><?php echo $db_patient2_ref_address; ?></div>
                    </div>
		      
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Ref. Phone No']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_ref_phone_no; ?></div>
                    </div>
		    
		    <div class="formRow">
                    <div class="grid2"><label><?php echo $lang['Ref. Mobile No']; ?>:</label></div>
                    <div class="grid10"><?php echo $db_patient2_ref_mobile_no; ?></div>
                    </div>
		    
	     </div>
	    <!-- end tabs  -->
	    
	    <div id="tabs-outpatient">
                
                    
                    
                        <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Consultant']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_consultant1=mysql_query("SELECT * FROM tbl_consultant WHERE id!='$db_transaction_consultant2_consultant_id' ORDER BY firstname ASC");
				$option_consultant1="";
				while($row=mysql_fetch_array($query_consultant1)) {
				$option_consultant1 .= "<option value='$row[id]'";
				$option_consultant1 .= ">". $row['firstname'] ." ". $row['lastname'] ."</option>";  }
				?>    
				<select name="consultant" id="consultant"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <?php if($db_transaction_consultant2_consultant_id!=0){echo "<option value='$db_transaction_consultant2_consultant_id'>$db_consultant2_firstname $db_consultant2_lastname</option>"; }else{echo"<option value=''></option> ";}?>
				<?php echo $option_consultant1; ?>
				</select>
                            </div>             
                    </div>
                   
                       <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Remarks']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="remark" id="remark" class="auto lim"><?php echo $db_transaction2_remark; ?></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                    </div>
                        
		    <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Account Status']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_transaction_type1=mysql_query("SELECT * FROM tbl_transaction_type WHERE id != '$db_transaction_type2_id' ORDER BY id ASC");
				$option_transaction_type1="";
				while($row=mysql_fetch_array($query_transaction_type1)) {
				$option_transaction_type1 .= "<option value='$row[id]'";
				$option_transaction_type1 .= ">". $row['transaction_type'] ."</option>";  }
				?>    
				<select name="a_status" id="a_status"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                 <?php if($db_transaction_type2_id!=0){echo "<option value='$db_transaction_type2_id'>$db_transaction_type2_transaction_type</option>"; }else{echo"<option value=''></option> ";}?>
				<?php echo $option_transaction_type1; ?>
				</select>
                            </div>             
                    </div>
                    
                
            </div>
            
            
      
               
     
            <div id="tabs-diagnosis">
                
                <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Admitting Diagnosis']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="admitting_diagnosis" id="admitting_diagnosis" class="auto lim"><?php echo $db_transaction_diagnosis2_admitting_diagnosis; ?></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                </div>
                 
                <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Final Diagnosis']; ?>:</label></div>
                        <div class="grid10">
                            <textarea rows="8" cols="" name="final_diagnosis" id="final_diagnosis" class="auto lim"><?php echo $db_transaction_diagnosis2_final_diagnosis; ?></textarea>
                            <span class="note" id="limitingtext">Field limited to 100 characters.</span>
                        </div>
                </div>
                
            </div>
            <!-- end diagnosis -->
            
            
            
            
            
            
            
<?php
if($_GET['type']=="delete"&&$_GET['tf_id']){
$sql = "UPDATE tbl_transaction_file SET  a_status='3' WHERE id ='$_GET[tf_id]' AND a_status='1'";
$result = mysql_query($sql) or die("Error: Failed to Update!");      
    
die ("<script> alert('Deleted.');
window.location.href='$connect_url_data/outpatient/e/$db_transaction2_id';		
</script> ");   
}
?>
            
            
             <div id="tabs-file">
                  <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Upload File']; ?>:</label> </div>
                            <div class="grid10">
                                <input type="file" class="styled" name="file" id="file"  /> (file format: doc, docs, pdf)
                            </div>
                     </div>
                  
<div class="shownpars">					
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dTable" id="item-datatable">
<thead>
    <tr>
	<th width="3%"></th>
	<th width="40%"><?php echo $lang['File/ Document Name']; ?></th>
	<th width="14%"><?php echo $lang['Uploaded by']; ?></th>
	<th width="13%"><?php echo $lang['Date']; ?></th>
	<th width="13%"><?php echo $lang['Time']; ?></th>
	<th width="19%"><?php echo $lang['Action']; ?></th>
    </tr>	
</thead>
<tbody>
<?php
$query_transaction_file2 = mysql_query("SELECT * FROM tbl_transaction_file WHERE transaction_id='$db_transaction2_id' AND a_status=1");
while($row= mysql_fetch_assoc($query_transaction_file2))
{
    $db_transaction_file2_id = $row['id'];
    $db_transaction_file2_file = $row['file'];
    $db_transaction_file2_user_id = $row['user_id'];
    $db_transaction_file2_date = $row['date'];
    $db_transaction_file2_time = $row['time'];
    $db_transaction_file2_a_status = $row['a_status'];
    
$query_user2 = mysql_query("SELECT * FROM tbl_user WHERE id='$db_transaction_file2_user_id'");
while($row= mysql_fetch_assoc($query_user2))
{
    $db_user2_id = $row['id'];
    $db_user2_firstname = $row['firstname'];
    $db_user2_middlename = $row['middlename'];
    $db_user2_middlename_sub =  substr($db_user2_middlename,0,1);
    $db_user2_lastname = $row['lastname'];
}
?>
<tr>
    <td><span class="fa fa-file"></span></td>
    <td><?php echo $db_transaction_file2_file; ?></td>
    <td><?php echo "$db_user2_firstname $db_user2_middlename_sub. $db_user2_lastname"; ?></td>
    <td><?php echo $db_transaction_file2_date; ?></td>
    <td><?php echo $db_transaction_file2_time; ?></td>
    <td style="text-align:center;"><a href="<?php echo $connect_url_data; ?>/file/patient/<?php echo $db_transaction_file2_file; ?>" download><span class="fa fa-download"></span> Download</a>&nbsp;&nbsp;<a href='<?php echo $connect_url_data; ?>/outpatient/e/<?php echo $db_transaction2_id; ?>&tf_id=<?php echo $db_transaction_file2_id; ?>&type=delete' onclick="return confirm('Are you sure you want to delete this item?')"><i class='fa fa-times'></i> Delete</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
                  
                
             </div>
             <!-- end file --> 
             
             
             
             
             
             
	    
</div>
</div>	    
<!-- end tabs body -->
                  
                </div>
            </fieldset>
	    
    <div class="formRow">
                    <div class="grid2"></div>
                    <div class="grid10">
			<a href="#" class="buttonM bBlue" onclick="document.getElementById('form').submit();"><span class="fa fa-save"></span><span><?php echo $lang['Save']; ?></span></a>
		        <a href="#" class="buttonM bBlue" onclick="window.close();"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
</form>

</body>
</html>
