diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index a2bef2a62da7e27e60559d17c4f7bece216fe8ab..7d7c73aa6a9482e42240b2581ea78f44d0157e68 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -930,7 +930,13 @@ class SelectionField extends FormField { 'id'=>1, 'label'=>'Widget', 'required'=>false, 'default'=>false, 'choices'=>array(false=>'Drop Down', true=>'Typeahead'), - 'hint'=>'Typeahead will work better for large lists')), + 'hint'=>'Typeahead will work better for large lists' + )), + 'prompt' => new TextboxField(array( + 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', + 'hint'=>'Leading text shown before a value is selected', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -945,7 +951,7 @@ class SelectionField extends FormField { } class SelectionWidget extends ChoicesWidget { - function render() { + function render($mode=false) { $config = $this->field->getConfiguration(); $value = false; if ($this->value instanceof DynamicListItem) { @@ -957,9 +963,9 @@ class SelectionWidget extends ChoicesWidget { $value = $this->value; $name = $this->getEnteredValue(); } - if (!$config['typeahead']) { + if (!$config['typeahead'] || $mode=='search') { $this->value = $value; - return parent::render(); + return parent::render($mode); } $source = array(); @@ -972,7 +978,8 @@ class SelectionWidget extends ChoicesWidget { <span style="display:inline-block"> <input type="text" size="30" name="<?php echo $this->name; ?>" id="<?php echo $this->name; ?>" value="<?php echo $name; ?>" - autocomplete="off" /> + placeholder="<?php echo $config['prompt']; + ?>" autocomplete="off" /> <input type="hidden" name="<?php echo $this->name; ?>_id" id="<?php echo $this->name; ?>_id" value="<?php echo $value; ?>"/> <script type="text/javascript"> diff --git a/include/class.forms.php b/include/class.forms.php index 538515c760130318403402a9298d7658fc8f09f1..2bbb04a66559d7264816968e2ce023b9b271e083 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -509,6 +509,11 @@ class TextboxField extends FormField { 'id'=>4, 'label'=>'Validation Error', 'default'=>'', 'configuration'=>array('size'=>40, 'length'=>60), 'hint'=>'Message shown to user if the input does not match the validator')), + 'placeholder' => new TextboxField(array( + 'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'', + 'hint'=>'Text shown in before any input from the user', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -568,6 +573,11 @@ class TextareaField extends FormField { 'html' => new BooleanField(array( 'id'=>4, 'label'=>'HTML', 'required'=>false, 'default'=>true, 'configuration'=>array('desc'=>'Allow HTML input in this box'))), + 'placeholder' => new TextboxField(array( + 'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'', + 'hint'=>'Text shown in before any input from the user', + 'configuration'=>array('size'=>40, 'length'=>40), + )), ); } @@ -688,7 +698,7 @@ class ChoiceField extends FormField { )), 'prompt' => new TextboxField(array( 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', - 'hint'=>'Text shown in the drop-down select before a value is selected', + 'hint'=>'Leading text shown before a value is selected', 'configuration'=>array('size'=>40, 'length'=>40), )), ); @@ -896,7 +906,13 @@ class PriorityField extends ChoiceField { } function getConfigurationOptions() { - return array(); + return array( + 'prompt' => new TextboxField(array( + 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', + 'hint'=>'Leading text shown before a value is selected', + 'configuration'=>array('size'=>40, 'length'=>40), + )), + ); } } FormField::addFieldTypes('Built-in Lists', function() { @@ -949,7 +965,8 @@ class TextboxWidget extends Widget { <input type="<?php echo static::$input_type; ?>" id="<?php echo $this->name; ?>" <?php echo $size . " " . $maxlength; ?> - <?php echo $classes.' '.$autocomplete; ?> + <?php echo $classes.' '.$autocomplete + .' placeholder="'.$config['placeholder'].'"'; ?> name="<?php echo $this->name; ?>" value="<?php echo Format::htmlchars($this->value); ?>"/> </span> @@ -984,7 +1001,8 @@ class TextareaWidget extends Widget { $class = 'class="richtext no-bar small"'; ?> <span style="display:inline-block;width:100%"> - <textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class; ?> + <textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class + .' placeholder="'.$config['placeholder'].'"'; ?> name="<?php echo $this->name; ?>"><?php echo Format::htmlchars($this->value); ?></textarea> @@ -1021,20 +1039,27 @@ class PhoneNumberWidget extends Widget { } class ChoicesWidget extends Widget { - function render() { + function render($mode=false) { $config = $this->field->getConfiguration(); // Determine the value for the default (the one listed if nothing is // selected) $choices = $this->field->getChoices(); - $def_key = $this->field->get('default'); - if (!$def_key && $config['default']) - $def_key = $config['default']; - $have_def = isset($choices[$def_key]); - if (!$have_def) + // We don't consider the 'default' when rendering in 'search' mode + $have_def = false; + if ($mode != 'search') { + $def_key = $this->field->get('default'); + if (!$def_key && $config['default']) + $def_key = $config['default']; + $have_def = isset($choices[$def_key]); + if (!$have_def) + $def_val = ($config['prompt']) + ? $config['prompt'] : 'Select'; + else + $def_val = $choices[$def_key]; + } else { $def_val = ($config['prompt']) - ? $config['prompt'] : 'Select'; - else - $def_val = $choices[$def_key]; + ? $config['prompt'] : 'Select'; + } $value = $this->value; if ($value === null && $have_def) $value = $def_key; diff --git a/include/class.ticket.php b/include/class.ticket.php index fd407d922896498450ff72ed93ad78a70895e584..855d4650431164713b28c85ee2390e4482c7f258 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -109,8 +109,8 @@ class Ticket { if (!$this->_answers) { foreach (DynamicFormEntry::forTicket($this->getId(), true) as $form) foreach ($form->getAnswers() as $answer) - $this->_answers[$answer->getField()->get('name')] - = $answer; + if ($tag = mb_strtolower($answer->getField()->get('name'))) + $this->_answers[$tag] = $answer; } } @@ -1252,6 +1252,7 @@ class Ticket { return $this->getOwner(); break; default: + $tag = mb_strtolower($tag); if (isset($this->_answers[$tag])) // The answer object is retrieved here which will // automatically invoke the toString() method when the @@ -2184,7 +2185,7 @@ class Ticket { $fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic'); break; case 'staff': - $fields['deptId'] = array('type'=>'int', 'required'=>1, 'error'=>'Dept. required'); + $fields['deptId'] = array('type'=>'int', 'required'=>0, 'error'=>'Dept. required'); $fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Topic required'); $fields['duedate'] = array('type'=>'date', 'required'=>0, 'error'=>'Invalid date - must be MM/DD/YY'); case 'api': diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index a5e0505304dccc59be810befbc061a15ab28d462..ea3c0d64b30014271d41384ba1247b6a60ea6447 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -101,8 +101,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </td> <td> <select name="source"> - <option value="" selected >— Select Source —</option> - <option value="Phone" <?php echo ($info['source']=='Phone')?'selected="selected"':''; ?>>Phone</option> + <option value="Phone" <?php echo ($info['source']=='Phone')?'selected="selected"':''; ?> selected="selected">Phone</option> <option value="Email" <?php echo ($info['source']=='Email')?'selected="selected"':''; ?>>Email</option> <option value="Other" <?php echo ($info['source']=='Other')?'selected="selected"':''; ?>>Other</option> </select> @@ -111,46 +110,55 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <tr> <td width="160" class="required"> - Department: + Help Topic: </td> <td> - <select name="deptId"> - <option value="" selected >— Select Department —</option> + <select name="topicId" onchange="javascript: + $('#dynamic-form').load( + 'ajax.php/form/help-topic/' + this.value); + "> <?php - if($depts=Dept::getDepartments()) { - foreach($depts as $id =>$name) { - echo sprintf('<option value="%d" %s>%s</option>', - $id, ($info['deptId']==$id)?'selected="selected"':'',$name); + if ($topics=Topic::getHelpTopics()) { + if (count($topics) == 1) + $selected = 'selected="selected"'; + else { ?> + <option value="" selected >— Select Help Topic —</option> +<?php } + foreach($topics as $id =>$name) { + echo sprintf('<option value="%d" %s %s>%s</option>', + $id, ($info['topicId']==$id)?'selected="selected"':'', + $selected, $name); + } + if (count($topics) == 1 && !$form) { + $T = Topic::lookup($id); + $form = DynamicForm::lookup($T->ht['form_id']); } } ?> </select> - <font class="error"><b>*</b> <?php echo $errors['deptId']; ?></font> + <font class="error"><b>*</b> <?php echo $errors['topicId']; ?></font> </td> </tr> - <tr> - <td width="160" class="required"> - Help Topic: + <td width="160"> + Department: </td> <td> - <select name="topicId" onchange="javascript: - $('#dynamic-form').load( - 'ajax.php/form/help-topic/' + this.value); - "> - <option value="" selected >— Select Help Topic —</option> + <select name="deptId"> + <option value="" selected >— Select Department —</option> <?php - if($topics=Topic::getHelpTopics()) { - foreach($topics as $id =>$name) { + if($depts=Dept::getDepartments()) { + foreach($depts as $id =>$name) { echo sprintf('<option value="%d" %s>%s</option>', - $id, ($info['topicId']==$id)?'selected="selected"':'',$name); + $id, ($info['deptId']==$id)?'selected="selected"':'',$name); } } ?> </select> - <font class="error"><b>*</b> <?php echo $errors['topicId']; ?></font> + <font class="error"><?php echo $errors['deptId']; ?></font> </td> </tr> + <tr> <td width="160"> SLA Plan: diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php index d72982411337e76705d4d66d3601c7f1869162f3..c8fca5ee60c1af3861e7d5e37d6fbf53013cc52a 100644 --- a/include/staff/tickets.inc.php +++ b/include/staff/tickets.inc.php @@ -634,7 +634,8 @@ if ($results) { elseif (!$f->hasData()) continue; ?><label><?php echo $f->getLabel(); ?>:</label> - <div style="display:inline-block;width: 12.5em;"><?php $f->render(); ?></div> + <div style="display:inline-block;width: 12.5em;"><?php + $f->render('search'); ?></div> <?php } ?> </fieldset> <p>