Newer
Older
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
//Editing Department.
$title='Update Department';
$action='update';
$submit_text='Save Changes';
$info=$dept->getInfo();
$info['id']=$dept->getId();
$info['groups'] = $dept->getAllowedGroups();
$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;
if (!isset($info['group_membership']))
$info['group_membership'] = 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)
<i class="help-tip icon-question-sign" href="#type"></i>
SLA:
</td>
<td>
<select name="sla_id">
Peter Rotich
committed
<option value="0">— 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>
<select name="manager_id">
<option value="0">— None —</option>
<?php
$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>
<tr>
<td>Ticket Assignment:</td>
<td>
<input type="checkbox" name="assign_members_only" <?php echo
$info['assign_members_only']?'checked="checked"':''; ?>>
Restrict ticket assignment to department members
<i class="help-tip icon-question-sign" href="#sandboxing"></i>
</span>
<em><strong>Outgoing Email Settings</strong>:</em>
</th>
</tr>
<tr>
<td width="180">
Outgoing Email:
</td>
<td>
<select name="email_id">
<option value="0">— 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">
Template Set:
</td>
<td>
<select name="tpl_id">
<option value="0">— 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>Autoresponder Settings</strong>:
<i class="help-tip icon-question-sign" href="#auto_response_settings"></i></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> for this Department <i class="help-tip icon-question-sign" href="#new_ticket"></i>
</span>
</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> for this Department <i class="help-tip icon-question-sign" href="#new_message"></i>
</span>
Peter Rotich
committed
Auto-Response Email:
Peter Rotich
committed
<option value="0" selected="selected">— 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>
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
<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>Alerts & Notices:</strong> <i class="help-tip icon-question-sign" href="#group_membership"></i></em>
</th>
</tr>
<tr>
<td width="180">
Recipients:
</td>
<td>
<span>
<select name="group_membership">
<option value="2" <?php echo $info['group_membership'] == 2 ?'selected="selected"':'';
?>>No one (disable Alerts & Notices)</option>
<option value="0" <?php echo $info['group_membership'] == 0 ?'selected="selected"':'';
?>>Department members only</option>
<option value="1" <?php echo $info['group_membership'] == 1 ?'selected="selected"':'';
?>>Department and Group members</option>
</select>
<i class="help-tip icon-question-sign" href="#group_membership"></i>
</span>
<tr>
<th colspan="2">
<em><strong>Group Access</strong>: Check all groups allowed to access this department. <i class="help-tip icon-question-sign" href="#department_access"></i></em>
</th>
</tr>
<?php
$sql='SELECT group_id, group_name, count(staff.staff_id) as members '
.' FROM '.GROUP_TABLE.' grp '
.' LEFT JOIN '.STAFF_TABLE. ' staff USING(group_id) '
.' GROUP by grp.group_id '
.' ORDER BY group_name';
if(($res=db_query($sql)) && db_num_rows($res)){
while(list($id, $name, $members) = db_fetch_row($res)) {
$members=sprintf('<a href="staff.php?a=filter&gid=%d">%d</a>', $id, $members);
$ck=($info['groups'] && in_array($id,$info['groups']))?'checked="checked"':'';
echo sprintf('<tr><td colspan=2> <label><input type="checkbox" name="groups[]" value="%d" %s> %s</label> (%s)</td></tr>',
$id, $ck, $name, $members);
}
}
?>
<em><strong>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>
<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>