<?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 echo $lang['Transaction Patient']; ?></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/jquery.sparkline.min.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.easytabs.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/functions_blank_no_sidebar.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data ?>/datatable/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data ?>/datatable/js/columnFilter.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data ?>/js/files/bootstrap.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_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
if($_POST)
{
$consultant = $_POST['consultant'];
$remark =mysql_real_escape_string($_POST['remark']);
$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');
");    
}


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


	

      <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;">       
          
<?php
if($_GET['type']=="delete"&&$_GET['tc_id']){
$sql = "UPDATE tbl_transaction_charge SET  a_status='3' WHERE id ='$_GET[tc_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/transaction/patient/charge/$db_transaction2_id';		
</script> ");   
}
?>
			
<div style="position:relative;height:1px;left:-15px;float:right;top:12px;z-index:10;">
  <a class="buttonM bBlue" href="javascript:void(0);" onclick="oTable.fnReloadAjax();" style="border-radius:5px;"><span class="fa fa-refresh"></span><span><?php echo $lang['Refresh']; ?></span></a>
</div>

<script type="text/javascript" charset="utf-8">      
$(document).ready(function () {
  
  oTable =$('#transaction-patient-datatable').dataTable(
  {
    
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
      
if ( aData[0]){$('td:eq(0)', nRow).html( '<center><i class="fa fa-connectdevelop"></i></center>');}

if ( aData[7]==1){$('td:eq(6)', nRow).html("<center> <a href='<?php echo $connect_url_data; ?>/transaction/patient/charge/<?php echo $db_transaction2_id; ?>&tc_id="+aData[0]+"&type=delete' onclick=\"return confirm('Are you sure you want to delete this transaction?')\"><i class='fa fa-times'></i> <?php echo $lang['Delete']; ?></a></center>");}
else{$('td:eq(6)', nRow).html( '<center>-</center>');}
  
     },

"sPaginationType": "full_numbers",
"aaSorting": [[ 2, "asc" ]],
"sDom": '<"top"f>rt<"bottom"i><"bottom"p>',
"bAutoWidth": false,
"oLanguage": {
"sSearch": "<i class='fa fa-search' style='margin-left:20px;'></i>"
},

"sAjaxSource": "<?php echo $connect_url_data; ?>/transaction/transaction-patient-datatable.php?transaction_id=<?php echo $db_transaction2_id; ?>",
"aoColumns": [
    { "mData": null },
           null,
           null,
           null,
	   null,
            null,
    { "mData": null },
           
         ]          
  });

$('.dataTables_filter input').attr("placeholder", "<?php echo $lang['Search Keywords']; ?>");

});
//end ready function

 $.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback, bStandingRedraw )
{
    if ( sNewSource !== undefined && sNewSource !== null ) {
        oSettings.sAjaxSource = sNewSource;
    }
 
    // Server-side processing should just call fnDraw
    if ( oSettings.oFeatures.bServerSide ) {
        this.fnDraw();
        return;
    }
 
    this.oApi._fnProcessingDisplay( oSettings, true );
    var that = this;
    var iStart = oSettings._iDisplayStart;
    var aData = [];
 
    this.oApi._fnServerParams( oSettings, aData );
 
    oSettings.fnServerData.call( oSettings.oInstance, oSettings.sAjaxSource, aData, function(json) {
        /* Clear the old information from the table */
        that.oApi._fnClearTable( oSettings );
 
        /* Got the data - add it to the table */
        var aData =  (oSettings.sAjaxDataProp !== "") ?
            that.oApi._fnGetObjectDataFn( oSettings.sAjaxDataProp )( json ) : json;
 
        for ( var i=0 ; i<aData.length ; i++ )
        {
            that.oApi._fnAddData( oSettings, aData[i] );
        }
         
        oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
 
        that.fnDraw();
 
        if ( bStandingRedraw === true )
        {
            oSettings._iDisplayStart = iStart;
            that.oApi._fnCalculateEnd( oSettings );
            that.fnDraw( false );
        }
 
        that.oApi._fnProcessingDisplay( oSettings, false );
 
        /* Callback item function - for event handlers etc */
        if ( typeof fnCallback == 'function' && fnCallback !== null )
        {
            fnCallback( oSettings );
        }
    }, oSettings );
};
</script>

<div class="shownpars">					
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dTable" id="transaction-patient-datatable">
<thead>
    <tr>
	<th width="3%"></th>
	<th width="15%"><?php echo $lang['Transaction Charge No']; ?></th>
	<th width="31%"><?php echo $lang['Remarks']; ?></th>
	<th width="20%"><?php echo $lang['Total Amount']; ?></th>
    <th width="13%"><?php echo $lang['Created by']; ?></th>
	<th width="10%"><?php echo $lang['Status']; ?></th>
	<th width="10%"><?php echo $lang['Status']; ?>Status</th>
    </tr>	
</thead>
<tbody>

</tbody>
</table>
</div>
	    

</div>	    
<!-- end tabs body -->
                  
                </div>
            </fieldset>
	    
    <div class="formRow">
                    <div class="grid2"></div>
                    <div class="grid10">
                        <a href="#" class="buttonM bBlue" onclick="window.close();"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
             
</body>
</html>
