<?php if ($seasons==1 && $typec==2) { ?> 

<?php
$result1p = $mysqli->query("SELECT * FROM prices WHERE item_id='$id'");
$nrrows1p = mysqli_num_rows($result1p);

$result5 = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang");
$nrrows5 = mysqli_num_rows($result5);
?>
<?php if  ($nrrows5>0) {?>

      <div>
        <table class="tablewidth">
          <tr> 
            <td width="50"><span class="icon icstyle1 fa-eur color1"></span></td>
            <td>
              
              <table>
                <tr>
<?php
$result6 = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang ORDER BY id");
while($row = $result6->fetch_array()) {
$seasonid=$row['insert_id'];
$season=$row['name'];
$date1=$row['date1'];
$date1b=$row['date1b'];
$date2=$row['date2'];
$date2b=$row['date2b'];

$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);
?>
 <td valign="top">
<div class="divprice text2"> 
<a href="edit-season.php?id=<?php echo $seasonid?>" class="color1"><?php echo $season ?></a> <br>
<?php if ($date1!='0000') echo $date1 ?> - <?php if ($date1b!='0000') echo $date1b ?>
<br>
<?php if ($date2!='0000') echo $date2 ?> - <?php if ($date2b!='0000') echo $date2b ?>
</div>
 </td>
<?php } ?>    
                  </tr>
                </table>
              
              </td>
            <td width="140">&nbsp;</td>
            </tr>
          </table>
      </div>
      
<?php
if (isset($_POST['update'.$id])) {

foreach($_REQUEST['priceid'] as $key => $idvalueprice ) {

$dayid = $mysqli->real_escape_string(stripslashes($_REQUEST['dayid'.$idvalueprice]));
$pprice = $mysqli->real_escape_string(stripslashes($_REQUEST['pprice'.$idvalueprice]));
$available = $mysqli->real_escape_string(stripslashes($_REQUEST['available'.$idvalueprice]));	
$mysqli->query("UPDATE prices SET day_id=$dayid, price='$pprice', available='$available' WHERE id='$idvalueprice'");
}

}
?> 

<div class="divprices text2">
<table class="tablewidth">
        <tr> 
          <td width="50">&nbsp;</td>
          <td>

<form name="formp" method="post">
<div class="inlined padtop5">		
<table>
<tr>
<?php
$result7 = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang ORDER BY priority");
while($row = $result7->fetch_array()) {
$seasonid=$row['insert_id'];
$season=$row['name'];
$date1=$row['date1'];
$date2=$row['date2'];
?>
<td>
 
<?php
$result8 = $mysqli->query("SELECT * FROM prices WHERE item_id='$id' AND season_id=$seasonid");
while($row = $result8->fetch_array()) {
$priceid=$row['id'];
$dayid=$row['day_id'];
$pprice=$row['price'];
$available=$row['available'];

$resultd = $mysqli->query("SELECT id FROM days WHERE id=$dayid");
$rowsd = mysqli_num_rows($resultd);
?>

<div class="divprice">

<?php if  ($rowsd>0) { ?> 
<select name="dayid<?php echo $priceid ?>" class="forms2">
<?php
$result9 = $mysqli->query("SELECT * FROM days ORDER BY nr1");
while($row = $result9->fetch_array()) {
$dayid1=$row['id'];
$nr1=$row['nr1'];
$nr2=$row['nr2'];
?>
<option value="<?php echo $dayid1 ?>"<?php if ($dayid1==$dayid) { echo " selected"; }?>> 
<?php echo $nr1 ?>-<?php echo $nr2 ?>
</option>
<?php }?>
</select>

<?php }else{?>
<input type="hidden" name="dayid<?php echo $priceid ?>" value="0">
<?php } ?>

<input type="hidden" name="priceid[]" value="<?php echo $priceid ?>"> 

<input type="text" name="pprice<?php echo $priceid ?>" value="<?php echo $pprice ?>" size="1" maxlength="11" class="forms2">

<?php if ($availability==1) { ?>
<input type="hidden" name="available<?php echo $priceid ?>" value="0"> <input type="checkbox" name="available<?php echo $priceid ?>" value="1"<?php if ($available==1) { echo " checked"; }?>>
<?php }else{?>
<input type="hidden" name="available<?php echo $priceid ?>" value="<?php echo $available ?>">
<?php } ?> 

</div>

<?php } ?>
 
</td>
<?php } ?>    
   </tr>
</table>
</div>
<?php if ($nrrows1p>0) {?>
<div class="floatright pad10">
<button type="submit" name="update<?php echo $id ?>" title="<?php echo $adminsubmit ?>" class="button buttonsmall bgrcolor1"><span class="icon fa-check"></span></button>
</div>
<?php } ?>
</form>         
           
 </td>
 <td class="divpriceitem">
            
<?php 
$result1s = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang");
$nrrows1s = mysqli_num_rows($result1s);

$result1d = $mysqli->query("SELECT * FROM days");
$nrrows1d = mysqli_num_rows($result1d);
$row = $result1d->fetch_array(); 
$did=$row['id'];
if (!$did) { $did=0; $nrrows1d=1; }
?>

<?php if  ($nrrows1p<$nrrows1s*$nrrows1d) {?>
<div class="floatleft">
<a href="add-price.php?itemid=<?php echo $id?>" title="<?php echo $adminadd ?> &#8364;" class="links"><span class="icon fa-plus-square"></span></a> 
</div>
<?php }?>
            
<?php 
$result2p = $mysqli->query("SELECT * FROM prices WHERE item_id='$id'");
$nrrows2p = mysqli_num_rows($result2p);
?>
<?php if ($nrrows2p>0) {?>
            
<?php
if (isset($_POST['deleteprice'.$id])) {
$mysqli->query("DELETE FROM prices WHERE item_id='$id'");
$mysqli->query("ALTER TABLE prices AUTO_INCREMENT = 1");
?>
<meta http-equiv="refresh" content="0">
<?php } ?>
<div class="floatright">      
<form name="forma" method="post">
<input type="hidden" name="deleteprice<?php echo $id ?>" value="submit">
<button type="submit" name="deleteprice<?php echo $id ?>" title="<?php echo $admindelete ?>" class="buttonicon color1"><span class="icon fa-trash-o"></span></button>
</form>
</div>
            
<?php } ?>
<div class="cleared"></div>  
          </td>
        </tr>
      </table>
      
</div>

<?php } ?>

<?php } ?>