diff --git a/admin_index.php b/admin_index.php
index c2623832..3c52fd7d 100644
--- a/admin_index.php
+++ b/admin_index.php
@@ -148,18 +148,6 @@ if($page == 'overview')
$cron_last_runs = getCronjobsLastRun();
$outstanding_tasks = getOutstandingTasks();
- $opentickets = 0;
- $opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
- WHERE `answerto` = "0" AND (`status` = "0" OR `status` = "1")
- AND `lastreplier`="0" AND `adminid` = "' . $userinfo['adminid'] . '"');
- $awaitingtickets = $opentickets['count'];
- $awaitingtickets_text = '';
-
- if($opentickets > 0)
- {
- $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '' . $opentickets['count'] . ''));
- }
-
if(function_exists('sys_getloadavg'))
{
$loadArray = sys_getloadavg();
diff --git a/customer_index.php b/customer_index.php
index 571c1774..f07fb20d 100644
--- a/customer_index.php
+++ b/customer_index.php
@@ -60,18 +60,6 @@ if ($page == 'overview') {
$userinfo['traffic'] = round($userinfo['traffic'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $settings['panel']['decimal_places']);
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota email_autoresponder ftps tickets subdomains aps_packages');
- $opentickets = 0;
- $opentickets = $db->query_first('SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
- WHERE `customerid` = "' . $userinfo['customerid'] . '"
- AND `answerto` = "0"
- AND (`status` = "0" OR `status` = "2")
- AND `lastreplier`="1"');
- $awaitingtickets = $opentickets['count'];
- $awaitingtickets_text = '';
-
- if ($opentickets > 0) {
- $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '' . $opentickets['count'] . ''));
- }
eval("echo \"" . getTemplate('index/index') . "\";");
} elseif ($page == 'change_password') {
diff --git a/lib/init.php b/lib/init.php
index 1c6598c3..4474304e 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -431,6 +431,40 @@ if (AREA == 'admin' || AREA == 'customer') {
unset($navigation_data);
}
+/**
+ * header information about open tickets (only if used)
+ */
+if ($settings['ticket']['enabled'] == '1') {
+ $awaitingtickets = 0;
+ $awaitingtickets_text = '';
+ $opentickets = 0;
+
+ if (AREA == 'admin' && isset($userinfo['adminid'])) {
+ $opentickets = $db->query_first('
+ SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
+ WHERE `answerto` = "0" AND (`status` = "0" OR `status` = "1")
+ AND `lastreplier`="0" AND `adminid` = "' . $userinfo['adminid'] . '"
+ ');
+ $awaitingtickets = $opentickets['count'];
+
+ if ($opentickets > 0) {
+ $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '' . $opentickets['count'] . ''));
+ }
+ }
+ elseif (AREA == 'customer' && isset($userinfo['customerid'])) {
+ $opentickets = $db->query_first('
+ SELECT COUNT(`id`) as `count` FROM `' . TABLE_PANEL_TICKETS . '`
+ WHERE `answerto` = "0" AND (`status` = "0" OR `status` = "2")
+ AND `lastreplier`="1" AND `customerid` = "' . $userinfo['customerid'] . '"
+ ');
+ $awaitingtickets = $opentickets['count'];
+
+ if ($opentickets > 0) {
+ $awaitingtickets_text = strtr($lng['ticket']['awaitingticketreply'], array('%s' => '' . $opentickets['count'] . ''));
+ }
+ }
+}
+
$webfont = str_replace('+', ' ', $settings['panel']['webfont']);
eval("\$header = \"" . getTemplate('header', '1') . "\";");