<?
session_start();
include $_SERVER[DOCUMENT_ROOT] . "/common/conf/config.inc.php";
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/auth/auth.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/category/category.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/shop/shop.lib.php";
if(!in_array("shop_good_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]!="ROOT"):
	jsMsg("권한이 없습니다.");
	jsHistory("-1");
endif;

if($_POST[evnMode]=="insert"){
//	_DEBUG($_POST);
//	exit;
	//DB연결
	$dblink = SetConn($_conf_db["main_db"]);

	$RS = insertGood();

	if($RS==true){
		jsGo("good.php","","");
	}else{
		jsMsg("상품 등록에 실패 하였습니다.");
		jsHistory("-1") ;
	}

	//DB해제
	SetDisConn($dblink);


}else if($_POST[evnMode]=="edit"){
	//DB연결
	$dblink = SetConn($_conf_db["main_db"]);

	$idx = mysql_real_escape_string(trim($_POST[idx]));

	$RS = editGood($idx);

	if($RS==true){
		jsGo($_REQUEST[rt_url],"","");
		//jsGo("good.php?cat_no=".$_POST[cat_no],"","");
	}else{
		jsMsg("상품 수정에 실패 하였습니다.");
		jsHistory("-1") ;
	}

	//DB해제
	SetDisConn($dblink);


}else if($_POST[evnMode]=="delete"){
	//DB연결
	$dblink = SetConn($_conf_db["main_db"]);

	$idx = mysql_real_escape_string(trim($_REQUEST[idx]));

	$RS = deleteGood($idx);

	if($RS==true){
		//jsGo("good.php","","");
		jsGo("good.php?cat_no=".$_POST[cat_no]."&cat=".$_REQUEST[cat]."&cat2=".$_REQUEST[cat2]."&cat3".$_REQUEST[cat3],"","");
	}else{
		jsMsg("상품 삭제에 실패 하였습니다.");
		jsHistory("-1") ;
	}

	//DB해제
	SetDisConn($dblink);
}
?>
