<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////

  $lang = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0,2);
  if(is_file ("../lang/".$lang."/".$lang.".php")) include "../lang/".$lang."/".$lang.".php";
     else include "../lang/ru/ru.php";

  $title=$titlepage=$TEXT['city-title'];
  $helppage=$TEXT['city-help'];

  require_once "../config.php";
  require_once "../util/top.php";

  if($result2['user'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['master'] == 1) puterror2($TEXT['error-loginform4']);
  if($result2['manager'] == 1) puterror2($TEXT['error-loginform4']);

  $order = array();
  $order['city_order'] = "city";

  $sort = "city";

  foreach($order as $parametr => $field)
  {
    if(isset($_GET["$parametr"]))
    {
      if($_GET["$parametr"] == "up")
      {
        $_GET["$parametr"] = "down";
        $sort = $field;
      }
      else
      {
        $_GET["$parametr"] = "up";
        $sort = "$field DESC";
      }
    }
    else $_GET["$parametr"] = "up";
  }

?>
 <img alt="<?php echo $TEXT['city-add-new'] ;?>" src= "../img/insert.png" height="15" align="top" /><a class="boldit" href="addform.php" title="<?php echo $TEXT['city-add-new-tit']; ?>"><?php echo $TEXT['city-add-new'] ;?></a>
 <br />
 <br />
 <span class="tabledata"><?php echo $TEXT['city-text1'] ;?></span>
<table class="table" border="1" cellpadding="3" cellspacing="0" width="60%" >
<?php
     $query = "SELECT * FROM `tbl_city` ORDER BY $sort ";
     $result = mysql_query($query);
     if (!$result) puterror2($TEXT['error-tbl1']);
       if (mysql_num_rows($result)>0);
         {
           $href = "index.php?city_id=".$result['city_id'];
           ?>
           <tr class="tableheadercat">
             <td><a href=<?php echo $href."&city_order=".$_GET['city_order']; ?> title="<?php echo $TEXT['global-sort']; ?>"><?php echo $TEXT['tbl-city']; ?></a></td>
             <td colspan=2><?php echo $TEXT['tbl-action']; ?></td>
           </tr>
           <?php
             while($result_citys = mysql_fetch_array($result,MYSQL_ASSOC))
              {
              $edit = "<a href=editform.php?city_id=".$result_citys['city_id']." title='".$TEXT['tbl-edit-tit']."'>".$TEXT['tbl-edit']."</a>";
              $delete = "<a href=deleteform.php?city_id=".$result_citys['city_id']." title='".$TEXT['tbl-delete-tit']."'>".$TEXT['tbl-delete']."</a>";
           ?>
           <tr class='tabledata' onmouseover="this.style.backgroundColor='#cccccc';" onmouseout="this.style.backgroundColor='#ffffff';">
              <td><?php echo $result_citys['city']; ?></td>
              <td><?php echo $edit; ?></td>
              <td><?php echo $delete; ?></td>
                 </tr>
           <?php
              }
         }
?>
</table>
<?php
  require_once "../util/bottom.php";
?>