<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$r=$r['order']['roleid']; 
	if(!in_array($_roleid,$r) && $_userid!=ADMIN_FOUNDERS)showmsg_nourl('您没有该操作的权限!');
	$action=empty($action)?'manage':trim($action);

	$c=new cache();
	switch($action)
	{
		case 'manage':
			if(isset($do_submit)) 
			{
				foreach($id as $val)
				{
					$db->update(DB_PRE.'cargo_method',array('name'=>$name[$val],'desc'=>$desc[$val],'fee'=>$fee[$val],'orderby'=>$orderby[$val]),'id='.intval($val));
				}
				$c->cache_cargomethod();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=cargomethod&action=manage');
			}
			$result=$db->fetch_all("SELECT * FROM ".DB_PRE."cargo_method ORDER BY ".DB_PRE."cargo_method.orderby ASC,id DESC");
			include admin_tlp('cargomethod_manage');
			break;
		case 'add':
			if(isset($do_submit)) 
			{
				if(!$newcargomethod['name'])showmsg('发货方式名称不能为空!');
				$db->insert(DB_PRE.'cargo_method',$newcargomethod,true);
				$c->cache_cargomethod();
				showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=cargomethod&action=manage');
			}
			include admin_tlp('cargomethod_add');
			break;
		case 'delete':
			$db->mysql_delete(DB_PRE.'cargo_method',intval($id));
			$c->cache_cargomethod();
			cache_delete("cache_cargomethod".intval($id).".cache.php",DIRCMS_ROOT.'data/cache/');
			showmsg($LANG['MANAGE_SUCEESS'],ADMIN_FILE.'?file=cargomethod&action=manage');
			break;
	}
?>
