<?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';?>

<?php
$id = $mysqli->real_escape_string(stripslashes($_REQUEST['id']));

$result = $mysqli->query("SELECT insert_id FROM items WHERE lang_id=$lang ORDER BY insert_id desc LIMIT 1");
$row = $result->fetch_array(); 
$isid=$row['insert_id'];
$insertid=$isid + 1;

$result = $mysqli->query("SELECT name, category_id, section_id FROM items WHERE insert_id='$id' AND lang_id=$lang");
$row = $result->fetch_array(); 
$itemname=$row['name'];
$catid=$row['category_id'];
$secid=$row['section_id'];

$result = $mysqli->query("SELECT name, type, promote FROM categories WHERE insert_id='$catid' AND lang_id=$lang");
$row = $result->fetch_array(); 
$category=$row['name'];
$typec=$row['type'];
$promotec=$row['promote'];

$resultsc = $mysqli->query("SELECT id FROM sections WHERE lang_id=$lang");
$srows = mysqli_num_rows($resultsc);

$result = $mysqli->query("SELECT page_id FROM items WHERE page_id>0 AND lang_id=$lang ORDER BY page_id desc LIMIT 1");
$row = $result->fetch_array(); 
$pgid=$row['page_id'];
$pageid=$pgid + 1;
?>
    
<div class="container">
<div class="frame">
<div class="frametitles fedit"><?php echo $adminedit ?>
<div class="floatright"><a href="add-item.php?catid=<?php echo $catid?>"><img src="img/add.png" alt="<?php echo $adminadditem ?>" title="<?php echo $adminadditem ?>"></a></div>
<div class="floatright"><a href="list-items.php?catid=<?php echo $catid ?>&amp;secid=<?php echo $secid ?>"><img src="img/list.png" alt="<?php echo $category ?>" title="<?php echo $category ?>"></a></div>
</div>
<div class="framein">

<?php
if  (isset($_POST['deleteimg'])) {
unlink("./".$filepath."items/".$id.".jpg");
$mysqli->query("UPDATE items SET image='0' WHERE insert_id=$id");
}
if  (isset($_POST['deletefile'])) {
array_map('unlink', glob("./".$filepath."items/files/".$id.".*"));
$mysqli->query("UPDATE items SET file='' WHERE insert_id=$id");
}
?>

<?php if ($id) { ?> 
<form name="forma" method="post" enctype="multipart/form-data">
<input type="hidden" name="max_file_size" value="5000000">
<input type="hidden" name="id" value="<?php echo $id ?>">
<input type="hidden" name="file" value="<?php echo $file?>">

<table>
    <tr>
      <td class="tabletd1">&nbsp;</td>
      <td class="tabletd2"><span class="icon fa-folder-open"></span></td>
      <td>
      
<select name="category_id">
<?php
$result1 = $mysqli->query("SELECT insert_id, name, type, level, parent FROM categories WHERE level=1 AND type<3 AND lang_id=$lang ORDER BY priority");
while($row = $result1->fetch_array()) {
$catid1=$row['insert_id'];
$category1=$row['name'];
$typec1=$row['type'];
$level=$row['level'];
$parent=$row['parent'];
?>
<option value="<?php echo $catid1 ?>"<?php if ($catid1==$catid) { echo " selected"; }?><?php if ($typec1==2) { echo ' class="color1"'; }?>>
&raquo; <?php echo $category1 ?>
</option>
  
<?php 
$result2 = $mysqli->query("SELECT insert_id, name, type FROM categories WHERE parent='$catid1' AND lang_id=$lang ORDER BY priority");
while($row = $result2->fetch_array()) {
$catid2=$row['insert_id'];
$category2=$row['name'];
$typec2=$row['type'];
?>
<option value="<?php echo $catid2 ?>"<?php if ($catid2==$catid) { echo " selected"; }?><?php if ($typec2==2) { echo ' class="color1"'; }?>> 
----&raquo; <?php echo $category2 ?>
</option>
<?php } ?>
<?php } ?>
</select>

<?php if ($srows>0 && $catid>1) { ?>
&nbsp; &nbsp;
<select name="section_id">
<?php
$result1s = $mysqli->query("SELECT insert_id, name, level, parent FROM sections WHERE level=1 AND lang_id=$lang ORDER BY priority");
while($row = $result1s->fetch_array()) {
$secid1=$row['insert_id'];
$section1=$row['name'];
$level=$row['level'];
$parent=$row['parent'];
?>
<option value="<?php echo $secid1 ?>"<?php if ($secid1==$secid) { echo " selected"; }?> class="color2">
&raquo; <?php echo $section1 ?>
</option>
  
<?php 
$result2s = $mysqli->query("SELECT insert_id, name FROM sections WHERE parent='$secid1' AND lang_id=$lang ORDER BY priority");
while($row = $result2s->fetch_array()) {
$secid2=$row['insert_id'];
$section2=$row['name'];
?>
<option value="<?php echo $secid2 ?>"<?php if ($secid2==$secid) { echo " selected"; }?> class="color2"> 
----&raquo; <?php echo $section2 ?>
</option>
<?php } ?>
<?php } ?>
</select>
<?php } ?>
      </td>
    </tr>
    </table>
    
<?php
$result30 = $mysqli->query("SELECT * FROM lang WHERE active=1 ORDER BY priority");
while($row = $result30->fetch_array()) {
$langid=$row['id'];
$language=$row['language'];
$dir=$row['dir'];
?>

<?php
$result51 = $mysqli->query("SELECT * FROM items WHERE insert_id=$id AND lang_id=$langid");
while($row = $result51->fetch_array()) {
$name=$row['name'];
$description=$row['description'];
$details=$row['details'];
$text=$row['text'];
$extra=$row['extra'];

$insert_id=$row['insert_id'];
$lang_id=$row['lang_id'];
$category_id=$row['category_id'];
$section_id=$row['section_id'];
$page_id=$row['page_id'];
$code=$row['code'];
$url=$row['url'];
$email=$row['email'];
$script=$row['script'];
$price=$row['price'];
$offerprice=$row['offerprice'];
$weight=$row['weight'];
$unit=$row['unit'];
$image=$row['image'];
$file=$row['file'];
$new=$row['new'];
$available=$row['available'];
$promote=$row['promote'];
$size=$row['size'];
$color=$row['color'];
$showpage=$row['showpage'];
$publish=$row['publish'];
$priority=$row['priority'];
$date=$row['date'];
?>

<?php 
if  (isset($_POST['submit'])) {
$category_id = $mysqli->real_escape_string(stripslashes($_REQUEST['category_id']));
$section_id = $mysqli->real_escape_string(stripslashes($_REQUEST['section_id']));
$result = $mysqli->query("SELECT type FROM categories WHERE insert_id='$category_id' AND lang_id=$lang");
$row = $result->fetch_array(); 
$typec=$row['type'];

$name = $mysqli->real_escape_string(stripslashes($_REQUEST["name$langid"]));
$name = strip_tags($name);
$name = trim($name);

$page=preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $name);
$page=transliterate($page);
setlocale(LC_ALL, 'en_GB'); 
$page = iconv("UTF-8", "ASCII//TRANSLIT", $page); 
$page=preg_replace("/[^a-zA-Z0-9- ]/", ' ', $page);
$page = trim($page);
$page=preg_replace('/\s+/', '-', $page);
$page=strtolower(preg_replace('/\-+/', '-', $page));

$name = preg_replace('/\s+/', ' ',$name);
$description = $mysqli->real_escape_string(stripslashes($_REQUEST["description$langid"]));
$description = strip_tags($description);
$description = str_replace('\r\n', ' ',$description);
$description = preg_replace('/\s+/', ' ',$description);
$details = $mysqli->real_escape_string(stripslashes($_REQUEST["details$langid"]));
$details = str_replace('\r\n', ' ',$details);
$text = $mysqli->real_escape_string(stripslashes($_REQUEST["text$langid"]));
$text = str_replace('\r\n', ' ',$text);
$extra = $mysqli->real_escape_string(stripslashes($_REQUEST["extra$langid"]));
$unit = $mysqli->real_escape_string(stripslashes($_REQUEST["unit$langid"]));

$code = $mysqli->real_escape_string(stripslashes($_REQUEST['code']));
$url = $mysqli->real_escape_string(stripslashes($_REQUEST['url']));
$url=preg_replace('/\s+/', '', $url);
$email = $mysqli->real_escape_string(stripslashes($_REQUEST['email']));
$email=preg_replace('/\s+/', '', $email);
$email = strtolower($email);
$script = $mysqli->real_escape_string(stripslashes($_REQUEST['script']));
$price = $mysqli->real_escape_string(stripslashes($_REQUEST['price']));	
$offerprice = $mysqli->real_escape_string(stripslashes($_REQUEST['offerprice']));
$weight = $mysqli->real_escape_string(stripslashes($_REQUEST['weight']));
$image = $mysqli->real_escape_string(stripslashes($_REQUEST['image']));
$filen = $mysqli->real_escape_string(stripslashes($_REQUEST['filen']));
$publish = $mysqli->real_escape_string(stripslashes($_REQUEST['publish']));
$new = $mysqli->real_escape_string(stripslashes($_REQUEST['new']));	
$available = $mysqli->real_escape_string(stripslashes($_REQUEST['available']));	
$size = $mysqli->real_escape_string(stripslashes($_REQUEST['size']));
$color = $mysqli->real_escape_string(stripslashes($_REQUEST['color']));
$showpage = $mysqli->real_escape_string(stripslashes($_REQUEST['showpage']));	
$priority = $mysqli->real_escape_string(stripslashes($_REQUEST['priority']));
$date = $mysqli->real_escape_string(stripslashes($_REQUEST['date']));

$promote1 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote1']));
if ($category_id==1){
$promote1 = 0;
}
$promote2 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote2']));
$promote4 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote4']));
$promote5 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote5']));
$promote = $promote1.$promote2.$promote4.$promote5;

if( $filen=='' ){
$file= "";
}	

$result = $mysqli->query("SELECT page, type FROM categories WHERE insert_id='$category_id' AND lang_id=$langid");
$row = $result->fetch_array(); 
$cpage=$row['page'];
$typec=$row['type'];

if( $typec==0){
$typei = 1;
} else {
$typei = $typec;
}

if( $page_id>0){
$pageid = $page_id;
} else {
if($typec==2 OR ($details AND $text)){
$pageid = $pageid;
} else {
$pageid = 0;
}}
if ($pageid>0 AND !$page){
$page = $cpage;
}

$mysqli->query("UPDATE items SET category_id='$category_id', section_id='$section_id', page_id='$pageid', page='$page', name='$name', description='$description', details='$details', text='$text', extra='$extra', code='$code', url='$url', email='$email', script='$script', price='$price', offerprice='$offerprice', weight='$weight', unit='$unit', image='$image', file='$file', type='$typei', publish='$publish', new='$new', available='$available', promote='$promote', size='$size', color='$color', showpage='$showpage', priority='$priority', date='$date' WHERE insert_id='$id' AND lang_id=$langid");
?>
<meta http-equiv="refresh" content="0;URL=edit-item.php?id=<?php echo $id ?>"> 
<?php } ?>

<!--DUPLICATE -->
<?php 
if  (isset($_POST['duplicate'])) {
$category_id = $mysqli->real_escape_string(stripslashes($_REQUEST['category_id']));
$section_id = $mysqli->real_escape_string(stripslashes($_REQUEST['section_id']));
$result = $mysqli->query("SELECT type FROM categories WHERE insert_id='$category_id' AND lang_id=$lang");
$row = $result->fetch_array(); 
$typec=$row['type'];

$name = $mysqli->real_escape_string(stripslashes($_REQUEST["name$langid"]));
$name = strip_tags($name);
$name = trim($name);

$page=preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $name);
$page=transliterate($page);
setlocale(LC_ALL, 'en_GB'); 
$page = iconv("UTF-8", "ASCII//TRANSLIT", $page); 
$page=preg_replace("/[^a-zA-Z0-9- ]/", ' ', $page);
$page = trim($page);
$page=preg_replace('/\s+/', '-', $page);
$page=strtolower(preg_replace('/\-+/', '-', $page));

$name = preg_replace('/\s+/', ' ',$name);
$description = $mysqli->real_escape_string(stripslashes($_REQUEST["description$langid"]));
$description = strip_tags($description);
$description = str_replace('\r\n', ' ',$description);
$description = preg_replace('/\s+/', ' ',$description);
$details = $mysqli->real_escape_string(stripslashes($_REQUEST["details$langid"]));
$details = str_replace('\r\n', ' ',$details);
$text = $mysqli->real_escape_string(stripslashes($_REQUEST["text$langid"]));
$text = str_replace('\r\n', ' ',$text);
$extra = $mysqli->real_escape_string(stripslashes($_REQUEST["extra$langid"]));
$unit = $mysqli->real_escape_string(stripslashes($_REQUEST["unit$langid"]));

$code = $mysqli->real_escape_string(stripslashes($_REQUEST['code']));
$url = $mysqli->real_escape_string(stripslashes($_REQUEST['url']));
$url=preg_replace('/\s+/', '', $url);
$email = $mysqli->real_escape_string(stripslashes($_REQUEST['email']));
$email=preg_replace('/\s+/', '', $email);
$email = strtolower($email);
$script = $mysqli->real_escape_string(stripslashes($_REQUEST['script']));
$price = $mysqli->real_escape_string(stripslashes($_REQUEST['price']));	
$offerprice = $mysqli->real_escape_string(stripslashes($_REQUEST['offerprice']));
$weight = $mysqli->real_escape_string(stripslashes($_REQUEST['weight']));
$image = $mysqli->real_escape_string(stripslashes($_REQUEST['image']));
$filen = $mysqli->real_escape_string(stripslashes($_REQUEST['filen']));
$publish = $mysqli->real_escape_string(stripslashes($_REQUEST['publish']));
$new = $mysqli->real_escape_string(stripslashes($_REQUEST['new']));	
$available = $mysqli->real_escape_string(stripslashes($_REQUEST['available']));	
$size = $mysqli->real_escape_string(stripslashes($_REQUEST['size']));
$color = $mysqli->real_escape_string(stripslashes($_REQUEST['color']));
$showpage = $mysqli->real_escape_string(stripslashes($_REQUEST['showpage']));	
$priority = $mysqli->real_escape_string(stripslashes($_REQUEST['priority']));

$promote1 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote1']));
if ($category_id==1){
$promote = 0;
}
$promote2 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote2']));
$promote4 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote4']));
$promote5 = $mysqli->real_escape_string(stripslashes($_REQUEST['promote5']));
$promote = $promote1.$promote2.$promote4.$promote5;

if( $filen=='' ){
$file= "";
}	

$result = $mysqli->query("SELECT page, type FROM categories WHERE insert_id='$category_id' AND lang_id=$langid");
$row = $result->fetch_array(); 
$cpage=$row['page'];
$typec=$row['type'];

if( $typec==0){
$typei = 1;
} else {
$typei = $typec;
}

$result = $mysqli->query("SELECT page_id FROM items WHERE page_id>0 AND insert_id!=$insertid ORDER BY page_id desc LIMIT 1");
$row = $result->fetch_array(); 
$pgid=$row['page_id'];
$pageid=$pgid + 1;

if($typec==2 OR ($details AND $text)){
$pageid=$pgid + 1;
} else {
$pageid = 0;
}
if ($pageid>0 AND !$page){
$page = $cpage;
}
$date = date ("j.m.Y");

$mysqli->query("INSERT INTO items (insert_id, lang_id, category_id, section_id, page_id, page, name, description, details, text, extra, code, url, email, script, price, offerprice, weight, unit, image, file, type, new, available, promote, size, color, showpage, publish, priority, date) VALUES ('$insertid', '$langid', '$category_id', '$section_id', '$pageid', '$page', '$name', '$description', '$details', '$text', '$extra', '$code', '$url', '$email', '$script', '$price', '$offerprice', '$weight', '$unit', '$image', '$file', '$typei', '$new', '$available', '$promote', '$size', '$color', '$showpage', '$publish', '$priority', '$date')");

?>
<meta http-equiv="refresh" content="0;URL=edit-item.php?id=<?php echo $insertid ?>"> 
<?php } ?>

<hr class="overline bordercolor1">
  <table>
    <tr>
      <td class="tabletd1"><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"></td> 
      <td class="tabletd2">
	  <?php echo $adminnamed ?> 
        <?php if ($typec==2) { echo '*'; } ?>
        </td>
      <td> 
        <input type="text" name="name<?php echo $langid ?>" value="<?php echo $name ?>" size="100"<?php if ($typec==2) { echo ' required'; } ?>>
        </td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"></td>
      <td><?php echo $admintext ?></td>
      <td>
      <div class="diveditor1"><textarea name="details<?php echo $langid ?>" cols="75" rows="10" class="mceEditor"><?php echo $details ?></textarea></div>
      <div class="diveditor2"><textarea name="text<?php echo $langid ?>" cols="100" rows="10" class="mceEditor"><?php echo $text ?></textarea></div>
      </td>
    </tr>
    <tr>
      <td><?php if ($adminunit OR $adminextra) { ?><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"><?php } ?></td>
      <td><?php echo $adminunit ?> </td>
      <td>
      <?php if ($adminunit) { ?>
      <input name="unit<?php echo $langid ?>" type="text" size="15" value="<?php echo $unit ?>" class="inputauto">
      &nbsp; &nbsp; &nbsp;
      <?php } ?>
      <?php if ($adminextra) { ?>  
      <?php echo $adminextra ?> <input type="text" name="extra<?php echo $langid ?>" size="40" value="<?php echo $extra ?>" class="inputauto">
      <?php } ?>
      </td>
    </tr>
    </table>

<div class="divtags">
<span class="icon icstyle1 fa-tags color2" title="meta tags"></span>
<hr>
  <table class="tcolor">
    <tr>
      <td class="tabletd1"><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"></td>
      <td class="tabletd2"><?php echo $admindesc ?></td>
      <td><textarea name="description<?php echo $langid ?>" cols="75" rows="3"><?php echo $description ?></textarea></td>
    </tr>
    </table>
</div>
  
<?php } ?>

<?php } ?>

<!--NEW LANG -->

<?php
$result52 = $mysqli->query("SELECT * FROM lang WHERE id NOT IN (SELECT lang_id FROM items WHERE insert_id='$id') AND active=1 ORDER BY main desc, priority");
$nrrows52 = mysqli_num_rows($result52);
while($row = $result52->fetch_array()) {
$langid2=$row['id'];
$language2=$row['language'];
$dir2=$row['dir'];
?>

<?php if  ($nrrows52>0) { ?>

<hr class="overline bordercolor1">
  <table>
    <tr>
      <td class="tabletd1"><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td> 
      <td class="tabletd2">
	  <?php echo $adminnamed ?> 
      <?php if ($typec==2) { echo '*'; } ?>
        </td>
      <td> 
        <input type="text" name="name<?php echo $langid2 ?>" size="100"<?php if ($typec==2) { echo ' required'; } ?>>
        </td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td>
      <td><?php echo $admintext ?> 1</td>
      <td>
      <div class="diveditor1"><textarea name="details<?php echo $langid2 ?>" cols="75" rows="10" class="mceEditor"></textarea></div>
      <div class="diveditor2"><textarea name="text<?php echo $langid2 ?>" cols="100" rows="10" class="mceEditor"></textarea></div>
      </td>
    </tr>
    <?php if ($typec==2) { ?>  
    <tr>
      <td><?php if ($adminunit OR $adminextra) { ?><img src="img/<?php echo $dir ?>.png" width="16" height="16" title="<?php echo $language ?>" alt="<?php echo $language ?>"><?php } ?></td>
      <td><?php echo $adminunit ?> </td>
      <td>
      <?php if ($adminunit) { ?>
      <input name="unit<?php echo $langid2 ?>" type="text" size="15" class="inputauto">
      &nbsp; &nbsp; &nbsp;
      <?php } ?>
      <?php if ($adminextra) { ?>  
      <?php echo $adminextra ?> <input type="text" name="extra<?php echo $langid2 ?>" size="40" class="inputauto">
      <?php } ?>
      </td>
    </tr>
    <?php } ?>
    </table>
    
<div class="divtags">   
<span class="icon icstyle1 fa-tags color2" title="meta tags"></span>
<hr>
  <table class="tcolor">
    <tr>
      <td class="tabletd1"><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td>
      <td class="tabletd2"><?php echo $admindesc ?></td>
      <td><textarea name="description<?php echo $langid2 ?>" cols="75" rows="3"></textarea></td>
    </tr>
    </table>
</div>
        
<?php 
if  (isset($_POST['submit'])) {
$name = $mysqli->real_escape_string(stripslashes($_REQUEST["name$langid2"]));
$name = strip_tags($name);
$name = trim($name);

$page=preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $name);
$page=transliterate($page);
setlocale(LC_ALL, 'en_GB'); 
$page = iconv("UTF-8", "ASCII//TRANSLIT", $page); 
$page=preg_replace("/[^a-zA-Z0-9- ]/", ' ', $page);
$page = trim($page);
$page=preg_replace('/\s+/', '-', $page);
$page2=strtolower(preg_replace('/\-+/', '-', $page));

$name2 = preg_replace('/\s+/', ' ',$name);
	
$description2 = $mysqli->real_escape_string(stripslashes($_REQUEST["description$langid2"]));
$description2 = strip_tags($description2);
$description2 = str_replace('\r\n', ' ',$description2);
$description2 = preg_replace('/\s+/', ' ',$description2);
$details2 = $mysqli->real_escape_string(stripslashes($_REQUEST["details$langid2"]));
$details2 = str_replace('\r\n', ' ',$details2);
$text2 = $mysqli->real_escape_string(stripslashes($_REQUEST["text$langid2"]));
$text2 = str_replace('\r\n', ' ',$text2);
$unit2 = $mysqli->real_escape_string(stripslashes($_REQUEST["unit$langid2"]));
$extra2 = $mysqli->real_escape_string(stripslashes($_REQUEST["extra$langid2"]));

if( $typec==0 OR $typec==1){
$page2 = '';
} else {
$page2 = $page2;
}

$mysqli->query("INSERT INTO items (insert_id, lang_id, category_id, section_id, page_id, page, name, description, details, text, extra, code, url, email, script, price, offerprice, weight, unit, image, file, type, publish, new, available, promote, size, color, priority, date) VALUES ('$insert_id', '$langid2', '$category_id', '$section_id', '$pageid', '$page2', '$name2', '$description2', '$details2', '$text2', '$extra2', '$code', '$url', '$email', '$script', '$price', '$offerprice', '$weight', '$unit2', '$image', '$file', '$typei', '$publish', '$new', '$available', '$promote', '$size', '$color', '$priority', '$date')");
?>
<meta http-equiv="refresh" content="0;URL=edit-item.php?id=<?php echo $id ?>">    
    
<?php } ?>
<?php } ?>
<?php } ?>

<!--END NEW LANG -->

<hr>
<table>
  <tr>
    <td class="tabletd1">&nbsp;</td>
    <td class="tabletd2"><span class="icon fa-link" title="Link url"></span></td>
    <td><input name="url" type="text" value="<?php echo $url ?>" size="100"></td>
  </tr>
   <?php if ($type==4 && $typec==2) { ?>
  <tr>
    <td>&nbsp;</td>
    <td><span class="icon fa-envelope" title="Email"></span></td>
    <td><input type="text" name="email" value="<?php echo $email ?>" size="40"></td>
  </tr>
 <?php } ?> 
  <tr>
    <td>&nbsp;</td>
    <td><span class="icon fa-code" title="<?php echo $adminscript ?>"></span></td>
    <td><textarea name="script" cols="75" rows="6"><?php echo $script ?></textarea></td>
  </tr>
  
<?php if ($typec==2 && $type!=3 && $type!=4 && $type!=6) { ?>

    <tr>
    <td>&nbsp;</td>
    <td><span class="icon fa-barcode" title="<?php echo $admincode ?>"></span></td>
    <td><input name="code" type="text" value="<?php echo $code ?>" size="60" class="inputauto"></td>
  </tr>
  <tr class="price divdprice">
    <td>&nbsp;</td>
    <td><span class="icon fa-eur"></span>
    <div class="floatright"><?php echo $adminprice ?></div>
    </td>
    <td>
      <input type="text" name="price" value="<?php echo $price ?>" size="15" maxlength="11" class="inputauto">
      &nbsp; &nbsp; 
     <?php echo $adminpriceo ?> <input type="text" name="offerprice" value="<?php echo $offerprice ?>" size="15" maxlength="11" class="inputauto">
     </td>
  </tr>
  <?php if ($adminweight) { ?>
    <tr class="divweight">
      <td>&nbsp;</td>
      <td><span title="<?php echo $adminweight ?> Kg">Kg</span></td>
      <td>
  <input type="text" name="weight" value="<?php echo $weight ?>" size="15" maxlength="11" class="inputauto"> 
      </td>
    </tr>
  <?php } ?>
  <?php } ?>
   
    <tr>
      <td>&nbsp;</td> 
      <td><span class="icon fa-image" title="<?php echo $adminimg ?>"></span></td>
      <td>
  <input type="hidden" name="image" value="0">
  <input type="checkbox" name="image" value="1"<?php if ($image==1) { echo " checked"; }?>>
        
 <input name="upload" type="file" size="50" title="upload photo .jpg">           

<?php if (file_exists("./".$filepath."items/".$id.".jpg")) { ?>
<img src="<?php echo $filepath ?>items/<?php echo $id ?>.jpg" width="80">

<button type="submit" name="deleteimg" title="<?php echo $admindelete ?> <?php echo $adminimg ?>" class="buttonicon color1"><span class="icon fa-trash-o"></span></button>
<?php } ?>  
    
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><span class="icon fa-file-text" title="<?php echo $adminfile ?>"></span></td>
      <td>
<?php if ($file!='') { ?>
<input type="hidden" name="filen" value=""> 
<input type="checkbox" name="filen" value="<?php echo $file ?>" checked> 
<?php } ?> 
 
      <input name="uploadfile" type="file" size="50" title="upload file - max 5 MB">
      
<?php if ($file!='') { ?>
&nbsp; &nbsp;
<a href="<?php echo $filepath ?>items/files/<?php echo $id?>.<?php echo $file ?>" target="blank"><span class="icon icstyle1 fa-file-text color1" title="file"></span></a>

<button type="submit" name="deletefile" title="<?php echo $admindelete ?> file" class="buttonicon color1"><span class="icon fa-trash-o"></span></button>
<?php } ?>  
      </td>
    </tr>

<tr class="divextra">
    <td>&nbsp;</td>
    <td><span class="icon fa-cog" title="<?php echo $adminfeatures ?>"></span></td>
    <td>
    <table class="widthauto aligncenter text1">
        <tr>
  <?php if ($typec==2) { ?>       
          <td>
 <?php echo $adminnew ?> <br>
 <input type="hidden" name="new" value="0"> <input type="checkbox" name="new" value="1"<?php if ($new==1) { echo " checked"; }?>>     
          </td>
  <?php } ?> 
  
  <?php if ($typec==2) { ?>          
   <td>
<?php echo $adminavailable ?> <br>
<input type="hidden" name="available" value="0"> <input type="checkbox" name="available" value="1"<?php if ($available==1) { echo " checked"; }?>>  
          </td>
 <?php } ?> 
  <?php if ($typec==2) { ?>         
          <td>
 <?php echo $adminshow ?> <br>
 <input type="hidden" name="showpage" value="0"> <input type="checkbox" name="showpage" value="1"<?php if ($showpage==1) { echo " checked"; }?>>  
 
          </td>
  <?php } ?>  
 <?php if ($promoteitem==1 OR $menu1==1 OR $menu2==1 OR preg_match("/2/", $promotec)) { ?>        
          <td>
<?php echo $adminpromote ?>

        <div>
<input type="hidden" name="promote" value="0"> 
<?php if ($promoteitem==1) { ?>
<span class="icon icstyle fa-home"></span>
<input type="checkbox" name="promote1" value="1"<?php if (preg_match("/1/", $promote)) { echo " checked"; }?>>
&nbsp; &nbsp;
<?php } ?>

<?php if (preg_match("/2/", $promotec)) { ?>
<span class="icon icstyle fa-chevron-circle-down"></span>
<input type="checkbox" name="promote2" value="2"<?php if (preg_match("/2/", $promote)) { echo " checked"; }?>>
&nbsp; &nbsp;
<?php } ?> 

<?php if ($menu1==1) { ?>
<span class="icon icstyle fa-toggle-left"></span>
<input type="checkbox" name="promote4" value="4"<?php if (preg_match("/4/", $promote)) { echo " checked"; }?>>
&nbsp; &nbsp;
<?php } ?> 

<?php if ($menu2==1) { ?>
<span class="icon icstyle fa-toggle-right"></span>
<input type="checkbox" name="promote5" value="5"<?php if (preg_match("/5/", $promote)) { echo " checked"; }?>>
&nbsp; &nbsp;
<?php } ?>     
 
 </div>
          </td>
<?php } ?>       
<?php if ($package>1 && $typec<2) { ?>  
          <td>
          Full size <br>
          <input type="hidden" name="size" value="0"> <input type="checkbox" name="size" value="1"<?php if ($size==1) { echo " checked"; }?>> 
          </td>
         <?php } ?> 
          <?php if ($typec<2) { ?>
          <td>
           <?php echo $admincolor ?> <br>
          <input type="hidden" name="color" value="0"> <input type="checkbox" name="color" value="2"<?php if ($color==2) { echo " checked"; }?>> 
          </td>
          <?php } ?> 
          </tr>
        </table>
        </td>
  </tr>

    <tr>
      <td>&nbsp;</td> 
      <td><span class="icon fa-eye<?php if ($publish=='no') { echo "-slash"; }?>" title="<?php echo $adminpublish ?>"></span></td>
      <td>
      <input type="hidden" name="publish" value="no"> <input type="checkbox" name="publish" value="yes"<?php if ($publish=='yes') { echo " checked"; }?>>
     </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><span class="icon fa-sort-numeric-asc" title="<?php echo $adminpriority ?>"></span></td>
      <td>
      <input type="text" name="priority" value="<?php echo $priority ?>" size="15" maxlength="11" class="inputauto">
     <input type="hidden" name="date" value="<?php echo $date ?>">
      <?php if ($dateitem==1) { ?>
      &nbsp; &nbsp; &nbsp;
     <div class="divdate"> <span class="icon fa-calendar" title="<?php echo $admindate ?>"></span> <input type="text" name="date" value="<?php echo $date ?>" size="15" maxlength="10" class="inputauto"></div>   
     <?php } ?> 
      </td>
    </tr>
    </table>

<!--UPLOAD --> 
<?php
if  ( isset($_POST['submit']) AND ($_FILES['upload']['tmp_name'] != "" ) ) {

$file_tmp =$_FILES['upload']['tmp_name'];
	   
		$uploadid=$id;
		$uploaddir = $filepath.'items/'; 
		$uploadname = $uploadid.'.jpg'; 
	
		copy($file_tmp,$uploaddir.$uploadname);
		$mysqli->query("UPDATE items SET image='1' WHERE insert_id=$uploadid");
	
resizephoto($uploaddir.$uploadname,$uploaddir.$uploadname,$thumb_w,$thumb_h);

}
?>

<!--DUPLICATE -->
<?php
if  ( isset($_POST['duplicate']) ) {
	
if  ( $_FILES['upload']['tmp_name'] != "" ) {
$file_tmp =$_FILES['upload']['tmp_name'];
} else {
$file_tmp = $filepath.'items/'.$id.'.jpg';
}
	   
		$uploaddir = $filepath.'items/'; 
		$uploadname = $insertid.'.jpg'; 
	
		copy($file_tmp,$uploaddir.$uploadname);
		if  ( $_FILES['upload']['tmp_name'] != "" ) {
		$mysqli->query("UPDATE items SET image='1' WHERE insert_id=$insertid");
		}
	
resizephoto($uploaddir.$uploadname,$uploaddir.$uploadname,$thumb_w,$thumb_h);

}
?>

<?php
if  ( isset($_POST['submit']) AND ($_FILES['uploadfile']['tmp_name'] != "" ) ) {

$file_tmpf =$_FILES['uploadfile']['tmp_name'];
		
$filename = $_FILES["uploadfile"]["name"];
$tmp = explode('.', $filename);
$filetype = end($tmp);

if( $filetype == "exe" ){
$file= "";
} else {
$file= $filetype;
}

		$uploadid=$id;
		$uploaddirfile = $filepath.'items/files/'; 
		$uploadnamefile = $uploadid.".".$filetype; 
	
		copy($file_tmpf,$uploaddirfile.$uploadnamefile);
		$mysqli->query("UPDATE items SET file='$file' WHERE insert_id=$uploadid");

}
?>    
   
   <hr>
  <div class="divallbuttons">
<div class="divlist">
<a href="list-items.php?catid=<?php echo $catid ?>&amp;secid=<?php echo $secid ?>" title="<?php echo $adminlist ?>" class="icstyle1 color1"><span class="icon fa-tasks"></span></a>
&nbsp;
<button type="submit" name="duplicate" title="Duplicate <?php echo $itemname ?>" class="buttonicon icstyle1 color2"><span class="icon fa-clone"></span></button>
</div>
<div class="divbuttons">
  <button type="submit" name="submit" class="button"><span class="icon fa-check"></span> <?php echo $adminsubmit ?></button>
  <button type="reset" name="reset" class="button buttondelete"><span class="icon fa-refresh"></span> <?php echo $adminreset ?></button>
</div>
   </div>
   
</form>  
<?php } ?>

</div>
</div>
</div>

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

</body>
</html>