<?php
session_start();
include '../db_connect.php';

$vchno=$_POST[vchno];
if($_POST[vouchertype]=='JOURNAL')
{
		echo "<table width='100%' cellspacing='0' id='table_prod_details'>
	<thead>
	  <tr>
		<th scope='col'>PAYTYPE</th>
		 <th scope='col'>BILL ID</th>
		<th scope='col'>AMOUNT</th>
		<th scope='col'>BILL ID(Cr)</th>
		<th scope='col'>AMOUNT(Cr)</th>
		<th scope='col'>ANGST</th>
		
		<th width='8%'></th>
		<th width='8%'></th>
	  </tr>
	  </thead>";
	 echo "<tfoot class='tablefooter' style='width:100%'><tr ><td><textarea name='ptype'  >Total</textarea></td><td><textarea name='bno'   count='nor'></textarea></td><td><textarea name='amt'  count='yes'></textarea></td><td><textarea name='crbno'  ></textarea></td><td><textarea name='cramt' count='yes'></textarea></td><td><textarea name='angst_d' ></textarea></td><td style='display:none'><textarea   class='temp'  > </textarea></td><td style='display:none'><textarea   name='eid'  > </textarea></td><td style='display:none'><textarea name='p_refno'></textarea></td><td style='display:none'><textarea name='vtype'></textarea></td><td style='display:none'><textarea name='vno' ></textarea></td><td width='8%'></td><td align='center' width='8%'></td></tr></tfoot><tbody>";
  if(!empty($vchno))
 {
	$prod_det=mysqli_query($con,"SELECT * FROM  `vchdetails` where vchno='$vchno'  order by entryid ");
	if($prod_det)
	{	
		while($prod_det_row=mysqli_fetch_array($prod_det))
		{
			echo "<tr><td><textarea name='ptype' class='ptype'>$prod_det_row[paytype]</textarea></td><td><textarea name='bno'  class='bno'>$prod_det_row[billno]</textarea></td><td><textarea name='amt' class='amt'>$prod_det_row[amount]</textarea></td><td><textarea name='crbno'  class='crbno'>$prod_det_row[crbillno]</textarea></td><td><textarea name='cramt' class='cramt'>$prod_det_row[cramount]</textarea></td><td><textarea name='angst_d' class='angst_d'>$prod_det_row[angst_d]</textarea></td><td style='display:none'><textarea   class='temp'  name='temp'> </textarea></td><td style='display:none'><textarea   name='eid'  class='eid'> $prod_det_row[entryid]</textarea></td><td style='display:none'><textarea   name='p_refno'  class='p_refno' >$prod_det_row[refno]</textarea></td><td style='display:none'><textarea   name='vtype'  class='vtype' >$prod_det_row[vchtype]</textarea></td><td style='display:none'><textarea name='vno'  class='vno' >$prod_det_row[vchno]</textarea></td><td width='8%'><div><input type='button' name='prod_save' id='prod_save' class='prod_save filter_table' style='display:none' value='Save' /></div></td><td align='center' width='8%'><input type='button'    class='delete_voucher delete_row' value='X' /></td></tr>";
			$sr_track=$sr_track+1;
			
		}
		
	}
	

else
echo "error".mysqli_error($con);
 }
 
 
echo "<tr class='lastfoot'><td><textarea name='ptype' class='ptype'> $paytype</textarea></textarea></td><td><textarea name='bno' class='bno'> </textarea></td><td><textarea  name='amt' class='amt'></textarea></td><td><textarea name='crbno' class='crbno'> </textarea></td><td><textarea name='cramt' class='cramt'></textarea></td><td><select  name='angst_d'   class='angst_d angst'></select></td><td width='8%'><div> <input type='button' name='prod_savenew' id='prod_savenew' class='prod_savenew filter_table' style='display:none' value='Save' /></div></td><td width='8%'></td><td style='display:none'><textarea   class='temp'  name='temp'> </textarea></td><td style='display:none'><textarea   name='eid'  class='eid'></textarea></td><td style='display:none'><textarea name='p_refno'  class='p_refno'> </textarea></td><td style='display:none' ><textarea name='vtype' class='vtype'> </textarea></td><td style='display:none'><textarea   name='vno' class='vno'> $vchno</textarea></td></tr>";
 
	}
else
{
echo "<table width='100%' cellspacing='0' id='table_prod_details'>
<thead
  <tr>
    <th scope='col'>PAYTYPE</th>";
	if($_POST[vouchertype]=='PURCHASE')
   echo " <th scope='col'>BOOK ID</th>";
   else
   echo " <th scope='col'>BILL ID</th>";
   echo " <th scope='col'>AMOUNT</th>";
   if($_POST[vouchertype]=='RECEIPT')
   echo " <th scope='col'>Adjustment</th>";
	echo "<th width='8%'></th>
	<th width='8%'></th>
  </tr>
  </thead>";
  echo "<tfoot class='tablefooter' style='width:100%'><tr><td><textarea name='ptype' class='ptype' >Total</textarea></td><td><textarea name='bno'  class='bno' count = 'nor' ></textarea></td><td><textarea name='amt'  count='yes'></textarea></td>";
 if($_POST[vouchertype]=='RECEIPT')
echo "<td><textarea  name='cramt'  count='yes'></textarea></td>";
echo "<td style='display:none'><textarea class='temp' ></textarea></td><td style='display:none'><textarea name='eid' class='eid' ></textarea></td><td style='display:none'><textarea name='vtype'  class='vtype' ></textarea></td><td style='display:none'><textarea name='vno'  class='vno' ></textarea></td><td width='8%'></td><td align='center' width='8%'></td></tr></tfoot><tbody>";
 if(!empty($vchno))
 {
	 if($_POST[vouchertype]=='PURCHASE'){
$prod_det=mysqli_query($con,"SELECT * FROM  `purcdetails` where vchno='$vchno' order by entryid ");}
else{
$prod_det=mysqli_query($con,"SELECT * FROM  `vchdetails` where vchno='$vchno' order by entryid ");}
if($prod_det)
{	
while($prod_det_row=mysqli_fetch_array($prod_det))
{
echo "<tr><td><textarea name='ptype' class='ptype' >$prod_det_row[paytype]</textarea></td><td><textarea name='bno' class='bno' >$prod_det_row[billno]</textarea></td><td><textarea name='amt' class='amt' >$prod_det_row[amount]</textarea></td>";
 if($_POST[vouchertype]=='RECEIPT')
echo "<td><textarea name='cramt' class='cramt' >$prod_det_row[cramount]</textarea></td>";

echo "<td style='display:none'><textarea class='temp' ></textarea></td><td style='display:none'><textarea name='eid'  class='eid' >$prod_det_row[entryid]</textarea></td><td style='display:none'><textarea name='vtype'  class='vtype' >$prod_det_row[vchtype]</textarea></td><td style='display:none'><textarea name='vno'  class='vno' >$prod_det_row[vchno]</textarea></td><td width='8%'><div><input type='button' name='prod_save' class='prod_save filter_table' style='display:none' value='Save' /></div></td><td align='center' width='8%'><input type='button' class='delete_voucher delete_row' value='X' /></td></tr>";
$sr_track=$sr_track+1;
}
}

else
echo "error".mysqli_error($con);
 }
 
 //making against ref default in purchase and receipt
 if($_POST[vouchertype]=='PURCHASE'||$_POST[vouchertype]=='RECEIPT')
 $paytype='Agnst Ref';
 else
 $paytype='';

echo "<tr class='lastfoot'><td><textarea name='ptype' class='ptype' >$paytype</textarea></td><td><textarea name='bno' class='bno' ></textarea></td><td><textarea name='amt' class='amt' ></textarea></td>";
 if($_POST[vouchertype]=='RECEIPT')
echo "<td><textarea name='cramt' class='cramt' ></textarea></td>";

echo "<td style='display:none'><textarea class='temp' ></textarea></td><td style='display:none'><textarea name='vno' class='vno' >$vchno</textarea></td><td style='display:none' ><textarea name='vtype' class='vtype' ></textarea></td><td width='8%'><div> <input type='button' name='prod_savenew'  class='prod_savenew filter_table' style='display:none' value='Save' /></div></td><td width='8%'></td></tr>";

 echo "</tbody></table>";
}
?>
