<?php 
ob_start();
$PageSecurity = 4;
include('includes/DefinePOClass.php');
include('includes/session.inc');
include('includes/SQL_CommonFunctions.inc');
include('includes/function_lib.php');
if($_REQUEST['id']!=''){ 

//$dsql=DB_query("select * from requisitionorderdetails where requsitionno='".$_REQUEST['id']."'",$db);
//$num5=DB_num_rows($dsql);
 
 //$appsql=DB_query("select * from pr_head_approval where requisition_id='".$myrow['requisitionno']."' and requiNo='".$rosql['id']."' and sr_no='1'",$db);


//$SqlApp=DB_query("SELECT Approved_by from materialrequisitions where requisitionno='".$_REQUEST['id']."'",$db);?>
<table width="100%" border="0" style="border:1px solid #333333;" cellspacing="0" cellpadding="3">
<tr style="height:30px;">
	<td style="border-bottom:1px solid #FF0000;"><strong>Approval By</strong></td>
        <td style="border-bottom:1px solid #FF0000;"><strong>Approval Status</strong></td>
</tr>
<?php $i=1;
$pr_assign_app=DB_query($str="SELECT B.approval_by as approval_by, B.approval_name FROM  conf_purch_approval AS A INNER JOIN conf_purch_app_details AS B ON A.id=B.purch_approval_id WHERE A.doc_type='PR' and dept_wise='false'",$db);
while($pr_assign_approval=DB_fetch_array($pr_assign_app))
{
  $dsql=DB_query("select id from requisitionorderdetails where requsitionno='".$_REQUEST['id']."'",$db);
 $num5=DB_num_rows($dsql);
 $flag=0;$flag1=0;$prnum=0;

  while($detailsql=DB_fetch_array($dsql))
  {
  //echo "select * from pr_head_approval where requisition_id='".$_REQUEST['id']."' and requiNo='".$detailsql['id']."' and sr_no='".$i."' and approved_by='".$pr_assign_approval['approval_by']."'";
      $appsql=DB_query("select * from pr_head_approval where requisition_id='".$_REQUEST['id']."' and requiNo='".$detailsql['id']."' and sr_no='".$i."' and approved_by='".$pr_assign_approval['approval_by']."'",$db);
      
      while($approvalsql=DB_fetch_array($appsql))

      {
        if($approvalsql['approvalStatus']=='3')	
	      {
	      	//echo "hi";
	         $flag=$flag+1;	
          }
     }
  }
 // echo $flag."##".$num5;
  if($flag==$num5)
	{
	   $status='Approved';	
	}
	else
	{
		$status="Pending";
	}
 

 ?>
<tr class="row1">
	<td><?php echo $pr_assign_approval['approval_name']; ?></td>
        <td><?php echo $status; ?></td>
</tr>
    <?php  $i++;}?>
</table>

<?php } ?>

