Newer
Older
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$info=array();
$qstr='';
if($staff && $_REQUEST['a']!='add'){
//Editing Department.
$title='Update Staff';
$action='update';
$submit_text='Save Changes';
$passwd_text='To reset the password enter a new one below';
$info=$staff->getInfo();
$info['id']=$staff->getId();
$info['teams'] = $staff->getTeams();
$info['signature'] = Format::viewableImages($info['signature']);
$qstr.='&id='.$staff->getId();
}else {
$title='Add New Staff';
$action='create';
$submit_text='Add Staff';
$passwd_text='Temporary password required only for "Local" authenication';
//Some defaults for new staff.
$info['change_passwd']=1;
$qstr.='&a=add';
}
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
<form action="staff.php?<?php echo $qstr; ?>" method="post" id="save" autocomplete="off">
<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>Staff Account</h2>
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php echo $title; ?></h4>
<em><strong>User Information</strong></em>
</th>
</tr>
</thead>
<tbody>
<tr>
<td width="180" class="required">
Username:
</td>
<td>
<input type="text" size="30" class="staff-username typeahead"
name="username" value="<?php echo $info['username']; ?>">
<span class="error">* <?php echo $errors['username']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
First Name:
</td>
<td>
<input type="text" size="30" name="firstname" class="auto first"
value="<?php echo $info['firstname']; ?>">
<span class="error">* <?php echo $errors['firstname']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Last Name:
</td>
<td>
<input type="text" size="30" name="lastname" class="auto last"
value="<?php echo $info['lastname']; ?>">
<span class="error">* <?php echo $errors['lastname']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Email Address:
</td>
<td>
<input type="text" size="30" name="email" class="auto email"
value="<?php echo $info['email']; ?>">
<span class="error">* <?php echo $errors['email']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Phone Number:
</td>
<td>
<input type="text" size="18" name="phone" class="auto phone"
value="<?php echo $info['phone']; ?>">
<span class="error"> <?php echo $errors['phone']; ?></span>
Ext <input type="text" size="5" name="phone_ext" value="<?php echo $info['phone_ext']; ?>">
<span class="error"> <?php echo $errors['phone_ext']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Mobile Number:
</td>
<td>
<input type="text" size="18" name="mobile" class="auto mobile"
value="<?php echo $info['mobile']; ?>">
<span class="error"> <?php echo $errors['mobile']; ?></span>
</td>
</tr>
<?php if (!$staff) { ?>
<tr>
<td width="180">Welcome Email</td>
<td><input type="checkbox" name="welcome_email" id="welcome-email" <?php
if ($info['welcome_email']) echo 'checked="checked"';
?> onchange="javascript:
var sbk = $('#backend-selection');
if ($(this).is(':checked'))
$('#password-fields').hide();
else if (sbk.val() == '' || sbk.val() == 'local')
$('#password-fields').show();
" />
Send staff welcome email with account access link
</td>
</tr>
<?php } ?>
<em><strong>Authentication</strong>: <?php echo $passwd_text; ?> <span class="error"> <?php echo $errors['temppasswd']; ?></span></em>
<tr>
<td>Authentication Backend</td>
<td>
<select name="backend" id="backend-selection" onchange="javascript:
if (this.value != '' && this.value != 'local')
$('#password-fields').hide();
else if (!$('#welcome-email').is(':checked'))
$('#password-fields').show();
">
<option value="">— Use any available backend —</option>
<?php foreach (StaffAuthenticationBackend::allRegistered() as $ab) {
if (!$ab->supportsAuthentication()) continue; ?>
<option value="<?php echo $ab::$id; ?>" <?php
if ($info['backend'] == $ab::$id)
echo 'selected="selected"'; ?>><?php
echo $ab::$name; ?></option>
<?php } ?>
</select>
</td>
</tr>
</tbody>
<tbody id="password-fields" style="<?php
if ($info['welcome_email'] || ($info['backend'] && $info['backend'] != 'local'))
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
<tr>
<td width="180">
Password:
</td>
<td>
<input type="password" size="18" name="passwd1" value="<?php echo $info['passwd1']; ?>">
<span class="error"> <?php echo $errors['passwd1']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Confirm Password:
</td>
<td>
<input type="password" size="18" name="passwd2" value="<?php echo $info['passwd2']; ?>">
<span class="error"> <?php echo $errors['passwd2']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Forced Password Change:
</td>
<td>
<input type="checkbox" name="change_passwd" value="0" <?php echo $info['change_passwd']?'checked="checked"':''; ?>>
<strong>Force</strong> password change on next login.
</td>
</tr>
<tr>
<th colspan="2">
<em><strong>Staff's Signature</strong>: Optional signature used on outgoing emails. <span class="error"> <?php echo $errors['signature']; ?></span></em>
</th>
</tr>
<tr>
<td colspan=2>
<textarea class="richtext no-bar" name="signature" cols="21"
rows="5" style="width: 60%;"><?php echo $info['signature']; ?></textarea>
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
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
<br><em>Signature is made available as a choice, on ticket reply.</em>
</td>
</tr>
<tr>
<th colspan="2">
<em><strong>Account Status & Settings</strong>: Dept. and assigned group controls access permissions.</em>
</th>
</tr>
<tr>
<td width="180" class="required">
Account Type:
</td>
<td>
<input type="radio" name="isadmin" value="1" <?php echo $info['isadmin']?'checked="checked"':''; ?>>
<font color="red"><strong>Admin</strong></font>
<input type="radio" name="isadmin" value="0" <?php echo !$info['isadmin']?'checked="checked"':''; ?>><strong>Staff</strong>
<span class="error"> <?php echo $errors['isadmin']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Account 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"':''; ?>><strong>Locked</strong>
<span class="error"> <?php echo $errors['isactive']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Assigned Group:
</td>
<td>
<select name="group_id" id="group_id">
<option value="0">— Select Group —</option>
<?php
$sql='SELECT group_id, group_name, group_enabled as isactive FROM '.GROUP_TABLE.' ORDER BY group_name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name,$isactive)=db_fetch_row($res)){
$sel=($info['group_id']==$id)?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s %s</option>',$id,$sel,$name,($isactive?'':' (Disabled)'));
}
}
?>
</select>
<span class="error">* <?php echo $errors['group_id']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Primary Department:
</td>
<td>
<select name="dept_id" id="dept_id">
<option value="0">— Select Department —</option>
<?php
$sql='SELECT dept_id, dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$name)=db_fetch_row($res)){
$sel=($info['dept_id']==$id)?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$id,$sel,$name);
}
}
?>
</select>
<span class="error">* <?php echo $errors['dept_id']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
Staff's Time Zone:
</td>
<td>
<select name="timezone_id" id="timezone_id">
<option value="0">— Select Time Zone —</option>
<?php
$sql='SELECT id, offset,timezone FROM '.TIMEZONE_TABLE.' ORDER BY id';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id,$offset, $tz)=db_fetch_row($res)){
$sel=($info['timezone_id']==$id)?'selected="selected"':'';
echo sprintf('<option value="%d" %s>GMT %s - %s</option>',$id,$sel,$offset,$tz);
}
}
?>
</select>
<span class="error">* <?php echo $errors['timezone_id']; ?></span>
</td>
</tr>
<tr>
<td width="180">
Daylight Saving:
</td>
<td>
<input type="checkbox" name="daylight_saving" value="1" <?php echo $info['daylight_saving']?'checked="checked"':''; ?>>
Observe daylight saving
<em>(Current Time: <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['daylight_saving']); ?></strong>)</em>
</td>
</tr>
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
338
339
340
341
<tr>
<td width="180">
Limited Access:
</td>
<td>
<input type="checkbox" name="assigned_only" value="1" <?php echo $info['assigned_only']?'checked="checked"':''; ?>>Limit ticket access to ONLY assigned tickets.
</td>
</tr>
<tr>
<td width="180">
Directory Listing:
</td>
<td>
<input type="checkbox" name="isvisible" value="1" <?php echo $info['isvisible']?'checked="checked"':''; ?>>Show the user on staff's directory
</td>
</tr>
<tr>
<td width="180">
Vacation Mode:
</td>
<td>
<input type="checkbox" name="onvacation" value="1" <?php echo $info['onvacation']?'checked="checked"':''; ?>>
Staff on vacation mode. (<i>No ticket assignment or alerts</i>)
</td>
</tr>
<?php
//List team assignments.
$sql='SELECT team.team_id, team.name, isenabled FROM '.TEAM_TABLE.' team ORDER BY team.name';
if(($res=db_query($sql)) && db_num_rows($res)){ ?>
<tr>
<th colspan="2">
<em><strong>Assigned Teams</strong>: Staff will have access to tickets assigned to a team they belong to regardless of the ticket's department. </em>
</th>
</tr>
<?php
while(list($id,$name,$isactive)=db_fetch_row($res)){
$checked=($info['teams'] && in_array($id,$info['teams']))?'checked="checked"':'';
echo sprintf('<tr><td colspan=2><input type="checkbox" name="teams[]" value="%d" %s>%s %s</td></tr>',
$id,$checked,$name,($isactive?'':' (Disabled)'));
}
} ?>
<tr>
<th colspan="2">
<em><strong>Admin Notes</strong>: Internal notes viewable by all admins. </em>
</th>
</tr>
<tr>
<td colspan=2>
<textarea class="richtext no-bar" name="notes" cols="28"
rows="7" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
</td>
</tr>
</tbody>
</table>
<p style="padding-left:250px;">
<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="staff.php"'>