예제 #1
0
    function printForm()
    {
        $GLOBALS['system']->includeDBClass('person_group');
        $params = $this->getValue('params');
        ?>
		<h3>Find me people...</h3>

		<h4>whose person/family record matches these rules:</h4>
		<table class="table table-border table-auto-width indent-left table-condensed">
		<?php 
        foreach ($this->_query_fields as $i) {
            $v = $this->_field_details[$i];
            if (in_array($v['type'], array('select', 'reference', 'datetime', 'text')) && !in_array($i, array('p.first_name', 'p.last_name', 'f.family_name', 'p.remarks', 'p.email'))) {
                ?>
				<tr>
					<td>
						<label class="checkbox">
							<input autofocus="1" type="checkbox" name="enable_rule[]" value="<?php 
                echo $i;
                ?>
" id="enable_rule_<?php 
                echo $i;
                ?>
" class="select-rule-toggle" <?php 
                if (isset($params['rules'][$i])) {
                    echo 'checked="checked" ';
                }
                ?>
/>
							<strong><?php 
                echo $v['label'];
                ?>
</strong>
							<?php 
                if ($v['type'] == 'datetime') {
                    echo 'is between...';
                } else {
                    echo 'is...';
                }
                ?>
						</label>
					</td>
					<td>
						<div class="select-rule-options" <?php 
                if (!isset($params['rules'][$i])) {
                    echo 'style="display: none" ';
                }
                ?>
>
							<?php 
                $key = str_replace('.', '_', $i);
                if ($v['type'] == 'datetime') {
                    $value = array_get($params['rules'], $i, array('from' => '2000-01-01', 'to' => date('Y-m-d')));
                    print_widget('params_' . $key . '_from', array('type' => 'date'), $value['from']);
                    echo ' and ';
                    print_widget('params_' . $i . '_to', array('type' => 'date'), $value['to']);
                } else {
                    $v['allow_multiple'] = TRUE;
                    print_widget('params_' . $key, $v, array_get($params['rules'], $i, $v['type'] == 'select' ? array() : ''));
                }
                ?>
						</div>
					</td>
				</tr>
				<?php 
            }
        }
        ?>
		</table>
		
		<?php 
        // DATE FIELD RULES
        if ($GLOBALS['system']->featureEnabled('DATES')) {
            if (empty($params['dates']) && !empty($params['rules']['date'])) {
                $params['dates'][] = $params['rules']['date'] + array('criteria' => 'between');
                unset($params['rules']['date']);
            }
            ?>
			<h4>who have
				<?php 
            $dlParams = array('type' => 'select', 'options' => array('OR' => 'any', 'AND' => 'all'));
            print_widget('params_date_logic', $dlParams, array_get($params, 'date_logic', 'AND'));
            ?>
				 the following date fields...</h4>
			<table class="table expandable indent-left" id="datefield-rules">
			<?php 
            $values = array_get($params, 'dates', array());
            if (empty($values)) {
                $values[] = array('typeid' => NULL, 'criteria' => 'any', 'anniversary' => TRUE, 'from' => '2000-01-01', 'to' => date('Y-m-d'));
            }
            foreach ($values as $i => $value) {
                ?>
				<tr>
					<td class="narrow">
						<?php 
                print_widget('params_date_' . $i . '_typeid', array('type' => 'select', 'options' => array(0 => '--Choose--') + Person::getDateTypes()), (string) $value['typeid']);
                ?>
					</td>
					<td>
						<?php 
                // backwards compatibility:
                if (array_get($value, 'criteria') == 'between') {
                    $value['criteria'] = $value['anniversary'] ? 'anniversary' : 'exact';
                }
                $cparams = array('type' => 'select', 'options' => array('any' => 'filled with any value', 'empty' => 'not filled in', 'exact' => 'with exact value within...', 'anniversary' => 'with exact value or anniversary within...'), 'class' => 'datefield-rule-criteria');
                print_widget('params_date_' . $i . '_criteria', $cparams, $value['criteria']);
                $pts = array('fixed' => '', 'relative' => '');
                $pts[array_get($value, 'periodtype', 'fixed')] = 'checked="checked"';
                ?>
						<div class="datefield-rule-period">
							<label class="checkbox">
								<input type="radio" name="params_date_<?php 
                echo $i;
                ?>
_periodtype" value="fixed" <?php 
                echo $pts['fixed'];
                ?>
 />
								the period from
								<?php 
                print_widget('params_date_' . $i . '_from', array('type' => 'date'), $value['from']);
                ?>
								to
								<?php 
                print_widget('params_date_' . $i . '_to', array('type' => 'date'), $value['to']);
                ?>
							</label>
							<label class="checkbox">
								<input type="radio" name="params_date_<?php 
                echo $i;
                ?>
_periodtype" value="relative"<?php 
                echo $pts['relative'];
                ?>
 />
								the
								<?php 
                print_widget('params_date_' . $i . '_periodlength', array('type' => 'int'), array_get($value, 'periodlength', 14));
                ?>
								day period
								<?php 
                print_widget('params_date_' . $i . '_periodanchor', array('type' => 'select', 'options' => array('before' => 'before', 'ending' => 'ending on', 'starting' => 'starting on', 'after' => 'after')), array_get($value, 'periodanchor', 'ending'));
                ?>
								the day the report is executed
							</label>

						</div>
					</td>
				</tr>
				<?php 
            }
            ?>
			</table>
			<?php 
        }
        ?>

		<h4>who <strong>are</strong> in one or more of these groups:</h4>
		<div class="indent-left">

			<?php 
        Person_Group::printMultiChooser('include_groupids', array_get($params, 'include_groups', array()), array(), TRUE);
        ?>

			<label class="checkbox">
				<input type="checkbox" name="enable_group_membership_status" data-toggle="enable" data-target="#group-membership-status *" value="1"	<?php 
        if (!empty($params['group_membership_status'])) {
            echo 'checked="checked"';
        }
        ?>
 />
				with membership status of
			</label>
			<span id="group-membership-status"><?php 
        Person_Group::printMembershipStatusChooser('group_membership_status', array_get($params, 'group_membership_status'), true);
        ?>
</span>

			<label class="checkbox">
				<input type="checkbox" name="enable_group_join_date" data-toggle="enable" data-target="#group-join-dates *" value="1"	<?php 
        if (!empty($params['group_join_date_from'])) {
            echo 'checked="checked"';
        }
        ?>
 />
				and joined the group between
			</label> 
			<span id="group-join-dates">
			<?php 
        print_widget('group_join_date_from', array('type' => 'date'), array_get($params, 'group_join_date_from'));
        ?>
			and <?php 
        print_widget('group_join_date_to', array('type' => 'date'), array_get($params, 'group_join_date_to'));
        ?>
			</span>
		</div>


		<h4>who are <strong>not</strong> in any of these groups:</h4>
		<div class="indent-left">
			<?php 
        Person_Group::printMultiChooser('exclude_groupids', array_get($params, 'exclude_groups', array()), array(), TRUE);
        ?>
		</div>
	
	<?php 
        if ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE)) {
            ?>
		<h4>who have a person note containing the phrase:</h4>
		<div class="indent-left">
			<input type="text" name="note_phrase" size="60" value="<?php 
            echo isset($params["note_phrase"]) ? $params["note_phrase"] : "";
            ?>
">
		</div>
		<?php 
        }
        if ($GLOBALS['user_system']->havePerm(PERM_VIEWATTENDANCE)) {
            ?>
		<h4>whose attendance...</h4>
		<div class="indent-left">
			at 
			<?php 
            $groupid_params = array('type' => 'select', 'options' => array(null => '(Nothing)', '__cong__' => 'their congregation'), 'attrs' => array('data-toggle' => 'enable', 'data-target' => '.attendance-input'));
            $groups = $GLOBALS['system']->getDBObjectData('person_group', array('!attendance_recording_days' => 0, 'is_archived' => 0), 'AND');
            foreach ($groups as $id => $groupdata) {
                $groupid_params['options'][$id] = $groupdata['name'];
            }
            print_widget('attendance_groupid', $groupid_params, array_get($params, 'attendance_groupid', 0));
            ?>
			<br />

			has been 

			<?php 
            $operator_params = array('type' => 'select', 'options' => array('<' => 'less than', '>' => 'more than'), 'class' => 'attendance-input');
            print_widget('attendance_operator', $operator_params, array_get($params, 'attendance_operator', '<'));
            ?>
			<input name="attendance_percent" type="text" size="2" class="int-box attendance-input" value="<?php 
            echo (int) array_get($params, 'attendance_percent', 50);
            ?>
" />%

			<br />over the last <input name="attendance_weeks" type="text" size="2" class="int-box attendance-input" value="<?php 
            echo (int) array_get($params, 'attendance_weeks', 2);
            ?>
" /> weeks
		</div>
		<?php 
        }
        ?>

		<h3>For each person found, show me...</h3>
		<?php 
        $show_fields = array_get($params, 'show_fields', array());
        ?>

		<table class="table-condensed expandable indent-left">
		<?php 
        foreach ($show_fields as $chosen_field) {
            ?>
			<tr>
				<td>
					<img src="<?php 
            echo BASE_URL;
            ?>
/resources/img/expand_up_down_green_small.png" class="icon insert-row-below" style="position: relative; top: 2ex" title="Create a blank entry here" />
				</td>
				<td>
					<?php 
            $options = array('' => '');
            foreach ($this->_show_fields as $i => $opt) {
                if (is_null($opt)) {
                    $options['--' . $i] = '-----';
                } else {
                    $options[$opt] = $this->_field_details[$opt]['label'];
                }
            }
            if ($GLOBALS['user_system']->havePerm(PERM_VIEWATTENDANCE)) {
                $options['--Z'] = '-----';
                $options['attendance_percent'] = 'Attendance rate during specified period';
                $options['attendance_numabsences'] = 'Number of absences since last marked present';
            }
            if ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE)) {
                $options['--Y'] = '-----';
                $options['notes.subjects'] = 'Notes matching the phrase above';
                $options['actionnotes.subjects'] = 'Notes requiring action';
            }
            if ($GLOBALS['system']->featureEnabled('DATES')) {
                $options['--A'] = '-----';
                foreach (Person::getDateTypes() as $typeid => $name) {
                    $options['date---' . $typeid] = ucfirst($name) . ' Date';
                }
            }
            $options['--B'] = '-----';
            if ($GLOBALS['system']->featureEnabled('PHOTOS')) {
                $options['photo'] = 'Photo';
            }
            $options['groups'] = 'Which of the selected groups they are in';
            $options['membershipstatus'] = 'Group membership status';
            $options['all_members'] = 'Names of all their family members';
            $options['adult_members'] = 'Names of their adult family members';
            if ($GLOBALS['system']->featureEnabled('PHOTOS')) {
                $options['photo'] = 'Photo';
            }
            $options['--D'] = '-----';
            $options['view_link'] = 'A link to view their person record';
            $options['edit_link'] = 'A link to edit their person record';
            $options['checkbox'] = 'A checkbox for bulk actions';
            print_widget('show_fields[]', array('options' => $options, 'type' => 'select', 'disabled_prefix' => '--'), $chosen_field);
            ?>
				</td>
				<td class="nowrap">
					<img src="<?php 
            echo BASE_URL;
            ?>
/resources/img/arrow_up_thin_black.png" class="icon move-row-up" title="Move this item up" />
					<img src="<?php 
            echo BASE_URL;
            ?>
/resources/img/arrow_down_thin_black.png" class="icon move-row-down" title="Move this item down" />
					<img src="<?php 
            echo BASE_URL;
            ?>
/resources/img/cross_red.png" class="icon delete-row" title="Delete this item" />
				</td>
			</tr>
			<?php 
        }
        ?>
		</table>


		<h3>Group the results...</h3>
		<?php 
        $gb = array_get($params, 'group_by', '');
        ?>
		<div class="indent-left">
			<select name="group_by">
				<option value=""<?php 
        if ($gb == '') {
            echo ' selected="selected"';
        }
        ?>
>all together</option>
				<option value="groupid"<?php 
        if ($gb == 'groupid') {
            echo ' selected="selected"';
        }
        ?>
>by group membership</option>
			<?php 
        foreach ($this->_query_fields as $i) {
            $v = $this->_field_details[$i];
            if (!in_array($v['type'], array('select', 'reference'))) {
                continue;
            }
            ?>
				<option value="<?php 
            echo $i;
            ?>
"<?php 
            if ($gb == $i) {
                echo ' selected="selected"';
            }
            ?>
>by <?php 
            echo $v['label'];
            ?>
</option>
				<?php 
        }
        ?>
			</select>
			<p class="smallprint">Note: Result groups that do not contain any persons will not be shown</p>
		</div>

		<h3>Sort the results by...</h3>

		<select name="sort_by" class="indent-left">
		<?php 
        $sb = array_get($params, 'sort_by');
        foreach ($this->_show_fields as $name) {
            if (is_null($name)) {
                ?>
				<option disabled="disabled">------</option>
				<?php 
            } else {
                ?>
				<option value="<?php 
                echo $name;
                ?>
"<?php 
                if ($sb == $name) {
                    echo ' selected="selected"';
                }
                ?>
><?php 
                echo ents($this->_field_details[$name]['label']);
                ?>
</option>
				<?php 
            }
        }
        ?>
		<option disabled="disabled">------</option>
		<option value="attendance_percent"<?php 
        if ($sb == "attendance_percent") {
            echo ' selected="selected"';
        }
        ?>
>Attendance rate during the specified period</option>
		<option value="attendance_numabsences""<?php 
        if ($sb == "attendance_numabsences") {
            echo ' selected="selected"';
        }
        ?>
>Number of absences since last marked present</option>
		<?php 
        if ($GLOBALS['system']->featureEnabled('DATES')) {
            ?>
			<option disabled="disabled">------</option>
			<?php 
            foreach (Person::getDateTypes() as $typeid => $name) {
                ?>
				<option value="date---<?php 
                echo $typeid;
                ?>
"<?php 
                if ($sb == 'date---' . $typeid) {
                    echo ' selected="selected"';
                }
                ?>
><?php 
                echo ents($name);
                ?>
 date</option>
				<?php 
            }
        }
        ?>
		</select>

		<?php 
        if ($GLOBALS['user_system']->havePerm(PERM_MANAGEREPORTS)) {
            ?>
			<h3>I want to save this report...</h3>
			<div class="indent-left">
				<label type="radio">
					<input type="radio" name="save_option" value="new" id="save_option_new" <?php 
            if (empty($this->id)) {
                echo 'checked="checked"';
            }
            ?>
 />
					as a new report called
					<input type="text" name="new_query_name" />
				</label>
		
				<label type="radio">
					<input type="radio" name="save_option" value="replace" id="save_option_replace" <?php 
            if ($this->id && $this->id != 'TEMP') {
                echo 'checked="checked"';
            }
            ?>
 />
					in place of an existing report
					<?php 
            print_widget('replace_query_id', array('type' => 'reference', 'references' => 'person_query'), $this->id);
            ?>
				</label>

				<label type="radio">
					<input type="radio" name="save_option" value="temp" id="save_option_temp"<?php 
            if (empty($this->id) || $this->id == 'TEMP') {
                echo ' checked="checked"';
            }
            ?>
 />
					only temporarily as an ad-hoc report
				</label>
			</div>
			<?php 
        }
    }
예제 #2
0
    function printForm()
    {
        $GLOBALS['system']->includeDBClass('person_group');
        $actions = $this->getValue('actions');
        $notes = array_get($actions, 'notes');
        if (empty($notes)) {
            $notes = array(array());
            // 1 blank note to start us off
        }
        ?>
		<table class="action-plan">
			<tbody>
				<tr>
					<th>Name</th>
					<td><?php 
        $this->printFieldInterface('name');
        ?>
</td>
				</tr>
				<tr>
					<th>Notes</th>
					<td>
						When this plan is executed, add these notes to the person/family:
						<table class="expandable">
						<?php 
        foreach ($notes as $i => $note) {
            ?>
							<tr>
								<td>
									<div class="well">
									<?php 
            $this->_printNoteForm($note, $i);
            ?>
									</div>
								</td>
							</tr>
							<?php 
        }
        ?>
						</table>
					</td>
				</tr>
				<tr>
					<th>Groups</th>
					<td>
						When this plan is executed, <b>add</b> the persons / famiy members to these groups:
						<?php 
        Person_Group::printMultiChooser('groups', array_get($actions, 'groups', array()), array(), FALSE);
        ?>
					</td>
				</tr>
				<tr>
					<th></th>
					<td>
						When this plan is executed, <b>remove</b> the persons / famiy members from these groups:
						<?php 
        Person_Group::printMultiChooser('groups_remove', array_get($actions, 'groups_remove', array()), array(), FALSE);
        ?>
					</td>
				</tr>
				<tr>
					<th>Fields</th>
					<td>
						When this plan is executed, for each person / family member:
						<table class="fields">
						<?php 
        $fields = array_get($actions, 'fields', array());
        $dummy = new Person();
        foreach (array('congregationid', 'status', 'age_bracket') as $field) {
            $value = '';
            $addToExisting = FALSE;
            $v = array_get($fields, $field);
            if ($v) {
                $value = $v['value'];
                $addToExisting = $v['add'];
            }
            $dummy->fields[$field]['allow_empty'] = TRUE;
            $dummy->fields[$field]['empty_text'] = '(No change)';
            if (strlen($value)) {
                $dummy->setValue($field, $value);
            }
            echo '<tr><td>';
            print_widget('fields_enabled[' . $field . ']', array('type' => 'checkbox'), strlen($value));
            echo 'Set ' . $dummy->getFieldLabel($field) . ' </td><td>';
            $dummy->printFieldInterface($field);
            echo '</td></tr>';
        }
        $customFields = $GLOBALS['system']->getDBObjectData('custom_field', array(), 'OR', 'rank');
        $dummy = new Custom_Field();
        $addParams = array('type' => 'select', 'options' => array('Replacing existing values ', 'Adding to existing values'));
        foreach ($customFields as $fieldid => $fieldDetails) {
            $value = '';
            $addToExisting = FALSE;
            $v = array_get($fields, 'custom_' . $fieldid);
            if ($v) {
                $value = $v['value'];
                $addToExisting = $v['add'];
            }
            $dummy->populate($fieldid, $fieldDetails);
            echo '<tr><td>';
            print_widget('fields_enabled[custom_' . $fieldid . ']', array('type' => 'checkbox'), strlen($value));
            echo 'Set ' . ents($dummy->getValue('name')) . '&nbsp;</td><td>';
            if ($fieldDetails['type'] == 'date') {
                // For now, we only support setting date fields to the reference date.
                // But there is room for future expansion to support fixed dates too.
                $dateVal = $noteVal = '';
                if (strlen($value)) {
                    list($dateVal, $noteVal) = explode('===', $value);
                }
                echo 'to the reference date, with note ';
                print_widget('custom_' . $fieldid . '_note', array('type' => 'text'), $noteVal);
            } else {
                $dummy->printWidget($value);
            }
            if ($dummy->getValue('allow_multiple')) {
                print_widget('fields_addvalue[custom_' . $fieldid . ']', $addParams, $addToExisting);
            }
            echo '</td></tr>';
        }
        ?>
						</table>
					</td>
				</tr>
				<tr>
					<th>Attendance</th>
					<td>
						<input type="hidden" name="mark_present" value="0" />
						<label class="checkbox">
							<input type="checkbox" id="mark_present" name="mark_present" value="1" <?php 
        if (array_get($actions, 'attendance')) {
            echo 'checked="checked"';
        }
        ?>
>
							When this plan is executed, mark the persons / family members as present at their congregation for the most recent attendance date
						</label>
						<p><small>This will only have effect if they are in a congregation. They will be marked present for the most recent date on which attendance has been recorded for that congregation.</small></p>
					</td>
				</tr>
				<tr>
					<th>Options</th>
					<td>
						
						<input type="hidden" name="default_on_create_family" value="0" />
						<label class="checkbox">
							<input type="checkbox" id="default_on_create_family" name="default_on_create_family" value="1" <?php 
        if ($this->getValue('default_on_create_family')) {
            echo 'checked="checked"';
        }
        ?>
>
							By default, execute this plan when creating a new family
						</label>

						<input type="hidden" name="default_on_add_person" value="0" />
						<label class="checkbox">
							<input type="checkbox" id="default_on_add_person" name="default_on_add_person" value="1" <?php 
        if ($this->getValue('default_on_add_person')) {
            echo 'checked="checked"';
        }
        ?>
>
							By default, execute this plan when adding a new person to an existing family
						</label>
					</td>
				</tr>
			</tbody>
		</table>
		<script>
		$('form').submit(function() {
			var ok = true;
			$('.note').each(function() {
				var t = $(this);
				if ((t.find('textarea:first').val() != '') && (t.find('input[name$="_subject"]').val() == '')) {
					t.find('input[name$="_subject"]').select();
					alert("All notes to be added must include a subject");
					ok = false;
				}
				if (!ok) return false;
				if (t.find('input[type=radio][value=relative]').attr('checked') && t.find('input[name$=action_date_offset]').val() == '') {
					t.find('input[name$=action_date_offset]').focus();
					alert("If a relative action date is selected you must specify a number of days");
					ok = false;
				}
			});
			return ok;
		});
		</script>
		<?php 
    }
예제 #3
0
    function printFieldInterface($name, $prefix = '')
    {
        switch ($name) {
            case 'password':
                if ($GLOBALS['user_system']->getCurrentUser('id') == $this->id || $GLOBALS['user_system']->havePerm(PERM_SYSADMIN)) {
                    ?>
					<input type="password" data-minlength="<?php 
                    echo (int) $this->getMinPasswordLength();
                    ?>
" autocomplete="off" name="<?php 
                    echo $prefix . $name . '1';
                    ?>
" /><br />
					<input type="password" data-minlength="<?php 
                    echo (int) $this->getMinPasswordLength();
                    ?>
" autocomplete="off" name="<?php 
                    echo $prefix . $name . '2';
                    ?>
" /><br />
					<p class="help-inline">Enter once, then again to confirm. Passwords must be at least <?php 
                    echo (int) $this->getMinPasswordLength();
                    ?>
 characters and contain 2 letters and 2 numbers</p>
					<?php 
                } else {
                    ?>
					<p class="small">A user's password can only be edited by system administrators or the user themselves</p>
					<?php 
                }
                break;
            case 'restrictions':
                $GLOBALS['system']->includeDBClass('person_group');
                if ($GLOBALS['user_system']->havePerm(PERM_SYSADMIN)) {
                    ?>
					<table class="standard">
						<tr>
							<th>Restrict to these congregations: &nbsp;</th>
							<th>Restrict to these groups:</th>
						</tr>
						<tr>
							<td>
								<?php 
                    print_widget('restrictions[congregation]', array('type' => 'reference', 'references' => 'congregation', 'allow_multiple' => true), array_get($this->_restrictions, 'congregation', array()));
                    ?>
							</td>
							<td>
								<?php 
                    Person_Group::printMultiChooser('restrictions[group]', array_get($this->_restrictions, 'group', array()), array(), FALSE);
                    ?>
							</td>
						</tr>
					</table>
					<p class="help-inline">If you select congregations or groups here, this user will only be able to see persons who belong to one of the selected congregations or groups.  It will look like those are the only congregations, groups and persons in the system.  Users with congregation or group restrictions cannot add new persons or families.  Changes to restrictions take effect immediately.</p>
					<?php 
                } else {
                    $this->printFieldValue($name);
                    ?>
					<p class="help-inline">Only system administrators can edit this field</p>
					<?php 
                }
                break;
            case 'permissions':
                if ($name == 'permissions') {
                    // Subtly display the numeric permission level to help with config.php
                    ?>
					<div title="This number represents this combination of permissions, and can be used to set the default permissions in the config file" style="color: #ccc; position: absolute; right: 10px; padding: 3px"><?php 
                    echo $this->getValue($name);
                    ?>
</div>
					<?php 
                }
                if ($GLOBALS['user_system']->havePerm(PERM_SYSADMIN)) {
                    parent::printFieldInterface($name, $prefix);
                    ?>
					<p class="help-inline"><b>Note:</b> Changes to permissions only take effect the next time a user logs in</p>
					<?php 
                } else {
                    $this->printFieldValue($name);
                    ?>
					<p class="help-inline">Only system administrators can edit this field</p>
					<?php 
                }
                break;
            default:
                parent::printFieldInterface($name, $prefix);
        }
    }
예제 #4
0
    function printForm()
    {
        $GLOBALS['system']->includeDBClass('person_group');
        $actions = $this->getValue('actions');
        $notes = array_get($actions, 'notes');
        if (empty($notes)) {
            $notes = array(array());
            // 1 blank note to start us off
        }
        ?>
		<table>
			<tbody>
				<tr>
					<th>Name</th>
					<td><?php 
        $this->printFieldInterface('name');
        ?>
</td>
				</tr>
				<tr>
					<th>Notes</th>
					<td>
						When this plan is executed, add these notes to the person/family:
						<table class="expandable">
						<?php 
        foreach ($notes as $i => $note) {
            ?>
							<tr>
								<td>
									<div class="well">
									<?php 
            $this->_printNoteForm($note, $i);
            ?>
									</div>
								</td>
							</tr>
							<?php 
        }
        ?>
						</table>
					</td>
				</tr>
				<tr>
					<th>Groups</th>
					<td>
						When this plan is executed, <b>add</b> the persons / famiy members to these groups:
						<?php 
        Person_Group::printMultiChooser('groups', array_get($actions, 'groups', array()), array(), TRUE);
        ?>
					</td>
				</tr>
				<tr>
					<th></th>
					<td>
						When this plan is executed, <b>remove</b> the persons / famiy members from these groups:
						<?php 
        Person_Group::printMultiChooser('groups_remove', array_get($actions, 'groups_remove', array()), array(), TRUE);
        ?>
					</td>
				</tr>
			<?php 
        if ($GLOBALS['system']->featureEnabled('DATES')) {
            $datetype_params = array('type' => 'select', 'options' => array('' => '(Choose type)'));
            $dateFields = $GLOBALS['system']->getDBObjectData('custom_field', array('type' => 'date'), 'OR', 'rank');
            foreach ($dateFields as $fieldID => $fieldDetails) {
                $datetype_params['options'][$fieldID] = $fieldDetails['name'];
            }
            $datenote_params = array('type' => 'text', 'width' => 40);
            ?>
				<tr>
					<th>Dates</th>
					<td>
						When this plan is executed, for each person / family member:
						<table class="expandable">
						<?php 
            $dates = array_get($actions, 'dates');
            if (empty($dates)) {
                $dates = array('' => '');
            }
            foreach ($dates as $typeid => $note) {
                ?>
							<tr>
								<td class="nowrap">
								Set 
								<?php 
                print_widget('datetypes[]', $datetype_params, "{$typeid}");
                ?>
								to the reference date, with note
								<?php 
                print_widget('datenotes[]', $datenote_params, $note);
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>
						</table>
					</td>
				</tr>
				<?php 
        }
        ?>
				<tr>
					<th>Options</th>
					<td>
						
						<input type="hidden" name="default_on_create_family" value="0" />
						<label class="checkbox">
							<input type="checkbox" id="default_on_create_family" name="default_on_create_family" value="1" <?php 
        if ($this->getValue('default_on_create_family')) {
            echo 'checked="checked"';
        }
        ?>
>
							By default, execute this plan when creating a new family
						</label>

						<input type="hidden" name="default_on_add_person" value="0" />
						<label class="checkbox">
							<input type="checkbox" id="default_on_add_person" name="default_on_add_person" value="1" <?php 
        if ($this->getValue('default_on_add_person')) {
            echo 'checked="checked"';
        }
        ?>
>
							By default, execute this plan when adding a new person to an existing family
						</label>
					</td>
				</tr>
			</tbody>
		</table>
		<script>
		$('form').submit(function() {
			var ok = true;
			$('.note').each(function() {
				var t = $(this);
				if ((t.find('textarea:first').val() != '') && (t.find('input[name$="_subject"]').val() == '')) {
					t.find('input[name$="_subject"]').select();
					alert("All notes to be added must include a subject");
					ok = false;
				}
				if (!ok) return false;
				if (t.find('input[type=radio][value=relative]').attr('checked') && t.find('input[name$=action_date_offset]').val() == '') {
					t.find('input[name$=action_date_offset]').focus();
					alert("If a relative action date is selected you must specify a number of days");
					ok = false;
				}
			});
			return ok;
		});
		</script>
		<?php 
    }