<?php include 'sets.php';?>
<?php
$superuser="0";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Webadmin <?php echo $domain ?></title>
<?php include 'codes.php';?>
</head>
<body>

<?php include 'navbar.php';?>
    
<div class="container">
<div class="frame">
<div class="frametitles flist">

<?php
$result = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang");
$nrrows = mysqli_num_rows($result);
?>
<a href="list-seasons.php"><?php echo $adminseason ?></a> (<?php echo $nrrows ?>)
<div class="floatright"><a href="add-season.php"><img src="img/add.png" alt="<?php echo $adminaddcat ?>" title="<?php echo $adminaddcat ?>"></a></div>
</div>
<div class="framein">

<?php
$result = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang ORDER BY priority");
while($row = $result->fetch_array()) {
$id=$row['insert_id'];
$insert_id=$row['insert_id'];
$name=$row['name'];
$date1=$row['date1'];
$date1b=$row['date1b'];
$date2=$row['date2'];
$date2b=$row['date2b'];
$priority=$row['priority'];

$date1 = substr($date1, 2, 4).".".substr($date1, 0, 2);
$date1b = substr($date1b, 2, 4).".".substr($date1b, 0, 2);
$date2 = substr($date2, 2, 4).".".substr($date2, 0, 2);
$date2b = substr($date2b, 2, 4).".".substr($date2b, 0, 2);
?>
   <div class="framerow">
      <table>
        <tr> 
          <td class="divpriority"><?php echo $priority ?></td>
          <td> 
<a href="edit-season.php?id=<?php echo $id?>" class="titles"><?php echo $name ?></a> &nbsp;
<?php if ($date1!='0000') echo $date1 ?> &raquo; <?php if ($date1b!='0000') echo $date1b ?>
 <?php if ($date2!='0000') echo '<strong>&amp;</strong>' ?> 
<?php if ($date2!='0000') echo $date2 ?> <?php if ($date2b!='0000') echo '&raquo; '.$date2b ?>
            </td>
          <td class="divoption">
            <a href="edit-season.php?id=<?php echo $id?>" class="linkoption" title="<?php echo $adminedit ?>"><span class="icon fa-edit"></span> <?php echo $adminedit ?></a>
            </td>
          <td class="divoption"> 
            
            <?php
if  (isset($_POST['deleterow'])) {
$mysqli->query("DELETE FROM seasons WHERE insert_id='{$_REQUEST['id']}'");
$mysqli->query("ALTER TABLE seasons AUTO_INCREMENT = 1");
$mysqli->query("DELETE FROM prices WHERE season_id='{$_REQUEST['id']}'");
$mysqli->query("ALTER TABLE prices AUTO_INCREMENT = 1");
?>
            <meta http-equiv="refresh" content="0;URL=list-seasons.php">   
            <?php } ?>       
              <form name="formdelete" method="post">
              <input type="hidden" name="id" value="<?php echo $id ?>">
              <button type="submit" name="deleterow" class="linkoption linkdelete" title="<?php echo $admindelete ?>"><span class="icon fa-trash-o"></span> <?php echo $admindelete ?></button>
              </form>
            
            </td>
          </tr>
      </table>
    </div>
    <?php } ?>
</div>
</div>
</div>

<?php include 'menudown.php';?>

</body>
</html>