Skip to content
Snippets Groups Projects
cannedresponse.inc.php 6.13 KiB
Newer Older
Jared Hancock's avatar
Jared Hancock committed
<?php
if(!defined('OSTSCPINC') || !$thisstaff) die('Access Denied');
Peter Rotich's avatar
Peter Rotich committed
$info=$qs = array();
Jared Hancock's avatar
Jared Hancock committed
if($canned && $_REQUEST['a']!='add'){
    $title=__('Update Canned Response');
Jared Hancock's avatar
Jared Hancock committed
    $action='update';
    $submit_text=__('Save Changes');
Jared Hancock's avatar
Jared Hancock committed
    $info=$canned->getInfo();
    $info['id']=$canned->getId();
Peter Rotich's avatar
Peter Rotich committed
    $qs += array('id' => $canned->getId());
    // Replace cid: scheme with downloadable URL for inline images
    $info['response'] = $canned->getResponseWithImages();
    $info['notes'] = Format::viewableImages($info['notes']);
Jared Hancock's avatar
Jared Hancock committed
}else {
    $title=__('Add New Canned Response');
Jared Hancock's avatar
Jared Hancock committed
    $action='create';
    $submit_text=__('Add Response');
Jared Hancock's avatar
Jared Hancock committed
    $info['isenabled']=isset($info['isenabled'])?$info['isenabled']:1;
Peter Rotich's avatar
Peter Rotich committed
    $qs += array('a' => $_REQUEST['a']);
Jared Hancock's avatar
Jared Hancock committed
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);

?>
Peter Rotich's avatar
Peter Rotich committed
<form action="canned.php?<?php echo Http::build_query($qs); ?>" method="post" id="save" enctype="multipart/form-data">
 <?php csrf_token(); ?>
Jared Hancock's avatar
Jared Hancock committed
 <input type="hidden" name="do" value="<?php echo $action; ?>">
 <input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
 <input type="hidden" name="id" value="<?php echo $info['id']; ?>">
 <h2><?php echo __('Canned Response')?>
 &nbsp;<i class="help-tip icon-question-sign" href="#canned_response"></i></h2>
 <table class="form_table fixed" width="940" border="0" cellspacing="0" cellpadding="2">
Jared Hancock's avatar
Jared Hancock committed
    <thead>
        <tr><td></td><td></td></tr> <!-- For fixed table layout -->
Jared Hancock's avatar
Jared Hancock committed
        <tr>
            <th colspan="2">
                <h4><?php echo $title; ?></h4>
                <em><?php echo __('Canned response settings');?></em>
Jared Hancock's avatar
Jared Hancock committed
            </th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td width="180" class="required"><?php echo __('Status');?>:</td>
Jared Hancock's avatar
Jared Hancock committed
            <td>
                <label><input type="radio" name="isenabled" value="1" <?php
                    echo $info['isenabled']?'checked="checked"':''; ?>>&nbsp;<?php echo __('Active'); ?>&nbsp;</label>
                <label><input type="radio" name="isenabled" value="0" <?php
                        echo !$info['isenabled']?'checked="checked"':''; ?>>&nbsp;<?php echo __('Disabled'); ?>&nbsp;</label>
Jared Hancock's avatar
Jared Hancock committed
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['isenabled']; ?></span>
            </td>
        </tr>
        <tr>
            <td width="180" class="required"><?php echo __('Department');?>:</td>
Jared Hancock's avatar
Jared Hancock committed
            <td>
                <select name="dept_id">
                    <option value="0">&mdash; <?php echo __('All Departments');?> &mdash;</option>
Jared Hancock's avatar
Jared Hancock committed
                    <?php
                    if (($depts=Dept::getDepartments())) {
                        foreach($depts as $id => $name) {
Jared Hancock's avatar
Jared Hancock committed
                            $selected=($info['dept_id'] && $id==$info['dept_id'])?'selected="selected"':'';
                            echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
                        }
                    }
                    ?>
                </select>
                &nbsp;<span class="error">*&nbsp;<?php echo $errors['dept_id']; ?></span>
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <em><strong><?php echo __('Canned Response');?></strong>: <?php echo __('Make the title short and clear.');?>&nbsp;</em>
Jared Hancock's avatar
Jared Hancock committed
            </th>
        </tr>
        <tr>
            <td colspan=2>
                <div><b><?php echo __('Title');?></b><span class="error">*&nbsp;<?php echo $errors['title']; ?></span></div>
Jared Hancock's avatar
Jared Hancock committed
                <input type="text" size="70" name="title" value="<?php echo $info['title']; ?>">
                <br><br>
                <div style="margin-bottom:0.5em"><b><?php echo __('Canned Response'); ?></b>
                    <font class="error">*&nbsp;<?php echo $errors['response']; ?></font>
                    &nbsp;&nbsp;&nbsp;(<a class="tip" href="#ticket_variables"><?php echo __('Supported Variables'); ?></a>)
                <textarea name="response" cols="21" rows="12"
                    data-root-context="cannedresponse"
                    style="width:98%;" class="richtext draft draft-delete" <?php
    list($draft, $attrs) = Draft::getDraftAndDataAttrs('canned',
        is_object($canned) ? $canned->getId() : false, $info['response']);
    echo $attrs; ?>><?php echo $draft ?: $info['response'];
                ?></textarea>
                <div><h3><?php echo __('Canned Attachments'); ?> <?php echo __('(optional)'); ?>
                &nbsp;<i class="help-tip icon-question-sign" href="#canned_attachments"></i></h3>
                <div class="error"><?php echo $errors['files']; ?></div>
Jared Hancock's avatar
Jared Hancock committed
                </div>
                $attachments = $canned_form->getField('attachments');
                if ($canned && ($files=$canned->getAttachedFiles())) {
                    $ids = array();
                    foreach ($files as $f)
                }
                print $attachments->render(); ?>
Jared Hancock's avatar
Jared Hancock committed
            </td>
        </tr>
        <tr>
            <th colspan="2">
                <em><strong><?php echo __('Internal Notes');?></strong>: <?php echo __('Notes about the canned response.');?>&nbsp;</em>
Jared Hancock's avatar
Jared Hancock committed
            </th>
        </tr>
        <tr>
            <td colspan=2>
                <textarea class="richtext no-bar" name="notes" cols="21"
                    rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
Jared Hancock's avatar
Jared Hancock committed
            </td>
        </tr>
    </tbody>
</table>
 <?php if ($canned && $canned->getFilters()) { ?>
    <div id="msg_warning"><?php echo __('Canned response is in use by email filter(s)');?>: <?php
    echo implode(', ', $canned->getFilters()); ?></div>
Jared Hancock's avatar
Jared Hancock committed
<p style="padding-left:225px;">
    <input type="submit" name="submit" value="<?php echo $submit_text; ?>">
    <input type="reset"  name="reset"  value="<?php echo __('Reset'); ?>" onclick="javascript:
        $(this.form).find('textarea.richtext')
            .redactor('deleteDraft');
        location.reload();" />
    <input type="button" name="cancel" value="<?php echo __('Cancel'); ?>" onclick='window.location.href="canned.php"'>
Jared Hancock's avatar
Jared Hancock committed
</p>
</form>