<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_header') ?>

	<div class="bigCaption">Categories <span>( <?= anchor('category/add/' . $Category_list['ParentId'], 'add new' ) ?> )</span> </div>

	<?
		if( !empty($Category_list['ParentId']) && !empty( $Category_list['BreadCrumb'] ) ):
	?>
		<div class="categoryBC">
			<?= anchor('admin/category_list/list/', 'root' ); ?>
	<?
			foreach($Category_list['BreadCrumb'] as $iBCId => $aBC):
	?>
		<span style="font-weight:normal;">&bull;&bull;&gt;</span> <?= anchor('admin/category_list/list/' . $iBCId, $aBC['Title']); ?>

	<?		endforeach; ?>
		</div>
	<?
		endif;
	?>

	<?= form_open('admin/category_list/' . $Category_list['Mode'] . '/' . $Category_list['ParentId'], array( 'id' => 'approve_category_form') ); ?>
		<!-- <div class="tableSubmit"><input type="submit" value="submit" class="admSubmit" /></div> -->
		<div><input type="hidden" id="action" name="action" value="" /></div>
		<table cellpadding="0" cellspacing="1" width="100%" class="contentList">

		<? if( 'list' == $Category_list['Mode'] ): ?>
				<tr class="head">
					<td class="id">id</td>
					<td class="checkbox"><input type="checkbox" disabled="disabled" /></td>
					<td class="title">title</td>
					<td class="desc">description</td>
					<td class="keywords">keywords</td>
					<td class="num">order&nbsp;&nbsp;<img src="<?= base_url(); ?>views/_images/save_order.gif" alt="" style="vertical-align:middle; cursor:pointer;" onclick="javascript: document.getElementById('approve_category_form').submit(); return false;" /></td>
					<td colspan="4" class="action">action</td>
				</tr>
				<?
				$i = 0;
				foreach( $Category_list['CategoryList'] as $aCategory ):

					if( ($i%2) == 0 )
					{
						$sClassName = 'odd';
					}
					else
					{
						$sClassName = 'even';
					}
				 ?>
				<tr class="<?= $sClassName ?>">
					<td class="id textCenter">
						<?= $aCategory['Id'] ?>
					</td>
					<td><input type="checkbox" name="CategoryId[]" value="<?= $aCategory['Id'] ?>" id="c<?= $aCategory['Id'] ?>" /></td>
					<td>

						<span class="<?= $aCategory['Status'] ?>"><?= anchor('admin/category_list/list/' . $aCategory['Id'], $aCategory['Title'] );  ?></span>

						<? if( !empty($aCategory['subcategories']) ): ?>
							<div class="subItems">
								<strong>subitems</strong>:
								<?
									foreach( $aCategory['subcategories'] as $aSub ):
										echo '<span class="' . $aSub['Status'] . '">' . anchor('admin/category_list/list/' . $aSub['Id'], $aSub['Title'] ) . '</span>, ';
									endforeach;
								?>
							</div>
						<? endif; ?>
					</td>
					<td class="desc">
						<?= $aCategory['Description'] ?>
					</td>
					<td class="keywords">
						<?= $aCategory['Keywords'] ?>
					</td>
					<td class="textCenter num">
						<input type="hidden" name="OrderId[]" value="<?= $aCategory['Id']?>" />
						<input type="text" name="OrderValue[]" value="<?= $aCategory['CategoryOrder']?>" onchange="javascript: document.getElementById('action').value = 'order'" class="text" />
					</td>
					<td class="view textCenter">
						<?= anchor($this->config->item('uri_category').$aCategory['BaseName'], 'view') ?>
					</td>
					<td class="textCenter edit">
						<?= anchor('category/edit/' . $aCategory['Id'], 'edit') ?>
					</td>

						<? if( $aCategory['Status'] == 'inactive' ): ?>
							<td class="textCenter activate">
								<a href="#" onclick="javascript: document.getElementById('action').value='active'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">activate</a>
							</td>
						<? else: ?>
							<td class="textCenter deactivate">
								<a href="#" onclick="javascript: document.getElementById('action').value='inactive'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">deactivate</a>
							</td>
						<? endif; ?>
					<td class="textCenter delete">
						<a href="#" onclick="javascript: document.getElementById('action').value='deleted'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">delete</a>
					</td>
				</tr>
				<? $i++;

				endforeach;
			elseif( 'tree' == $Category_list['Mode'] ): ?>
				<tr class="head">
					<td class="id">id</td>
					<td class="checkbox"><input type="checkbox" /></td>
					<td class="title">title</td>
					<td class="desc">description</td>
					<td class="keywords">keywords</td>
					<!-- <td class="num">order</td> -->
					<td colspan="4" class="action">action</td>
				</tr>
				<?
				$i = 0;
				foreach( $Category_list['CategoryList'] as $aCategory ):

					if( ($i%2) == 0 )
					{
						$sClassName = 'odd';
					}
					else
					{
						$sClassName = 'even';
					}
				 ?>
				<tr class="<?= $sClassName ?>">
					<td class="id textCenter">
						<?= $aCategory['Id'] ?>
					</td>
					<td><input type="checkbox" name="CategoryId[]" value="<?= $aCategory['Id'] ?>" id="c<?= $aCategory['Id'] ?>" /></td>
					<td style="padding-left:<?= (4+(20*$aCategory['Sublevel'])) ?>px">

						<span class="<?= $aCategory['Status'] ?>"><?= anchor('admin/category_list/list/' . $aCategory['Id'], $aCategory['Title'] );  ?></span>

						<?/* if( !empty($aCategory['SubCategoryList']) ): ?>
							<div class="subItems">
								<strong>subitems</strong>:
								<?
									foreach( $aCategory['SubCategoryList'] as $aSub ):
										echo '<span class="' . $aSub['Status'] . '">' . anchor('admin/category_list/list/' . $aSub['Id'], $aSub['Title'] ) . '</span>, ';
									endforeach;
								?>
							</div>
						<? endif; */?>
					</td>
					<td class="desc">
						<?= $aCategory['Description'] ?>
					</td>
					<td class="keywords">
						<?= $aCategory['Keywords'] ?>
					</td>
					<!--
					<td class="textCenter num">
						{num}
					</td>
					-->
					<td class="view textCenter">
						<?= anchor($this->config->item('uri_category').$aCategory['BaseName'], 'view') ?>
					</td>
					<td class="textCenter edit">
						<?= anchor('category/edit/' . $aCategory['Id'], 'edit') ?>
					</td>
						<? if( $aCategory['Status'] == 'inactive' ): ?>
							<td class="textCenter activate">
								<a href="#" onclick="javascript: document.getElementById('action').value='active'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">activate</a>
							</td>
						<? else: ?>
							<td class="textCenter deactivate">
								<a href="#" onclick="javascript: document.getElementById('action').value='inactive'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">deactivate</a>
							</td>
						<? endif; ?>
					<td class="textCenter delete">
						<a href="#" onclick="javascript: document.getElementById('action').value='deleted'; document.getElementById('c<?= $aCategory['Id'] ?>').checked = true; document.getElementById('approve_category_form').submit(); return false;">delete</a>
					</td>
				</tr>
				<? $i++;

				endforeach;
			endif; ?>
		</table>
		<!-- <div class="tableSubmit"><input type="submit" value="submit" class="admSubmit" /></div> -->
	<?= form_close(); ?>
<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_footer') ?>