<?php
include_once("module/company/includes/company_class.php");
$user=new user();
//============================================================

//--------------------------------------------------------------------
$sql="select custom_pages from ".SHOPSETTING." where company_id='$bcid'";
$db->query($sql);
$re=$db->fetchRow();
$hpages=$re['custom_pages'];
$hpages=unserialize($hpages);
//-----------排序
if($_POST)
{
	foreach($_POST['ids'] as $v)
	{
		$npages[$v]=$hpages[$v];
	}
	$ids=serialize($npages);
	$sql="update ".SHOPSETTING." set custom_pages='$ids' where company_id='$bcid'";
	$db->query($sql);
	die;
}
//-----------修改
if($_GET['creat'])
{
	if($re)
	{
		$hpages[$_GET['creat']]=$_GET['name'];
		$ids=serialize($hpages);
		$sql="update ".SHOPSETTING." set custom_pages='$ids' where company_id='$bcid'";
		$db->query($sql);
	}
	else
	{
		$hpages[$_GET['creat']]=$_GET['name'];
		$ids=serialize($hpages);
		$sql="insert into ".SHOPSETTING." set custom_pages='$ids', company_id='$bcid'";
		$db->query($sql);
	}
	msg("main.php?m=company&s=cominfo&type=$_GET[creat]&name=".urlencode($_GET['name']));
}
//-----------创建
if($_GET['creat'])
{
	if($re)
	{
		$hpages[$_GET['creat']]=$_GET['name'];
		$ids=serialize($hpages);
		$sql="update ".SHOPSETTING." set custom_pages='$ids' where company_id='$bcid'";
		$db->query($sql);
	}
	else
	{
		$hpages[$_GET['creat']]=$_GET['name'];
		$ids=serialize($hpages);
		$sql="insert into ".SHOPSETTING." set custom_pages='$ids', company_id='$bcid'";
		$db->query($sql);
	}
	msg("main.php?m=company&s=cominfo&type=$_GET[creat]&name=".urlencode($_GET['name']));
}
//-------------删除
if($_GET['del'])
{
	unset($hpages[$_GET['del']]);
	$ids=serialize($hpages);
	$sql="update ".SHOPSETTING." set custom_pages='$ids' where company_id='$bcid'";
	$db->query($sql);
}
//-----------------
if($config['language']=='cn')
{
	$cpages=array(
		'list1'=>'质量控制',
		'list2'=>'企业管理',
		'list3'=>'信用认证',
		'list4'=>'研发能力',
		'list5'=>'代理网点',
		'list6'=>'生产设备',
	);
}
else
{
	$cpages=array(
		'list1'=>'Quality Control',
		'list2'=>'Management',
		'list3'=>'Certificates',
		'list4'=>'R&D',
		'list5'=>'Look for Agent',
		'list6'=>'Production Equipment',
	);
}
$tpl->assign("cpages",$cpages);
if(is_array($hpages))
{
	$tpl->assign("hpages",$hpages);
	$tpl->assign("keyhpages",array_flip($hpages));
}
//=============================================================
$tpl->assign("config",$config);
$tpl->assign("lang",$lang);
$output=tplfetch("custom_pages.htm");
?>