<?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
if ($type==2) {
$priority1="1";	
}
if ($newsletter==1) {
$priority2="2";
}
if ($reviews==1 OR $reviewsitem==1 OR $reviewsinfo==1) {
$priority3="3";
}

$typec = $mysqli->real_escape_string(stripslashes($_REQUEST['t']));

$result = $mysqli->query("SELECT id FROM members");
$nrrows = mysqli_num_rows($result);
?>
<a href="list-categories.php?t=<?php echo $typec ?>"><?php if ($typec==3) { echo $adminsubmenu; }?><?php if ($typec==4) { echo $adminmembers." (".$nrrows.")"; }?></a> 

<div class="floatright"><?php if ($typec==3) { ?><a href="add-categoryt.php?t=<?php echo $typec ?>"><img src="img/add.png" alt="<?php echo $adminaddcat ?>" title="<?php echo $adminaddcat ?>"></a><?php } ?></div>
</div>
<div class="framein">
<?php if ($typec) { ?>

<?php
if ($typec==4) {
$result = $mysqli->query("SELECT * FROM categories WHERE type='$typec' AND (priority='$priority1' OR priority='$priority2' OR priority='$priority3') AND lang_id=$lang ORDER BY priority");
} else {
$result = $mysqli->query("SELECT * FROM categories WHERE type='$typec' AND lang_id=$lang ORDER BY priority");
}

while($row = $result->fetch_array()) {
$id=$row['insert_id'];
$name=$row['name'];
$active=$row['active'];
$publish=$row['publish'];
$priority=$row['priority'];

if ($priority==1) {
$icon="user";
}
if ($priority==2) {
$icon="envelope";
}
if ($priority==3) {
$icon="comment";
}

$resultm = $mysqli->query("SELECT id FROM members WHERE category_id='$id'");
$nrrowsm = mysqli_num_rows($resultm);
?> 

    <div class="framerow<?php if ($publish=='no') { echo " notpublished"; }?>">
      <table>
        <tr>
          <td class="divpriority">
		  <?php if ($typec==3) { ?><?php echo $priority ?><?php } ?>
          </td>
          <td class="divpriority">
          <?php if ($typec==4) { ?> <span class="icon fa-<?php echo $icon ?> color1"></span> <?php } ?>
          <?php if ($priority==1 && $typec==3 && $type==2 && $inquiry==0) { ?> <span class="icon fa-shopping-cart color1"></span> <?php } ?>
          &nbsp; &nbsp;
          <?php if ($active==1) { ?> <?php if ($type==2) { ?><span class="icon fa-eur price"></span> <?php }else{?><span class="icon fa-list-alt price"></span><?php } ?> <?php } ?>
          </td>
          <td>
          <?php if ($typec==3) { ?>
		  <a href="edit-categoryt.php?id=<?php echo $id?>" class="titles"><?php echo $name ?></a>
          <?php } ?>
          <?php if ($typec==4) { ?>
		  <a href="list-members.php?catid=<?php echo $id?>" class="titles"><?php echo $name ?></a> (<?php echo $nrrowsm ?>)
          <?php } ?>
            </td>
          <td width="50" align="center">
          <?php if ($publish=='no') { ?>
          <span class="icon icstyle1 fa-eye-slash" title="<?php echo $adminpublish ?> &raquo; <?php echo $adminno ?>"></span>  
          <?php } ?>
          </td>
          <td class="divoption">
            <a href="edit-categoryt.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 ($typec==3 && $id!=1) { ?>
            
<?php
if  (isset($_POST['deleteitem'.$id])) {
$mysqli->query("DELETE FROM categories WHERE type='$typec' AND insert_id='$id'");
$mysqli->query("ALTER TABLE categories AUTO_INCREMENT = 1");
$mysqli->query("DELETE FROM extras WHERE type=1 AND category_id='$id'");
$mysqli->query("ALTER TABLE extras AUTO_INCREMENT = 1");
?>
<meta http-equiv="refresh" content="0">  
<?php } ?>       
              <form name="formdelete" method="post">
              <input type="hidden" name="id" value="<?php echo $id ?>">
              <button type="submit" name="deleteitem<?php echo $id ?>" class="linkoption linkdelete" title="<?php echo $admindelete ?>"><span class="icon fa-trash-o"></span> <?php echo $admindelete ?></button>
              </form>
            
            <?php } ?>          
            </td>
          </tr>
      </table>
    </div>
 <?php } ?>   
 
<?php } ?>
 
</div>
</div>
</div>

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

</body>
</html>