
<table width="100%" border="1" cellspacing="0" cellpadding="3" style="border-collapse:collapse;">
  <tr>
    <td class="tabledata">Supplier Name</td>
    <td class="tabledata">P.O. Date</td>
      <td class="tabledata">Expected Delivery Date</td>
  </tr>

  <?php
  //$dataarray=array();
  if($_SESSION['AssignedBranch']!='0')
	  {	
	  $ss1="select distinct client from salesorder where branch in('".$_SESSION['AssignedBranch']."') and client!=0  order by client ASC";
	  	 $site_sql1=DB_query($ss1,$db);
	  
	  }
	  else
	  {
	  $ss1="select distinct client from salesorder where client!=0  order by client ASC";
		$site_sql1=DB_query($ss1,$db);
	  }
  
  while($row=DB_fetch_array($site_sql1))
  {
  $grand=0;
  $row1=DB_query("select basicAmount   from salesorder inner join salesorder_details on salesorder.id=salesorder_details.masterId where  ApprovalStatus='Approved' and  client='".$row['client']."' group by salesorder.id ",$db);
  while($row12=DB_fetch_array($row1))
  {
  $grand=$grand+$row12['basicAmount'];
  }
  $basic=0;	
  $row5=DB_query("select grandTotal  from salesorder inner join salesorder_details on salesorder.id=salesorder_details.masterId where  ApprovalStatus='Approved' and  client='".$row['client']."' group by salesorder.id  ",$db);
  while($row51=DB_fetch_array($row5))
  {
  $basic=$basic+$row51['grandTotal'];
  }
  $dataarray[]=array('client' => $row['client'], 'basic' => $basic,'grand'=>$grand);	
  }
  foreach ($dataarray as $key => $row)
  {   
   $volume[$key]  = $row['basic'];
   $edition[$key] = $row['grand'];
}  
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $dataarray);
 $k=0;
  $count1=count($dataarray);
 foreach ($dataarray as $key => $row2)
   {
  
   $data=4;

   if($k<$data)
   {
   		     	
  ?>
  <tr>
    <td class="tabledata_fist"><?php echo $s->getField('clientmaster','id',$row2['client'],'c_name'); ?></td>
    <td class="tabledata1"><?php echo $row2['basic']; ?></td>
    <td class="tabledata1"><?php echo $row2['grand']; ?></td>
  </tr>
<?php } $k++;  } ?>
</table>
<div  align="right" class="seemore" ><a href="#" onclick="showsalesdata()">Show More</a></div>

