<table width="100%" border="1" cellspacing="2" cellpadding="2">

   <tr class="row1">

   <td class="tabledata">SNo.</td>

   <td width="22%" class="tabledata">Area</td>

   <td width="22%" class="tabledata">Area Code</td>

   <td width="21%" class="tabledata">Unit</td> 

   <td width="36%" class="tabledata">Company Name</td> 

   <td width="11%" class="tabledata">Status</td>

   <td width="6%"  colspan="2" class="tabledata">Action</td>

  

  

   </tr>

   <?php 

      // LIMIT $startpoint,$perpage

  $GetRecord = "Select * from $table where CompanyId='".$_SESSION['ACGCompanyId']."'  order by id  ";

   $ResultData = DB_query($GetRecord,$db);

   $i=1;

   if(DB_num_rows($ResultData)==0)

   echo "<td>--No Record--</td>";

   

   while($RowData = DB_fetch_array($ResultData))

   {

   

   

        $customer=$s->GetTotalRecordsTalbes('clientmaster',"Zone='".$RowData['id']."'");

		$enqiry=$s->GetTotalRecordsTalbes('dbl_enquiry_form',"zone='".$RowData['id']."'");

		$salsorder=$s->GetTotalRecordsTalbes('dbl_process_sale_order',"zone='".$RowData['id']."'");

		$dispatch=$s->GetTotalRecordsTalbes('dbl_dealer_dispatch',"zone='".$RowData['id']."'");

		$subzone=$s->GetTotalRecordsTalbes('subzone_master',"zone='".$RowData['id']."'");

		$associate=$s->GetTotalRecordsTalbes('dbl_dealer',"area_code='".$RowData['id']."'");

		

		if($enqiry<=0 && $salesorder<=0 && $dispatch<=0 && $customer<=0 && $subzone<=0 && $associate<=0)

		{

		$status=0;

		}

		else

		{

		$status=1;

		}

   

   

   

   

   

   

   

   

   

   

   

   

   

   ?>

 <tr class="row1"> 

 <td  width="4%"><?php echo $i; ?></td>

    <td ><?php echo $RowData['ZoneTitle']; ?>	  </td>

	 <td ><?php echo $RowData['zonecode']; ?>	  </td>

	  <td ><?php 

	   if($RowData['Site']=='0')

	   {

	   echo "All";

	   }

	   else

	   {

	  echo   $Sitename= $s->getField('locations','loccode',$RowData['Site'],'locationname');	 

	  }

	  

 	   ?></td>

   <td >

   	

  <?php 	echo   $Companyname= $s->getField('companies','CompanyId',$RowData['CompanyId'],'CompanyName'); ?>

   	

   </td>

   	<td ><div align="center"><?php echo ($RowData['status']=='Y'?'Active':'Inactive'); ?></div> </td>	



   <td ><div align="center"><a href="<?php echo $targetpage?>&amp;action=Edit&amp;id=<?php echo $RowData['id']; ?>"><img src="images/icon-edit.png"  width="10" height="10"/></a>

  <?php if($status==0) { ?>

  <a href="<?php echo $targetpage?>&amp;action=Delete&amp;id=<?php echo $RowData['id']; ?>" 

  onclick="return confirm('This Area will be deleted. Are you sure?')"><img src="images/delete.Gif"  width="10" height="10"/></a>

 <?php } else { ?>

<img src="images/delete.Gif"  width="10" height="10"  onclick="abc()" />

 <?php } ?> 

  

  

  </div>  </td>

	 </tr>

 

	<?php $i++;}   

   ?> 

   

     </table>

  

 