<?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
$itemid = $mysqli->real_escape_string(stripslashes($_REQUEST['itemid']));

$result = $mysqli->query("SELECT * FROM items WHERE insert_id='$itemid' AND lang_id=$lang");
$row = $result->fetch_array(); 
$item=$row['name'];
?>
<a href="edit-item.php?id=<?php echo $itemid?>"><?php echo $item ?></a>
<div class="floatright"><a href="add-extra.php?itemid=<?php echo $itemid?>"><img src="img/add.png" alt="<?php echo $adminadditem ?>" title="<?php echo $adminadditem ?>"></a></div>
</div>
<div class="framein">

<?php
$result1 = $mysqli->query("SELECT * FROM categories WHERE type=3 AND lang_id=$lang ORDER BY priority");
while($row = $result1->fetch_array()) {
$catid=$row['insert_id'];
$category=$row['name'];
?>
<div class="divitem">
        <table>
          <tr valign="top"> 
            <td width="200"> 
            <div class="padtop10">
			<strong><?php echo $category ?></strong>
            </div>
            </td>
            <td> 
  <?php
$result2 = $mysqli->query("SELECT * FROM extras WHERE type=1 AND item_id='$itemid' AND item_id='$itemid' AND category_id='$catid' AND lang_id=$lang ORDER BY priority");
while($row = $result2->fetch_array()) {
$id=$row['insert_id'];
$insert_id=$row['insert_id'];
$item_id=$row['item_id'];
$name=$row['name'];
$color=$row['color'];
$price=$row['price'];
$weight=$row['weight'];
$image=$row['image'];
$file=$row['file'];
$publish=$row['publish'];
$priority=$row['priority'];
?>
    <div class="framerow<?php if ($publish=='no') { echo " notpublished"; }?>">
     <table>
     <tr valign="top">
     <td class="divpriority"><?php echo $priority ?></td>
     <td class="divimage">
      <?php if ($image==1) { ?>
      <a id="thumb<?php echo $id ?>" href="<?php echo $filepath ?>extras/<?php echo $id ?>.jpg" onclick="return hs.expand(this)" class="plinks">
      <img src="../includes/image.php?image=<?php echo $filepath ?>extras/<?php echo $id ?>.jpg&amp;nwidth=70" alt="<?php echo $name ?>"></a>
      <?php } ?>          
      </td>
      <td class="divpriority">
       <?php if ($color!='') { ?>
       <div class="divcolor" style="background: #<?php echo $color ?>;"></div> 
       <?php } ?>       
       <?php if ($publish=='no') { ?>
       <span class="icon icstyle1 fa-eye-slash" title="<?php echo $adminpublish ?> &raquo; <?php echo $adminno ?>"></span>  
       <?php } ?>
       </td>
         <td class="padtop10">
<?php if ($file!='') { ?>
<div class="divfile"><a href="<?php echo $filepath ?>extras/files/<?php echo $id?>.<?php echo $file ?>" target="blank"><span class="icon icstyle1 fa-file-text color1" title="file"></span></a></div>
<?php } ?>         
<?php echo $name ?>
        </td>
        <td class="divpriceitem">
	   <?php if ($price!='0.00') { ?>
        <span class="price"> <?php echo $price ?> &#8364; </span>
       <?php } ?>
      </td>
        <td class="divdetails">
<?php if ($weight!='0.00') { ?>
<div class="padtop10">  <b> <?php echo $adminweight ?> <?php echo $weight ?> </b> </div>
<?php } ?>
        </td>
       <td class="divoption">
       <a href="edit-extra.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'.$id])) {
$mysqli->query("DELETE FROM extras WHERE type=1 AND insert_id='$id'");
if (file_exists("./".$filepath."extras/".$id.".jpg")) {
unlink("./".$filepath."extras/".$id.".jpg");
}
if (file_exists("./".$filepath."extras/files/".$id.".".$file)) {
unlink("./".$filepath."extras/files/".$id.".".$file);
}
$mysqli->query("ALTER TABLE extras AUTO_INCREMENT = 1");
?>
<meta http-equiv="refresh" content="0;URL=list-extras.php?itemid=<?php echo $item_id ?>">
<?php } ?>
<form name="formdelete" method="post">
<input type="hidden" name="id" value="<?php echo $id ?>">
<input type="hidden" name="itemid" value="<?php echo $item_id ?>">
<button type="submit" name="deleterow<?php echo $id ?>" class="linkoption linkdelete" title="<?php echo $admindelete ?>"><span class="icon fa-trash-o"></span> <?php echo $admindelete ?></button>
</form>
                      </td>
                  </tr>
                </table>
              </div>    
           <?php } ?>
            </td>
          </tr>
        </table>
    </div>
    <?php } ?>
    
</div>
</div>
</div>

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

</body>
</html>