Ejemplo n.º 1
0
    /**
     * Print an interface to configure parameters for this field if its type is 'select'
     * @param string $prefix
     * @param array $params  Existing params of this field
     */
    public static function printParamsSelect($prefix, $params)
    {
        ?>
		<table class="select-options table-condensed expandable reorderable">
			<thead>
				<tr>
					<td colspan="2">
						Options: &nbsp;
						<small><i>(Drag to re-order)</i></small>
					</td>
					<td><i class="icon-trash"></i></td>
				</tr>
			</thead>
			<tbody>
				<?php 
        $options = array_get($params, 'options', array());
        $options[''] = '';
        $i = 0;
        foreach ($options as $optionID => $optionValue) {
            ?>
					<tr>
						<td class="cursor-move">
							<?php 
            if ($optionID !== '') {
                echo $optionID;
            }
            print_hidden_field($prefix . 'option_ids[]', $optionID);
            ?>
						</td>
						<td>
							<?php 
            print_widget($prefix . 'option_values[]', array('type' => 'text'), $optionValue);
            ?>
						</td>
						<td class="center">
							<?php 
            if ($optionID !== '') {
                ?>
								<input type="checkbox" name="<?php 
                echo $prefix;
                ?>
options_delete[]" value="<?php 
                echo $optionID;
                ?>
"
								data-toggle="strikethrough" data-target="row"
								title="Click to delete this option" />
								<?php 
            }
            ?>
						</td>
					</tr>
					<?php 
            $i++;
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
Ejemplo n.º 2
0
    /**
     * Print the interface for configuring the fields WITHIN this note template
     */
    private function _printFieldsConfiguration()
    {
        $fields = $GLOBALS['system']->getDBObjectData('note_template_field', array('templateid' => $this->id), 'OR', 'rank');
        $fieldTypeParams = array('type' => 'select', 'options' => array('custom' => 'Person Field', 'independent' => 'Independent Field'), 'attrs' => array('data-toggle' => 'visible', 'data-target' => 'row td.template-field-props>*', 'data-match-attr' => 'data-fieldtype'));
        ?>
		<small>When a note is added to a person using this template, the user will be prompted for the
			following fields.  Values that the user supplies for "independent" fields will be saved
			only within the note.  Values for "person" fields are will be saved within the note and will also
			update the corresponding 
			<a href="<?php 
        build_url(array('view' => 'admin__custom_fields'));
        ?>
">custom field</a>
			in the person record.</small>

		<table class="table expandable reorderable">
			<thead>
				<tr>
					<th class="narrow">ID</th>
					<th class="narrow">Type</th>
					<th>Name</th>
					<th>Details</th>
					<th class="narrow"><i class="icon-trash"></i></th>
				</tr>
			</thead>
			<tbody>

			<?php 
        $i = 0;
        $dummyField = new Note_Template_Field();
        // Hack this field because we don't want 'empty' in the dropdown.
        $dummyField->fields['customfieldid']['allow_empty'] = FALSE;
        $fields += array(0 => array());
        foreach ($fields as $id => $field) {
            $prefix = 'fields_' . $i . '_';
            $dummyField->populate($id, $field);
            $dummyField->acquireLock();
            if (!$id) {
                $fieldTypeParams['options'] = array('' => '--Choose new field type--') + $fieldTypeParams['options'];
            }
            ?>
				<tr>
					<td class="narrow cursor-move">
						<?php 
            print_hidden_field('index[]', $i);
            print_hidden_field($prefix . 'id', $id);
            if ($id) {
                echo $id;
            }
            ?>
					</td>
					<td class="narrow">
						<?php 
            $fieldType = $id ? array_get($field, 'customfieldid') ? 'custom' : 'independent' : '';
            print_widget($prefix . 'fieldtype', $fieldTypeParams, $fieldType);
            ?>
					</td>
					<td class="template-field-props">
						<div data-fieldtype="custom">
							<?php 
            $dummyField->printFieldInterface('customfieldid', $prefix);
            ?>
						</div>

						<div data-fieldtype="independent">
							<?php 
            $dummyField->printFieldInterface('label', $prefix);
            ?>
						</div>
					</td>
					<td class="template-field-props">
						<div data-fieldtype="independent">
							&nbsp;Type:
							<?php 
            $dummyField->printFieldInterface('type', $prefix);
            ?>
							<br />
							<?php 
            $dummyField->printFieldInterface('params', $prefix);
            ?>
						</div>

					</td>
					<td>
						<?php 
            if ($id) {
                ?>
							<input type="checkbox" name="<?php 
                echo $prefix;
                ?>
delete" data-toggle="strikethrough" data-target="row" value="<?php 
                echo $id;
                ?>
" />
							<?php 
            }
            ?>
					</td>
				</tr>
				<?php 
            $i++;
        }
        ?>
			</tbody>
		</table>
		<?php 
    }
    function printView()
    {
        if (is_null($this->fields)) {
            return;
        }
        if (empty($this->fields)) {
            ?>
			<p><i>No custom fields have been set up in the system yet.</i></p>
			<?php 
        }
        $field = new Custom_Field();
        $this->fields['_new_'] = $field;
        ?>
		<form method="post">
		<table id="custom-fields-editor" class="table table-auto-width expandable valign-top">
			<thead>
				<tr>
					<th>ID</th>
					<th>Name</th>
					<th>Type</th>
					<th>Multi?</th>
					<th>Parameters</th>
					<th><i class="icon-trash"></i></th>
				</tr>
			</thead>
			<tbody>
			<?php 
        $i = 0;
        foreach ($this->fields as $field) {
            $prefix = 'fields_' . $i . '_';
            ?>
				<tr>
					<td class="cursor-move">
						<?php 
            echo $field->id;
            print_hidden_field($prefix . 'id', $field->id);
            print_hidden_field('index[]', $i);
            ?>
					</td>
					<td>
						<?php 
            $field->printFieldInterface('name', $prefix);
            ?>
					</td>
					<td>
						<?php 
            if ($field->id) {
                $field->printFieldValue('type');
            } else {
                $field->printFieldInterface('type', $prefix);
            }
            ?>
					</td>
					<td class="center">
						<?php 
            $field->printFieldInterface('allow_multiple', $prefix);
            ?>
					</td>
					<td>
						<?php 
            $field->printFieldInterface('params', $prefix);
            ?>
					</td>
					<td class="center">
						<?php 
            if ($field->id) {
                ?>
							<input type="checkbox" name="<?php 
                echo $prefix;
                ?>
delete" value="1"
								   data-toggle="strikethrough" data-target="row"
								   title="Click to delete this field" />
							<?php 
            }
            ?>
					</td>
				</tr>
				<?php 
            $i++;
        }
        ?>
			</tbody>
		</table>
		<input type="submit" class="btn" value="Save" />
		</form>
		<?php 
    }
Ejemplo n.º 4
0
    private function printRunSheetEditor()
    {
        $cong = $GLOBALS['system']->getDBObject('congregation', $this->congregationid);
        $startTime = preg_replace('/[^0-9]/', '', $cong->getValue('meeting_time'));
        $dummyItem = new Service_Item();
        ?>
		<div class="span6">
			<h3>Run Sheet</h3>
			<form method="post" id="service-plan-container" data-lock-length="<?php 
        echo LOCK_LENGTH;
        ?>
">
			<input type="hidden" name="save_service" value="1" />
			<table class="table table-bordered table-condensed no-autofocus" id="service-plan" data-starttime="<?php 
        echo $startTime;
        ?>
">
				<thead>
					<tr>
						<th class="narrow">Start</th>
						<th class="narrow">#</th>
						<th>Item</th>
						<th class="personnel">Personnel</th>
						<th class="narrow">&nbsp</th>
					</tr>
				</thead>

				<tbody>
				<?php 
        $items = $this->service->getItems();
        if (empty($items)) {
            ?>
					<tr id="service-plan-placeholder">
						<td colspan="5" style="padding: 50px; text-align: center">
							<?php 
            if ($this->editing) {
                ?>
								<i>Drag or double-click components to add them to this service</i>
								<?php 
            } else {
                ?>
								<i>This service does not yet have any items</i>
								<?php 
            }
            ?>
						</td>
					</tr>
					<?php 
        } else {
            foreach ($items as $rank => $item) {
                if (strlen($item['heading_text'])) {
                    ?>
							<tr>
								<td colspan="4">
									<input type="text" class="service-heading unfocused" name="" value="<?php 
                    echo ents($item['heading_text']);
                    ?>
" />
								</td>
								<td class="tools">
									<a href="javascript:;" data-action="remove"><i class="icon-trash"></i></a>
								</td>
							</tr>
							<?php 
                }
                ?>
						<tr class="service-item<?php 
                if (empty($item['componentid'])) {
                    echo ' ad-hoc';
                }
                ?>
">
							<td class="start"></td>
							<td class="number"></td>
							<td class="item">
								<span>
								<?php 
                if (!empty($item['runsheet_title_format'])) {
                    $title = $item['runsheet_title_format'];
                    $title = str_replace('%title%', $item['title'], $title);
                    $title = $this->service->replaceKeywords($title);
                } else {
                    $title = $item['title'];
                }
                echo ents($title);
                ?>
								</span>
								<?php 
                print_hidden_field('title[]', $title);
                foreach (array('componentid', 'length_mins', 'show_in_handout') as $k) {
                    ?>
									<input type="hidden" name="<?php 
                    echo $k;
                    ?>
[]" class="<?php 
                    echo $k;
                    ?>
" value="<?php 
                    echo ents($item[$k]);
                    ?>
" />
									<?php 
                }
                ?>
								<textarea name="note[]" class="unfocused" 
									<?php 
                if (!strlen($item['note'])) {
                    echo 'style="display:none" ';
                    echo 'rows="1" ';
                } else {
                    echo 'rows="' . (substr_count($item['note'], "\n") + 1) . '" ';
                }
                ?>
><?php 
                echo ents($item['note']);
                ?>
</textarea>
							</td>
							<td class="personnel"><input class="unfocused" name="personnel[]" type="text" value="<?php 
                echo ents($item['personnel']);
                ?>
" /></td>
							<td class="tools">
								<?php 
                $this->_printTools();
                ?>
							</td>
						</tr>
						<?php 
            }
        }
        ?>
					<tr id="service-item-template">
						<td class="start"></td>
						<td class="number"></td>
						<td class="item">
							<span></span>
							<textarea name="note[]" class="unfocused" rows="1" style="display: none"></textarea>
						</td>
						<td class="personnel"><input name="personnel[]" type="text" value="" /></td>
						<td class="tools"><?php 
        $this->_printTools();
        ?>
</td>
					</tr>
					<tr id="service-heading-template">
						<td colspan="4">
							<input class="service-heading" name="" />
						</td>
						<td class="tools"><a href="javascript:;" data-action="remove"><i class="icon-trash"></i></a></td>
					</tr>

				</tbody>

				<tfoot>
					<tr>
						<td colspan="5">
							<?php 
        $this->printNotesFields();
        ?>
						</td>
					</tr>
					<tr>
						<td colspan="5">
							<button type="submit" class="btn">Save</button>
						</td>
					</tr>
				</tfoot>
			</table>
			</form>

			<div class="modal hide fade-in" id="ad-hoc-modal" role="dialog">
				<div class="modal-header">
					<h4>Add ad-hoc service item</h4>
				</div>
				<div class="modal-body form-horizontal">
					<div class="control-group">
						<label class="control-label">
							Title
						</label>
						<div class="controls">
							<?php 
        $dummyItem->printFieldInterface('title');
        ?>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">
							Show in handout?
						</label>
						<div class="controls">
							<?php 
        $dummyItem->setValue('show_in_handout', 'title');
        $dummyItem->printFieldInterface('show_in_handout');
        ?>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">
							Length
						</label>
						<div class="controls">
							<?php 
        $dummyItem->setValue('length_mins', 2);
        $dummyItem->printFieldInterface('length_mins');
        ?>
							mins
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<input class="btn" type="button" value="Save item" data-action="saveItemDetails" />
					<input class="btn" type="button" value="Cancel" data-dismiss="modal" />
				</div>
				
			</div>
 		</div>
		<?php 
    }