Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isadmin()) die('Access Denied');
$info=array();
$qstr='';
if($dept && $_REQUEST['a']!='add'){
//Editing Department.
$title='Update Department';
$action='update';
$submit_text='Save Changes';
$info=$dept->getInfo();
$info['id']=$dept->getId();
$qstr.='&id='.$dept->getId();
}else {
$title='Add New Department';
$action='create';
$submit_text='Create Dept';
$info['ispublic']=isset($info['ispublic'])?$info['ispublic']:1;
$info['ticket_auto_response']=isset($info['ticket_auto_response'])?$info['ticket_auto_response']:1;
$info['message_auto_response']=isset($info['message_auto_response'])?$info['message_auto_response']:1;
$qstr.='&a='.$_REQUEST['a'];
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
<form action="departments.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>Department</h2>
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php echo $title; ?></h4>
<em>Department Information</em>
</th>
</tr>
</thead>
<tbody>
<tr>
<td width="180" class="required">
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">
Type:
</td>
<td>
<input type="radio" name="ispublic" value="1" <?php echo $info['ispublic']?'checked="checked"':''; ?>><strong>Public</strong>
<input type="radio" name="ispublic" value="0" <?php echo !$info['ispublic']?'checked="checked"':''; ?>><strong>Private</strong> (Internal)
<span class="error">* </span>
</td>
</tr>
<tr>
<td width="180" class="required">
Email:
</td>
<td>
<select name="email_id">
<option value="0">— Select Department Email —</option>
<?php
$sql='SELECT email_id,email,name FROM '.EMAIL_TABLE.' email ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)){
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);
}
}
?>
</select>
<span class="error">* <?php echo $errors['email_id']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Template:
</td>
<td>
<select name="tpl_id">
<option value="0">— System default —</option>
<?php
$sql='SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_TABLE.' tpl WHERE isactive=1 ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$selected=($info['tpl_id'] && $id==$info['tpl_id'])?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
}
}
?>
</select>
<span class="error">* <?php echo $errors['tpl_id']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
SLA:
</td>
<td>
<select name="sla_id">
<option value="0">— System 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>
</td>
</tr>
<?php
if($dept && $dept->getNumUsers()){ ?>
<tr>
<td width="180" class="required">
Manager:
</td>
<td>
<select name="manager_id">
<option value="0">— None —</option>
<option value="0" disabled="disabled">Select Department Manager (Optional)</option>
<?php
$sql='SELECT staff_id,CONCAT_WS(" ",firstname,lastname) as name FROM '.STAFF_TABLE.' staff '.
'WHERE dept_id='.db_input($dept->getId()).' ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$selected=($info['manager_id'] && $id==$info['manager_id'])?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$selected,$name);
}
}
?>
</select>
<span class="error"> <?php echo $errors['manager_id']; ?></span>
</td>
</tr>
<?php } ?>
<tr>
<th colspan="2">
<em><strong>Auto Response Settings</strong>: Overwrite global auto-response settings for tickets routed to the Dept.</em>
</th>
</tr>
<tr>
<td width="180">
New Ticket:
</td>
<td>
<input type="checkbox" name="ticket_auto_response" value="0" <?php echo !$info['ticket_auto_response']?'checked="checked"':''; ?> >
<strong>Disable</strong> new ticket auto-response for this Dept.
</td>
</tr>
<tr>
<td width="180">
New Message:
</td>
<td>
<input type="checkbox" name="message_auto_response" value="0" <?php echo !$info['message_auto_response']?'checked="checked"':''; ?> >
<strong>Disable</strong> new message auto-response for this Dept.
</td>
</tr>
<tr>
<td width="180">
Auto Response Email:
</td>
<td>
<select name="autoresp_email_id">
<option value="" disabled="disabled">Select Outgoing Email</option>
<option value="0">— Department Email (Above) —</option>
<?php
$sql='SELECT email_id,email,name FROM '.EMAIL_TABLE.' email ORDER by name';
if(($res=db_query($sql)) && db_num_rows($res)){
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);
}
}
?>
</select>
<span class="error"> <?php echo $errors['autoresp_email_id']; ?></span>
</td>
</tr>
<tr>
<th colspan="2">
<em><strong>Department Signature</strong>: Optional signature used on outgoing emails. <span class="error"> <?php echo $errors['signature']; ?></span></em>
</th>
</tr>
<tr>
<td colspan=2>
<textarea name="signature" cols="21" rows="5" style="width: 60%;"><?php echo $info['signature']; ?></textarea>
<br><em>Signature is made available as a choice, on ticket reply, for public departments.</em>
</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="departments.php"'>
</p>
</form>