<?php include 'en/admin/_adminheader.php'; ?>
<h2>Resources Page: Tools for Personal</h2>
<p>
	Below is a list of the files that you have on the Resources page under
	"Tools for Personal" sorted
	into the categories under which they appear on the Resources page.
	You can add, edit or delete categories and you can add files to and delete
	files from each category.
</p>
<p>
	<a href='/admin/resources.php?what=toolsforpersonal&do=addfile' title='Add a file' class='action'>Add a file to a category</a>
	<a href='/admin/resources.php?what=toolsforpersonal&do=addcat' title='Add a Category' class='action'>Add a category</a>
</p>
<table>
	<thead>
		<tr>
			<td>Category</td>
			<td>Files</td>
			<td>Actions</td>
		</tr>
	</thead>
	<tbody>
<?php $count = 0; foreach($this->data['categories'] as $cat): ?>
		<tr <?php if($count % 2 == 1): echo "class='alt_row'"; endif; $count++; ?>>
			<td>
			<?php
				echo $cat->name;
				# say if this a subcategory of another cat
				if((int)$cat->subcategoryof != 0):
					for($c = 0; $c < count($this->data['categories']->category); $c++):
						if((int)$this->data['categories']->category[$c]['id'] == (int)$cat->subcategoryof):
							echo "<br />| sub-category of ".$this->data['categories']->category[$c]->name;
						endif;
					endfor;
				endif;
			?>
			</td>
			<td>
			<?php foreach($cat->file as $file): ?>
				<a href='/admin/resources.php?what=toolsforpersonal&do=deletefile&which=<?php echo $file ?>&cat=<?php echo $cat['id'] ?>' title='Delete this file'>delete</a>
				|
				<?php echo $file; ?>
				<br />
			<?php endforeach; ?>
			</td>
			<td>
				<a href='/admin/resources.php?what=toolsforpersonal&do=editcat&which=<?php echo $cat['id'] ?>' title='Edit Category' class='action'>Edit</a>
				<a href='/admin/resources.php?what=toolsforpersonal&do=deletecat&which=<?php echo $cat['id'] ?>' title='Delete Category' class='action'>Delete</a>
			</td>
		</tr>
<?php endforeach; ?>
	</tbody>
</table>
