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 add_access_extensions();
97 echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
98 echo "</div>\n"; // header
100 echo "<div id='cssmenu'>\n";
103 $account = $this->wa_get_apps($title, $applications, $sel_app);
104 foreach($applications as $app)
106 if ($_SESSION["wa_current_user"]->check_application_access($app))
108 $acc = access_string($app->name);
109 $class = ($account[3] == $app->id ? "active" : "");
110 $n = count($app->modules);
112 $class .= " has-sub";
114 $u_agent = $_SERVER['HTTP_USER_AGENT'];
115 if (preg_match('/android/i', $u_agent) && preg_match('/mobile/i', $u_agent)) {
117 $dashboard = "$local_path_to_root/index.php?application=$app->id";
120 $link = "$local_path_to_root/index.php?application=$app->id '$acc[1]";
121 echo " <li class ='$class'><a href='$link><span>" . $acc[0] . "</span></a>\n";
129 echo " <li><a href='$dashboard'><span><font color='red'>"._("Dashboard")."</font></span></a></li>\n";
130 foreach ($app->modules as $module)
132 if (!$_SESSION["wa_current_user"]->check_module_access($module))
134 echo " <li class='has-sub'><a href='#'><span>$module->name</span></a>\n";
136 foreach ($module->lappfunctions as $appfunction)
137 $apps2[] = $appfunction;
138 foreach ($module->rappfunctions as $appfunction)
139 $apps2[] = $appfunction;
140 $application = array();
144 $class = "class='align_right'";
146 echo " <ul $class>\n";
152 foreach ($apps2 as $application)
154 $lnk = access_string($application->label);
155 if ($_SESSION["wa_current_user"]->can_access_page($application->access))
157 if ($application->label != "")
159 echo " <li><a href='$path_to_root/$application->link'><span>$lnk[0]</span></a></li>\n";
162 elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
163 echo " <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a></li>\n";
169 echo " </ul>\n"; // menu
175 echo "</div>\n"; // menu
177 echo "<div class='fa-body'>\n";
180 elseif ($title && !$no_menu && !$is_index)
182 echo "<div class='fa-content'>\n";
183 echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
185 .(user_hints() ? "<span id='hints'></span>" : '')
187 ."</tr></table></center>";
191 function menu_footer($no_menu, $is_index)
193 global $path_to_root, $SysPrefs, $version, $db_connections;
194 include_once($path_to_root . "/includes/date_functions.inc");
196 if (!$no_menu && !$is_index)
197 echo "</div>\n"; // fa-content
198 echo "</div>\n"; // fa-body
201 echo "<script type='text/javascript'>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
202 {document.getElementById('cssmenu').style.position = 'fixed';}</script>\n";
203 echo "<div class='fa-footer'>\n";
204 if (isset($_SESSION['wa_current_user']))
206 echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
207 echo "<span class='date'>".Today() . " " . Now()."</span>\n";
208 echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
209 echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
210 echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
211 echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
212 echo "<span class='date'>".show_users_online()."</span>\n";
214 echo "</div>\n"; // footer
216 echo "</div>\n"; // fa-main
219 function display_applications(&$waapp)
221 global $path_to_root;
223 $sel = $waapp->get_selected_application();
224 meta_forward("$path_to_root/admin/dashboard.php", "sel_app=$sel->id");