getPageTitle(); ?>
For each member in the family, you can use the Change link to choose a different individual to fill that role in the family. You can also use the Remove link to remove that individual from the family.
When you have finished changing the family members, click the save button to save the changes.'); ?>
//$CHIL = WT_Filter::postArray('CHIL', WT_REGEX_XREF);
$CHIL = array();
for ($i=0; ;++$i) {
if (isset($_POST['CHIL'.$i])) {
$CHIL[] = WT_Filter::post('CHIL'.$i, WT_REGEX_XREF);
} else {
break;
}
}
$family = WT_Family::getInstance($xref);
check_record_access($family);
$controller
->setPageTitle(WT_I18N::translate('Change family members'))
->pageHeader();
// Current family members
$old_father = $family->getHusband();
$old_mother = $family->getWife();
$old_children = $family->getChildren();
// New family members
$new_father = WT_Individual::getInstance($HUSB);
$new_mother = WT_Individual::getInstance($WIFE);
$new_children = array();
if (is_array($CHIL)) {
foreach ($CHIL as $child) {
$new_children[] = WT_Individual::getInstance($child);
}
}
if ($old_father !== $new_father) {
if ($old_father) {
// Remove old FAMS link
foreach ($old_father->getFacts('FAMS') as $fact) {
if ($fact->getTarget() === $family) {
$old_father->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old HUSB link
foreach ($family->getFacts('HUSB|WIFE') as $fact) {
if ($fact->getTarget() === $old_father) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
if ($new_father) {
// Add new FAMS link
$new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
// Add new HUSB link
$family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan);
}
}
if ($old_mother !== $new_mother) {
if ($old_mother) {
// Remove old FAMS link
foreach ($old_mother->getFacts('FAMS') as $fact) {
if ($fact->getTarget() === $family) {
$old_mother->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old WIFE link
foreach ($family->getFacts('HUSB|WIFE') as $fact) {
if ($fact->getTarget() === $old_mother) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
if ($new_mother) {
// Add new FAMS link
$new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan);
// Add new WIFE link
$family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan);
}
}
foreach ($old_children as $old_child) {
if ($old_child && !in_array($old_child, $new_children)) {
// Remove old FAMC link
foreach ($old_child->getFacts('FAMC') as $fact) {
if ($fact->getTarget() === $family) {
$old_child->deleteFact($fact->getFactId(), !$keep_chan);
}
}
// Remove old CHIL link
foreach ($family->getFacts('CHIL') as $fact) {
if ($fact->getTarget() === $old_child) {
$family->deleteFact($fact->getFactId(), !$keep_chan);
}
}
}
}
foreach ($new_children as $new_child) {
if ($new_child && !in_array($new_child, $old_children)) {
// Add new FAMC link
$new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan);
// Add new CHIL link
$family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
}
}
$controller->addInlineJavascript('closePopupAndReloadParent();');
break;
////////////////////////////////////////////////////////////////////////////////
// Change the order of FAMS records within an INDI record
////////////////////////////////////////////////////////////////////////////////
case 'reorder_fams':
$xref = WT_Filter::post('xref', WT_REGEX_XREF, WT_Filter::get('xref', WT_REGEX_XREF));
$option = WT_Filter::post('option');
$person = WT_Individual::getInstance($xref);
check_record_access($person);
$controller
->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});')
//-- update the order numbers after drag-n-drop sorting is complete
->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });')
->setPageTitle(WT_I18N::translate('Re-order families'))
->pageHeader();
$fams = $person->getSpouseFamilies();
if ($option=='bymarriage') {
usort($fams, array('WT_Family', 'compareMarrDate'));
}
?>
';
echo '
', $controller->getPageTitle(), '
';
init_calendar_popup();
echo '