<?php

	if($_SESSION['level'] < 9)
			{
			$_SESSION['error'] = "You have NO ACCESS to Enhanche Items";
			include('error.php');
			} else {


		$active_page = !empty($_GET['page']) ? $_GET['page'] : 0;
		
		$result=mysql_query('SELECT COUNT(itemid) FROM global_shop WHERE isSell = 1');
		list($cashshopentries)=mysql_fetch_row($result);
		$result=mysql_query('SELECT COUNT(itemid) FROM global_shop');
		list($cashshopentries2)=mysql_fetch_row($result);
		$result=mysql_query('SELECT COUNT(itemid) FROM global_shop');
		list($entries)=mysql_fetch_row($result);

			$blaettern=new blaettern($active_page, $entries);
			$blaettern->setLinkHref('index.php?show=cashshop_menu&content=add_cashshop&amp;page=');
			$blaettern->setDelimiter1(' ');
			$blaettern->setDelimiter3(', ');
			$blaettern->setLinkActiveMore(' style="font-size:13px;"');
			$blaettern->setLinkFirstLastText('Machst Du Seite 1', 'Machst Du Seite ganz hinten');
			$blaettern->setShowActiveLink('false');
			$blaettern->setShowFirstLast(false);
			$blaettern->setShowNextPrev(false);
			$blaettern->setEntriesPerPage(50);
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td class="sitemenu"><strong>Cashshop</strong></td>
            </tr>
            <tr>
              <td class="sitemenu"><hr size="1" /></td>
            </tr>
			<tr>
              <td class="sitemenu"><?php
									echo $_SESSION['done']; 
									unset($_SESSION['done']);		
									?></td>
            </tr>
            <tr>
              <td align="left" valign="top" class="sitemenu"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="23%" align="left" valign="top" bgcolor="#333333" class="sitemenu">Add Items to Cashshop...</td>
                </tr>
                <tr>
                  <td align="left" valign="top" class="sitemenu">
                    <table width="100%" border="0" cellspacing="1" cellpadding="0">
                      <tr>
                        <td colspan="6" align="left" valign="top" class="sitemenu">Items on Cashshop: <?php echo $cashshopentries; ?>  || Total Items: <?php echo $cashshopentries2; ?></td>
                        </tr>
					<tr>
                        <td colspan="6" align="middle" valign="top" class="sitemenu"><?php echo $blaettern->create(); ?></td>
                        </tr>
                      <tr>
                        <td width="25%" align="left" valign="top" bgcolor="#202020" class="sitemenu"><strong>Itemname</strong></td>
						<td width="7%" align="center" valign="top" bgcolor="#202020" class="sitemenu"><strong>Lot</strong></td>
                        <td width="16%" align="left" valign="top" bgcolor="#202020" class="sitemenu"><strong>ID</strong></td>
                        <td width="13%" align="center" valign="top" bgcolor="#202020" class="sitemenu"><strong>Price</strong></td>
                        <td width="13%" align="center" valign="top" bgcolor="#202020" class="sitemenu"><strong>New Price</strong></td>
                        <td width="15%" align="center" valign="top" bgcolor="#202020" class="sitemenu"><strong>Category</strong></td>
                        <td width="6%" align="center" bgcolor="#202020" class="sitemenu"><strong>Sell?</strong></td>
						<td width="5%" align="center" bgcolor="#202020" class="sitemenu"><strong>EDIT</strong></td>
                      </tr>
<?php
						$bg = "";
					
						$result=mysql_query('SELECT * FROM global_shop ORDER BY id ASC LIMIT '.($blaettern->getEntriesPerPage() * $blaettern->getActivePage()).', '.$blaettern->getEntriesPerPage())or die(mysql_error());
						while ($row = mysql_fetch_array($result)) 
							{

								if ($bg== "") { $bg = "#4F4F4F"; } else { $bg = ""; }
								if ($row['categorie'] == 1) { $select1 = "selected"; } else { $select1 = ""; }
								if ($row['categorie'] == 2) { $select2 = "selected"; } else { $select2 = ""; }
								if ($row['categorie'] == 3) { $select3 = "selected"; } else { $select3 = ""; }
								if ($row['categorie'] == 4) { $select4 = "selected"; } else { $select4 = ""; }
								if ($row['categorie'] == 5) { $select5 = "selected"; } else { $select5 = ""; }
								if ($row['categorie'] == 6) { $select6 = "selected"; } else { $select6 = ""; }								
								
								echo "	<form id='form1' name='form1' method='post' action='action.php?action=changeshopitem' />
										<tr>
										<td align='left' valign='top' class='sitemenu'><input name='itemshopname' type='text' size='30' maxlength='25' value='".$row['itemshopname']."'/></td>
										<td align='center' valign='top' class='sitemenu'>".$row['lot']."</td>
										<td align='left' valign='top' class='sitemenu'>".$row['itemname']."</td>
										<td align='center' valign='top' class='sitemenu'>".$row[price]."</td>
										<td align='center' valign='top' class='sitemenu'>
											<input name='newprice' type='text' id='newprice' size='5' maxlength='5' value='".$row[price]."'/>
										</td>
										<td align='center' valign='top' class='sitemenu'>
											<select name='category' id='category'>";
											echo "<option value=''"; if($row['categorie'] == '') echo " selected='selected'"; echo "> - - - -</option>";
											echo "<option value='1'"; if($row['categorie'] == 1) echo " selected='selected'"; echo ">Consumables</option>";
											echo "<option value='2'"; if($row['categorie'] == 2) echo " selected='selected'"; echo ">Costumes</option>";
											echo "<option value='3'"; if($row['categorie'] == 3) echo " selected='selected'"; echo ">Enhanchment</option>";
											echo "<option value='4'"; if($row['categorie'] == 4) echo " selected='selected'"; echo ">Mini-Houses</option>";
											echo "<option value='5'"; if($row['categorie'] == 5) echo " selected='selected'"; echo ">Mini-Pets</option>";
											echo "<option value='6'"; if($row['categorie'] == 6) echo " selected='selected'"; echo ">Mounts</option>";
											echo "
											</select>
										</td>
										<td align='center' class='sitemenu'>
										<input type='hidden' name='changeshopitem' id='changeshopitem' />
										<input type='hidden' name='shopid' value='".$row['itemid']."' />
										";
										echo "<input type='checkbox' name='issell' id='issell' value='1'"; if($row['isSell'] == 1) echo " checked='checked'"; echo " />";
										echo"
										
										</td>
										<td align='center' class='sitemenu'><input type='submit' name='button' id='button' value='go'></form>
										</td>
										</tr>";
							}
?>
					  
                    </table>
                  </td>
                </tr>
              </table>
                <br />
                <br />
                <br />
                <br />
                <br /></td>
            </tr>
          </table>
<?php
	}
?>