Newer
Older
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$submit_text=__('Save Changes');
$info = $dept->getInfo();
$info['id'] = $dept->getId();
$info['groups'] = $dept->getAllowedGroups();
$title=__('Add New Department');
$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;
if (!isset($info['group_membership']))
$info['group_membership'] = 1;
$info = Format::htmlchars(($errors && $_POST) ? $_POST : $info);
<form action="departments.php?<?php echo Http::build_query($qs); ?>" 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><?php echo __('Department');?></h2>
<br>
<ul class="tabs">
<li class="active"><a href="#settings">
<i class="icon-file"></i> <?php echo __('Settings'); ?></a></li>
<li><a href="#access">
<i class="icon-lock"></i> <?php echo __('Access'); ?></a></li>
</ul>
<div id="settings" class="tab_content">
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php echo $title; ?></h4>
<em><?php echo __('Department Information');?></em>
<tr>
<td width="180">
<?php echo __('Parent');?>:
</td>
<td>
<select name="pid">
<option value="">— <?php echo __('Top-Level Deptartment'); ?> —</option>
<?php foreach (Dept::getDepartments() as $id=>$name) {
if ($info['id'] && $id == $info['id'])
continue; ?>
<option value="<?php echo $id; ?>" <?php
if ($info['pid'] == $id) echo 'selected="selected"';
?>><?php echo $name; ?></option>
<?php } ?>
</select>
</td>
</tr>
<input data-translate-tag="<?php echo $dept ? $dept->getTranslateTag() : '';
?>" 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">
<input type="radio" name="ispublic" value="1" <?php echo $info['ispublic']?'checked="checked"':''; ?>><strong><?php echo __('Public');?></strong>
<input type="radio" name="ispublic" value="0" <?php echo !$info['ispublic']?'checked="checked"':''; ?>><strong><?php echo __('Private');?></strong> <?php echo mb_convert_case(__('(internal)'), MB_CASE_TITLE);?>
<i class="help-tip icon-question-sign" href="#type"></i>
<option value="0">— <?php echo __('System Default'); ?> —</option>
if($slas=SLA::getSLAs()) {
foreach($slas as $id =>$name) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, ($info['sla_id']==$id)?'selected="selected"':'',$name);
<span class="error"><?php echo $errors['sla_id']; ?></span> <i class="help-tip icon-question-sign" href="#sla"></i>
<option value="0">— <?php echo __('None'); ?> —</option>
$sql='SELECT staff_id,CONCAT_WS(", ",lastname, firstname) as name '
.' FROM '.STAFF_TABLE.' staff '
.' 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>
<i class="help-tip icon-question-sign" href="#manager"></i>
</span>
<td><?php echo __('Ticket Assignment'); ?>:</td>
<input type="checkbox" name="assign_members_only" <?php echo
$info['assign_members_only']?'checked="checked"':''; ?>>
<?php echo __('Restrict ticket assignment to department members'); ?>
<i class="help-tip icon-question-sign" href="#sandboxing"></i>
</span>
<em><strong><?php echo __('Outgoing Email Settings'); ?></strong>:</em>
</th>
</tr>
<tr>
<td width="180">
<?php echo __('Outgoing Email'); ?>:
</td>
<td>
<select name="email_id">
<option value="0">— <?php echo __('System Default'); ?> —</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> <i class="help-tip icon-question-sign" href="#email"></i>
</td>
</tr>
<tr>
<td width="180">
<?php echo __('Template Set'); ?>:
<option value="0">— <?php echo __('System Default'); ?> —</option>
<?php
$sql='SELECT tpl_id,name FROM '.EMAIL_TEMPLATE_GRP_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> <i class="help-tip icon-question-sign" href="#template"></i>
<em><strong><?php echo __('Autoresponder Settings'); ?></strong>:
<i class="help-tip icon-question-sign" href="#auto_response_settings"></i></em>
<input type="checkbox" name="ticket_auto_response" value="0" <?php echo !$info['ticket_auto_response']?'checked="checked"':''; ?> >
<?php echo __('<strong>Disable</strong> for this Department'); ?>
<i class="help-tip icon-question-sign" href="#new_ticket"></i>
<input type="checkbox" name="message_auto_response" value="0" <?php echo !$info['message_auto_response']?'checked="checked"':''; ?> >
<?php echo __('<strong>Disable</strong> for this Department'); ?>
<i class="help-tip icon-question-sign" href="#new_message"></i>
<?php echo __('Auto-Response Email'); ?>:
<option value="0" selected="selected">— <?php echo __('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 = (isset($info['autoresp_email_id'])
&& $id == $info['autoresp_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>
<i class="help-tip icon-question-sign" href="#auto_response_email"></i>
</span>
</td>
</tr>
<tr>
<th colspan="2">
<em><strong><?php echo __('Alerts and Notices'); ?>:</strong>
<i class="help-tip icon-question-sign" href="#group_membership"></i></em>
</th>
</tr>
<tr>
<td width="180">
</td>
<td>
<span>
<select name="group_membership">
<?php foreach (array(
Dept::ALERTS_DISABLED => __("No one (disable Alerts and Notices)"),
Dept::ALERTS_DEPT_ONLY => __("Department members only"),
Dept::ALERTS_DEPT_AND_GROUPS => __("Department and Group members"),
) as $mode=>$desc) { ?>
<option value="<?php echo $mode; ?>" <?php
if ($info['group_membership'] == $mode) echo 'selected="selected"';
?>><?php echo $desc; ?></option><?php
} ?>
</select>
<i class="help-tip icon-question-sign" href="#group_membership"></i>
</span>
<em><strong><?php echo __('Department Signature'); ?></strong>:
<span class="error"> <?php echo $errors['signature']; ?></span>
<i class="help-tip icon-question-sign" href="#department_signature"></i></em>
<textarea class="richtext no-bar" name="signature" cols="21"
rows="5" style="width: 60%;"><?php echo $info['signature']; ?></textarea>
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
</div>
<div id="access" class="tab_content" style="display:none">
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan=2>
<em><?php echo __('Primary department members have access to this department by default'); ?></em>
</th>
</tr>
<tr>
<th width="40%"><?php echo __('Group'); ?></th>
<th><?php echo __('Role'); ?></th>
</tr>
</thead>
<tbody>
<?php
$deptId = $dept ? $dept->getId() : 0;
$roles = Role::getRoles();
$groups = Group::objects()
->annotate(array(
'isenabled'=>new SqlExpr(array(
'flags__hasbit' => Group::FLAG_ENABLED))
))
->order_by('name');
foreach ($groups as $group) {
$DeptAccess = $group->getDepartmentsAccess();
?>
<tr>
<td>
<label>
<?php
$ck = ($info['groups'] && in_array($group->getId(), $info['groups'])) ? 'checked="checked"' : '';
echo sprintf('%s %s',
sprintf('<input type="checkbox" class="grp-ckb"
name="groups[]" value="%s" %s />',
$group->getId(), $ck),
Format::htmlchars($group->getName()));
?>
</label>
</td>
<td>
<?php
$_name = 'group'.$group->getId().'_role_id';
?>
<select name="<?php echo $_name; ?>">
<option value="0">— <?php
echo sprintf('%s (%s)',
__('Group Default'),
$group->getRole());
?>
—</option>
<?php
foreach ($roles as $rid => $role) {
$sel = '';
if (isset($info[$_name]))
$sel = ($info[$_name] == $rid) ? 'selected="selected"' : '';
elseif ($deptId && isset($DeptAccess[$deptId]))
$sel = ($DeptAccess[$deptId] == $rid) ? 'selected="selected"' : '';
echo sprintf('<option value="%d" %s>%s</option>',
$rid, $sel, $role);
} ?>
</select>
<i class="help-tip icon-question-sign" href="#dept-role"></i>
</td>
</tr>
<?php
} ?>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<?php echo __('Select');?>:
<a id="selectAll" href="#grp-ckb"><?php echo __('All');?></a>
<a id="selectNone" href="#grp-ckb"><?php echo __('None');?></a>
<a id="selectToggle" href="#grp-ckb"><?php echo __('Toggle');?></a>
</td>
</tr>
</tfoot>
</table>
</div>
<input type="submit" name="submit" value="<?php echo $submit_text; ?>">
<input type="reset" name="reset" value="<?php echo __('Reset');?>">
<input type="button" name="cancel" value="<?php echo __('Cancel');?>"
onclick='window.location.href="?"'>