<?php
include('../config/config.php');
include('../classes/classTransaction.php');
include('../classes/classPatient.php');


################################################################################
#########################Pagination Starts here. {########################
################################################################################
$tranOb = new classTransaction;
$tranOb->setAccountHeadID(2);
$tranOb->setLocationID($_SESSION['security']['location_id']);
$tranOb->setTransactionPurpose('ipd_refund');
$transaction_count = $tranOb->countTransactionByAccountHeadByID();		

$array['item_count'] = $transaction_count;
if(isset($_GET['page']) && isset($_GET['items']))
{
	if($array['item_count'] > $_GET['items'])
	{
		$array['pages'] = ceil($array['item_count']/$_GET['items']);
		if($_GET['page'] >$array['pages'])
		{
			$_GET['page'] = 1;
		}
		$array['current_page'] = $_GET['page'];
		if($_GET['page'] > 1)
		{
			$starting_record = $_GET['items']*($_GET['page']-1);
			$ending_record = $_GET['items'];
			$array['limit'] = $starting_record . "," . $ending_record;
			$limit = $array['limit'];
		}
		else
		{
			$limit = $_GET['items'];
		}
	}
	else
	{
		$array['current_page'] = $_GET['current_page'] = 1;
		$array['pages'] = 1;
		$array['limit'] = $_GET['items'];
		$limit = $array['limit'];
	}
}
else
{
	if($array['item_count'] > 20)
	{
		$array['pages'] = ceil($array['item_count']/20);
	}
	else
	{
		$array['pages'] = 1;
	}
	$array['current_page'] = 1;
	$array['limit'] = 20;
	$limit = $array['limit'];
}

$_SESSION['pagination']['item_count']=$array['item_count'];
$_SESSION['pagination']['pages']=$array['pages'];
$_SESSION['pagination']['current_page']=$array['current_page'];
$_SESSION['pagination']['limit']=$limit;

################################################################################
######################### Pagination Ends here. }##########################
################################################################################

try
{
	$tranOb = new classTransaction;
	$tranOb->setAccountHeadID(2);
	$tranOb->setLocationID($_SESSION['security']['location_id']);
	$tranOb->setTransactionPurpose('ipd_refund');
	$transaction_data = $tranOb->retrieveTransactionByAccountHeadByID($limit);	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}


try
{
	$accheadOb = new classTransaction;
	$accheadOb->setAccountHeadID(2);
	$acchead_data = $accheadOb->retrieveAccountHeadByID();	
	
	$accounthead_name = $acchead_data[0]['acchead_name'];
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}

/*echo '<pre>';
print_r($transaction_data);
echo '</pre>';*/

?>
<!DOCTYPE html>
<html><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head> 
    <link rel="shortcut icon" href="../images/favicon.png">
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Med2TEC Hospital Management Information System</title>
    <!-- InstanceEndEditable -->
    <!--Core CSS -->
    <link href="../bs3/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="../css/style.css" rel="stylesheet">
    <link href="../css/style-responsive.css" rel="stylesheet"/> 
    <link href="../popUp/popUp.css" rel="stylesheet">
    <link href="../css/bootstrap-fullcalendar.css" rel="stylesheet"/> 
    
    <link href="../css/clndr.css" rel="stylesheet">
    
    <link href="../css/css/font-awesome.css" rel="stylesheet">
    
    <link href="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.css" rel="stylesheet">
    <link href="../assets/jvector-map/jquery-jvectormap-1.2.2.css" rel="stylesheet">    
    <link href="../assets/jquery-multi-select/css/multi-select.css" rel="stylesheet" type="text/css">
    <!--clock css-->
    <link href="../assets/css3clock/css/style.css" rel="stylesheet"> 
    <!--Morris Chart CSS -->
    <link rel="stylesheet" href="../assets/morris-chart/morris.css">
    <!-- Custom styles for this template -->
   
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >   
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>

<section id="container">
    <!--header start-->
    <header class="header fixed-top clearfix">
        <!--logo start-->
        <div class="brand">

            <a href="home.php" class="logo">
                <img src="../images/logo.png" alt="">
            </a>
            <div class="sidebar-toggle-box">
                <div class="fa fa-bars"></div>  
            </div>
        </div> 
        <!--logo end-->

        <div class="nav notify-row" id="top_menu" style="float: right; margin-top: 16px; margin-left: 0px; margin-right: 10px;">
            <!--  notification start -->
             <img alt="" src="../images/org_logos/<?php echo $_SESSION['security']['org_id']?>.png">
            <!--  notification end -->
        </div>
        <div class="top-nav clearfix">
            <!--search & user info start-->
            <ul class="nav pull-right top-menu">
                <li>
                    <div class="toggle-right-box"><!-- InstanceBeginEditable name="print" -->
                    <a href="javascript:Popup('printopdtransact.php')"><i class="fa fa-print" style="margin-left: 11px; margin-top: 11px;"></i></a>
					<!-- InstanceEndEditable --></div>
                </li>
                <!-- user login dropdown start-->
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <img alt="" src="../images/avatar1_small.jpg"> 
                        <span class="username"><?php echo $username;?></span>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu extended logout">
                        <li><a href="profile.php"><i class=" fa fa-suitcase"></i>Profile</a></li>
                        <li><a href="#update_password-box" class="update_password-window"><i class="fa fa-cog"></i> Change Password</a></li>
                        <li><a href="../logout.php"><i class="fa fa-key"></i> Log Out</a></li>
                    </ul>
                </li>
                <!-- user login dropdown end -->
                <li>
                    <div class="toggle-right-box">
                        <div class="fa fa-bars"></div>
                    </div>
                </li>
            </ul>
            <!--search & user info end-->
        </div>
    </header>
    <!--header end-->
    <!--sidebar start-->
   <aside>
        <div id="sidebar" class="nav-collapse">
            <!-- sidebar menu start-->
            <ul class="sidebar-menu" id="nav-accordion">
             <?php
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);

		  if($orgOb->getDB())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i> 
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
				}
		  }
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==10||$_SESSION['security']['userrole_id']==100)
				{
					?>
					    <li class="sub-menu">
                    	<a href="dbpatient.php" style="background:#BC1C4A;">
                        <i class="fa fa-user"></i>
                        <span>Patient Registration</span>
                    	</a>
                    	</li>
					  <?php
				}
		  
		  if($orgOb->getOPD())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==4||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<li class="sub-menu">
						<a href="dbopd.php" style="background:#003366;">
						<i class="fa fa-th"></i>
						<span>Out-Patient (OPD)</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getIPD())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#8EC63F;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
				}
					
		  }
		  if($orgOb->getOT())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100) 
				{
			   		?>
						<li class="sub-menu">
						<a href="dbot.php" style="background:#D6502A;">
						<i class="fa fa-th"></i>
						<span>Operation Theater</span>
						</a>
						</li>
                        <?php
				}
		  }			
		  if($orgOb->getPharmacy())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==7||$_SESSION['security']['userrole_id']==8||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
			  		?>
						<li class="sub-menu">
						<a href="dbpharmacy.php" style="background:#00869C;">
						<i class="fa fa-th"></i>
						<span>Pharmacy</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getDiagnostic())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==14||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  
					  ?>
						<!--<li class="sub-menu">
						<a href="dbemergency.php" style="background:#3AC7F9;">
						<i class="fa fa-tasks"></i>
						<span>Facility Management </span>
						</a>
						</li>-->
						<?php
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<li class="sub-menu">
						<a href="dbadmin.php" style="background:#28282E;">
						<i class="fa fa-laptop"></i>
						<span>Admin Panel</span>
						</a>
						</li>
						<?php
				}
		  }
		  ?>
               
            </ul> 
            <div style="position: absolute; bottom: 2%; padding-left:10%;"><a href="http://www.softusion.com/" target="_blank"><img width="30" height="40" src="../images/SoftusionLOGO.png" alt=""><span style="font-size: 11px; float: right; margin-top: 15%;">Designed by Softusion Inc.</span></a></div><br>
            <!-- sidebar menu end-->
        </div>
    </aside>
    <!--sidebar end-->
    <!--main content start-->
	<!-- InstanceBeginEditable name="center" -->
  <section id="main-content">
    <section class="wrapper">
       
        <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
  <tbody>
    <tr>
      <td width="12%" align="center"><a href="dbipd.php"><img src="../images/icondb.png"></a></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><a href="dbipd.php">In Patient</a></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
  </tbody>
</table>

    
<br> 
      <!-- page start-->
      <div class="row">
        <div class="col-sm-12">
          <section class="panel">
           <header class="panel-heading">
              <h2>IPD PAYMENTS & REFUNDS</h2>
            </header>
           
            <table width="100%" border="0" cellpadding="1" cellspacing="0">
              <tr>
                	<td width="10%" align="right"></td>
                	<td width="50%"></td>
                  	<td width="5%" align="right"></td>
                  	<td width="25%" align="right"></td>
                  	<td width="10%"></td>
                  
              </tr>
            </table>
            <br>
            <br>
            <div class="panel-body" style="padding-top: 0px; margin-top: -34px;">
              <div class="adv-table">
                <table  class="display table table-bordered table-striped" id="dynamic-table">
                
                  <thead>
                    <tr>
                        
                         <th width="10%" align="center">Date</th>
                         <th width="10%" align="center">Transact ID</th>
                         <th width="25%" align="left">Account Title</th>
                         <th width="15%" align="left">Patient Name</th>
                         <th width="15%">Transaction Amount</th>
                         <th width="15%">Refunded Amount</th>
                         <th width="10%" align="center">&nbsp;</th>
                    </tr>
                  </thead>
                  
                  <tbody>
                  	<?php
					if(isset($transaction_data[0]['transact_id'])&&$transaction_data[0]['transact_id']!='')
					{
						for($t=0;$t<count($transaction_data);$t++)
						{
							if($t%2==0){$class='gradeX';}else{$class='gradeC';}
							
							if($transaction_data[$t]['patient_id']!=0)
							{
								$retrievePatientOb =  new classPatient;
								$retrievePatientOb->setPatientAutoID($transaction_data[$t]['patient_id']);
								$patient_single_detail = $retrievePatientOb->retrievePatientByPatientID();
							
								$patient_name = $patient_single_detail[0]['patient_fname'].' '.$patient_single_detail[0]['patient_lname'];
							}
							else
							{
								$patient_name = 'Out Door';
							}
							
							$accountOb = new classTransaction;
							$accountOb->setAccountID($transaction_data[$t]['account_id']);
							$account_data = $accountOb->retrieveAccountByID();
							
							
							$amount_payable = $transaction_data[$t]['payment']-$transaction_data[$t]['refunded_amount'];
							?>
							<tr class="<?php echo $class;?>">
                            
								
                                <td align="center"><?php echo date('d M Y',$transaction_data[$t]['transact_time']);?></td>
								<td align="center"><?php echo $transaction_data[$t]['transact_id'];?></td>
								<td align="left"><?php echo $account_data[0]['account_name'];?></td>
								<td align="left"><?php echo $patient_name;?></td>
                                
								<td align="right" >Rs. <?php if($transaction_data[$t]['payment']!=0){echo number_format($transaction_data[$t]['payment'],2);}else{echo 0;}?></td>
                                
                               
                               <td align="right" > <?php if($transaction_data[$t]['refunded_amount']!=0){echo 'Rs. '.number_format($transaction_data[$t]['refunded_amount'],2);}else{}?></td>
                                
								<td align="center">
                                <?php
								if($amount_payable!=0)
								{
									?>
									<a href="#transaction-box" class="transaction-window transaction_data" id="<?php echo $t;?>"> <span class="label label-danger label-mini">Refund</span></a>
									<?php
								}
								else
								{
									if($transaction_data[$t]['payment']!=0)
									{
										?>
										<span class="label label-success label-mini">Refunded</span>
										<?php
									}
								}
								?>
                                </td>
                                
							</tr>
                            
                            <input type="hidden" name="patient_id" class="set_to_pop" id="patient_id_<?php echo $t;?>" value="<?php echo $transaction_data[$t]['patient_id'];?>">
                            <input type="hidden" name="patient_name" class="set_to_pop" id="patient_name_<?php echo $t;?>" value="<?php echo $patient_name;?>">
                            
                            <input type="hidden" name="account_id" class="set_to_pop" id="account_id_<?php echo $t;?>" value="<?php echo $transaction_data[$t]['account_id'];?>">
                            <input type="hidden" name="account_name" class="set_to_pop" id="account_name_<?php echo $t;?>" value="<?php echo $account_data[0]['account_name'];?>">
                            
                            <input type="hidden" name="transact_id" class="set_to_pop" id="transact_id_<?php echo $t;?>" value="<?php echo $transaction_data[$t]['transact_id'];?>">
                            
                            <input type="hidden" name="amount_paid" class="set_to_pop" id="amount_paid_<?php echo $t;?>" value="<?php echo $transaction_data[$t]['payment'];?>">
                            
                            <input type="hidden" name="amount_payable" class="set_to_pop" id="amount_payable_<?php echo $t;?>" value="<?php echo $amount_payable;?>">
                             
                            <input type="hidden" name="refunded_amount" class="set_to_pop" id="refunded_amount_<?php echo $t;?>" value="<?php echo $transaction_data[$t]['refunded_amount'];?>">
                            <?php
						}
						?>
							
                  </tbody>
                  
                  <tfoot>
                  </tfoot>
                  
                </table>
                
                <Br>
                
                 <?php
						}
					else
					{
						?><table>
                 	<tr>
                    	<td align="right">No Transactions yet!</td>
                  	</tr>  
                </table>
                        
                        <?php
					}
				  ?>
                  
                  
                <table>
                 	<tr>
                    	<td align="right"><?php include('pagination.php'); ?></td>
                  	</tr>  
                </table>
                
              </div>
            </div>
          </section>
        </div>
      </div>
      <!-- page end-->
    </section>
  </section>
  <!-- InstanceEndEditable --><!--main content end-->
<!--right sidebar start-->
 
<!--right sidebar end-->
</section>
<!-- Placed js at the end of the document so the pages load faster -->
<!--Core js-->
<!--<script src="../js/jquery-1.10.2.min.js"></script>-->
  
 
<script src="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.js"></script>
<script src="../bs3/js/bootstrap.min.js"></script>



<script src="../js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../popUp/popUp.js"></script>
<script src="../js/ajax.js"></script>

<script src="../js/lib/jquery.js"></script>
<script src="../assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script>
<script src="../js/calendar/external-dragging-calendar.js"></script>
<script src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>
<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot-chart/excanvas.min.js"></script><![endif]-->
<script src="../assets/jQuery-slimScroll-1.3.0/jquery.slimscroll.js"></script>
<script src="../assets/skycons/skycons.js"></script>
<script src="../assets/jquery.scrollTo/jquery.scrollTo.js"></script>
<script src="../js/jquery.easing.min.js"></script>
<script src="../assets/calendar/clndr.js"></script>
<script src="../js/underscore-min.js"></script>
<script src="../assets/calendar/moment-2.2.1.js"></script>
<script src="../js/calendar/evnt.calendar.init.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-us-lcc-en.js"></script>
<script src="../assets/gauge/gauge.js"></script>



<!--clock init-->
<script src="../assets/css3clock/js/script.js"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<!--Morris Chart-->
<script src="../assets/morris-chart/morris.js"></script>
<script src="../assets/morris-chart/raphael-min.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.animator.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.growraf.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/custom-select/jquery.customSelect.min.js" ></script>
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>
<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>



<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>
<!--<start===================>-->
<script src="../js/lib/jquery.js"></script>


<script src="../bs3/js/bootstrap.min.js"></script>



<script class="include" type="text/javascript" src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>

<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<script src="../assets/sparkline/jquery.sparkline.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.js"></script>
<script src="../assets/flot-chart/jquery.flot.tooltip.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.resize.js"></script>
<script src="../assets/flot-chart/jquery.flot.pie.resize.js"></script>
<script type="text/javascript" src="../assets/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="../assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

<!--dynamic table-->
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>

<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>

<script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../datepicker/jquery-ui.js"></script>

<!--<script type="text/javascript" src="../popUp/jquery-1.9.0.js"></script>-->
<script type="text/javascript">

 function Popup(apri) { 
	window.open(apri,"","top=10,left=200,width=800,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
 }
</script> 

<div id="update_password-box" class="update_password-popup">
    
    <div class="pop_header">
        <span>Change Password</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_update_password_form"></div>
          
          <form action="" method="post" id="update_password_form" class="cmxform form-horizontal" onSubmit="return false;">
          	
            <br>
            
         	<div class="form-group">
            <label class="control-label col-lg-3" for="lastname">New Password:</label>
                <div class="col-lg-6">
                    <input type="password" name="password" class="form-control" value="" id="exampleInputPassword1">
                </div>
            </div>
           
            <p align="right">
            	<input type="hidden" name="user_id" value="<?php if(isset($user_id)&&$user_id!=''){echo $user_id;}else{ echo 
				$_SESSION['security']['user_id'];}?>">
                <input type="hidden" name="updateUserPwd" value="yes">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Update"/>
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div> 
 
</body>  
<!-- InstanceEnd --></html>

<div id="transaction-box" class="transaction-popup">
    
    <div class="pop_header">
        <span>Transaction</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_insert_ipdrefundtransaction_form" style="margin:10px;"></div>
          
          <form action="" method="post" id="insert_ipdrefundtransaction_form" class="cmxform form-horizontal" onSubmit="return false;">
          
           	<div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Account Head:</label>
              <div class="col-lg-6">
              <input type="hidden" name="acchead_id" value="<?php echo 1;?>">
               <?php echo $accounthead_name;?>
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Account Name:</label>
              <div class= "col-lg-6" id="account_name">
              </div>
              <input type="hidden" name="account_id" id="account_id" value="">
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Account Type:</label>
              <div class="col-lg-6">
                 <input type="hidden" name="type" value="Expense">
               <?php echo 'Expense';?>
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Patient Name:</label>
              <div class= "col-lg-6" id="patient_name">
              </div>
              <input type="hidden" name="patient_id" id="patient_id" value="">
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Amount Paid:</label>
              <div class="col-lg-6" id="amount_paid"></div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Refunded Amount:</label>
              <div class="col-lg-6" id="refunded_amount"></div>
				
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Refund Amount:</label>
              <div class="col-lg-6">
                <input type="text" name="payment_amount" id="lastname" class="form-control">
              </div>
            </div>
            
            <p align="right">
              <input type="hidden" name="trx_ipd_refund" value="yes">
              <input type="hidden" name="transact_id" id="transact_id" value="">
              <input type="hidden" name="amount_payable" id="amount_payable" value="">
              <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Save" />
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<script>

$(".transaction_data").click(function() {
	
	var id = this.id;
	
	account_id = $("#account_id_"+id).val();
	account_name = $("#account_name_"+id).val();
	
	patient_id = $("#patient_id_"+id).val();
	patient_name = $("#patient_name_"+id).val();
	
	amount_payable = $("#amount_payable_"+id).val();
	
	amount_paid = $("#amount_paid_"+id).val();
	
	transact_id = $("#transact_id_"+id).val();
	
	refunded_amount = $("#refunded_amount_"+id).val();
	
	$("#account_id").val(account_id);
	$("#account_name").html(account_name);
	
	$("#patient_id").val(patient_id);
	$("#patient_name").html(patient_name);
	
	$("#amount_paid").html(amount_paid);
	
	$("#amount_payable").val(amount_payable);

	$("#transact_id").val(transact_id);
	
	$("#refunded_amount").html(refunded_amount);
	
	
	
});
</script>