<?php 
$PageSecurity = 5;
include("includes/session.inc");
include("includes/DefineSuppTransClass.php");
include("includes/function_lib.php");

//echo "SELECT prdate FROM materialrequisitions WHERE Reqno='".$_REQUEST['p']."'";
$vendor_date= DB_query("SELECT req_date FROM purchase WHERE id='".$_REQUEST['p']."'",$db);
$get_date=DB_fetch_array($vendor_date);
echo $_REQUEST['p'];

$data="";
$data2="";	
$data1.="<input type='hidden' value='".$get_date['req_date']."' name='pr_date'/>";

	$data2.="<div style='overflow:auto; width:800px; height:auto; padding-left:auto;padding-right:auto;'>
				<table width='100%' border='1' cellpadding='3' cellspacing='0' style='border-collapse:collapse; border:#666666 solid 1px;'>
				<tr>
				  <td colspan='9' class='tabledata'>Period Wise</td>
				</tr>
				<tr>
				  <td class='tabledata'>S. No.</td>
				  <td class='tabledata'>Date</td>
				  <td class='tabledata'>TT No.</td>
				  <td class='tabledata'>Party Name</td>
				  <td class='tabledata'>Product Name</td>
				  <td class='tabledata'>Invoice No.</td>
				  <td class='tabledata'>Fault Details</td>
				  <td class='tabledata'>Scope of service</td>
				  <td class='tabledata'>Technician</td>
				  <td class='tabledata'>Current Status</td>
				</tr>";
				   $prid=array();
				  $val=$_REQUEST['p']; 
		
				  $sql="SELECT  * FROM purchase_details WHERE purchase_id='".$val."'";
			
				  $ErrMsg="Requisition Details Don't Exist";
				  $result_req =DB_query($sql,$db,$ErrMsg);
				  $i=0;
				  while($myrow_req = DB_fetch_array($result_req))
				  {
				  	$id=$myrow_req['id'];
					$asset_group=$myrow_req['asset_group'];
					$asset_name=$myrow_req['asset_name'];
					$make=$myrow_req['make'];
					$color=$myrow_req['color'];
					$grade=$myrow_req['grade'];
					$quantity=$myrow_req['req_quentity'];
					
$rate_master="Select * from rate_master where ItemId='".$proid."' AND PartyId='".$VendorCode."' AND Category='Purchase' AND DeActivate='0'";
				$rate_result=DB_query($rate_master,$db);
				$rate_row=DB_fetch_array($rate_result);
 
$data2.="<tr bgcolor='#FFFFFF'>
  <td>";
    $data2.=$asset_group;
    $data2.="<input type='hidden' name='asset_group[]' style='width:70px'  value=".$asset_group."/>
			<input type='hidden' name='id[]' value=".$id."/></td>
  <td>";
    $data2.=$asset_name;
    $data2.="<input type='hidden' name='asset_name[]' style='width:70px;'  value=".$asset_name."></td>
  	<td>";
	$make=$s->getField('product_manufacture','id',$make,'manufacturer');
    $data2.=$make;
    $data2.="<input type='hidden' name='make[]' style='width:70px' value=".$make.">
  </td>
  <td>";
	$colorname=$s->getField('product_color','id',$color,'color');
	$data2.=$colorname;
    $data2.="<input type='hidden' style='width:70px' name='color[]' value=".$color.">
  </td>
  <td>";
	$gradename=$s->getField('product_grade','id',$grade,'grade');
	$data2.=$gradename;
    $data2.="<input type='hidden' style='width:70px' name='grade[]' value=".$grade." >
  </td>";
  $data2.="<td>";
  $uom=$myrow_req['unit'];
  $data2.=$uom;
  $data2.="<input type='hidden' name='uom[]' value='".$uom."' style='width:70px;'/></td>";
  $data2.="<td>&nbsp</td>
  <td>";
  $data2.=$quantity;
   $data2.="<input type='hidden' name='quantity[$i]' id='quantity$i' style='width:70px;'  value=".$quantity."	/></td>
  <td><input style='width:70px;'  type='text' name='rate[$i]' id='rate$i' value=".$rate_row['Rate']." /></td>
  <td><input style='width:70px;' type='text' name='total_price[$i]' id='total_price$i' value='' onFocus='calculateTotalPrice($i)' /></td>
  <td><select style='width:80px;' name='PerAmo[$i]' id='PerAmo_$i'>
      			<option value='Amount'>Amount</option>
            	<option value='PercentAmt'>Percent Amt</option>
    </select></td>
  <td>";
  $data2.="<input type='text' style='width:35px' name='discount[$i]' id='discount$i' onblur='DiscountAmount(this.value,$i)' /></td>
  <td>";
  $data2.="<input type='text' readonly='true' style='width:35px' name='discount_amt[$i]' id='discount_amt$i' style='width:100%;' onfocus='Check(this.value,$i)'/></td>
  <td>";
  $data2.="<input type='text' readonly='true' name='final_amt[$i]' id='final_amt$i' style='width:70px;' /></td>
  <td><select style='width:100%;' name='spl_disc_type[$i]' id='spl_disc_type$i'>
  		<option value='Amount'>Amount</option>
         <option value='PercentAmt'>Percent Amt</option>
  </select></td>
  <td>";
  $data2.="<input type='text' name='spl_disc_per[$i]' id='spl_disc_per$i' size='10' style='width:35px;' onblur='DiscountAmountdpc(this.value,$i)' /></td>
  <td>";
  $data2.="<input type='text' style='width:35px' name='spl_disc[$i]' id='spl_disc$i' readonly='true' style='width:70px;' onfocus='check1(this.value,$i)'/></td>
  <td>";
  $data2.="<input type='text' style='width:70px' name='basic[$i]' id='basic$i' readonly='true' /></td>
  
  <td><select name='hide_billing_type[$i]' id='hide_billing_type$i' style='width:85px' onchange='checkExcisable(this.value,$i,this.value)'>
      <option value=''>Select</option>
      <option value='NonExcisable'>NonExcisable</option>
      <option value='Excisable'>Excisable</option>
      <option value='IncludeTax'>IncludeTax</option>
    </select></td>
  <td><select name='excise_type[$i]' id='excise_flag$i' style='width:120px;' onchange='claculateExcise($i,this.value)' onFocus='checkexiseflag($i)'>
      <option value=''>Select</option>";
    
    	    $excise_sql=DB_query("Select * from excise_tax where caption like '%excise%' and form_type='Purchase'",$db);
			while($excise_row=DB_fetch_array($excise_sql))
			{
      $data2.="<option value=".$excise_row['id'].">";
	  $data2.=$excise_row['caption'];
	  $data2.="</option>";
			}
    $data2.="</select>
	<div id='exciseId_$i'></div>
   </td>";
    	     $cessSql=DB_query("Select caption from excise_tax where caption like '%cess%'",$db);
			 $k=1;
			 while($cessRow=DB_fetch_array($cessSql))
			 {
			 	$caption[$k]=$cessRow['caption']; 
				$rate_sql=DB_query("Select def_rate from excise_tax where caption='".$caption[$k]."'",$db);
				while($rate_row=DB_fetch_array($rate_sql))
				{
					$rate[$k]=$rate_row['def_rate'];
				}
				$k++;
			 } 
  $data2.="<td><input name='excise_per[$i]' id='excise_per$i' type='text' value='$rate[1]' style='width:35px;' readonly  onFocus='caldata($i)' />
    <input name='excise_val[$i]' id='excise_val$i' type='text' value=''  style='width:70px;' readonly onFocus='calculateECess($i)'/></td>
	
  <td><input name='e_cess_per[$i]' id='e_cess_per$i' type='text' value='$rate[2]' style='width:35px;' />
    <input name='e_cess_val[$i]' id='e_cess_val$i' type='text' value=''  style='width:65px;' onFocus='calculateSAHCess($i)'/></td>
	
  <td><input type='text' name='taxable_amt[$i]' id='taxable_amt$i' value='' style='width:70px;' onFocus='calculateTaxable($i)' /></td>
 
  <td><input type='text' name='totalamt[$i]' id='totalamt$i' size='8' style='width:70px;'  onfocus='cal_grandtotal($i);' value='0'/></td>
</tr>";
$i++;
				 }	
 $data2.="<input type='hidden' name='count' id='count' value=".$i." style='width:70px' />
</table> </div>";
echo $data=$data1."__".$data2;
?>
