<?
if($_POST["cont_id"]=="")
{
echo"undefinedata";
exit();
}

//var
$cont_id			=	base64_decode($_POST["cont_id"]);
$cont_code			=	$_POST["cont_code"];
$cont_name			=	$_POST["cont_name"];
$cont_name_eng		=	$_POST["cont_name_eng"];
$cont_des			=	$_POST["cont_des"];
$cont_des_eng		=	$_POST["cont_des_eng"];
$walkto				=	$_POST["walkto"];


//call data

 $sql="SELECT * FROM sbs_contact WHERE cont_id='".$cont_id."'";
 $result=mysql_query($sql) or die ( $sql);
 $ROW=mysql_fetch_array($result);

//checkfile

$name_time = time();


//ถ้ามีภาพแผนที่
if($_FILES['cont_thumb']['name'] != ""){

//หาเอกเทนชั่นของภาพ
$bdoc_filename = stripslashes($_FILES['cont_thumb']['name']);
$bdoc_extension = getExtension($bdoc_filename);
//upload doc
$bnewdocname="../datacenter/map". $name_time.".".$bdoc_extension;
copy($_FILES['cont_thumb']['tmp_name'], $bnewdocname);
$cont_thumb_name = "map".$name_time.".".$bdoc_extension;
if($ROW["cont_thumb"] != "")
	{
unlink("../datacenter/".$ROW["cont_thumb"]);
	}
}
else
{
$cont_thumb_name = $ROW["cont_thumb"];
}


//ถ้ามีภาพแผนที่
if($_FILES['cont_thumb_eng']['name'] != ""){

//หาเอกเทนชั่นของภาพ
$bdoc_filename = stripslashes($_FILES['cont_thumb_eng']['name']);
$bdoc_extension = getExtension($bdoc_filename);
//upload doc
$bnewdocname="../datacenter/mape". $name_time.".".$bdoc_extension;
copy($_FILES['cont_thumb_eng']['tmp_name'], $bnewdocname);
$cont_thumb_name_eng = "mape".$name_time.".".$bdoc_extension;
if($ROW["cont_thumb_eng"] != "")
	{
unlink("../datacenter/".$ROW["cont_thumb_eng"]);
	}
}
else
{
$cont_thumb_name_eng = $ROW["cont_thumb_eng"];
}




$sqlupdate="UPDATE sbs_contact SET
cont_name = '$cont_name',
cont_name_eng = '$cont_name_eng',
cont_des = '$cont_des',
cont_des_eng = '$cont_des_eng',
cont_thumb = '$cont_thumb_name',
cont_thumb_eng = '$cont_thumb_name_eng'
WHERE cont_id ='".$cont_id."' LIMIT 1";


$resultupdate = mysql_query("$sqlupdate") or die ("$sqlupdate");

if($resultupdate)
{
Jsalert("แก้ไขรายละเอียดเสร็จสิ้น");
GoToURL("$walkto");
}


?>