<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
* @version $Id: zone.assign_zones.php,v 1.2 2005/01/27 19:34:04 soeren_nb Exp $
* @package mambo-phpShop
* @subpackage HTML
* Contains code from PHPShop(tm):
* 	@copyright (C) 2000 - 2004 Edikon Corporation (www.edikon.com)
*	Community: www.phpshop.org, forums.phpshop.org
* Conversion to Mambo and the rest:
* 	@copyright (C) 2004-2005 Soeren Eberhardt
*
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* mambo-phpShop is Free Software.
* mambo-phpShop comes with absolute no warranty.
*
* www.mambo-phpshop.net
*/
mm_showMyFileName( __FILE__ );

search_header($PHPSHOP_LANG->_PHPSHOP_ASSIGN_ZONE_PG_LBL, "zone", "assign_zones"); 

// Enable the multi-page search result display
$limitstart = mosGetParam( $_REQUEST, "limitstart", 0 );
$keyword = mosGetParam( $_REQUEST, "keyword", "" );


if (!empty($keyword)) {
  $list  = "SELECT * FROM #__pshop_country WHERE ";
  $count = "SELECT count(*) as num_rows FROM #__pshop_country WHERE ";
  $q  = "(country_name LIKE '%$keyword%')";
  $q .= "ORDER BY country_name ASC ";
  $list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
  $count .= $q;   
}
else  {
  $q = "";
  $list  = "SELECT * FROM #__pshop_country ORDER BY country_id ASC ";
  $count = "SELECT count(*) as num_rows FROM #__pshop_country"; 
  $list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
  $count .= $q;   
}
$db->query($count);
$db->next_record();
$num_rows = $db->f("num_rows");
if ($num_rows == 0) {
  echo $PHPSHOP_LANG->_PHPSHOP_NO_SEARCH_RESULT;
}
else {
?>

<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<th width="25%" align="center">
<?php echo $PHPSHOP_LANG->_PHPSHOP_ZONE_ASSIGN_COUNTRY_LBL;?>
</th>
<th width="25%" align="center">
<?php echo $PHPSHOP_LANG->_PHPSHOP_ZONE_ASSIGN_CURRENT_LBL;?>
</th>
<th width="25%" align="center">
<?php echo $PHPSHOP_LANG->_PHPSHOP_ZONE_ASSIGN_ASSIGN_LBL;?>
</th>
<th width="25%" align="center">
<?php echo $PHPSHOP_LANG->_PHPSHOP_ZONE_ASSIGN_UPDATE_LBL;?>
</th>
</tr>



<?php
$db->query($list);
$i = 0;
while ($db->next_record()) {
  if ($i++ % 2) 
     $bgcolor=SEARCH_COLOR_1;
  else
     $bgcolor=SEARCH_COLOR_2;
?>
<FORM METHOD="POST" ACTION="<?php echo $PHP_SELF ?>">
<input type="hidden" name="country_id" value="<?php echo $db->f("country_id");?>">
  <tr BGCOLOR=<?php echo $bgcolor ?>> 
<TD WIDTH="25%" ALIGN="CENTER"><?php $db->p("country_name") ?> </TD>
<TD WIDTH="25%" ALIGN="CENTER">
<?php 
// Get the zone rate for each country

$per_item = $ps_zone->per_item($db->f("zone_id"));
$zone_limit = $ps_zone->zone_limit($db->f("zone_id"));
?>

Per Item: <?php echo $per_item;?>        Limit: <?php echo $zone_limit;?><BR>
<?php
    if($db->f("zone_id") > "1") {
          $url = SECUREURL . "administrator/index2.php?page=zone.zone_form&zone_id=" . $db->f("zone_id");
       echo "<A HREF=\"" . $sess->url($url) . "\">";
       echo "Edit This Zone"; 
       echo "</A>"; 
}
?>
</TD>
<TD WIDTH="25%" ALIGN="CENTER">
<?php
$ps_zone->list_zones("zone_id", $db->f("zone_id"));
?>

<input type="hidden" name="option" value="com_phpshop" />
<input type="hidden" name="page" value="zone.assign_zones">
<input type="hidden" name="func" value="zoneassign"></TD>
<TD WIDTH="25%" ALIGN="CENTER">
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="<?php echo $PHPSHOP_LANG->_PHPSHOP_ZONE_ASSIGN_UPDATE_LBL;?>">
</TD>
</TR>
</FORM>

<?php 
}
  }
echo "</table>";
 search_footer("zone", "assign_zones", $offset, $num_rows, $keyword); 

?>
