/
helpdesk.php
163 lines (151 loc) · 4.42 KB
/
helpdesk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?
// Copyright 2002 Brian Ronald. All rights reserved.
// Portable PHP/MySQL Corporate Intranet System
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////////////
// This file is a module which builds the second layer helpdesk menu
// and includes other files in order to fulfill the functions
// selected from that menu.
require("head.inc");
if($userid==0)
{
print("<h1>".$lang['need_logged_in_helpdesk']."</h1>");
require("tail.inc");
die("");
}
unset($helpdeskadmin);
// Set a variable so we know the rights of the logged in user
$sql = "SELECT helpdesk FROM userflags WHERE userid = $userid";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
if($row["helpdesk"]=="y")
{
$helpdeskadmin=true;
}
else
{
$helpdeskadmin=false;
}
}
}
// Build the second layer menu, based on user rights
unset($module);
$module[$lang['manage_calls']]="viewcalls.inc";
$module[$lang['log_new_call']]="logcall.inc";
$module[$lang['search']]="helpsearch.inc";
$module[$lang['faq']]="helpdeskfaq.inc";
if($helpdeskadmin)
$module[$lang['edit_faqs']]="faqadmin.inc";
if(!(isset($callmodule)))
$callmodule=$lang['manage_calls'];
// Build an array to cache all the users' names in the users table
$sql = "SELECT userid, firstname, lastname FROM users ORDER BY lastname";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$userhash[$row["userid"]]=$row["firstname"]." ".$row["lastname"];
$userrevhash[$row["userid"]]=$row["lastname"].", ".$row["firstname"];
}
}
// Build an array to cache all the faq categories
$sql = "SELECT * FROM faqcategory ORDER BY name";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$faqc[$row["categoryid"]]=$row["name"];
}
}
else
{
$faqc[1]=$lang['no_categories_defined'];
}
// Build an array to cache all the call categories
$sql = "SELECT * FROM callcategory ORDER BY name";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$callc[$row["categoryid"]]=$row["name"];
}
}
else
{
$callc[1]=$lang['no_categories_defined'];
}
// Build an array to cache all the locations
$sql = "SELECT * FROM locations ORDER BY name";
$result = @ mysqli_query($intranet_db,$sql);
showerror();
if(@ mysqli_num_rows($result) != 0)
{
while($row = @ mysqli_fetch_array($result,MYSQLI_ASSOC))
{
$locations[$row["locationid"]]=$row["name"];
}
}
else
{
$locations[1]=$lang['no_locations_defined'];
}
// Hard-coded array of call priorities.
$priority[0]=$lang['waiting'];
$priority[1]=$lang['immediate'];
$priority[2]=$lang['very_important'];
$priority[3]=$lang['important'];
$priority[4]=$lang['standard'];
$priority[5]=$lang['less_important'];
$priority[6]=$lang['not_important'];
$priority[9]=$lang['parked'];
?>
<table>
<tr>
<?
$mod_percent=100 / count($module);
foreach($module as $mod_tag=>$mod_file) // Render the second layer menu
{
if($callmodule==$mod_tag)
{
$valid=true;
print("<th class=\"module_selected\" width=\"$mod_percent%\">");
}
else
{
print("<th class=\"module\" width=\"$mod_percent%\">");
}
print("<a class=\"module\" href=\"$PHP_SELF?callmodule=".rawurlencode($mod_tag)."\">$mod_tag</a></td>\n");
}
?>
</tr>
</table>
<? // Include the relevant file as selected from the menu
if(isset($valid))
{
require($module["$callmodule"]);
}
require("tail.inc");
?>