Location: PHPKode > scripts > ER Manager > ermanager/edit_company.php
<?PHP

require_once "functions.php";

localnet_or_die(); //check for localnet

//save data
if($save) {
	//prepare data
	
	$language = $lang_i . $lang_d . $lang_f . $lang_e;
	
	$SETS = "
		language       = '".addslashes($language )."',
		category       = '".addslashes($category )."',
		title       = '".addslashes($title )."',
		salutation      = '".addslashes($salutation)."',
		company      = '".addslashes($company)."',
		firstname      = '".addslashes($firstname)."',
		lastname      = '".addslashes($lastname)."',
		street      = '".addslashes($street)."',
		zip      = '".addslashes($zip)."',
		city      = '".addslashes($city)."',
		phone      = '".addslashes($phone)."',
		fax      = '".addslashes($fax)."',
		email      = '".addslashes($email)."',
		website      = '".addslashes($website)."',
		logo      = '".addslashes($logo)."',
		generic_comment      = '".addslashes($generic_comment)."'
	";

if($id) {	
	  //update existing record
		$INSERT = "UPDATE er_companies SET ".$SETS." WHERE id = ".$id."";
		runSQL($INSERT);
	} else {
$INSERT = "INSERT INTO er_companies SET ".$SETS." ";
runSQL($INSERT); 

//get id for inserted data
$SELECT = "SELECT id from er_companies ORDER BY id desc LIMIT 1";
$result = runSQL($SELECT);
$id = $result[0][id];
} // end else
		
} // end if($save)

if( ($id and !$save) or !$id) {

//load existing data
if($id and !$save) {
	$SELECT = "SELECT * FROM er_companies WHERE id = ".$id."";
	$entity = runSQL($SELECT);
}

//prepare templates
$smarty->assign('http_error',$CLIENTERROR);
tpl_header();
tpl_edit_company($entity);
tpl_footer();

//display templates
$smarty->display('header.tpl');
flush();
$smarty->display('edit_company.tpl');
$smarty->display('footer.tpl');

} //end if($id and !save)

else { require "company.php"; }

?>
Return current item: ER Manager