function printView()
    {
        ?>
		<form method="post" id="add-family">
			<input type="hidden" name="new_person_submitted" value="1" />
			<input type="hidden" name="familyid" value="<?php 
        echo ents($_REQUEST['familyid']);
        ?>
" />
			<h3>New Person Details</h3>
			<?php 
        $this->_person->printForm();
        if ($chooser = Action_Plan::getMultiChooser('execute_plan', 'add_person')) {
            ?>
				<h3>Action Plans</h3>
				<p>Execute the following action plans for the new person:</p>
				<?php 
            echo $chooser;
            ?>
				<p>Reference date for plans: <?php 
            print_widget('plan_reference_date', array('type' => 'date'), NULL);
            ?>
</p>
				<?php 
        }
        ?>
			<button type="submit" class="btn">Add Family Member</button>
			<a href="<?php 
        echo build_url(array('view' => 'families'));
        ?>
" class="btn">Cancel</a>
		</form>
		<?php 
    }
    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 
    }
    function printView()
    {
        if (!empty($this->_plan)) {
            if (empty($this->_plan->id) || $this->_plan->haveLock()) {
                ?>
				<form method="post">
					<input type="hidden" name="plan_submitted" value="1" />
					<?php 
                $this->_plan->printForm();
                ?>
					<input class="btn" type="submit" value="Save Action Plan" />
					<a class="btn" href="<?php 
                echo build_url(array('planid' => NULL));
                ?>
">Cancel</a>
				</form>
				<?php 
            } else {
                $this->_plan->printSummary();
            }
        } else {
            ?>
			<p><a href="<?php 
            echo build_url(array('planid' => 0, 'delete' => NULL));
            ?>
"><i class="icon-plus-sign"></i>Add new plan</a></p>
			<?php 
            $saved_plans = $GLOBALS['system']->getDBObjectData('action_plan', array(), '', 'name');
            if (empty($saved_plans)) {
                ?>
				<i>There are not yet any action plans saved in the system</i>
				<?php 
            } else {
                ?>
				<table class="table table-hover table-striped table-min-width">
					<thead>
						<tr>
							<th>ID</th>
							<th>Name</th>
							<th>Last modified</th>
							<th>&nbsp;</th>
						</tr>
					</thead>
					<tbody>
					<?php 
                $dummy_plan = new Action_Plan();
                foreach ($saved_plans as $id => $details) {
                    $dummy_plan->populate($id, $details);
                    ?>
						<tr>
							<td><?php 
                    echo (int) $id;
                    ?>
</td>
							<td class="nowrap"><?php 
                    echo ents($details['name']);
                    ?>
</td>
							<td class="nowrap"><?php 
                    $dummy_plan->printFieldValue('modified');
                    ?>
 by <?php 
                    echo $dummy_plan->printFieldValue('modifier');
                    ?>
</td>
							<td class="narrow action-cell">
								<a href="?view=<?php 
                    echo ents($_REQUEST['view']);
                    ?>
&planid=<?php 
                    echo $id;
                    ?>
"><i class="icon-wrench"></i>Edit</a> &nbsp;
								<a href="?view=<?php 
                    echo ents($_REQUEST['view']);
                    ?>
&planid=<?php 
                    echo $id;
                    ?>
&delete=1" class="confirm-title" title="Delete this action plan"><i class="icon-trash"></i>Delete</a>
							</td>
						</tr>
						<?php 
                }
                ?>
					</tbody>
				</table>
				<?php 
            }
        }
    }
<?php

include_once 'size_detector.class.php';
// ------------------------ MODALS --------------------------
// -------ACTION PLAN MODAL --------- //
$GLOBALS['system']->includeDBClass('action_plan');
$plan_chooser = Action_Plan::getMultiChooser('planid', array());
if ($plan_chooser) {
    ?>
	<div id="action-plan-modal" class="modal hide fade" role="dialog" aria-hidden="true">
		<form method="post" action="?view=_execute_plans&personid[]=<?php 
    echo (int) $person->id;
    ?>
">
			<div class="modal-header">
				<h4>Execute Action Plan for <?php 
    $person->printFieldValue('name');
    ?>
</h4>
			</div>
			<div class="modal-body">
				<p><?php 
    echo $plan_chooser;
    ?>
</p>
				<p>Reference date for plans: <?php 
    print_widget('plan_reference_date', array('type' => 'date'), NULL);
    ?>
</p>
			</div>
			<div class="modal-footer">