function processView()
 {
     $GLOBALS['system']->setFriendlyErrors(TRUE);
     $this->_person =& $GLOBALS['system']->getDBObject('person', (int) $_REQUEST['personid']);
     if (!empty($_REQUEST['move_to'])) {
         if ($_REQUEST['move_to'] == 'new') {
             $family =& $GLOBALS['system']->getDBObject('family', (int) $this->_person->getValue('familyid'));
             $family->id = 0;
             $family->create();
             $this->_person->setValue('familyid', $family->id);
             $this->_person->save();
             add_message('New family created with same details as old family.  You should update the new family\'s details as required');
             redirect('_edit_family', array('familyid' => $family->id));
             // exits
         } else {
             if (empty($_REQUEST['familyid'])) {
                 trigger_error("You must select a new family to move to, or choose to create a new family");
                 return false;
             }
             $family =& $GLOBALS['system']->getDBObject('family', (int) $_REQUEST['familyid']);
             if ($family) {
                 $old_familyid = $this->_person->getValue('familyid');
                 $this->_person->setValue('familyid', (int) $_REQUEST['familyid']);
                 if ($this->_person->save()) {
                     add_message('Person moved to family "' . $family->toString() . '"');
                     $remaining_members = $GLOBALS['system']->getDBObjectData('person', array('familyid' => $old_familyid));
                     if (empty($remaining_members)) {
                         $old_family =& $GLOBALS['system']->getDBObject('family', $old_familyid);
                         if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
                             // add a note
                             $GLOBALS['system']->includeDBClass('family_note');
                             $note = new Family_Note();
                             $note->setValue('familyid', $old_familyid);
                             $note->setValue('subject', 'Archived by System');
                             $note->setValue('details', 'The system is archiving this family because its last member (' . $this->_person->toString() . ' #' . $this->_person->id . ') has been moved to another family (' . $family->toString() . ' #' . $family->id . ')');
                             $note->create();
                         }
                         // archive the family record
                         $old_family->setValue('status', 'archived');
                         $old_family->save();
                     }
                     redirect('persons', array('personid' => $this->_person->id));
                     // exits
                 }
             }
         }
     }
 }
    function printForm()
    {
        $GLOBALS['system']->includeDBClass('person');
        $person = new Person();
        $person->fields['first_name']['width'] = 11;
        $person->fields['last_name']['width'] = 11;
        $person->fields['email']['width'] = 25;
        ?>
		<form method="post" id="add-family" class="form-horizontal">
			<input type="hidden" name="new_family_submitted" value="1" />
			<div class="">

			<label>Family Name:</label>
			<?php 
        $this->_family->printFieldInterface('family_name');
        ?>
			
			</div>

			<div>
			<h3>Family Members</h3>
			<table class="expandable">
			<?php 
        include_once 'include/size_detector.class.php';
        if (SizeDetector::isNarrow()) {
            ?>
				<tr>
					<td>
						<div class="compact-2col family-member-box">
							<label>First Name</label>
							<label>Last Name</label>
							<div><?php 
            $person->printFieldInterface('first_name', 'members_0_');
            ?>
</div>
							<div class="last_name preserve-value"><?php 
            $person->printFieldInterface('last_name', 'members_0_');
            ?>
</div>

							<label>Gender</label>
							<label>Age</label>
							<div><?php 
            $person->printFieldInterface('gender', 'members_0_');
            ?>
</div>
							<div><?php 
            $person->printFieldInterface('age_bracket', 'members_0_');
            ?>
</div>

							<label>Status</label>
							<label>Congregation</label>
							<div class="person-status preserve-value"><?php 
            $person->printFieldInterface('status', 'members_0_');
            ?>
</div>
							<div class="congregation"><?php 
            $person->printFieldInterface('congregationid', 'members_0_');
            ?>
</div>

							<label>Mobile</label>
							<label>Email</label>
							<div><?php 
            $person->printFieldInterface('mobile_tel', 'members_0_');
            ?>
</div>
							<div><?php 
            $person->printFieldInterface('email', 'members_0_');
            ?>
</div>

						</div>



					</td>
				</tr>
				<?php 
        } else {
            ?>
				<thead>
					<tr>
						<td>First Name</td>
						<td>Last Name</td>
						<td>Gender</td>
						<td>Age</td>
						<td>Status</td>
						<td>Cong.</td>
						<td>Mobile Tel</td>
						<td>Email</td>
					</tr>
				<thead>
				<tbody>
					<tr>
						<td><?php 
            $person->printFieldInterface('first_name', 'members_0_');
            ?>
</td>
						<td class="last_name preserve-value"><?php 
            $person->printFieldInterface('last_name', 'members_0_');
            ?>
</td>
						<td><?php 
            $person->printFieldInterface('gender', 'members_0_');
            ?>
</td>
						<td><?php 
            $person->printFieldInterface('age_bracket', 'members_0_');
            ?>
</td>
						<td class="person-status preserve-value"><?php 
            $person->printFieldInterface('status', 'members_0_');
            ?>
</td>
						<td class="congregation preserve-value"><?php 
            $person->printFieldInterface('congregationid', 'members_0_');
            ?>
</td>
						<td><?php 
            $person->printFieldInterface('mobile_tel', 'members_0_');
            ?>
</td>
						<td><?php 
            $person->printFieldInterface('email', 'members_0_');
            ?>
</td>
					</tr>
				</tbody>
				<?php 
        }
        ?>
			</table>
			</div>

			<h3>Family Details <small>(optional)</small></h3>
			<?php 
        $this->_family->fields['family_name']['readonly'] = 1;
        $this->_family->printForm();
        $this->_family->fields['family_name']['readonly'] = 0;
        ?>

		<?php 
        if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
            ?>
			<div <?php 
            echo REQUIRE_INITIAL_NOTE ? '' : 'class="optional"';
            ?>
>
			<h3>Initial Note <small>(<?php 
            echo REQUIRE_INITIAL_NOTE ? 'required' : 'optional';
            ?>
)</small></h3>
			<?php 
            $GLOBALS['system']->includeDBClass('family_note');
            $note = new Family_Note();
            $note->printForm('initial_note_');
            ?>
			</div>
			<?php 
        }
        if ($plan_chooser = Action_Plan::getMultiChooser('execute_plan', 'create_family')) {
            ?>
			<h3>Action plans <small>(optional)</small></h3>
			<p>Execute the following action plans for the new family: </p>
			<div class="indent-left">
				<?php 
            echo $plan_chooser;
            ?>
				<p>Reference date for plans: <?php 
            print_widget('plan_reference_date', array('type' => 'date'), NULL);
            ?>
</p>
			</div>
			<?php 
        }
        ?>
		<h3>Create</h3>
			<div class="align-right">
				<input type="submit" class="btn" value="Create Family" />
				<input type="button" class="back btn" value="Cancel" />
			</div>
		</form>
		<?php 
    }