<?php require_once 'protect.php'; ?>
<?php 
$result5 = $mysqli->query("SELECT id FROM prices");
$rowspr = mysqli_num_rows($result5);
?>
<?php if ($rowspr>0) {?>
<div class="divprices">
<div class="titles3 color1"><?php echo $pricelist ?></div>
<table class="table">
<tr> 
<td width="150">
</td>
<?php
$result6 = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang ORDER BY priority");
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 class="tdprice">
<div class="text-center">
<strong><?php echo $season ?></strong> <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 ?>
<?php
$resultd = $mysqli->query("SELECT id FROM days");
$rowsd = mysqli_num_rows($resultd);  
?> 
<?php if  ($rowsd>0) { ?>
<!--days -->
<hr>
<div class="color1"><strong><?php echo $textdays ?></strong></div>
<?php
$result10 = $mysqli->query("SELECT * FROM days ORDER BY nr1");
while($row = $result10->fetch_array()) {	
$nr1=$row['nr1'];
$nr2=$row['nr2'];
?>  
<div class="divprice"><span class="example3"> <?php echo $nr1 ?><?php if ($nr2==0) { echo "+"; } else if ($nr2==$nr1) { } else { echo "-".$nr2; } ?> </span></div>
<?php } ?>	
<!--end days --> 
<hr>
<?php } ?>
<div class="color1"><strong>&#8364;</strong></div>	   
</div>
</td>
<?php } ?> 
</tr>
</table>
<?php 
$result7 = $mysqli->query("SELECT * FROM items WHERE insert_id IN (SELECT item_id FROM prices) AND category_id IN (SELECT insert_id FROM categories WHERE type=2 AND publish='yes') AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result7->fetch_array()) {	
$id=$row['insert_id'];
$category_id=$row['category_id'];
$pageid=$row['page_id'];
$pageitem=$row['page'];
if ($itempage==1) { $siteitem=$pageitem; }
$pagesiteitem=$siteitem.".".$pageid;
$name=$row['name'];
$image=$row['image'];
$publish=$row['publish'];

$result = $mysqli->query("SELECT * FROM categories WHERE insert_id=$category_id AND lang_id=$lang");
$row = $result->fetch_array(); 
$discount=$row['discount'];
$parent=$row['parent'];

$result = $mysqli->query("SELECT * FROM categories WHERE insert_id=$parent AND lang_id=$lang");
$row = $result->fetch_array(); 
$discount2=$row['discount'];
?>
<table class="table">
<tr class="tcolor">
<td width="150"> 
<?php if ($image==1 && $publish=='yes') { ?>
<a href="<?php echo $pagesiteitem ?>"><img src="<?php echo $sitepath ?>includes/image.php?image=../images/items/<?php echo $id ?>.jpg&amp;nwidth=60" alt="<?php echo $name ?>" title="<?php echo $name ?>"></a>
<?php } ?>
<?php if ($publish=='yes') { ?>
<a href="<?php echo $pagesiteitem ?>"><?php echo $name ?></a>
<?php }else{?>
<?php echo $name ?>
<?php } ?>
</td>
<?php
$result8 = $mysqli->query("SELECT * FROM seasons WHERE lang_id=$lang ORDER BY priority");
while($row = $result8->fetch_array()) {	
$seasonid=$row['insert_id'];
?>  
<td class="tdprice">
<div class="text-center"> 
<?php
$result9 = $mysqli->query("SELECT * FROM prices WHERE item_id=$id AND season_id=$seasonid");
while($row = $result9->fetch_array()) {	
$price=$row['price'];
$price1=$row['price'];
$pavailable=$row['available'];

if ($discount==0 && $discount2>0) { 
$discount=$discount2;
} 
else if ($discount==0 && $discount2==0) {
$discount=$sitediscount;
}
else{
$discount=$discount;
}

$price = $price-($price*(($discount+$langdiscount)/100));
$price = round($price, 2);
?>
<div class="divprice">
<?php if ($discount>0 OR $langdiscount>0) { ?><span class="price notvalid"><?php echo $price1 ?></span> <?php } ?>
<span class="price<?php if ($pavailable==0) { echo ' notavailable'; }?>"> <?php echo $price ?></span>
</div>
<?php } ?>
</div>
</td>
<?php } ?> 
</tr>
</table>
<?php } ?> 
</div>
<?php } ?>  
<hr>
<a href="<?php echo $siteform ?>" class="button"><?php echo $textrequest ?></a>
<div class="padtop20">
<!--terms -->
<?php 
$result1 = $mysqli->query("SELECT * FROM categories WHERE promote LIKE '%6%' AND lang_id=$lang");
$row = $result1->fetch_array();
$catid=$row['insert_id'];
$category=$row['name'];

$result2 = $mysqli->query("SELECT * FROM items WHERE category_id='$catid' AND lang_id=$lang AND publish='yes' ORDER BY priority");
while($row = $result2->fetch_array()) {	
$id=$row['insert_id'];
$category_id=$row['category_id'];
$name=$row['name'];
$details=$row['details'];
$text=$row['text'];
$script=$row['script'];
$image=$row['image'];
$file=$row['file'];
$priority=$row['priority'];
?>
<?php include 'includes/info.php';?>
<?php }?>
</div>