コード例 #1
0
    $dummy = new Person();
    foreach (array('congregationid', 'status', 'age_bracket') as $field) {
        $dummy->fields[$field]['allow_empty'] = TRUE;
        $dummy->fields[$field]['empty_text'] = '(No change)';
        $dummy->setValue($field, NULL);
        echo '<tr><td>Set ' . $dummy->getFieldLabel($field) . ' to: </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) {
        $dummy->populate($fieldid, $fieldDetails);
        echo '<tr><td>Set ' . ents($dummy->getValue('name')) . ' to: </td><td>';
        $dummy->printWidget('');
        if ($dummy->getValue('allow_multiple')) {
            echo '</td><td>';
            print_widget('custom_' . $fieldid . '_add', $addParams, 0);
        }
        echo '</td></tr>';
    }
    ?>
			</table>
			<input type="submit" class="btn" onclick="return confirm('Are you sure you want to bulk-update these persons?')" value="Go" data-set-form-action="<?php 
    echo BASE_URL;
    ?>
?view=_persons_bulk_update&backto=<?php 
    echo urlencode(http_build_query($_GET));
    ?>
" />
コード例 #2
0
ファイル: person.class.php プロジェクト: vanoudt/jethro-pmm
    function printForm($prefix = '', $fields = NULL)
    {
        include_once 'include/size_detector.class.php';
        if ($GLOBALS['system']->featureEnabled('PHOTOS') && (is_null($fields) || in_array('photo', $fields)) && !SizeDetector::isNarrow()) {
            $this->fields['photo'] = array('divider_before' => true);
            // fake field for interface purposes
            if ($this->id) {
                ?>
				<div class="person-photo-container">
					<img src="?call=photo&personid=<?php 
                echo (int) $this->id;
                ?>
" />
				</div>
				<?php 
            }
        }
        if (!$this->id) {
            unset($this->fields['familyid']);
        }
        parent::printForm($prefix, $fields);
        unset($this->fields['photo']);
        if (empty($fields) || in_array('custom', $fields)) {
            $customFields = $this->getCustomFields();
            $dummyField = new Custom_Field();
            if ($customFields) {
                ?>
				<hr />
				<div class="form-horizontal">
				<?php 
                foreach ($customFields as $fieldid => $fieldDetails) {
                    $dummyField->populate($fieldid, $fieldDetails);
                    $tableClass = $fieldDetails['allow_multiple'] ? 'expandable' : '';
                    $values = isset($this->_custom_values[$fieldid]) ? $this->_custom_values[$fieldid] : array('');
                    if ($fieldDetails['divider_before']) {
                        echo '<hr />';
                    }
                    ?>
					<div class="control-group">
						<?php 
                    if (strlen($fieldDetails['heading_before'])) {
                        ?>
								<h4><?php 
                        echo ents($fieldDetails['heading_before']);
                        ?>
</h4>
							<?php 
                    }
                    ?>

						<label class="control-label" for="custom_<?php 
                    echo $fieldid;
                    ?>
"><?php 
                    echo ents($fieldDetails['name']);
                    ?>
</label>
						<div class="controls">
							<table class="<?php 
                    echo $tableClass;
                    ?>
">
							<?php 
                    foreach ($values as $value) {
                        ?>
								<tr><td>
									<?php 
                        $dummyField->printWidget($value);
                        ?>
								</td></tr>
								<?php 
                    }
                    ?>
							</table>
						</div>
					</div>
					<?php 
                }
                ?>
				</div>
				<?php 
            }
        }
    }
コード例 #3
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 
    }