<?php
include('includes/global.php');

  if(array_key_exists('Translate', $_GET)) {
      $ID = $Database->SQLCommand("SELECT *, (SELECT user.user FROM user WHERE user.id = quests.user) as User FROM
      quests WHERE quests.Language = '1' AND quests.Complete = '1' order by 2");
      echo '<table border="1" cellpadding="2" cellspacing="0">
            <tr><th>Pořadové číslo</th><th>ID questu</th><th>Název Questu</th><th>Uživatel</th><th>Známka</th><th>Počet hlasování</th></tr>';
      while ($Line = mysql_fetch_array($ID)) {
        echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
        <td>'.$Line['entry'].'</td>
        <td>'.$Line['Title'].'</td>
        <td>'.$Line['User'].'</td>
        <td>'.$Line['Vote'].'</td>
        <td>'.$Line['CountVote'].'</td></tr>';
       }
      echo '</table>';
  } else {

    if(array_key_exists('limitx', $_GET)) {
      $limitx = mysql_escape_string($_GET['limitx']);  
      $limity = mysql_escape_string($_GET['limity']);  

      $ID = $Database->SQLCommand("SELECT * FROM quests WHERE Language = '0' LIMIT $limitx,$limity"); 
  //    $ID = $Database->SQLCommand("SELECT quests.entry FROM quests WHERE Language = '0' AND quests.entry NOT IN 
   //   (SELECT quests.entry FROM quests WHERE quests.Language = '1' AND state = '2') LIMIT $limitx,$limity");
      while ($Line = mysql_fetch_array($ID)) {
        $LineTranslate = mysql_fetch_array($Database->SQLCommand("SELECT * FROM quests WHERE Language <> 0 AND entry = '".$Line['entry']."'"));
        if (!$LineTranslate) 
        echo '<a href="form.php?ID='.$Line['ID'].'">['.$Line['entry'].']</a> - '.$Line['Title'].'<br />';  //.$Line['Title']
      }
  
    } else {
      if(array_key_exists('mydevelop', $_GET) and Licence(0)) {
     
      echo '<table border="1" cellpadding="2" cellspacing="0">
            <tr><th>Pořadové číslo</th><th>ID questu</th><th>Název Questu</th></tr>';
      $ID = $Database->SQLCommand("SELECT * FROM quests Where User='".$_SESSION['UserID']."' AND complete = '0' order by 1 ");
        while ($Line = mysql_fetch_array($ID)) {
          echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
          <td>'.$Line['entry'].'</td>
          <td>'.$Line['Title'].'</td></tr>';
        }
      echo '</table>';  
      } else {
        if(array_key_exists('my', $_GET) and Licence(0)) {
       
        echo '<table border="1" cellpadding="2" cellspacing="0">
              <tr><th>Pořadové číslo</th><th>ID questu</th><th>Název Questu</th><th>Známka</th></tr>';
        $ID = $Database->SQLCommand("SELECT * FROM quests Where User='".$_SESSION['UserID']."' order by 1 ");
          while ($Line = mysql_fetch_array($ID)) {
            echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
            <td>'.$Line['entry'].'</td>
            <td>'.$Line['Title'].'</td>
            <td>'.$Line['Vote'].'</td></tr>';
          }
        echo '</table>';  
        } else {
        }
      }
    }

        if(array_key_exists('selection', $_GET)) {
    
          for ($i=0; $i<30; ++$i) {
            $limity = 200;
            $limitx = $i*$limity;
            $Under = $limitx+$limity;
        	  echo '<a href="ListQuests.php?limitx='.$limitx.'&amp;limity='.$limity.'">'.$limitx.' - '.$Under.'</a><br />';      	
          }
        	echo '<a href="ListQuests.php?limitx='.$limitx.'&amp;limity=6000">Zbytek</a><br />';
    //  echo '<a href="ListQuests.php?limitx=3500&amp;limity=4000">3500-4000</a><br />';
        }

  }
  
  ShowFooter();
?>
