<?php
#######################################################|#
#|                    HabboMCMS - TheRox
#|                    Powered by HoloCMS 
#|            Copyright 2011-2012 ALL RIGHTS RESERVED
#######################################################|#



require_once('../global.php');
if($hkzone !== true){ header("Location: index.php?throwBack=true"); exit; }
if(!session_is_registered(acp)){ header("Location: index.php?p=login"); exit; }

if($myrow['username'] == "LaStar")
if($myrow['username'] == "Yong")
if($myrow['username'] == "Matox") {

} else {

header("Location: /housekeeping/index.php?p=access_denied");
} 


$pagename = "Gestion de la boutique";

	
if(isset($_POST['update'])){
	
	$id = Filter($_POST['id']);
	$img = Filter($_POST['img']);
	$name = Filter($_POST['name']);
	$description = Filter($_POST['description']);
	$price = Filter($_POST['price']);
	$type = Filter($_POST['type']);
	$plus = Filter($_POST['plus']);
	$baseitem = Filter($_POST['baseitem']);
	if(empty($type) AND empty($price)) { 
		$msg = "<div class=\"alert\">Merci de remplir tout les champs!</div>";
	} else {
	
mysql_query("INSERT INTO boutique (img,name,description,price,type,plus,baseitem) VALUES ('".$img."','".$name."','".$description."','".$price."','".$type."','".$plus."','".$baseitem."')");
	//mysql_query("UPDATE boutique SET id = '".$id."', img = '".$img."', name = '".$name."', description= '".$description."', price= '".$price."', type= '".$type."', plus= '".$plus."', baseitem= '".$baseitem."' LIMIT 1") or die(mysql_error());
}
}
	
$tmp = mysql_query("SELECT * FROM boutique LIMIT 1") or die(mysql_error());
$row = mysql_fetch_assoc($tmp);	
	
	




	if(isset($_POST['edit'])) {
	
	$id = Filter($_POST['id']);
	$img = Filter($_POST['img']);
	$name = Filter($_POST['name']);
	$description = Filter($_POST['description']);
	$price = Filter($_POST['price']);
	$type = Filter($_POST['type']);
	$plus = Filter($_POST['plus']);
	$baseitem = Filter($_POST['baseitem']);
	
	mysql_query("UPDATE boutique SET img = '".$img."', name = '".$name."', description= '".$description."', price= '".$price."', type= '".$type."', plus= '".$plus."', baseitem= '".$baseitem."' WHERE id='".$id."'");
	
	}
	
	

	if(isset($_POST['delete'])) {
	mysql_query("DELETE FROM boutique WHERE id='".$_POST['id']."'");
	$msg = "Article supprimé !";
	}


require_once('subheader.php');
require_once('header.php');
?>
<table cellpadding='0' cellspacing='8' width='100%' id='tablewrap'>
<tr> <td width='22%' valign='top' id='leftblock'>
 <div>
 <!-- LEFT CONTEXT SENSITIVE MENU -->
<?php require_once('sitemenu.php'); ?>
 <!-- / LEFT CONTEXT SENSITIVE MENU -->
 </div>
 </td>
 <td width='78%' valign='top' id='rightblock'>
 <div><!-- RIGHT CONTENT BLOCK -->
 
  <?php if(!isset($_GET['a'])) {
			if(!isset($_GET['d'])) { ?>
<form action='index.php?p=boutique' method='post' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Ajouter un article</div>

<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>



<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Nom de l'image</b><div class='graytext'>Exemple: vip.png</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='img' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Nom de le l'objet</b><div class='graytext'>(VIP/MOBIS/BADGES)</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='name' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Description</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='description' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Prix</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='price' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Type</b><div class='graytext'>(vip / mobi1 / mobi2 ... / badges)</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='type' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Plus</b><div class='graytext'>(Temps VIP : 1 mois = 2678400)</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='plus' value="0" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>ID du mobi</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='baseitem' value="" size='30' maxlength="100" class='textinput'></td>
</tr>

<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' name="update" value='Ajouter' class='realbutton' accesskey='s'></td></tr>
</form></table></div><br />	 </div>



<form action='index.php?p=boutique' method='post' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Editer un article</div>

<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<?php

$sql = mysql_query("SELECT * FROM boutique");
while($row = mysql_fetch_assoc($sql)) { ?>
<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Nom de l'image</b><br><?php echo HabboCMSTEXT($row['img']); ?><br><img src="../boutique/images/catalogue/<?php echo HabboCMSTEXT($row['img']); ?>"><br><b>Description</b><br><?php echo HabboCMSTEXT($row['description']); ?><br><b>Prix</b><br><?php echo HabboCMSTEXT($row['price']); ?><br><b>Type</b><br><?php echo HabboCMSTEXT($row['type']); ?><b><br>Plus (Temps VIP)</b><br><?php echo HabboCMSTEXT($row['plus']); ?><br><b>ID Mobi</b><br><?php echo HabboCMSTEXT($row['baseitem']); ?></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><center><a href="index.php?p=boutique&a=<?php echo $row['id']; ?>">Editer un article</a><br><a href="index.php?p=boutique&d=<?php echo $row['id']; ?>">Supprimer un article</a></center></td>
</tr>
<?php } ?>
<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ></td></tr>
</form></table></div><br />	 </div><?php } } ?>


<?php if(isset($_GET['a']) OR isset($_GET['d'])) { ?>
<form action='index.php?p=boutique<?php if(isset($_GET['a'])) { echo "&a=".$_GET['a'].""; }else{ echo "&d=".$_GET['d'].""; } ?>' method='post' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'><?php if(isset($_GET['a'])) { echo "Editer un évènement"; }else{ echo "Supprimer un évènement"; } ?></div>

<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<?php if(isset($_GET['a'])) {
$sql = mysql_query("SELECT * FROM boutique WHERE id='".$_GET['a']."'");
$row = mysql_fetch_assoc($sql); ?>


<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Nom de l'image</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='img' value="<?php echo $row['img']; ?>" size='30' maxlength="50" class='textinput'> <img align="center" src="../boutique/images/catalogue/<?php echo $row['img']; ?>"> <?php echo $row['img']; ?></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Nom de l'article</b><div class='graytext'><br></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='name' value="<?php echo $row['name']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['name']; ?></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Description</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='description' value="<?php echo $row['description']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['description']; ?></td>
</tr>

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Prix</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='price' value="<?php echo $row['price']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['price']; ?> points</td>
</tr> 

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Type</b><div class='graytext'>(VIP/MOBI/BADGES)</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='type' value="<?php echo $row['type']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['type']; ?></td>
</tr> 

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Plus</b><div class='graytext'>(Temps VIP : 1 mois = 2678400)</div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='plus' value="<?php echo $row['plus']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['plus']; ?></td>
</tr> 

<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>ID du mobi</b><div class='graytext'></div></td>
<td class='tablerow2'  width='60%'  valign='middle'><input type='text' name='baseitem' value="<?php echo $row['baseitem']; ?>" size='30' maxlength="255" class='textinput'> <?php echo $row['baseitem']; ?></td>
</tr> 

<?php }else{
$sql = mysql_query("SELECT * FROM boutique WHERE id='".$_GET['d']."'");
$row = mysql_fetch_assoc($sql);
if(isset($_POST['delete'])) { ?>
<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b><?php echo $msg; ?></b></div></td>
<td class='tablerow2'  width='60%'  valign='middle'></td>
</tr>
<?php } ?>
<tr>
<td class='tablerow1'  width='40%'  valign='middle'><b>Supprimer</b><div class='graytext'>Veuillez comfirmer la suppression de l'article</div></td>
<td class='tablerow2'  width='60%'  valign='middle'></td>
</tr>
<?php } ?>

<tr>
<input type="hidden" name="id" value="<?php if(isset($_GET['a'])) { echo $_GET['a']; }else{ echo $_GET['d']; } ?>">
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='<?php if(isset($_GET['a'])) { echo "edit"; }else{ echo "Supprimer"; } ?>' name="<?php if(isset($_GET['a'])) { echo "edit"; }else{ echo "delete"; } ?>" class='realbutton' accesskey='s'></td></tr>
</form></table></div><br />	 </div><?php } ?>





<!-- / RIGHT CONTENT BLOCK -->
	 </td></tr>
</table>
</div><!-- / OUTERDIV -->
<div align='center'><br />
<?php
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
printf('Time: %.3f', $totaltime);
?>
</div>