d71f39fe29e55a12fa5d56e0c5c91264f2e6e5ea
[fa-stable.git] / includes / page / header.inc
1 <?php
2
3 function help_url($title, $app)
4 {
5
6         global $help_page_url, $help_base_url, $applications, $help_page_title;
7
8         if (isset($help_page_url))
9         {
10                 return $help_base_url.$help_page_url;
11         }
12
13         $help_page_url = '';
14         if (isset($help_page_title))
15         {
16                 $help_page_url = $help_page_title;
17         }
18         elseif ($title==_("Main Menu"))
19         {
20                 $help_page_url = $applications[$app];
21         }
22         else
23         {
24                 $help_page_url = $title;
25         }
26
27         return $help_base_url.urlencode(str_replace(' ', '', ucwords($help_page_url)));
28 }
29
30 function page_header($title, $no_menu=false, $is_index=false, $onload="", $js="")
31 {
32         // titles and screen header
33         global $db_connections, $path_to_root, $def_app, $applications,
34                 $help_base_url, $help_page_url, $use_popup_windows,
35                 $js_lib, $js_static, $js_path;
36
37         if (isset($_GET['ajax'])) return;
38
39         $theme = user_theme();
40         $local_path_to_root = $path_to_root;
41
42         if ($help_base_url != null && $use_popup_windows && $js == '')
43         {
44                 if (!function_exists('get_js_open_window'))
45                 {
46                         include_once($path_to_root.'/includes/ui/ui_view.inc');
47                 }
48                 $js = get_js_open_window(900, 500);
49         }
50
51         // javascript includes collect
52         add_js_source($js);
53         $js ='';
54         foreach($js_static as $jsfile) {
55           $js .= '<script language="javascript" type="text/javascript" src="'.
56                 $js_path . $jsfile . '"></script>';
57         }
58         foreach($js_lib as $text) {
59           $js .= $text;
60         }
61         if (!isset($no_menu))
62         {
63                 $no_menu = false;
64         }
65         if (!isset($_SESSION["sel_app"]))
66                 session_register("sel_app");
67         if (isset($_SESSION["App"]) && is_object($_SESSION["App"]) && isset($_SESSION["App"]->selected_application) &&
68                 $_SESSION["App"]->selected_application != "")
69                 $sel_app = $_SESSION["App"]->selected_application;
70         elseif (isset($_SESSION["sel_app"]) && $_SESSION["sel_app"] != "")
71                 $sel_app = $_SESSION["sel_app"];
72         else
73                 $sel_app = $def_app;
74         $_SESSION["sel_app"] = $sel_app;
75
76         echo "<html dir='" . $_SESSION['language']->dir . "' >";
77         echo "<head><title>$title</title>";
78         $encoding = $_SESSION['language']->encoding;
79         $local_stylesheet = $_SESSION['language']->get_stylesheet();
80         echo "<meta http-equiv='Content-type' content='text/html'; charset='$encoding'>";
81         echo "<link href='$local_path_to_root/themes/$theme/default.css' rel='stylesheet' type='text/css' /> \n";
82         if (file_exists($local_path_to_root. "/".$local_stylesheet))
83                 echo "<link href='$local_path_to_root/$local_stylesheet' rel='stylesheet' type='text/css' /> \n";
84         if ($js != "")
85                 echo $js;
86         echo "</head> \n";
87         if ($onload == "")
88                 echo "<body>";
89         else
90                 echo "<body onload=\"$onload\">";
91         echo "<script language='javascript' src='".
92           $path_to_root. "/js/inserts.js' type='text/javascript'></script>\n";
93         echo "<table class='callout_main' border='0' cellpadding='0' cellspacing='0'>\n";
94         echo "<tr>\n";
95         echo "<td colspan='2' rowspan='2'>\n";
96
97         echo "<table class='main_page' border='0' cellpadding='0' cellspacing='0'>\n";
98         echo "<tr>\n";
99         echo "<td>\n";
100         echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
101         echo "<tr>\n";
102         echo "<td class='quick_menu'>\n";
103         if (!$no_menu)
104         {
105                 echo "<table cellpadding=0 cellspacing=0 width='100%'><tr><td>";
106                 echo "<div class=tabs>";
107                 foreach($applications as $app => $name)
108                 {
109                         echo "<a ".($sel_app == $app ? "class='selected' " : "").
110                         "href='$local_path_to_root/index.php?application=".$app.
111                                 SID ."'>" .$name . "</a>";
112                 }
113                 echo "</div>";
114
115                 echo "</td></tr></table>";
116
117                 echo "<table class=logoutBar>";
118                 echo "<tr><td class=headingtext3>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . "</td>";
119                 if ($help_base_url != null)
120                 {
121
122                         echo "<td align=right ><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='". help_url($title, $sel_app)."'>" . _("Help") . "</a></td>";
123                 }
124                 echo "<td class=logoutBarRight><a href='$local_path_to_root/access/logout.php?'>" . _("Logout") . "</a>";
125                 echo "</td></tr></table>";
126         }
127
128         echo "</td></tr></table>";
129
130         if ($title && !$no_menu && !$is_index)
131         {
132                 echo "<center><table width='100%'><tr><td width='100%' class='titletext'>$title</td></tr></table></center>";
133         }
134
135         if (!$is_index)
136                 echo "<br>";
137 }
138
139 ?>