<?php
	!defined('IN_MANAGE') && exit('Access Denied!');
	$action=empty($action)?'manage':trim($action);

	switch($action)
	{
		case 'manage':
			if(isset($job))
			{
				switch($job)
				{
					case 'split':
						if(!$id)
						{
							admin_error($adminlang['manage_select_error']);
						}

						if($modelobj->split($id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
					case 'subform':
						$result=$modelobj->submodellist($id);
						include admin_tlp('model-subform');
						break 2;
					case 'field':
						$result=$modelobj->fieldlist($id);
						include admin_tlp('model-field');
						break 2;
					case 'field_add':
						if(isset($do_submit))
						{
							if($modelobj->field_add($id,$info))
							{
								admin_success($adminlang['manage_success']);
							}
							else
							{
								admin_error($adminlang['manage_error']);
							}
						}
						$memmodel=$configobj->getmembermodel();
						$memgrade=$configobj->getmembergrade();
						include admin_tlp('model-field-add');
						break 2;
					case 'field_edit':
						if(isset($do_submit))
						{
							if($modelobj->field_edit($id,$info))
							{
								admin_success($adminlang['manage_success']);
							}
							else
							{
								admin_error($adminlang['manage_error']);
							}
						}
						$memmodel=$configobj->getmembermodel();
						$memgrade=$configobj->getmembergrade();
						$info=$modelobj->fieldinfo($id);
						include admin_tlp('model-field-edit');
						break 2;
					case 'field_delete':
						if($modelobj->field_delete($id))
						{
							admin_success($adminlang['manage_success']);
						}
						else
						{
							admin_error($adminlang['manage_error']);
						}
						break 2;
				}
			}
			else
			{
				$result=$modelobj->modellist();
				include admin_tlp('model-manage');
			}
			break;
		case 'add':
			if(isset($do_submit))
			{
				if($modelobj->add($info))
				{
					admin_success($adminlang['manage_success']);
				}
				else
				{
					admin_error($adminlang['manage_error']);
				}
			}
			include admin_tlp('model-add');
			break;
	}
?>