<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_header') ?>
	<div class="bigCaption">Manage Custom Fileds <span>( <?= anchor('admin/customfield/add', 'add new' ) ?> )</span></div>

		<div>

		<?=form_open('admin/customfield',array('id'=>'fieldorder'));?>
			
		<select name="CategoryId">
			<option value="0" <? ( 0 !== $data['Filter']['CatId'] ? '' : 'selected="selected"') ?> >all categories</option>
			<? foreach ( $data['CategoryList'] as $aCategory ) : ?>
				<?= '<option value="' . $aCategory['Id'] . '" ' . ( $aCategory['Id'] != $data['Filter']['CatId'] ? '' : 'selected="selected"') . ' >' . $aCategory['Title'] . '</option>' ?>
			<? endforeach ?>
		</select>

		&nbsp;
		<input type="submit" value="filter" class="submit" />
		<br />
		&nbsp;
		<br />		
		
		<table cellpadding="0" cellspacing="1" width="100%" class="contentList">
			<tr class="head">
				<td>Field Data:</td>
				<td class="num">order&nbsp;&nbsp;<img src="<?=site_url('views/_images/save_order.gif')?>" alt="" style="vertical-align:middle; cursor:pointer;" onclick="javascript: document.getElementById('fieldorder').submit(); return false;" /></td>
				<? foreach ( $this->aSystemVar['lang_list'] as $aItem ) : ?>
					<td class="textCenter">
						<strong><?=$aItem['Title']?></strong>
					</td>
				<? endforeach; ?>
			</tr>
			<? 
				$i = 0;
				foreach( $data['CustomFields'] as $aItem ):

				if( ($i%2) == 0 )
				{
					$sClassName = 'odd';
				}
				else
				{
					$sClassName = 'even';
				}
			?>

			<tr class="<?= $sClassName ?>" >
				<td>
					BaseName:<b style="color:green;"> <?=$aItem['BaseName']?></b>
					(<?=anchor('admin/customfield/edit/'.$aItem['Id'],'edit')?>
					|
					<a href="<?=site_url('admin/customfield/delete/'.$aItem['Id'])?>" onClick="return confirm('are you sure ??');" >delete</a>
					)
					<br />
					Category:<b>
					<? 	if ( !empty($aItem['CatTitle']) )
							echo $aItem['CatTitle'];
						elseif( !empty($aItem['CatBaseName']) )
							echo $aItem['CatBaseName'];
						else
							echo 'all categories';
					?>
					</b>					
					<br />
					FieldType:<b>
					<?
						switch ($aItem['FieldType'])
						{
							case 'num':
										echo 'Numeric field';
										break;
							case 'tfield':
										echo 'Text field';
										break;
							case 'textarea':
										echo 'Textarea';
										break;
							case 'radio':
										echo 'Radio button';
										break;
							case 'check':
										echo 'Checkbox';
										break;
							case 'select':
										echo 'Dropdown box';
										break;
							default:
										echo 'not defined';
										break;
						}
					?>
					</b>
					<br />
					Display: <b><?=(1==$aItem['Display']?'Visible':'Invisible')?></b>
					<br />
					Mode:<b>
					<?
						switch ($aItem['Mode'])
						{
							case 'simple':
										echo 'Additional field';
										break;
							case 'req':
										echo 'Required field';
										break;
							case 'adm':
										echo 'Visible only to admin';
										break;
							default:
										echo 'not defined';
										break;
						}
					?>
					<b>					
					<br />
				</td>
				<td class="textCenter num">
					<input type="text" name="Order[<?=$aItem['Id']?>]" value="<?=$aItem['FieldOrder']?>" class="text" />
				</td>
				<? foreach ( $this->aSystemVar['lang_list'] as $aLang ) : ?>
				<td class="title" style="text-align:center;">
					<? 
						if ( empty($data['LangList'][$aItem['Id']][$aLang['BaseName']]) )
						{
							echo '<strong>'.anchor('admin/customfield/edit/'.$aItem['Id'].'/'.$aLang['BaseName'], 'no', array('style'=>'color:#ff0000;')).'</strong>';
						}
						else
						{
							echo anchor('admin/customfield/edit/'.$aItem['Id'].'/'.$aLang['BaseName'],$data['LangList'][$aItem['Id']][$aLang['BaseName']]);
						}
					?>
				</td>
				<? endforeach; ?>
			</tr>
			<? $i++; ?>
		<? endforeach; ?>
		</table>			
		
		<?=form_close();?>
		
		</div>
		
<? $this->load->view( $this->aSystemVar['template_viewer_root'] . 'admin/_footer') ?>