<?
	require_once('user.php');
	require_once('mysql.php');
	require_once('functions.php');
	
	// SETUP MYSQL HANDLERS
	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();	
    $mysqldb2 = new mysql($host, $user, $pswd, $db); $mysqldb2->connect(); $mysqldb2->select();
?>
<ul id="sortable">
	<?
	$query = "SELECT * FROM ".$_GET['table']." ORDER BY sequence ASC";
	$mysqldb1->query($query);
	while ($record = $mysqldb1->fetchArray()) {
	
		switch ($_GET['table']) {
		case 'page':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['page']; ?></td>
                        <? if ($record['subpage'] != '') { ?>
                        <td><img src="../styles/default/arrow_right.png" alt="---" width="16" height="16" /></td>
						<td><? print $record['subpage']; ?></td>
                        <? } ?>
                        <? if ($record['subsubpage'] != '') { ?>
                        <td><img src="../styles/default/arrow_right.png" alt="---" width="16" height="16" /></td>
						<td><? print $record['subsubpage']; ?></td>
                        <? } ?>
					</tr>
				</table>
			</li>
			<?
			break;
		case 'advert':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
		case 'gallery':
            $query = "SELECT * FROM gallery_category WHERE id=".$record['gallery_category_id'];
            $mysqldb2->query($query);
            $gallery_category = $mysqldb2->fetchArray();
            $query = "SELECT * FROM gallery_subcategory WHERE id=".$record['gallery_subcategory_id'];
            $mysqldb2->query($query);
            $gallery_subcategory = $mysqldb2->fetchArray();
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $listing_category['name']; ?></td>
                        <? if ($gallery_category['name'] != '') { ?>
                        <td><? print $gallery_category['name']; ?></td>
                        <td><img src="../styles/default/arrow_right.png" alt="---" width="16" height="16" /></td>
                        <? } ?>
                        <? if ($gallery_subcategory['name'] != '') { ?>
                        <td><? print $gallery_subcategory['name']; ?></td>
                        <td><img src="../styles/default/arrow_right.png" alt="---" width="16" height="16" /></td>
                        <? } ?>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
        case 'gallery_category':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
        case 'gallery_subcategory':
            $query = "SELECT * FROM gallery_category WHERE id=".$record['gallery_category_id'];
            $mysqldb2->query($query);
            $gallery_category = $mysqldb2->fetchArray();
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <? if ($gallery_category['name'] != '') { ?>
                        <td><? print $gallery_category['name']; ?></td>
                        <td><img src="../styles/default/arrow_right.png" alt="---" width="16" height="16" /></td>
                        <? } ?>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
		case 'listing_category':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
		case 'listing_subcategory':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
		case 'listing_subsubcategory':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
        case 'slideshow':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['name']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
        case 'shipping':
			?>
			<li class="ui-state-default" id="item_<? print $record['id']; ?>">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td><img src="../styles/default/handle.png" alt="move" width="16" height="16" class="handle" /></td>
						<td><? if ($record['status'] == 'disabled') { ?><a href="javascript:enableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/disabled.png" alt="disabled" border="0" class="button"/></a><? } ?><? if ($record['status'] == 'enabled') { ?><a href="javascript:disableRecord('<? print $_GET['table']; ?>', <? print $record['id']; ?>);"><img src="../styles/default/enabled.png" alt="enabled" border="0" class="button"/></a><? } ?></td>
						<td><a href="../table/<? print $_GET['table']; ?>.php?id=<? print $record['id']; ?>"><img src="../styles/default/edit.png" alt="edit" border="0" class="button"/></a></td>
                        <td><? print $record['area']; ?></td>
					</tr>
				</table>
			</li>
			<?
			break;
		default:
		}
	}
	?>
</ul>
<?
	$mysqldb1->close();
    $mysqldb2->close();
?>