<?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 id FROM days");
$nrrows = mysqli_num_rows($result);
?>
<a href="list-days.php"><?php echo $admindays ?></a> (<?php echo $nrrows ?>)
<div class="floatright"><a href="add-day.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 days ORDER BY nr1");
while($row = $result->fetch_array()) {
$id=$row['id'];
$nr1=$row['nr1'];
$nr2=$row['nr2'];
$discount=$row['discount'];
?>
   <div class="framerow">
      <table>
        <tr>
          <td width="350">
  <form name="forma" method="post">
<?php
if (isset($_POST['update'.$id])) {
$nr1 = $mysqli->real_escape_string(stripslashes($_REQUEST['nr1']));
$nr2 = $mysqli->real_escape_string(stripslashes($_REQUEST['nr2']));	

$mysqli->query("UPDATE days SET nr1='$nr1', nr2='$nr2' WHERE id='$id'");
}?>

<div class="text margright20">
<span class="titles"> <?php echo $admindays ?> </span>

<input name="nr1" type="text" id="nr1" value="<?php echo $nr1 ?>" size="3" maxlength="11" class="inputauto"> 
        - 
<input name="nr2" type="text" id="nr2" value="<?php echo $nr2 ?>" size="3" maxlength="11" class="inputauto">
&nbsp; &nbsp; &nbsp;
<button type="submit" name="update<?php echo $id ?>" class="linkoption" title="<?php echo $adminedit ?>"><span class="icon fa-edit"></span> <?php echo $adminedit ?></button>
</div>
</form>

          </td>
          <td> 
            
            <?php
if  (isset($_POST['deleterow'])) {
$mysqli->query("DELETE FROM days WHERE id='{$_REQUEST['id']}'");
$mysqli->query("ALTER TABLE days AUTO_INCREMENT = 1");
$mysqli->query("DELETE FROM prices WHERE day_id='{$_REQUEST['id']}'");
$mysqli->query("ALTER TABLE prices AUTO_INCREMENT = 1");
?>
            <meta http-equiv="refresh" content="0;URL=list-days.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>