<?php
	include('includes/config.php');
	include('includes/functions.php');
	
	if ($_COOKIE['oam_username'] != md5($settings['user']) && $_COOKIE['oam_pass'] != md5($settings['pass'])) {
		header("Location:login.php");
	}
	$total = 20;
	
	if ($_POST['action'] == 'add_items') {
		$i = 0;
		while ($i < $total) {
			$i++;
			if ($_POST['name_' . $i] != '') {
				$insert = mysql_query('
					INSERT INTO oam_listings
					SET listings_name = "' . magic_quote_alter($_POST['name_' . $i]) . '",
						listings_notes = "' . magic_quote_alter($_POST['notes_' . $i]) . '",
						listings_shipping_charge = "' . magic_quote_alter($_POST['ship_charge_' . $i]) . '",
						listings_bought_price = "' . magic_quote_alter($_POST['bought_price_' . $i]) . '",
						listings_date_bought = "' . magic_quote_alter($_POST['date_bought_' . $i]) . '"');
			}
		}
		header('Location:index.php');
	}
	
	$i = 0;
	while ($i < $total) {
		$i++;
		$row_style = ternary($row_style,'main-row-1','main-row-2');
		$input_table .= '
			<tr>
				<td class="' . $row_style . '"><input type="text" name="name_' . $i . '" size="30" /></td>
				<td class="' . $row_style . '">$<input type="text" name="bought_price_' . $i . '" size="7" /></td>
				<td class="' . $row_style . '">$<input type="text" name="ship_charge_' . $i . '" size="7" /></td>
				<td class="' . $row_style . '"><input type="text" name="date_bought_' . $i . '" size="25" value="' .date('Y-m-d H:i:s') . '" /></td>
				<td class="' . $row_style . '"><textarea name="notes_' . $i . '" cols="30" rows=2"></textarea>
			</tr>';
	}
?>
<html>
<head>
	<style>
		.input-table {
			font-family:Verdana, Arial, Helvetica, sans-serif;
			border-collapse:collapse;
		}
		.input-table th {
			background-color:#006699;
			color:#FFFFFF;
			font-size:12px;
			padding:2px;
			border:1px solid #9F9F9F;
		}
		.input-table td {
			font-size:10px;
			vertical-align:top;
			border:1px solid #9F9F9F;
			padding:3px;
			background-color:#FFFFCC;
		}
		.input-table td input {
			font-size:10px;
			font-family:Verdana, Arial, Helvetica, sans-serif;
		}
		.input-table td textarea {
			font-size:10px;
			font-family:Verdana, Arial, Helvetica, sans-serif;
		}
			
	</style>
</head>
<link rel="stylesheet" type="text/css" href="includes/styles.css">
<body>
<h2>Add Listings</h2>

<p><a href="add-listings.php">Add New Listings</a> | <a href="index.php">Manage Listings</a> | <a href="stats.php">Earnings Statistics</a> | <a href="login.php">Log Out</a> | <a href="instructions.php">Instructions</a></p>

<form action="add-listings.php" method="post">
<input type="hidden" name="action" value="add_items" />

<input type="submit" value="Submit Items &gt;&gt;" /><br /><br />
<table class="main-table">
	<tr>
		<th>Item Name</th>
		<th>Bought Price</th>
		<th>Ship Charge</th>
		<th>Date Listed</th>
		<th>Notes</th>
	</tr>
	<?php echo $input_table; ?>
</table><br />
<input type="submit" value="Submit Items &gt;&gt;" />
</form>
<p>Auction Business Manager Developed by <a href="http://www.small-business-ideas.net">www.Small-Business-Ideas.net</a></p>
</body>
</html>