Newer
Older
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$matches=Filter::getSupportedMatches();
$match_types=Filter::getSupportedMatchTypes();
$info=array();
$qstr='';
if($filter && $_REQUEST['a']!='add'){
$title='Update Filter';
$action='update';
$submit_text='Save Changes';
$info=array_merge($filter->getInfo(),$filter->getFlatRules());
$info['id']=$filter->getId();
$qstr.='&id='.$filter->getId();
}else {
$title='Add New Filter';
$action='add';
$submit_text='Add Filter';
$info['isactive']=isset($info['isactive'])?$info['isactive']:0;
$qstr.='&a='.urlencode($_REQUEST['a']);
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
<form action="filters.php?<?php echo $qstr; ?>" method="post" id="save">
<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>Incoming Email Filter</h2>
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php echo $title; ?></h4>
<em>Filters are executed based on execution order. Filter can target specific ticket source.</em>
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</th>
</tr>
</thead>
<tbody>
<tr>
<td width="180" class="required">
Filter Name:
</td>
<td>
<input type="text" size="30" name="name" value="<?php echo $info['name']; ?>">
<span class="error">* <?php echo $errors['name']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Execution Order:
</td>
<td>
<input type="text" size="6" name="execorder" value="<?php echo $info['execorder']; ?>">
<em>(1...99 )</em>
<span class="error">* <?php echo $errors['execorder']; ?></span>
<input type="checkbox" name="stop_onmatch" value="1" <?php echo $info['stop_onmatch']?'checked="checked"':''; ?> >
<strong>Stop</strong> processing further on match!
</td>
</tr>
<tr>
<td width="180" class="required">
Filter Status:
</td>
<td>
<input type="radio" name="isactive" value="1" <?php echo $info['isactive']?'checked="checked"':''; ?>><strong>Active</strong>
<input type="radio" name="isactive" value="0" <?php echo !$info['isactive']?'checked="checked"':''; ?>>Disabled
<span class="error">* </span>
</td>
</tr>
<tr>
<td width="180" class="required">
Target:
<option value="">— Select a Target ‐</option>
<?php
foreach(Filter::getTargets() as $k => $v) {
echo sprintf('<option value="%s" %s>%s</option>',
$k, (($k==$info['target'])?'selected="selected"':''), $v);
}
$sql='SELECT email_id,email,name FROM '.EMAIL_TABLE.' email ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)) {
echo '<OPTGROUP label="Specific System Email">';
while(list($id,$email,$name)=db_fetch_row($res)) {
$selected=($info['email_id'] && $id==$info['email_id'])?'selected="selected"':'';
if($name)
$email=Format::htmlchars("$name <$email>");
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$email);
}
<span class="error">* <?php echo $errors['target']; ?></span>
<em><strong>Filter Rules</strong>: Rules are applied based on the criteria. <span class="error">* <?php echo $errors['rules']; ?></span></em>
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
</th>
</tr>
<tr>
<td colspan=2>
<em>Rules Matching Criteria:</em>
<input type="radio" name="match_all_rules" value="1" <?php echo $info['match_all_rules']?'checked="checked"':''; ?>>Match All
<input type="radio" name="match_all_rules" value="0" <?php echo !$info['match_all_rules']?'checked="checked"':''; ?>>Match Any
<span class="error">* </span>
<em>(case-insensitive comparison)</em>
</td>
</tr>
<?php
$n=($filter?$filter->getNumRules():0)+2; //2 extra rules of unlimited.
for($i=1; $i<=$n; $i++){ ?>
<tr id="r<?php echo $i; ?>">
<td colspan="2">
<div style="width:700; float:left;">
<select name="rule_w<?php echo $i; ?>">
<option value="">— Select One ‐</option>
<?php
foreach($matches as $k=>$v){
$sel=($info["rule_w$i"]==$k)?'selected="selected"':'';
echo sprintf('<option value="%s" %s>%s</option>',$k,$sel,$v);
}
?>
</select>
<select name="rule_h<?php echo $i; ?>">
<option value="0">— Select One ‐</option>
<?php
foreach($match_types as $k=>$v){
$sel=($info["rule_h$i"]==$k)?'selected="selected"':'';
echo sprintf('<option value="%s" %s>%s</option>',$k,$sel,$v);
}
?>
</select>
<input type="text" size="30" name="rule_v<?php echo $i; ?>" value="<?php echo $info["rule_v$i"]; ?>">
<span class="error"> <?php echo $errors["rule_$i"]; ?></span>
</div>
<?php
if($info["rule_w$i"] || $info["rule_h$i"] || $info["rule_v$i"]){ ?>
<div style="float:right;text-align:right;padding-right:20px;"><a href="#" class="clearrule">(clear)</a></div>
<?php
} ?>
<div class="clear"></div>
</td>
</tr>
<?php
if($i>=25) //Hardcoded limit of 25 rules...also see class.filter.php
break;
} ?>
<tr>
<th colspan="2">
<em><strong>Filter Actions</strong>: Can be overwriten by other filters depending on processing order. </em>
</th>
</tr>
<tr>
<td width="180">
<input type="checkbox" name="reject_ticket" value="1" <?php echo $info['reject_ticket']?'checked="checked"':''; ?> >
<strong><font class="error">Reject Ticket</font></strong> <em>(All other actions and filters are ignored)</em>
</td>
</tr>
<tr>
<td width="180">
Reply-To Email:
</td>
<td>
<input type="checkbox" name="use_replyto_email" value="1" <?php echo $info['use_replyto_email']?'checked="checked"':''; ?> >
<strong>Use</strong> Reply-To Email <em>(if available)</em>
</td>
</tr>
<tr>
<td width="180">
Ticket auto-response:
</td>
<td>
<input type="checkbox" name="disable_autoresponder" value="1" <?php echo $info['disable_autoresponder']?'checked="checked"':''; ?> >
<strong>Disable</strong> auto-response. <em>(Overwrites Dept. settings)</em>
</td>
</tr>
<tr>
<td width="180">
Canned Response:
</td>
<td>
<select name="canned_response_id">
<option value="">— None —</option>
<?php
$sql='SELECT canned_id,title FROM '.CANNED_TABLE
.' WHERE isenabled ORDER by title';
if ($res=db_query($sql)) {
while (list($id,$title)=db_fetch_row($res)) {
$selected=($info['canned_response_id'] &&
$id==$info['canned_response_id'])
? 'selected="selected"' : '';
echo sprintf('<option value="%d" %s>%s</option>',
$id, $selected, $title);
}
}
?>
</select>
<em>(Automatically respond with this canned response)</em>
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<tr>
<td width="180">
Department:
</td>
<td>
<select name="dept_id">
<option value="">— Default —</option>
<?php
$sql='SELECT dept_id,dept_name FROM '.DEPT_TABLE.' dept ORDER by dept_name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$selected=($info['dept_id'] && $id==$info['dept_id'])?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
}
}
?>
</select>
<span class="error">* <?php echo $errors['dept_id']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Priority:
</td>
<td>
<select name="priority_id">
<option value="">— Default —</option>
<?php
$sql='SELECT priority_id,priority_desc FROM '.PRIORITY_TABLE.' pri ORDER by priority_urgency DESC';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$selected=($info['priority_id'] && $id==$info['priority_id'])?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
}
}
?>
</select>
<span class="error">* <?php echo $errors['priority_id']; ?></span>
<em>(Overwrites department's priority)</em>
</td>
</tr>
<tr>
<td width="180">
SLA Plan:
</td>
<td>
<select name="sla_id">
<option value="0">— Default —</option>
<?php
$sql='SELECT id,name FROM '.SLA_TABLE.' sla ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$selected=($info['sla_id'] && $id==$info['sla_id'])?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
}
}
?>
</select>
<span class="error"> <?php echo $errors['sla_id']; ?></span>
<em>(Overwrites department's SLA)</em>
</td>
</tr>
<tr>
<td width="180">
Auto-assign To:
</td>
<td>
<select name="assign">
<option value="0">— Unassigned —</option>
<?php
$sql=' SELECT staff_id,CONCAT_WS(", ",lastname,firstname) as name '.
' FROM '.STAFF_TABLE.' WHERE isactive=1 ORDER BY name';
if(($res=db_query($sql)) && db_num_rows($res)){
echo '<OPTGROUP label="Staff Members">';
while (list($id,$name) = db_fetch_row($res)){
$k="s$id";
$selected = ($info['assign']==$k || $info['staff_id']==$id)?'selected="selected"':'';
?>
<option value="<?php echo $k; ?>"<?php echo $selected; ?>><?php echo $name; ?></option>
<?php }
echo '</OPTGROUP>';
}
$sql='SELECT team_id, name FROM '.TEAM_TABLE.' WHERE isenabled=1';
if(($res=db_query($sql)) && db_num_rows($res)){
echo '<OPTGROUP label="Teams">';
while (list($id,$name) = db_fetch_row($res)){
$k="t$id";
$selected = ($info['assign']==$k || $info['team_id']==$id)?'selected="selected"':'';
?>
<option value="<?php echo $k; ?>"<?php echo $selected; ?>><?php echo $name; ?></option>
<?php
}
echo '</OPTGROUP>';
}
?>
</select>
<span class="error"> <?php echo $errors['assign']; ?></span>
</td>
</tr>
<tr>
<th colspan="2">
<em><strong>Admin Notes</strong>: Internal notes. </em>
</th>
</tr>
<tr>
<td colspan=2>
<textarea name="notes" cols="21" rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
</td>
</tr>
</tbody>
</table>
<p style="padding-left:225px;">
<input type="submit" name="submit" value="<?php echo $submit_text; ?>">
<input type="reset" name="reset" value="Reset">
<input type="button" name="cancel" value="Cancel" onclick='window.location.href="filters.php"'>
</p>
</form>