<?php
include('../config/config.php');
include('../classes/classPatient.php');
include("../classes/classImages.php");
include('../classes/classDiagnostic.php');
include('../classes/classTransaction.php');
include("../classes/classVisits.php");
include("../classes/classShift.php");

/*echo '<pre>';
print_r($_POST);
print_r($_SESSION);
echo '</pre>';
exit;

*/
$shiftIDOb = new classShift;
$shift_data = $shiftIDOb->retrieveShiftByLocationIDTypeAndStatus($_SESSION['security']['location_id'],'open','diagnostic');
$_SESSION['temp']['diagshiftid'] = $shift_data[0]['shift_id'];

if(isset($_SESSION['temp']['diagshiftid']))
{
	$shiftid=$_SESSION['temp']['diagshiftid'];
}

if((isset($_GET['ref'])&&(base64_decode($_GET['ref'])=='new'))||(isset($_POST['save_exit'])&&($_POST['save_exit']=='Save & Exit')))
{
	unset($_SESSION['temp']['diaginvoice_id']);
	unset($_SESSION['temp']['patient_id']);
	
	if(isset($_POST['save_exit']))
	{
		header("Location:mgmttestsbydate.php");
	}
	else
	{
		header("Location:diagtestinv.php");	
	}
}

################# add items of visit prescription Start ####################################

if(isset($_GET['visitid'])&&isset($_GET['patientid'])!='')
{
	

	$_SESSION['temp']['visit_id'] = base64_decode($_GET['visitid']);
	$_SESSION['temp']['patient_id'] = base64_decode($_GET['patientid']);
	
	
	try
	{
		$createInvOb = new classDiagnostic;
		$createInvOb->setUserID($_SESSION['security']['user_id']);
		$createInvOb->setLocationID($_SESSION['security']['location_id']);
		$createInvOb->setPatientID($_SESSION['temp']['patient_id']);
		$createInvOb->setVisitID($_SESSION['temp']['visit_id']);
		$createInvOb->setShiftID($_SESSION['temp']['diagshiftid']);
		$createInvOb->createDiagInvoice();
		
		$_SESSION['temp']['diaginvoice_id'] = $createInvOb->getDiagInvoiceID();
		
		$retrieveVisitPrecOb = new classVisits;
		$retrieveVisitPrecOb->setVisitID($_SESSION['temp']['visit_id']);
		$prec_array = $retrieveVisitPrecOb->retrievePrescription();
		//print_r($prec_array);
		if(isset($prec_array[0]['presc_item_id'])&&$prec_array[0]['presc_item_id']!='')
		{
			
			for($prm=0;$prm<count($prec_array);$prm++)
			{
				
				if($prec_array[$prm]['labtest_id']!=0)
				{	
					$diagnosis_id = $prec_array[$prm]['labtest_id'];
					$diagnosis_type = 'labtest';
	
				}
				elseif($prec_array[$prm]['procedure_id']!=0)
				{	
					$diagnosis_id = $prec_array[$prm]['procedure_id'];
					$diagnosis_type = 'procedure';
					
	
				}
				else
				{
					$diagnosis_id = '';
					$diagnosis_type = '';
				}
				$addItemOb = new classDiagnostic;
				$addItemOb->setDiagnosisID($diagnosis_id);
				$addItemOb->setDiagnosisType($diagnosis_type);
				$addItemOb->setDiagInvoiceID($_SESSION['temp']['diaginvoice_id']);
				$addItemOb->addItemsInInvoice();
			}
		}
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
	
	header("Location:diagtestinv.php");
}

################# Delete Item Start ####################################

if(isset($_GET['diagitemdel'])&&$_GET['diagitemdel']!='')
{
	try
	{
		$delItemOb = new classDiagnostic;
		$delItemOb->setDiagItemID(base64_decode($_GET['diagitemdel']));
		$delItemOb->deleteDiagItemsInInvoice();
		header("Location:diagtestinv.php");
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

if(isset($_GET['diaggroupdel'])&&$_GET['diaggroupdel']!='')
{
	try
	{
		$delGroupOb = new classDiagnostic;
		$delGroupOb->setLabTestGroupID(base64_decode($_GET['diaggroupdel']));
		$delGroupOb->setDiagInvoiceID(base64_decode($_GET['inv_id']));
		$delGroupOb->deleteDiagGroupTestsInInvoice();
		header("Location:diagtestinv.php");
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}


################## Create Invoice Start ####################################

if((isset($_POST['patient_type'])&&$_POST['patient_type']!='')||(isset($_GET['patient_type'])&&$_GET['patient_type']!=''))
{
	if(isset($_POST['patient_type'])&&$_POST['patient_type']=='out_patient')
	{
		$_SESSION['temp']['patient_id'] = "0";
	}
	elseif(isset($_GET['patient_type'])&&$_GET['patient_type']!='')
	{
		$_SESSION['temp']['patient_id'] = $_GET['patient_type'];
	}
	else
	{
		$_SESSION['temp']['patient_id'] = $_POST['patient_type'];
	}

	try
	{
		$createInvOb = new classDiagnostic;
		$createInvOb->setUserID($_SESSION['security']['user_id']);
		$createInvOb->setLocationID($_SESSION['security']['location_id']);
		$createInvOb->setPatientID($_SESSION['temp']['patient_id']);
		$createInvOb->setShiftID($_SESSION['temp']['diagshiftid']);
		$createInvOb->setVisitID("0");
		$createInvOb->createDiagInvoice();
		
		$_SESSION['temp']['diaginvoice_id'] = $createInvOb->getDiagInvoiceID();
		
		if(isset($_GET['reffered_by'])&&$_GET['reffered_by']!='')
		{
			$updateRefOb = new classDiagnostic;
			$updateRefOb->setDiagInvoiceID($_SESSION['temp']['diaginvoice_id']);
			$updateRefOb->setReferringBy($_GET['reffered_by']);
			$updateRefOb->updateRefferedByInDiagInvoice();
		}
		
		
		header("Location:diagtestinv.php");
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

if(isset($_GET['diaginvoice_id'])&&isset($_GET['patient_id'])!='')
{
	$_SESSION['temp']['diaginvoice_id'] = base64_decode($_GET['diaginvoice_id']);
	$_SESSION['temp']['patient_id'] = base64_decode($_GET['patient_id']);
	header("Location:diagtestinv.php");
}

if(isset($_SESSION['temp']['patient_id'])&&$_SESSION['temp']['patient_id']!='')
{
	$patient_id = $_SESSION['temp']['patient_id'];
}
if(isset($_SESSION['temp']['diaginvoice_id'])&&$_SESSION['temp']['diaginvoice_id']!='')
{
	$invoice_id = $_SESSION['temp']['diaginvoice_id'];
}

################## Add Item In Invoice Start ####################################

if(isset($_POST['add_diag'])&&$_POST['add_diag']=='Add Test to Invoice')
{
	try
	{
		
		if(isset($_POST['labtest_ids'][0])&&$_POST['labtest_ids'][0]!='')
		{
			$addGroupOb = new classDiagnostic;
			$addGroupOb->setDiagnosisID($_POST['group_id']);
			$addGroupOb->setDiagnosisType('group');
			$addGroupOb->setDiagInvoiceID($_POST['diaginvoice_id']);
			$addGroupOb->addItemsInInvoice();
			
			for($li=0;$li<count($_POST['labtest_ids']);$li++)
			{
				$diagnosis_id = $_POST['labtest_ids'][$li];
				$diagnosis_type = 'labtest';
				
				$addItemOb = new classDiagnostic;
				$addItemOb->setDiagInvoiceID($_POST['diaginvoice_id']);
				$addItemOb->setLabTestGroupID($_POST['group_id']);
				$addItemOb->setDiagnosisID($diagnosis_id);
				$addItemOb->setDiagnosisType($diagnosis_type);
				$addItemOb->addItemsInInvoice();
			}
			/*$payment = $addItemOb->retrieveTestGroupCostByID($_POST['group_id'])+$addItemOb->retrieveInvoiceItemsTotal();
			$addItemOb->setPayment($payment);
			$addItemOb->setDiscount("0");
			$addItemOb->updateDiagInvoice();*/
			
		}
		else
		{
			$addItemOb = new classDiagnostic;
			if(@$_POST['labtest_id']!=''||@$_POST['procedure_id']!='')
			{
				if($_POST['labtest_id']!='')
				{
					$diagnosis_id = $_POST['labtest_id'];
					$diagnosis_type = 'labtest';
					$addItemOb->setLabTestGroupID("0");
				}
				elseif($_POST['procedure_id']!='')
				{
					$diagnosis_id = $_POST['procedure_id'];
					$diagnosis_type = 'procedure';
				}
			}
			else
			{
				$diagnosis_id = '';
				$diagnosis_type = '';
			}
			
			
			$addItemOb->setDiagnosisID($diagnosis_id);
			$addItemOb->setDiagnosisType($diagnosis_type);
			$addItemOb->setDiagInvoiceID($_POST['diaginvoice_id']);
			$addItemOb->addItemsInInvoice();
		}
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

################## Retrieve Data Start ####################################

try
{
	
	///////////// retrieve patients ////////////////////////////////////////
	
	$retrievePatientOb = new classPatient;
	if(isset($patient_id)&&($patient_id!=''&&$patient_id!=0))
	{
		$retrievePatientOb->setPatientAutoID($patient_id);
		$patient_single_detail = $retrievePatientOb->retrievePatientByPatientID();
		
	}
	
	///////////// retrieve invoice data ///////////////////////////////
	
	if(isset($invoice_id)&&$invoice_id!='')
	{
		$retrieveInvoiceOb = new classDiagnostic;
		$retrieveInvoiceOb->setDiagInvoiceID($invoice_id);
		$invoice_array = $retrieveInvoiceOb->retrieveInvoiceDetail();
		$invoice_items_array = $retrieveInvoiceOb->retrieveInvoiceItemsDetail();
	}
	
	///////////// retrieve test data ///////////////////////////////
	
	$retrieveTestOb = new classDiagnostic;
	$retrieveTestOb->setOrganizationID($_SESSION['security']['org_id']);
	$labtest_array = $retrieveTestOb->retrieveLabTests();
	$procedure_array = $retrieveTestOb->retrieveProcedures();
	$group_array = $retrieveTestOb->retrieveTestGroupsHavingTests();
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	
		

try
{
	$tranOb = new classTransaction;
	$account_data = $tranOb->retrieveAccountHeadAndAccountByID(11,9);	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}
/*echo '<pre>';
print_r($invoice_items_array);
echo '</pre>';
exit;
*/

?>
<!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('printdiaginv.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">
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i>
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
					  
				
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);
           
		  
				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)
				{
					?>
					    <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)
				{
					?>
						<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())
		  {
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#3AC7F9;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
					
		  }
		  if($orgOb->getOT())
		  {
			   		?>
						<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)
				{
			  		?>
						<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)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getEmergency())
		  {
					  ?>
						<li class="sub-menu">
						<a href="dbemergency.php" style="background:#8EC63F;">
						<i class="fa fa-tasks"></i>
						<span>Emergency </span>
						</a>
						</li>
						<?php
		  }
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9)
				{
					?>
						<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" -->
    <script type="text/javascript">

     function Popup(apri) { 
        window.open(apri,"","top=10,left=200,width=520,height=600,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
     }
</script>
  <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="dbdiagnostics.php"><img src="../images/icondb.png"></a></td>
       <td width="12%" align="center"><a href="mgmttestsbydate.php"><img src="../images/iconcash.png"></a></td>
      <!--<td width="12%" align="center"><a href="opdtests.php"><img src="../images/iconlabs.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="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><a href="dbdiagnostics.php">Diagnostics</a></td>
      <td align="center"><a href="mgmttestsbydate.php">Test Invoices</a></td>
      <!--<td align="center"><a href="opdtests.php">OPD Test Requests</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 height="24" align="center">&nbsp;</td>
    </tr>
  </tbody>
	</table>

	<br>
      <!-- page start-->
       <div class="row">
            <div class="col-sm-12">
                <section class="panel">
                    <div class="panel-body invoice">
                        <div class="invoice-header">
                            <div class="invoice-title col-md-3 col-xs-12">
                                    <h2>INVOICE</h2>
                            </div>
                            
                        </div>
                      	<?php
						if(isset($error_message)&&$error_message!='')
						{
							?>
                            <table>
							<tr>
								<td><span class="message_red"><?php echo $error_message;?></span></td>
							</tr>
                            <tr><td>&nbsp;</td></tr>
                            </table>
							<?php
						}
						?>
                        
                        <?php
						if(isset($_SESSION['temp']['diaginvoice_id'])&&$_SESSION['temp']['diaginvoice_id']!='')
						{
							?>
							<div id="result"></div>
                            
							
							<form action="" method="post">	
							

							<table width="100%" border="0" cellspacing="1" cellpadding="1">
                              <tr>
                                <td width="50%"><table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
                                  <tbody>
                                    <tr>
                                      <td>Patient ID:</td>
                                      <td><?php  if(isset($patient_single_detail[0]['patient_auto_id'])){echo $patient_single_detail[0]['patient_auto_id'];}?></td>
                                    </tr>
                                    <tr>
                                      <td width="18%">Patient Name:</td>
                                      <td width="82%"><strong>
                                        <?php if(isset($patient_single_detail[0]['patient_fname'])){echo ucwords($patient_single_detail[0]['patient_fname'].' '.$patient_single_detail[0]['patient_lname']);}else{echo 'Outdoor';}?>
                                        </strong> - s/d/w of: <strong>
                                          <?php if(isset($patient_single_detail[0]['relationship_name'])){echo ucwords($patient_single_detail[0]['relationship_name']);}?>
                                        </strong></td>
                                    </tr>
                                    <tr>
                                      <td>Gender:</td>
                                      <td><strong>
                                        <?php if(isset($patient_single_detail[0]['gender'])){echo $patient_single_detail[0]['gender'];}?>
                                         </strong> - Age: <strong>
                                          <?php if(isset($patient_single_detail[0]['age'])){echo $patient_single_detail[0]['age'].' years';}?>
                                      </strong></td>
                                    </tr>
                                    <tr>
                                      <td>Phone:</td>
                                      <td><strong>
                                        <?php if(isset($patient_single_detail[0]['phone'])){echo $patient_single_detail[0]['phone'];}?>
                                      </strong></td>
                                    </tr>
                                    <tr>
                                      <td>Address:</td>
                                      <td><strong>
                                        <?php if(isset($patient_single_detail[0]['address'])){echo $patient_single_detail[0]['address'];}?>
                                      </strong></td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>Invoice No:</td>
                                      <td><?php echo $invoice_id;?></td>
                                    </tr>
                                  </tbody>
                                </table></td>
                                <td width="50%">&nbsp;</td>
                              </tr>
                              <tr>
                                <td><table width="100%" border="0" align="left" cellspacing="0" cellpadding="0">
                                  <tbody>
                                    <tr>
                                      <td width="18%">Referred by:</td>
                                      <td width="82%"><input name="reffered_by" id="reffered_by" type="text" class="form-control" value="<?php echo $invoice_array[0]['referred_by'];?>" style="width:40%; margin-top:5px; margin-bottom:5px;"/></td>
                                    </tr>
                                     <tr>
                                      <td width="18%">Referred To:</td>
                                      <td width="82%"><input name="reffered_to" id="reffered_to" type="text" class="form-control" value="<?php echo $invoice_array[0]['referred_to'];?>" style="width:40%; margin-top:5px; margin-bottom:5px;"/></td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td>&nbsp;</td>
                                    </tr>
                                  </tbody>
                                </table></td>
                                <td><table width="100%" border="0" cellspacing="1" cellpadding="1">
                                  <tr>
                                    <td width="40%" valign="bottom"><select name="group_id" id="#select_group_tests-box" class="form-control input-sm m-bot15 select_group_tests-window" style="margin-top: 13px;">
                                      <option value="">Select Group</option>
                                      <?php
                                                                        for($g=0;$g<count($group_array);$g++)
                                                                        {
                                                                            ?>
                                      <option value="<?php echo $group_array[$g]['group_id'];?>"><?php echo $group_array[$g]['group_name'];?></option>
                                      <?php
                                                                        }
                                                                        ?>
                                    </select></td>
                                    <td width="30%" valign="bottom"><select name="labtest_id" class="form-control input-sm m-bot15">
                                      <option value="">Select Test</option>
                                      <?php
                                                                        for($l=0;$l<count($labtest_array);$l++)
                                                                        {
                                                                            ?>
                                      <option value="<?php echo $labtest_array[$l]['labtest_id'];?>"><?php echo $labtest_array[$l]['labtest_name'];?></option>
                                      <?php
                                                                        }
                                                                        ?>
                                    </select></td>
                                    <!--<td width="10%"><select name="procedure_id" class="form-control input-sm m-bot15">-->
                                    <!-- <option value="">Select Procedure</option>
                                                                        <?php
                                                                        //for($p=0;$p<count($procedure_array);$p++)
                                                                        //{
                                                                            ?>
                                                                            <option value="<?php //echo $procedure_array[$p]['procedure_id'];?>"><?php //echo $procedure_array[$p]['procedure_name'];?></option>-->
                                    <?php
                                                                        //}
                                                                        ?>
                                    <!-- </select></td>-->
                                    <td width="30%"><input name="diaginvoice_id" id="diaginvoice_id" type="hidden" class="btn btn-primary" value="<?php echo $invoice_id;?>"/>
                                      <input name="add_diag" type="submit" class="btn btn-primary" value="Add Test to Invoice" style="float:right; margin-right:20px;"/></td>
                                  </tr>
                                </table></td>
                              </tr>
                            </table>

                            </form>
							
							<table class="table table-invoice" style="margin-top:0px;">
                            
								<thead>
									<tr>
										<th width="10%">T-Code</th>
										<th width="30%">Description</th>
                                        <th width="15%" class="text-center">Specimen No.</th>
										<th width="15%" class="text-center">Price</th>
										<!--<th width="15%"class="text-center">Discount</th>-->
										<th width="15%" class="text-center">Amount</th>
									</tr>
								</thead>
                                
								<tbody>
                               	<?php
								
								if(isset($invoice_items_array[0]['diagitems_id'])&&$invoice_items_array[0]['diagitems_id']!='')
								{
									$old = 0;
									$group = '';
									
									for($ri=0;$ri<count($invoice_items_array);$ri++)
									{
											$type = $invoice_items_array[$ri]['diagnosis_type'];
											$id = $invoice_items_array[$ri]['diagnosis_id'];
											$diagitems_id = $invoice_items_array[$ri]['diagitems_id'];
											$price = $invoice_items_array[$ri]['price'];
											$specimen = $invoice_items_array[$ri]['specimen'];
											$group_id = $invoice_items_array[$ri]['group_id'];
											
											
											$diagOb = new classDiagnostic;
											if($type=='group')
											{
												$diagOb->setLabTestID($id);
												$diagnosis_name = $diagOb->retrieveTestGroupNameByID($id);
												$group_cost = $diagOb->retrieveTestGroupCostByID($id);
											}
											
											if($type=='labtest')
											{
												$diagOb->setLabTestID($id);
												$labtest_array = $diagOb->retrieveLabTestsByLabTestID();
												$diagnosis_name = $labtest_array[0]['labtest_name'];
											}
											if($type=='procedure')
											{
												$diagOb->setProcedureID($id);
												$proc_array = $diagOb->retrieveProcedureByProcedureID();
												$diagnosis_name = $proc_array[0]['procedure_name'];
											}
											
											
											if($group_id==0&&$group=='yes')
											{
												?>
                                                <tr>
                                                	<td style="background-color:white;"></td>
                                                	<td style="background-color:white;">&nbsp;</td>
                                                </tr>
                                                <?php
												$group = '';
											}
											
											
                                            if($type=='group')
											{
												?>
                                                <tr>
                                                
                                                	<td colspan="3" align="left"><a href="diagtestinv.php?diaggroupdel=<?php echo base64_encode($id);?>&inv_id=<?php echo base64_encode($invoice_id);?>"><img src="../images/cross.png" alt="Delete" border="0"/></a> <span style="font-size:14px;"><strong>Group: <?php echo ucwords($diagnosis_name);?></strong></span></a></td>
                                                    
                                                    <td align="right">Rs. <?php echo number_format($price,2);?></td>
                                                    <td align="right">Rs. <?php echo number_format($price,2);?></td>
                                                </tr>
                                                <?php
												$group = 'yes';
												
												
											}
											else
											{
												?>
											   
												<tr>
												
													<td><?php echo $id;?></td>
													
													<td><a href="diagtestinv.php?diagitemdel=<?php echo base64_encode($diagitems_id);?>"><img src="../images/cross.png" alt="Delete" border="0"/></a> <?php echo $diagnosis_name;?></td>
													
													<td class="text-center">
													<?php 
													if($type=='procedure'||$type=='group')
													{
														$specimen='';
														$type='hidden';
													}
													else
													{
														$type='text';
													}
													?>
													<input type="<?php echo $type;?>" name="specimen_no" size="12" value="<?php echo $specimen;?>" class="specimen_no" id="specimen_no_<?php echo $ri;?>">
													</td>
													
													<td class="text-right">
													<?php 
													if($group_id==0)
													{
														echo 'Rs. '.$price;
													}
													?>
													</td>
													
													<td class="text-right"><span id="net_total_<?php echo $ri;?>"><?php 
													if($group_id==0)
													{
														echo 'Rs. '.number_format($invoice_items_array[$ri]['net_total'],2);
													}
													?></span></td>
													
												</tr>
												
												<input name="diagnosis_id[]" class="diagnosis_id" id="diagnosis_id_<?php echo $ri;?>" value="<?php echo $id;?>" type="hidden" size="5"/>
												<input name="diagitems_id[]" class="diagitems_id" id="diagitems_id_<?php echo $ri;?>" value="<?php echo $diagitems_id;?>" type="hidden" size="5"/>
												<input name="discount[]" class="diag_discount" id="discount_diag_<?php echo $ri;?>" value="0" type="hidden">
												
												<?php
											}
									}
								}
								
								
								?>  
                                </tbody>
                                
							</table>
                           
							<div class="row">
								
								<div class="col-md-3 invoice-block pull-right">
									<ul class="unstyled amounts">
                                    
										<li>Total: Rs. <span id="invoice_amount"><?php echo $invoice_array[0]['invoice_amount']?></span></li>
										<li>Discount: 
                                        <select name="invoice_discount[]" class="diag_invoice_discount" id="invoice_discount">
                                        
                                            <option value="0" <?php if($invoice_array[0]['discount']=='0'){echo 'selected';}?>>None</option>
                                            <option value="1" <?php if($invoice_array[0]['discount']=='1'){echo 'selected';}?>>1%</option>
                                            <option value="2" <?php if($invoice_array[0]['discount']=='2'){echo 'selected';}?>>2%</option>
                                            <option value="3" <?php if($invoice_array[0]['discount']=='3'){echo 'selected';}?>>3%</option>
                                            <option value="4" <?php if($invoice_array[0]['discount']=='4'){echo 'selected';}?>>4%</option>
                                            <option value="5" <?php if($invoice_array[0]['discount']=='5'){echo 'selected';}?>>5%</option>
                                            <option value="6" <?php if($invoice_array[0]['discount']=='6'){echo 'selected';}?>>6%</option>
                                            <option value="7" <?php if($invoice_array[0]['discount']=='7'){echo 'selected';}?>>7%</option>
                                            <option value="8" <?php if($invoice_array[0]['discount']=='8'){echo 'selected';}?>>8%</option>
                                            <option value="9" <?php if($invoice_array[0]['discount']=='9'){echo 'selected';}?>>9%</option>
                                            <option value="10" <?php if($invoice_array[0]['discount']=='10'){echo 'selected';}?>>10%</option>
                                            <option value="11" <?php if($invoice_array[0]['discount']=='11'){echo 'selected';}?>>11%</option>
                                            <option value="12" <?php if($invoice_array[0]['discount']=='12'){echo 'selected';}?>>12%</option>
                                            <option value="13" <?php if($invoice_array[0]['discount']=='13'){echo 'selected';}?>>13%</option>
                                            <option value="14" <?php if($invoice_array[0]['discount']=='14'){echo 'selected';}?>>14%</option>
                                            <option value="15" <?php if($invoice_array[0]['discount']=='15'){echo 'selected';}?>>15%</option>
                                            
                                        </select>
                                        </li>
										<li class="grand-total">Amount Payable: Rs. <span id="amount_payable"><?php echo $invoice_array[0]['amount_payable'];?></span></li>
                                        <input type="hidden" name="amount_payable" id="amount_payable_form"  value="<?php echo $invoice_array[0]['amount_payable'];?>">
									</ul>
								</div>
							</div>
						  
							<div class="text-center invoice-btn">
                            <form action="" method="post">
                            <input name="save_exit" type="submit" class="btn btn-success btn-lg" value="Save & Exit"/>
                             <a href="#transaction-box" class="transaction-window transaction_data btn btn-success btn-lg" id="">Receive Payment</a>
                            <a href="javascript:Popup('printdiaginv.php')" class="btn btn-primary btn-lg"><i class="fa fa-print"></i> Print </a>
                            </form>
								<!--<a class="btn btn-success btn-lg"><i class="fa fa-check"></i> Submit Invoice </a>-->
								
							</div>
                            
                            <div class="col-md-9 payment-method">
									<h4>Terms &amp; Conditions</h4>
									<p>1. Check Cash before leaving.</p>
									<p>2. No Legal responsibility and Financial Liability is accepted for any error or ommission.</p>
									<p>3. Fee is non refundable, once the tests are done.</p>
                                    <p>4. NOT VALID FOR ANY COURT CASES.</p>
									<br>
									<h3 class="inv-label itatic">Thank you for your business</h3>
								</div>
							
							<?php
						}
						else
						{
							?>
                            <table width="100%" border="0">
                            <tr>
                                <td>
                                	<div class="form-group">
                                	<form action="" method="post" id="default_form">
                                        <label class="control-label col-lg-3" for="firstname" style="width:11%;">Patient Type:</label>
                                        <div class="col-lg-6">
                                            <select name="patient_type" id="patient_type" class="form-control input-sm m-bot15 patient_type">
                                                <option value="">Select Patient Type</option>
                                                <option value="in_patient">Registered Patient</option>
                                                <option value="out_patient">New Patient</option>
                                            </select>
                                        </div>
                                       <!-- <a href="#select_patient-box" class="select_patient-window btn btn-primary"  id="select_patient_popup" style="display:none; float:left; width:11%;">Select Patient</a>-->
                                    </form>
                                	</div>
                               	</td>
                            </tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr><td>&nbsp;</td></tr>
                            <tr><td>&nbsp;</td></tr>
                        </table>
                            <?php
						}
						?>
                    </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="select_patient-box" class="select_patient-popup">
    
    <div class="pop_header">
        <span>Select Patient</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <div class="scrollbar" style="height:300px;">
    
   		<form action="" method="post" id="patient_search_form">
    	<table width="100%" border="0" cellpadding="1" cellspacing="0">
         
          <tr>
          
            <td width="12%" align="right">Search Name: </td>
            <td width="15%">
                <input type="text" name="by_name" id="by_name" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">ID: </td>
            <td width="15%">
                <input type="text" name="by_id" id="by_id" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">Phone: </td>
            <td width="15%">
                <input type="text" name="by_phone" id="by_phone" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td><input name="search" type="submit" id="patient_search" class="btn btn-success btn-sm" value="Search"/></td>
            
            <td width="15%" align="left"><a href="#" id="view_all_patients">View All</a></td>
            
          
          </tr>
        </table>
        <input type="hidden" name="search_patient" value="Search">
        </form>  
         
    	<table class="display table table-bordered table-striped" id="dynamic-table">
        
          <thead>
            <tr>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">ID</th>
              <th width="10%" align="center">DOB</th>
              <th width="20%">Patient Name</th>
              <th width="15%">Phone</th>
              <th width="15%">Registration Date</th>
            </tr>
          </thead>
          
          <tbody id="default_body">
          </tbody>
         
        </table>
        
    </div>
    
</div>

<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_diagtransaction_form" style="margin:10px;"></div>
          
          <form action="" method="post" id="insert_diagtransaction_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 $account_data[0]['acchead_id'];?>">
               <?php echo $account_data[0]['acchead_name'];?>
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Account Name:</label>
              <div class= "col-lg-6">
                <input type="hidden" name="account_id" value="<?php echo $account_data[0]['account_id'];?>">
               <?php echo $account_data[0]['account_name'];?>
              </div>
            </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="<?php echo $account_data[0]['type'];?>">
               <?php echo $account_data[0]['type'];?>
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Amount Payable:</label>
              <div class="col-lg-6" id="amount_payable_html">
               
              </div>
              <input type="hidden" name="amount_payable" id="amount_payable_value" value="">
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Payment Amount:</label>
              <div class="col-lg-6">
                <input type="text" name="payment_amount" id="lastname" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Description:</label>
              <div class="col-lg-6">
                <textarea name="description" cols="43" rows="5"></textarea>
              </div>
            </div>
            
            <p align="right">
              <input type="hidden" name="patient_id" id="patient_id" value="<?php echo $patient_id;?>">
              <input type="hidden" name="diaginvoice_id" id="diaginvoice_id" value="<?php echo $invoice_id;?>">
              <input type="hidden" name="trx_diagnostic" value="yes">
              <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Save" />
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<div id="select_group_tests-box" class="select_group_tests-popup">
    
    <div class="pop_header">
        <span>Select LabTests</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
   
    <div class="scrollbar" style="height:300px;">
    <form action="" method="post">	
        
        <table width="100%">
            <tr>
                <td align="right">
                <input name="diaginvoice_id" type="hidden" class="btn btn-primary" value="<?php echo $invoice_id;?>"/>
               
                <input name="add_diag" type="submit" class="btn btn-primary" value="Add Test to Invoice" style="float:right; margin-top:10px;"/>	
                </td>
            </tr>
        </table>
        
        <div id="default_body_groups"></div>
        
    </form>   
    </div>
     
    
</div>

<div id="add_patient-box" class="add_patient-popup">
    
    <div class="pop_header">
        <span>Add Patient</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_patient_form" style="margin:10px;"></div>
          <form action="" method="post" id="insert_patient_form" class="cmxform form-horizontal" onSubmit="return false;">
          
           	<div class="form-group">
              <label class="control-label col-lg-3" for="firstname">First Name:</label>
              <div class="col-lg-6">
              	<input type="text" name="patient_fname" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Last Name:</label>
              <div class= "col-lg-6">
                <input type="text" name="patient_lname" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">S/D/W of:</label>
              <div class="col-lg-6">
                <input type="text" name="relationship_name" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Gender:</label>
              <div class="col-lg-6">
                <select name="gender" class="form-control input-sm m-bot15" style="width:50%;">
                    <option value="Male">Male</option>
                    <option value="Female">Female</option>
                </select>
              </div>
            </div>
            
             <div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Age:</label>
                <div class="col-lg-6">
                    <input type="text" name="age" class=" form-control" value="" style="width:50%; display:inline;">
                </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Phone:</label>
              <div class="col-lg-6">
                 <input type="text" name="phone" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Address:</label>
              <div class="col-lg-6">
               <input type="text" name="address" value="" class="form-control">
            </div>
            </div>
            
             <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Referred By:</label>
              <div class="col-lg-6">
               <input type="text" name="reffered_by" value="" class="form-control">
            </div>
            </div>
            
            <p align="right">
              <input type="hidden" name="add_patient_basic" value="yes">
              <input type="hidden" name="fee_per_session" value="0">
              <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;
	amount_payable = $("#amount_payable_form").val();
	
	$("#amount_payable_html").html(amount_payable);
	$("#amount_payable_value").val(amount_payable);
	
	
});


</script>