From 76370d1188dbf59c2a69bf91a19d74c72186e5f4 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 7 Feb 2014 13:21:47 -0600
Subject: [PATCH] staff ticket: Department is optional

---
 include/class.ticket.php          |  2 +-
 include/staff/ticket-open.inc.php | 38 +++++++++++++++----------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 76445c867..7ed012530 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -2008,7 +2008,7 @@ class Ticket {
                 $fields['topicId']  = array('type'=>'int',  'required'=>1, 'error'=>'Select help topic');
                 break;
             case 'staff':
-                $fields['deptId']   = array('type'=>'int',  'required'=>1, 'error'=>'Dept. required');
+                $fields['deptId']   = array('type'=>'int',  'required'=>0, 'error'=>'Dept. required');
                 $fields['topicId']  = array('type'=>'int',  'required'=>1, 'error'=>'Topic required');
                 $fields['duedate']  = array('type'=>'date', 'required'=>0, 'error'=>'Invalid date - must be MM/DD/YY');
             case 'api':
diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php
index 5de9012a6..aa15ff449 100644
--- a/include/staff/ticket-open.inc.php
+++ b/include/staff/ticket-open.inc.php
@@ -110,46 +110,46 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
         </tr>
         <tr>
             <td width="160" class="required">
-                Department:
+                Help Topic:
             </td>
             <td>
-                <select name="deptId">
-                    <option value="" selected >&mdash; Select Department &mdash;</option>
+                <select name="topicId" onchange="javascript:
+                        $('#dynamic-form').load(
+                            'ajax.php/form/help-topic/' + this.value);
+                        ">
+                    <option value="" selected >&mdash; Select Help Topic &mdash;</option>
                     <?php
-                    if($depts=Dept::getDepartments()) {
-                        foreach($depts as $id =>$name) {
+                    if($topics=Topic::getHelpTopics()) {
+                        foreach($topics as $id =>$name) {
                             echo sprintf('<option value="%d" %s>%s</option>',
-                                    $id, ($info['deptId']==$id)?'selected="selected"':'',$name);
+                                    $id, ($info['topicId']==$id)?'selected="selected"':'',$name);
                         }
                     }
                     ?>
                 </select>
-                &nbsp;<font class="error"><b>*</b>&nbsp;<?php echo $errors['deptId']; ?></font>
+                &nbsp;<font class="error"><b>*</b>&nbsp;<?php echo $errors['topicId']; ?></font>
             </td>
         </tr>
-
         <tr>
-            <td width="160" class="required">
-                Help Topic:
+            <td width="160">
+                Department:
             </td>
             <td>
-                <select name="topicId" onchange="javascript:
-                        $('#dynamic-form').load(
-                            'ajax.php/form/help-topic/' + this.value);
-                        ">
-                    <option value="" selected >&mdash; Select Help Topic &mdash;</option>
+                <select name="deptId">
+                    <option value="" selected >&mdash; Select Department &mdash;</option>
                     <?php
-                    if($topics=Topic::getHelpTopics()) {
-                        foreach($topics as $id =>$name) {
+                    if($depts=Dept::getDepartments()) {
+                        foreach($depts as $id =>$name) {
                             echo sprintf('<option value="%d" %s>%s</option>',
-                                    $id, ($info['topicId']==$id)?'selected="selected"':'',$name);
+                                    $id, ($info['deptId']==$id)?'selected="selected"':'',$name);
                         }
                     }
                     ?>
                 </select>
-                &nbsp;<font class="error"><b>*</b>&nbsp;<?php echo $errors['topicId']; ?></font>
+                &nbsp;<font class="error"><?php echo $errors['deptId']; ?></font>
             </td>
         </tr>
+
          <tr>
             <td width="160">
                 SLA Plan:
-- 
GitLab