<?php include('inc/header.php'); ?>
<h1>Member - [GM] Request Item</h1>
<div class="container">
<?php
	odbc_exec($odbc_connect, 'USE [WEBSITE_REV3]');
	echo '<div id="pageinc">';
	$page = @$_GET['page'];
	if(!isset($page)) { $page = 1; }
	$perpage = 20;
	$select = odbc_exec($odbc_connect, 'SELECT * FROM [rev3_requestitem] ORDER BY datetime DESC');
	$resultset = array();
	$counter = 0;
	while($row = odbc_fetch_array($select)) {
		$resultset[$counter++] = $row;
	}
	$all = odbc_exec($odbc_connect, 'SELECT * FROM [rev3_requestitem]');
	$count = odbc_num_rows($all);
	$countpages = $count / $perpage;
	echo '<div id="text"></div>';
	echo '<div id="box"></div>';
	echo '<table id="table" style="width: 100%;">
		<tr>
			<td id="key">GameMaster</td>
			<td id="key">Item ID:Name</td>
			<td id="key">Count</td>
			<td id="key">Cause</td>
			<td id="key" style="text-align: center;">Status</td>
			<td id="key" style="text-align: center;"><table align="center"><tr><td><img src="../images/date.png" /></td><td>Date/Time</td></tr></table></td>
			<td id="key" style="width: 60px;"></td>
		</tr>';
	for($i = $perpage * ($page-1);$i < $perpage*$page;$i++) {
		if(isset($resultset[$i])) {
			odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
			$charname = odbc_exec($odbc_connect, 'SELECT m_szName FROM [CHARACTER_TBL] WHERE m_idPlayer=\''.mssql_escape_string($resultset[$i]['playerid']).'\'');
			echo '<tr id="reqid_'.$resultset[$i]['reqid'].'" class="row">
				<td id="value">'.odbc_result($charname, 'm_szName').'</td>
				<td id="value">'.$resultset[$i]['itemid'].':'.$resultset[$i]['itemname'].'</td>
				<td id="value">'.$resultset[$i]['itemcount'].'</td>
				<td id="value">'.$resultset[$i]['cause'].'</td>
				<td id="value" style="text-align: center;"><span id="reqid_'.$resultset[$i]['reqid'].'_status">';
			if($resultset[$i]['status'] == 0) {
				echo 'Open';
			} else {
				echo 'Closed';
			}
			echo '</span></td>
				<td id="value" style="text-align: center;">'.date('Y/m/d H:i', strtotime($resultset[$i]['datetime'])).'</td>
				<td id="value">';
			if($resultset[$i]['status'] == 0) {
					echo' <a href="javascript:reqitmAccept('.$resultset[$i]['reqid'].');" id="reqid_'.$resultset[$i]['reqid'].'_accept" title="Accept" rel="tooltip"><img src="../images/success.png" /></a>
					<a href="javascript:reqitmDeny('.$resultset[$i]['reqid'].');" id="reqid_'.$resultset[$i]['reqid'].'_deny" title="Deny" rel="tooltip"><img src="../images/fail.png" /></a>';
			}
			echo'
				</td>
			</tr>';
		}
	}
	echo '</table><br/>';
	for($i=0; $i < $countpages; $i++) {
		$k = $i + 1;
		if($page == $k) {
			 echo '<span id="page"><b>'.$k.'</b></span>';
		} else {
			echo '<span id="page"><a href="javascript:reqitmPage('.$k.');">'.$k.'</a></span>';
		}
	}
	echo '</div><br/>';
?>
</div>
<?php include('inc/footer.php'); ?>