<?php
require(dirname(__FILE__)."/"."global.php");
require(dirname(__FILE__)."/../"."php168/all_area.php");
if($job=='edit'){
	if(!$lfjid){
		showerr("你還沒登錄");
	}
	$cpDB=$db->get_one("SELECT * FROM `{$pre}memberdata_1` WHERE uid='$lfjuid'");
	if($step==2){
		foreach( $_POST AS $key=>$value){
			$_POST[$key]=filtrate($value);
		}
		@extract($_POST);
		if(!$cpname){showerr("企業名稱不能為空");}
		if(!$cptype){showerr("請選擇企業性質");}
		if(!$cptrade){showerr("請選擇企業所屬行業");}
		if(!$cpfounder){showerr("企業法人不能為空");}
		if(!$cptelephone){showerr("公司電話不能為空");}
		if(!$cpaddress){showerr("公司地址不能為空");}
		if(!$cpcity){showerr("請選擇企業所在城市");}
		if(!$cpcode){showerr("組織機構代碼不能為空");}
		if(!ereg("^[0-9]{8}",$cpcode)){
			showerr("請認真填寫組織機構代碼");	//如果不想嚴格控制機構碼,請把這一行刪除
		}
		if(!$cpDB){
			$db->query("INSERT INTO `{$pre}memberdata_1` ( `uid` , `cpname` , `cplogo` , `cptype` , `cptrade` , `cpproduct` , `cpcity` , `cpfoundtime` , `cpfounder` , `cpmannum` , `cpmoney` , `cpcode` , `cppermit` , `cpweb` , `cppostcode` , `cptelephone` , `cpfax` , `cpaddress` ,`cplinkman`,`cpmobphone`,`cpqq`,`cpmsn`) VALUES ( '$lfjuid','$cpname','$cplogo','$cptype','$cptrade','$cpproduct','$cpcity','$cpfoundtime','$cpfounder','$cpmannum','$cpmoney','$cpcode','$cppermit','$cpweb','$cppostcode','$cptelephone','$cpfax','$cpaddress','$cplinkman','$cpmobphone','$cpqq','$cpmsn')");
			$grouptype=$webdb[AutoPassCompany]?'1':'-1';
			$db->query("UPDATE {$pre}memberdata SET grouptype='$grouptype' WHERE uid='$lfjuid'");
			refreshto("company.php?job=edit","你的資料已經提交",1);	
		}else{
			$db->query("UPDATE {$pre}memberdata_1 SET cpname='$cpname',cplogo='$cplogo',cptype='$cptype',cptrade='$cptrade',cpproduct='$cpproduct',cpcity='$cpcity',cpfoundtime='$cpfoundtime',cpfounder='$cpfounder',cpmannum='$cpmannum',cpmoney='$cpmoney',cpcode='$cpcode',cppermit='$cppermit',cpweb='$cpweb',cppostcode='$cppostcode',cptelephone='$cptelephone',cpfax='$cpfax',cpaddress='$cpaddress',cplinkman='$cplinkman',cpmobphone='$cpmobphone',cpqq='$cpqq',cpmsn='$cpmsn' WHERE uid='$lfjuid'");
			refreshto("company.php?job=edit","修改succeed",1);
		}			
	}
	$cptype[$cpDB[cptype]]=' selected ';	
}elseif($job=='view'){
	$cpDB=$db->get_one("SELECT * FROM `{$pre}memberdata_1` WHERE uid='$uid'");
	if(!$cpDB){
		showerr("資料不存在!!");
	}
}

require(dirname(__FILE__)."/"."head.php");
require(dirname(__FILE__)."/"."template/company.htm");
require(dirname(__FILE__)."/"."foot.php");

?>