Location: PHPKode > projects > HuMo-gen > admin/include/editor_cls.php
<?php
class editor_cls{

function living_place(){
	global $language, $tree_prefix, $person, $db, $page, $datum, $tijd;

	// *** Remove living place ***
	if (isset($_GET['living_place_drop'])){
		echo '<div class="confirm">';
      echo $language["editor_removetree"]; 
		echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" style="display : inline;">';
		echo '<input type="hidden" name="page" value="'.$_GET['page'].'">';
		echo '<input type="hidden" name="living_place_id" value="'.$_GET['living_place_drop'].'">';
		echo ' <input type="Submit" name="living_place_drop2" value="'.$language["admin_yes"].'" style="color : red; font-weight: bold;">';
		echo ' <input type="Submit" name="submit" value="'.$language["admin_no"].'" style="color : blue; font-weight: bold;">';
		echo '</form>';
		echo '</div>';
	}
	if (isset($_POST['living_place_drop2'])){
		$living_place_order=veilig($_POST['living_place_id']);
		$sql="DELETE FROM ".$tree_prefix."addresses WHERE address_person_id='".$person."'
			AND address_order='".$living_place_order."'";
		$result=mysql_query($sql) or die(mysql_error());

		$adres_sql="SELECT * FROM ".$tree_prefix."addresses
			WHERE address_person_id='".$person."' AND address_order>'".$living_place_order."'
			ORDER BY address_order";
		$event_qry=mysql_query($adres_sql,$db);
		while($eventDb=mysql_fetch_object($event_qry)){
			$sql="UPDATE ".$tree_prefix."addresses SET
			address_order='".($eventDb->address_order-1)."',
			address_changed_date='".$datum."',
			address_changed_time='".$tijd."'
			WHERE address_id='".$eventDb->address_id."'";
			$result=mysql_query($sql) or die(mysql_error());
		}
	}

	if (isset($_POST['living_place_add'])){
		$sql="INSERT INTO ".$tree_prefix."addresses SET
			address_person_id='".$person."',
			address_date='".strtoupper(veilig($_POST["address_date"]))."',
			address_place='".$_POST["address_place"]."',
			address_order='".veilig($_POST['address_order'])."',
			address_new_date='".$datum."',
			address_new_time='".$tijd."'";
		$result=mysql_query($sql) or die(mysql_error());
	}

	if (isset($_POST['living_place_change'])){
		$sql="UPDATE ".$tree_prefix."addresses SET
		address_place='".veilig($_POST["address_place"])."',
		address_date='".strtoupper(veilig($_POST["address_date"]))."',
		address_changed_date='".$datum."',
		address_changed_time='".$tijd."'";
		$sql.=" WHERE address_id='".veilig($_POST["address_id"])."'";
		$result=mysql_query($sql) or die(mysql_error());
	}

	if (isset($_GET['living_place_down'])){
		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='99'
		WHERE address_person_id='".$person."' AND address_order='".veilig($_GET["living_place_down"])."'";
		$result=mysql_query($sql) or die(mysql_error());

		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='".(veilig($_GET['living_place_down']))."'
		WHERE address_person_id='".$person."' AND address_order='".(veilig($_GET["living_place_down"])+1)."'";
		$result=mysql_query($sql) or die(mysql_error());

		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='".(veilig($_GET['living_place_down'])+1)."'
		WHERE address_person_id='".$person."' AND address_order=99";
		$result=mysql_query($sql) or die(mysql_error());
	}

	if (isset($_GET['living_place_up'])){
		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='99'
		WHERE address_person_id='".$person."' AND address_order='".veilig($_GET["living_place_up"])."'";
		$result=mysql_query($sql) or die(mysql_error());

		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='".(veilig($_GET['living_place_up']))."'
		WHERE address_person_id='".$person."' AND address_order='".(veilig($_GET["living_place_up"])-1)."'";
		$result=mysql_query($sql) or die(mysql_error());

		$sql="UPDATE ".$tree_prefix."addresses SET
		address_order='".(veilig($_GET['living_place_up'])-1)."'
		WHERE address_person_id='".$person."' AND address_order=99";
		$result=mysql_query($sql) or die(mysql_error());
	}

	// *** Living places ***
	echo '<p>'.$language["editor_domiciles"].'<br>';
	echo '<table class="humo standaard" border="1">';
	print '<tr class="tabel_kop"><th>'.$language["groups_option"].'</th><th colspan="2">'.$language["groups_value"].'</th></tr>';
	$adresqry=mysql_query("SELECT * FROM ".$tree_prefix."addresses
		WHERE address_person_id='".$person."' ORDER BY address_order",$db);
 	$adress_count=mysql_num_rows($adresqry);
	$address_nr=0;
	while($adresDb=mysql_fetch_object($adresqry)){
		$address_nr++;
		echo '<FORM METHOD="POST" action="'.$_SERVER['PHP_SELF'].'">';
		echo '<input type="hidden" name="page" value="'.$page.'">';
		echo '<input type="hidden" name="address_id" value="'.$adresDb->address_id.'">';
		echo '<tr><td>'.$language["editor_date"].' - '.$language["editor_place"].'</td><td>';

		echo ' <a href="index.php?page='.$page.'&amp;living_place_drop='.
			$adresDb->address_order.'"><img src="images/button_drop.png" border="0"></a>';

		if ($address_nr < $adress_count){
			echo ' <a href="index.php?page='.$page.'&amp;living_place_down='.$adresDb->address_order.'"><img src="images/pijl-laag.gif" border="0"></a>';
		}
		else{
			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		}
		if ($address_nr > 1){
			echo ' <a href="index.php?page='.$page.'&amp;living_place_up='.$adresDb->address_order.'"><img src="images/pijl-hoog.gif" border="0"></a>';
		}
		else{
			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
		}
		echo ' <input type="text" name="address_date" value="'.strtolower($adresDb->address_date).'" size="20">';
		echo ' <input type="text" name="address_place" value="'.$adresDb->address_place.'" size="60">';
		//echo $adresDb->address_text.' ';
		//echo $adresDb->address_source.' ';
		//echo' <input type="Submit" name="living_place_change" value="'.$language["admin_change"].'">';
		echo ' <BUTTON TYPE="submit" name="living_place_change" title="submit" class="knop"><img src="images/submit.gif" width="16"></BUTTON>';
		echo '</td</tr>';
		echo '</form>';

		// *** Save last place for index places ***
		if ($address_nr==$adress_count){
			$sql="UPDATE ".$tree_prefix."person SET
			pers_place_index='".veilig($adresDb->address_place)."'
			WHERE pers_gedcomnumber='".veilig($person)."'";
			$result=mysql_query($sql) or die(mysql_error());
		}
	}

	echo '<FORM METHOD="POST" action="'.$_SERVER['PHP_SELF'].'">';
		echo '<input type="hidden" name="page" value="'.$page.'">';
//$language["person_list_add"]='Gebeurtenis toevoegen';
		echo '<tr bgcolor="#CCFFFF"><td>'.$language["editor_date"].' - '.$language["editor_place"].'</td><td colspan="2">';
		echo '<input type="text" name="address_date" value="" size="20">';
		echo ' <input type="text" name="address_place" value="" size="60">';
		echo '<input type="hidden" name="address_order" value="'.($address_nr+1).'">';
		echo' <input type="Submit" name="living_place_add" value="'.$language["admin_add"].'"></td><tr>';
	echo '</form>';

	echo '</table>';
}

}
?>
Return current item: HuMo-gen