diff --git a/include/class.dept.php b/include/class.dept.php index d99985b4437bc145cc34d729eee238a83d555d52..e337884625d67b7cc458320dc436d2190c1ff757 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -395,13 +395,6 @@ class Dept { if($id && $id!=$vars['id']) $errors['err']='Missing or invalid Dept ID (internal error).'; - if(!isset($vars['id']) - && (!$vars['email_id'] || !is_numeric($vars['email_id']))) - $errors['email_id']='Email selection required'; - - if(isset($vars['tpl_id']) && !is_numeric($vars['tpl_id'])) - $errors['tpl_id']='Template selection required'; - if(!$vars['name']) { $errors['name']='Name required'; } elseif(strlen($vars['name'])<4) { diff --git a/include/staff/department.inc.php b/include/staff/department.inc.php index 99a571feccc69fcdcd529b5c628a76d77b2dadaa..bcfec6c44915c2534a094a2386cd761ed88551dc 100644 --- a/include/staff/department.inc.php +++ b/include/staff/department.inc.php @@ -62,49 +62,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </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_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> - </td> - </tr> - <tr> - <td width="180" class="required"> + <td width="180"> SLA: </td> <td> @@ -123,7 +81,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </td> </tr> <tr> - <td width="180" class="required"> + <td width="180"> Manager: </td> <td> @@ -166,7 +124,54 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> <tr> <th colspan="2"> - <em><strong>Auto Response Settings</strong>: Override global auto-response settings for tickets routed to the Dept.</em> + <em><strong>Email Settings</strong>: Outgoing email settings for the department.</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> + </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> + </td> + </tr> + <tr> + <th colspan="2"> + <em><strong>Autoresponder Settings</strong>: Override global auto-response settings for tickets routed to the department.</em> </th> </tr> <tr> diff --git a/include/staff/departments.inc.php b/include/staff/departments.inc.php index 23d6937e8c1f474997250370e4d0bd453f58771d..da9c74c5e3e3c3e3e38060e352eb4700b4812f34 100644 --- a/include/staff/departments.inc.php +++ b/include/staff/departments.inc.php @@ -54,7 +54,7 @@ else <caption><?php echo $showing; ?></caption> <thead> <tr> - <th width="7px"> </th> + <th width="7px"> </th> <th width="180"><a <?php echo $name_sort; ?> href="departments.php?<?php echo $qstr; ?>&sort=name">Name</a></th> <th width="80"><a <?php echo $type_sort; ?> href="departments.php?<?php echo $qstr; ?>&sort=type">Type</a></th> <th width="70"><a <?php echo $users_sort; ?>href="departments.php?<?php echo $qstr; ?>&sort=users">Users</a></th> @@ -68,17 +68,25 @@ else $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; if($res && db_num_rows($res)): $defaultId=$cfg->getDefaultDeptId(); + $defaultEmailId = $cfg->getDefaultEmail()->getId(); + $defaultEmailAddress = (string) $cfg->getDefaultEmail(); while ($row = db_fetch_array($res)) { $sel=false; if($ids && in_array($row['dept_id'],$ids)) $sel=true; - - $row['email']=$row['email_name']?($row['email_name'].' <'.$row['email'].'>'):$row['email']; + + if ($row['email_id']) + $row['email']=$row['email_name']?($row['email_name'].' <'.$row['email'].'>'):$row['email']; + elseif($defaultEmailId) { + $row['email_id'] = $defaultEmailId; + $row['email'] = $defaultEmailAddress; + } + $default=($defaultId==$row['dept_id'])?' <small>(Default)</small>':''; ?> <tr id="<?php echo $row['dept_id']; ?>"> <td width=7px> - <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['dept_id']; ?>" + <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['dept_id']; ?>" <?php echo $sel?'checked="checked"':''; ?> <?php echo $default?'disabled="disabled"':''; ?> > </td> <td><a href="departments.php?id=<?php echo $row['dept_id']; ?>"><?php echo $row['dept_name']; ?></a> <?php echo $default; ?></td> @@ -91,7 +99,8 @@ else <?php } ?> </b> </td> - <td><a href="emails.php?id=<?php echo $row['email_id']; ?>"><?php echo $row['email']; ?></a></td> + <td><a href="emails.php?id=<?php echo $row['email_id']; ?>"><?php + echo Format::htmlchars($row['email']); ?></a> </td> <td><a href="staff.php?id=<?php echo $row['manager_id']; ?>"><?php echo $row['manager']; ?> </a></td> </tr> <?php diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php index cc18ba3e949ced04453f15205329a297b4315b84..249f40dfcb0a15d0990a36378641b9d68a22b664 100644 --- a/setup/inc/class.installer.php +++ b/setup/inc/class.installer.php @@ -248,9 +248,6 @@ class Installer extends SetupWizard { $sql='UPDATE '.PREFIX."email SET dept_id=$dept_id_1"; db_query($sql, false); - $sql='UPDATE '.PREFIX."department SET email_id=$support_email_id" - .", autoresp_email_id=$support_email_id"; - db_query($sql, false); global $cfg; $cfg = new OsticketConfig();