Location: PHPKode > projects > Battle Cart > order/admin/labels.php
<?
require "basic.inc.php";
?>
<link rel="stylesheet" href="labels.css">
<?
if ($_GET['action'] == "reprint") {
	if (!$_GET['batch']) exit("Batch identifier required.");
	$result = mysql_query("SELECT * FROM orders WHERE fulfilled_time='".date("Y-m-d H:i:s", strtotime(urldecode($_GET['batch'])))."' ORDER BY time");
	$labelsInBatch = mysql_num_rows($result);
} else if ($_GET['action'] == "print") {
	if (!$_GET['num']) exit("Invalid number of labels.");
	$result = mysql_query("SELECT * FROM orders WHERE payment_status='Completed' AND fulfilled='0' ORDER BY time LIMIT ".$_GET['num']);
} else if ($_GET['action'] == "showtxns") {
	if (!$_GET['batch']) exit("Batch identifier required.");
	$result = mysql_query("SELECT txn_id,DATE_FORMAT(time,'%m-%d-%y %r') as time,first_name,last_name,payment_date FROM orders WHERE fulfilled_time='".date("Y-m-d H:i:s", strtotime(urldecode($_GET['batch'])))."' ORDER BY time");
	require "header.inc.php";
	?>
	<h1><b>This Batch</b></h1>
	
<table width="700">
  <tr><td><b>Transaction ID</b></td>
		<td><b>Order Date</b></td>
		<td><b>Customer Name</b></td></tr>
	<?
	while ($txn = mysql_fetch_array($result)) {
		?>
		<tr><td><a href="txn.php?id=<? echo $txn['txn_id'] ?>"><? echo $txn['txn_id'] ?></a></td><td><? echo date("M d, Y g:ia",strtotime($txn['payment_date'])) ?></td>
		
    <td><? echo $txn['first_name'] ?> <? echo $txn['last_name'] ?> (<a href="action.php?action=remove_txn&txn_id=<? echo $txn['txn_id'] ?>">remove</a>) 
      (<a href="edit.php?txn_id=<? echo $txn['txn_id'] ?>">edit</a>)</td>
	  </tr>
	<?
	}
	?>
	</table>
	
<a href="index.php">Back to main</a> 
<?
	exit();
}
if (!$result) exit("Invalid action.");
while ($pp = mysql_fetch_array($result)) {
	if ($labelsInBatch > 10) {
	?>
	<div id="row"> 
	  <div id="col1"><? echo $pp['address_name'] ? $pp['address_name'] : $pp['first_name']." ".$pp['last_name'] ?> 
		<br>
		<? echo $pp['address_street'] ?> <br>
		<? echo $pp['address_city'] ?><? if ($pp) echo "," ?> <? echo $pp['address_state'] ?> <? echo $pp['address_zip'] ?>
		<? if (!in_array($pp['address_country'],array("US","USA","United States"))) echo "<BR>".$pp['address_country']; ?>
		<br><br>
		<? echo $pp['parent_txn_id'] ? "(*) " : "" ?><? echo $pp['item_number'] ?></div>
	  <? $pp = mysql_fetch_array($result) ?>
	  <div id="col3"><? echo $pp['address_name'] ? $pp['address_name'] : $pp['first_name']." ".$pp['last_name'] ?> 
		<br>
		<? echo $pp['address_street'] ?> <br>
		<? echo $pp['address_city'] ?><? if ($pp) echo "," ?> <? echo $pp['address_state'] ?> <? echo $pp['address_zip'] ?>
		<? if (!in_array($pp['address_country'],array("US","USA","United States"))) echo "<BR>".$pp['address_country']; ?>
		<br><br>
		<? echo $pp['parent_txn_id'] ? "(*) " : "" ?><? echo $pp['item_number'] ?></div>
	  <? $pp = mysql_fetch_array($result) ?>
	  <div id="col2"><? echo $pp['address_name'] ? $pp['address_name'] : $pp['first_name']." ".$pp['last_name'] ?> 
		<br>
		<? echo $pp['address_street'] ?> <br>
		<? echo $pp['address_city'] ?><? if ($pp) echo "," ?> <? echo $pp['address_state'] ?> <? echo $pp['address_zip'] ?>
		<? if (!in_array($pp['address_country'],array("US","USA","United States"))) echo "<BR>".$pp['address_country']; ?>
		<br><br>
		<? echo $pp['parent_txn_id'] ? "(*) " : "" ?><? echo $pp['item_number'] ?></div>
	</div>
	<?
	} else {
	?>
	<div id="row"> 
	  <div id="10-col1"><? echo $pp['address_name'] ? $pp['address_name'] : $pp['first_name']." ".$pp['last_name'] ?> 
		<br>
		<? echo $pp['address_street'] ?> <br>
		<? echo $pp['address_city'] ?><? if ($pp) echo "," ?> <? echo $pp['address_state'] ?> <? echo $pp['address_zip'] ?>
		<? if (!in_array($pp['address_country'],array("US","USA","United States"))) echo "<BR>".$pp['address_country']; ?>
		<br><br>
		<? echo $pp['parent_txn_id'] ? "(*) " : "" ?><? echo $pp['item_number'] ?></div>
	  <? $pp = mysql_fetch_array($result) ?>
	  <div id="10-col2"><? echo $pp['address_name'] ? $pp['address_name'] : $pp['first_name']." ".$pp['last_name'] ?> 
		<br>
		<? echo $pp['address_street'] ?> <br>
		<? echo $pp['address_city'] ?><? if ($pp) echo "," ?> <? echo $pp['address_state'] ?> <? echo $pp['address_zip'] ?>
		<? if (!in_array($pp['address_country'],array("US","USA","United States"))) echo "<BR>".$pp['address_country']; ?>
		<br><br>
		<? echo $pp['parent_txn_id'] ? "(*) " : "" ?><? echo $pp['item_number'] ?></div>
	</div>
	<?
	}
}
mysql_query("UPDATE orders SET fulfilled='1', fulfilled_time=NOW() WHERE payment_status='Completed' AND fulfilled='0' ORDER BY time LIMIT ".$_GET['num']);
?>
Return current item: Battle Cart