2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 // Author: Joe Hunt, 17/11/2015. Upgraded to release 2.4. 10/11/2015.
16 function wa_get_apps($title, $applications, $sel_app)
18 foreach($applications as $app)
20 foreach ($app->modules as $module)
23 foreach ($module->lappfunctions as $appfunction)
24 $apps[] = $appfunction;
25 foreach ($module->rappfunctions as $appfunction)
26 $apps[] = $appfunction;
27 $application = array();
28 foreach ($apps as $application)
30 $url = explode('?', $application->link);
32 $pos = strrpos($app_lnk, "/");
35 $app_lnk = substr($app_lnk, $pos + 1);
36 $lnk = $_SERVER['REQUEST_URI'];
37 $url = explode('?', $lnk);
40 $asset = strstr($url[1], "FixedAsset");
42 $pos = strrpos($lnk, "/");
43 $lnk = substr($lnk, $pos + 1);
46 $acc = access_string($app->name);
47 $app_id = ($asset != false ? "assets" : $app->id);
48 return array($acc[0], $module->name, $application->label, $app_id);
54 return array("", "", "", $sel_app);
59 page(_($help_context = "Main Menu"), false, true);
64 end_page(false, true);
66 function shortcut($url, $label)
69 echo menu_link($url, $label);
72 function menu_header($title, $no_menu, $is_index)
74 global $path_to_root, $SysPrefs, $version;
76 $sel_app = $_SESSION['sel_app'];
77 echo "<div class='fa-main'>\n";
80 $applications = $_SESSION['App']->applications;
81 $local_path_to_root = $path_to_root;
82 $pimg = "<img src='$local_path_to_root/themes/".user_theme()."/images/preferences.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Preferences')."'> ";
83 $limg = "<img src='$local_path_to_root/themes/".user_theme()."/images/lock.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Change Password')."'> ";
84 $img = "<img src='$local_path_to_root/themes/".user_theme()."/images/on_off.png' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Logout')."'> ";
85 $himg = "<img src='$local_path_to_root/themes/".user_theme()."/images/help.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Help')."'> ";
86 echo "<div id='header'>\n";
88 echo " <li><a href='$local_path_to_root/admin/display_prefs.php?'>$pimg" . _("Preferences") . "</a></li>\n";
89 echo " <li><a href='$local_path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>$limg" . _("Change password") . "</a></li>\n";
90 if ($SysPrefs->help_base_url != null)
91 echo " <li><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='".
92 help_url()."'>$himg" . _("Help") . "</a></li>";
93 echo " <li><a href='$path_to_root/access/logout.php?'>$img" . _("Logout") . "</a></li>";
95 $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
96 echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
97 echo "</div>\n"; // header
99 echo "<div id='cssmenu'>\n";
102 $account = $this->wa_get_apps($title, $applications, $sel_app);
103 foreach($applications as $app)
105 if ($_SESSION["wa_current_user"]->check_application_access($app))
107 $acc = access_string($app->name);
108 $class = ($account[3] == $app->id ? "active" : "");
109 $n = count($app->modules);
111 $class .= " has-sub";
113 $u_agent = $_SERVER['HTTP_USER_AGENT'];
114 if (preg_match('/android/i', $u_agent) && preg_match('/mobile/i', $u_agent)) {
116 $dashboard = "$local_path_to_root/index.php?application=$app->id";
119 $link = "$local_path_to_root/index.php?application=$app->id '$acc[1]";
120 echo " <li class ='$class'><a href='$link><span>" . $acc[0] . "</span></a>\n";
128 echo " <li><a href='$dashboard'><span><font color='red'>"._("Dashboard")."</font></span></a></li>\n";
129 foreach ($app->modules as $module)
131 if (!$_SESSION["wa_current_user"]->check_module_access($module))
133 echo " <li class='has-sub'><a href='#'><span>$module->name</span></a>\n";
135 foreach ($module->lappfunctions as $appfunction)
136 $apps2[] = $appfunction;
137 foreach ($module->rappfunctions as $appfunction)
138 $apps2[] = $appfunction;
139 $application = array();
143 $class = "class='align_right'";
145 echo " <ul $class>\n";
151 foreach ($apps2 as $application)
153 $lnk = access_string($application->label);
154 if ($_SESSION["wa_current_user"]->can_access_page($application->access))
156 if ($application->label != "")
158 echo " <li><a href='$path_to_root/$application->link'><span>$lnk[0]</span></a></li>\n";
161 elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
162 echo " <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a></li>\n";
168 echo " </ul>\n"; // menu
174 echo "</div>\n"; // menu
176 echo "<div class='fa-body'>\n";
179 elseif ($title && !$no_menu && !$is_index)
181 echo "<div class='fa-content'>\n";
182 echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
184 .(user_hints() ? "<span id='hints'></span>" : '')
186 ."</tr></table></center>";
190 function menu_footer($no_menu, $is_index)
192 global $path_to_root, $SysPrefs, $version, $db_connections;
193 include_once($path_to_root . "/includes/date_functions.inc");
195 if (!$no_menu && !$is_index)
196 echo "</div>\n"; // fa-content
197 echo "</div>\n"; // fa-body
200 echo "<script type='text/javascript'>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
201 {document.getElementById('cssmenu').style.position = 'fixed';}</script>\n";
202 echo "<div class='fa-footer'>\n";
203 if (isset($_SESSION['wa_current_user']))
205 echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
206 echo "<span class='date'>".Today() . " " . Now()."</span>\n";
207 echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
208 echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
209 echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
210 echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
211 echo "<span class='date'>".show_users_online()."</span>\n";
213 echo "</div>\n"; // footer
215 echo "</div>\n"; // fa-main
218 function display_applications(&$waapp)
220 global $path_to_root;
222 $sel = $waapp->get_selected_application();
223 meta_forward("$path_to_root/admin/dashboard.php", "sel_app=$sel->id");