<?php 
//*********************START HERE*********************AMIT SINGH****************30-10-2012******************************

//$ClientSQL1=DB_query("Select * from clientmaster where CompanyId='".$_SESSION['ACGCompanyId']."' and  Site in('".$_SESSION['AssignedBranch']."') 
		//and Zone in(".$_SESSION['AssignedSites'].")",$db);



?>
<table width="100%" border="1" cellspacing="0" cellpadding="3">
  <tr>
    <td class="tabledata" style="font-size:10px;">Client</td>
    <td class="tabledata" style="font-size:10px;">Highest Sale</td>
  </tr>
<?php //$i=0; while($SQLRow=DB_fetch_array($ClientSQL1)) { 
$SQlhighestSale=DB_query("SELECT SUM(grandTotal) AS HighestSale,client_id FROM invoice GROUP BY client_id ORDER BY HighestSale DESC LIMIT 0,6",$db);
while($row2=DB_fetch_array($SQlhighestSale)) { 
//$abc=DB_fetch_array($SQlClint1);

//$dataarray2[]=array('client' => $SQLRow['c_name'], 'basic' => $abc['HighestSale']);	
//}
//foreach ($dataarray2 as $key => $row)
//  {   
//   $volume[$key]  = $row['basic'];
//   $edition[$key] = $row['client'];
//  }  
//array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $dataarray2);
// $k=0;
// foreach ($dataarray2 as $key => $row2)
//   {
//   
//if($row2['basic']!=''){
//$i++;
//if($i<4){?>  
  <tr>
    <td class="tabledata_fist" style="font-size:10px;"><?php echo $s->GetFieldValue('clientmaster',"id='".$row2['client_id']."'",'c_name'); ?></td>
    <td class="tabledata1" style="font-size:10px;"><?php  echo $row2['HighestSale']; ?></td>
  </tr>
 <?php //} } } ?><?php } ?>
</table>
<?php //if($i>=4) {?>
<!--<div  align="right" class="seemore" ><a href="#" onclick="showhighestsale()" >Show More</a></div> -->
<?php //} ?>