<?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 * FROM members WHERE id='$id'");
$row = $result->fetch_array();
$category_id=$row['category_id'];
$itemid=$row['item_id'];
$name=$row['name'];
$email=$row['email'];
$address=$row['address'];
$city=$row['city'];
$country=$row['country'];
$tel=$row['tel'];
$fax=$row['fax'];
$comments=$row['comments'];
$rate=$row['rate'];
$image=$row['image'];
$publish=$row['publish'];
$active=$row['active'];
$date=$row['date'];
?>
    
<div class="container">
<div class="frame">
<div class="frametitles fedit"><?php echo $adminedit ?>
<div class="floatright"><a href="add-member.php?catid=<?php echo $category_id?>"><img src="img/add.png" alt="<?php echo $adminadditem ?>" title="<?php echo $adminadditem ?>"></a></div>
</div>
<div class="framein">

<?php
if  (isset($_POST['deleteimg'])) {
unlink("./".$filepath."members/".$id.".jpg");
$mysqli->query("UPDATE members SET image='0' WHERE 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 ?>">

<?php 
if  (isset($_POST['submit'])) {
$id = $mysqli->real_escape_string(stripslashes($_REQUEST['id']));
$category_id = $mysqli->real_escape_string(stripslashes($_REQUEST['category_id']));
$name = $mysqli->real_escape_string(stripslashes($_REQUEST['name']));
$name = strip_tags($name);
$name = preg_replace('/\s+/', ' ',$name);
$name = mb_convert_case($name, MB_CASE_TITLE, "UTF-8");
$email = $mysqli->real_escape_string(stripslashes($_REQUEST['email']));
$email=preg_replace('/\s+/', '', $email);
$email = strtolower($email);
$address = $mysqli->real_escape_string(stripslashes($_REQUEST['address']));
$address = mb_convert_case($address, MB_CASE_TITLE, "UTF-8");
$city = $mysqli->real_escape_string(stripslashes($_REQUEST['city']));
$city = mb_convert_case($city, MB_CASE_TITLE, "UTF-8");
$country = $mysqli->real_escape_string(stripslashes($_REQUEST['country']));
$country = mb_convert_case($country, MB_CASE_TITLE, "UTF-8");
$tel = $mysqli->real_escape_string(stripslashes($_REQUEST['tel']));
$fax = $mysqli->real_escape_string(stripslashes($_REQUEST['fax']));
$comments = $mysqli->real_escape_string(stripslashes($_REQUEST['comments']));
$image = $mysqli->real_escape_string(stripslashes($_REQUEST['image']));
$publish = $mysqli->real_escape_string(stripslashes($_REQUEST['publish']));
$date = $mysqli->real_escape_string(stripslashes($_REQUEST['date']));
if ($publish='yes') { 
$active=1;
}

$mysqli->query("UPDATE members SET category_id='$category_id', name='$name', email='$email', address='$address', city='$city', country='$country', tel='$tel', fax='$fax', comments='$comments', image='$image', publish='$publish', date='$date', active='$active' WHERE id='$id'");	
?>
<meta http-equiv="refresh" content="0;URL=edit-member.php?id=<?php echo $id ?>">    
<?php } ?>
<table>
    <tr>
            <td class="tabletd1">&nbsp;</td> 
            <td class="tabletd2"><span class="icon fa-folder-open"></span></td>
            <td> 
<select name="category_id">
<?php
$result = $mysqli->query("SELECT * FROM categories WHERE type=4 AND active=1 AND lang_id=$lang ORDER BY priority");
while($row = $result->fetch_array()) {
$catid=$row['insert_id'];
$category=$row['name'];
?>
<option value="<?php echo $catid ?>"<?php if ($catid==$category_id) { echo " selected"; }?>> 
<?php echo $category ?>
</option>                
<?php } ?>
</select>
            </td>
          </tr>
    <tr>
      <td>&nbsp;</td> 
      <td><?php echo $adminname ?> *</td>
      <td> 
        <input type="text" name="name" value="<?php echo $name ?>" size="50" class="inputauto" required>
         &nbsp; &nbsp; &nbsp; &nbsp; 
      <span class="icon fa-envelope" title="Email"></span> &nbsp; 
      <input type="text" name="email" value="<?php echo $email ?>" size="40" class="inputauto">
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td><span class="icon fa-map-marker" title="<?php echo $adminaddress ?>"></span></td>
      <td>
      <input type="text" name="address" value="<?php echo $address ?>" title="<?php echo $adminaddress ?>" size="40" class="inputauto">
      &nbsp; 
      <input type="text" name="city" value="<?php echo $city ?>" title="<?php echo $admincity ?>" size="30" class="inputauto">
      &nbsp; 
      <input type="text" name="country" value="<?php echo $country ?>"  title="<?php echo $admincountry ?>"size="30" class="inputauto">
     </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>
      <span class="icon fa-phone" title="Tel"></span>   <span class="icon fa-fax" title="Fax"></span>
      </td>
      <td>
      <input type="text" name="tel" value="<?php echo $tel ?>" size="30" class="inputauto">
      &nbsp; 
      <input type="text" name="fax" value="<?php echo $fax ?>" size="30" class="inputauto">    
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><span class="icon fa-comment" title="<?php echo $adminreviews ?>"></span></td>
      <td><div class="diveditor"><textarea name="comments" cols="75" rows="10" class="mceEditor"><?php echo $comments ?></textarea></div></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><span class="icon fa-calendar" title="<?php echo $admindate ?>"></span></td>
      <td><input type="text" name="date" value="<?php echo $date ?>" size="15" maxlength="10" class="inputauto"></td>
    </tr>
    
<?php if ($itemid==0) { ?>
    <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."members/".$id.".jpg")) { ?>
<img src="<?php echo $filepath ?>members/<?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>
<?php } ?>    
    
    <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>
    </table>

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

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

}
?>  
 
   <hr>
  <div class="divallbuttons">
<div class="divlist"><a href="list-categories.php?t=4" title="<?php echo $adminlist ?>" class="icstyle1 color1"><span class="icon fa-tasks"></span></a></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>