Location: PHPKode > projects > Battle Cart > order/admin/batches.php
<?
require "basic.inc.php";
require "header.inc.php";
?>

<?
function sqlToList($page, $limit ) {
	if (($limit = round($limit)) > 100 || $limit < 0) $limit = 30;
	if (($page = round($page)) < 0) $page = 1;
	// Construct SQL query to find matching question
	$result = mysql_query("SELECT txn_id,DATE_FORMAT(fulfilled_time,'%Y-%m-%d %r') as fulfilled_time,first_name,last_name FROM orders WHERE payment_status='Completed' AND fulfilled='1' GROUP BY fulfilled_time ORDER BY fulfilled_time DESC LIMIT ".(($page - 1)*$limit).",$limit");
	$numQuestions = mysql_result(mysql_query("SELECT COUNT(DISTINCT fulfilled_time) FROM orders WHERE payment_status='Completed' AND fulfilled='1'"), 0);
	$prevNext = "<B>".($page > 1 ? "<A HREF=batches.php?page=".($page-1)."&limit=$limit>Prev</A>" : "Prev");
	$prevNext .= " | ";
	$prevNext .= (($numQuestions > ($page*$limit)) ? "<A HREF=batches.php?page=".($page+1)."&limit=$limit>Next</A>" : "Next");
	$prevNext .= " (".(($page - 1)*$limit + 1)."-".(($numQuestions < ($page*$limit)) ? $numQuestions : ($page*$limit))." of ".$numQuestions.")</B>";
	if (!$numQuestions) {
		$prevNext = "";
		echo "No batches found.";
	}
	echo $prevNext;
	echo "<P><table>";
	while ($txn = mysql_fetch_array($result)) {
		?>
	  <tr>
		<td><a href="labels.php?action=reprint&batch=<?=$txn['fulfilled_time']?>"><? echo $txn['fulfilled_time'] ?></a> 
		  (<a href="labels.php?action=showtxns&batch=<?=$txn['fulfilled_time']?>">view individual 
		  txns</a>) (<a href="action.php?action=unfulfill&batch=<?=$txn['fulfilled_time']?>">move 
		  back to unprinted queue</a>)</td>
	  </tr>
	  <?
	}
	echo "</table></P>";
	echo $prevNext."<BR><BR><B>Number per page:";
	for ($num=30;$num<101;$num+=35) {
		echo " <A HREF=batches.php?page=".ceil((($page - 1)*$limit + 1)/$num)."&limit=$num>$num</A>";
	}
	echo "</B>";
}

sqlToList(($page) ? $page : 1, ($limit) ? $limit : 30);
?>
<p><a href="index.php">Back to main</a></p>
Return current item: Battle Cart