<?php
if(!$_SESSION['admin_id']){
	pe_goto("index.php");
}
$menumark = 'product_list';
switch ($act) {
	/* ====================== 产品增加sql ====================== */
	case 'addsql':
		$fw='admin.php?mod=product&act=list';
		if($_g_pid){$fw.='&pid='.$_g_pid;}
		if ($db->pe_insert('product', pe_dbhold($_p_info))) {
			pe_success('产品发布成功!',$fw );
		}
		else {
			pe_error('产品发布失败...');
		}
	break;
	/* ====================== 产品修改sql ====================== */
	case 'editsql':
		$fw='admin.php?mod=product&act=list';
		if($_g_pid){$fw.='&pid='.$_g_pid;}
		if ($db->pe_update('product', array('product_id'=>$_g_id), pe_dbhold($_p_info))) {
			pe_success('产品修改成功!',$fw);
		}
		else {
			pe_error('产品修改失败...');
		}
	break;
	/* ====================== 产品删除sql ====================== */
	case 'delsql':
		if ($db->pe_delete('product', array('product_id'=>is_array($_p_product_id) ? $_p_product_id : $_g_id))) {
			pe_success('产品删除成功!');
		}
		else {
			pe_error('产品删除失败...');
		}
	break;
	/* ====================== 产品列表 ====================== */
	default :
		$package_list = $db->index('package_id')->pe_selectall('package','', '`package_id`, `package_name`');
		if($_g_pid){
			$where['package_id']=$_g_pid;
			$catname=$package_list[$_g_pid]['package_name'];
		}
		else{
			$where='';$catname='全部';
		}
		$info_list = $db->pe_selectall('product',$where);
		$action = "admin.php?mod=product&act=addsql";
		$seo = pe_seo('产品列表', '', '', 'admin');
		if ($act == 'edit') {
			$info = $db->pe_select('product', array('product_id'=>$_g_id));
			$action = "admin.php?mod=product&act=editsql&id={$_g_id}";
			$seo = pe_seo('修改产品', '', '', 'admin');
		}
		if($_g_pid){$action.='&pid='.$_g_pid;}
		
		
		include(pe_tpl('product_list.html'));
	break;
}
pe_result();
?>