Skip to content
Snippets Groups Projects
class.forms.php 35.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • Jared Hancock's avatar
    Jared Hancock committed
                });
            </script>
            <?php
            if ($config['time'])
                // TODO: Add time picker -- requires time picker or selection with
                //       Misc::timeDropdown
                echo '&nbsp;' . Misc::timeDropdown($hr, $min, $this->name . ':time');
        }
    
        /**
         * Function: getValue
         * Combines the datepicker date value and the time dropdown selected
         * time value into a single date and time string value.
         */
        function getValue() {
    
            $data = $this->field->getSource();
    
            $config = $this->field->getConfiguration();
            if ($datetime = parent::getValue()) {
                $datetime = (is_int($datetime) ? $datetime :
    
                    (($dt = DateTime::createFromFormat($cfg->getDateFormat() . ' G:i',
                            $datetime . ' 00:00'))
                        ? (int) $dt->format('U') : false)
                );
                if ($datetime && isset($data[$this->name . ':time'])) {
    
                    list($hr, $min) = explode(':', $data[$this->name . ':time']);
                    $datetime += $hr * 3600 + $min * 60;
                }
    
                if ($datetime && $config['gmt'])
    
                    $datetime -= (int) (3600 * $_SESSION['TZ_OFFSET'] +
                        ($_SESSION['TZ_DST'] ? date('I',$datetime) : 0));
            }
    
    Jared Hancock's avatar
    Jared Hancock committed
            return $datetime;
        }
    }
    
    
    class SectionBreakWidget extends Widget {
        function render() {
            ?><div class="form-header section-break"><h3><?php
            echo Format::htmlchars($this->field->get('label'));
            ?></h3><em><?php echo Format::htmlchars($this->field->get('hint'));
            ?></em></div>
            <?php
        }
    }
    
    class ThreadEntryWidget extends Widget {
    
        function render($client=null) {
            global $cfg;
    
            ?><div style="margin-bottom:0.5em;margin-top:0.5em"><strong><?php
            echo Format::htmlchars($this->field->get('label'));
            ?></strong>:</div>
    
            <textarea name="<?php echo $this->field->get('name'); ?>"
    
                placeholder="<?php echo Format::htmlchars($this->field->get('hint')); ?>"
                <?php if (!$client) { ?>
                    data-draft-namespace="ticket.staff"
                <?php } else { ?>
                    data-draft-namespace="ticket.client"
                    data-draft-object-id="<?php echo substr(session_id(), -12); ?>"
                <?php } ?>
                class="richtext draft draft-delete ifhtml"
    
                cols="21" rows="8" style="width:80%;"><?php echo
                $this->value; ?></textarea>
        <?php
        }
    
    
        function showAttachments($errors=array()) {
    
            global $cfg, $thisclient;
    
            if(($cfg->allowOnlineAttachments()
                && !$cfg->allowAttachmentsOnlogin())
                || ($cfg->allowAttachmentsOnlogin()
                    && ($thisclient && $thisclient->isValid()))) { ?>
            <hr/>
    
            <div><strong style="padding-right:1em;vertical-align:top">Attachments: </strong>
            <div style="display:inline-block">
            <div class="uploads" style="display:block"></div>
    
            <input type="file" class="multifile" name="attachments[]" id="attachments" size="30" value="" />
    
            <font class="error">&nbsp;<?php echo $errors['attachments']; ?></font>