Improvement of standard themes. 2 small gif files added. Shown upper right.
[fa-stable.git] / themes / default / renderer.php
1 <?php
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         class renderer
13         {
14                 function get_icon($category)
15                 {
16                         global  $path_to_root, $SysPrefs;
17
18                         if ($SysPrefs->show_menu_category_icons)
19                                 $img = $category == '' ? 'right.gif' : $category.'.png';
20                         else    
21                                 $img = 'right.gif';
22                         return "<img src='$path_to_root/themes/".user_theme()."/images/$img' style='vertical-align:middle;' border='0'>&nbsp;&nbsp;";
23                 }
24
25                 function wa_header()
26                 {
27                         page(_($help_context = "Main Menu"), false, true);
28                 }
29
30                 function wa_footer()
31                 {
32                         end_page(false, true);
33                 }
34
35                 function menu_header($title, $no_menu, $is_index)
36                 {
37                         global $path_to_root, $SysPrefs, $db_connections;
38                         echo "<table class='callout_main' border='0' cellpadding='0' cellspacing='0'>\n";
39                         echo "<tr>\n";
40                         echo "<td colspan='2' rowspan='2'>\n";
41
42                         echo "<table class='main_page' border='0' cellpadding='0' cellspacing='0'>\n";
43                         echo "<tr>\n";
44                         echo "<td>\n";
45                         echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
46                         echo "<tr>\n";
47                         echo "<td class='quick_menu'>\n"; // tabs
48
49                         $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
50                         if (!$no_menu)
51                         {
52                                 $applications = $_SESSION['App']->applications;
53                                 $local_path_to_root = $path_to_root;
54                                 $sel_app = $_SESSION['sel_app'];
55                                 echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td>";
56                                 echo "<div class='tabs'>";
57                                 foreach($applications as $app)
58                                 {
59                     if ($_SESSION["wa_current_user"]->check_application_access($app))
60                     {
61                         $acc = access_string($app->name);
62                         echo "<a class='".($sel_app == $app->id ? 'selected' : 'menu_tab')
63                             ."' href='$local_path_to_root/index.php?application=".$app->id
64                             ."'$acc[1]>" .$acc[0] . "</a>";
65                     }
66                                 }
67                                 echo "</div>";
68                                 echo "</td></tr></table>";
69                                 // top status bar
70                                 $pimg = "<img src='$local_path_to_root/themes/".user_theme()."/images/preferences.gif' width='14' height='14' border='0' alt='"._('Preferences')."'>&nbsp;&nbsp;";
71                                 $limg = "<img src='$local_path_to_root/themes/".user_theme()."/images/lock.gif' width='14' height='14' border='0' alt='"._('Change Password')."'>&nbsp;&nbsp;";
72                                 $img = "<img src='$local_path_to_root/themes/".user_theme()."/images/login.gif' width='14' height='14' border='0' alt='"._('Logout')."'>&nbsp;&nbsp;";
73                                 $himg = "<img src='$local_path_to_root/themes/".user_theme()."/images/help.gif' width='14' height='14' border='0' alt='"._('Help')."'>&nbsp;&nbsp;";
74                                 echo "<table class='logoutBar'>";
75                                 echo "<tr><td class='headingtext3'>" . $db_connections[user_company()]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . "</td>";
76                                 echo "<td class='logoutBarRight'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;' alt='ajaxmark'></td>";
77                                 echo "  <td class='logoutBarRight'><a class='shortcut' href='$path_to_root/admin/display_prefs.php?'>$pimg" . _("Preferences") . "</a>&nbsp;&nbsp;&nbsp;\n";
78                                 echo "  <a class='shortcut' href='$path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>$limg" . _("Change password") . "</a>&nbsp;&nbsp;&nbsp;\n";
79
80                                 if ($SysPrefs->help_base_url != null)
81                                 {
82                                         echo "<a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='". help_url()."'>$himg" . _("Help") . "</a>&nbsp;&nbsp;&nbsp;";
83                                 }
84                                 echo "<a class='shortcut' href='$local_path_to_root/access/logout.php?'>$img" . _("Logout") . "</a>&nbsp;&nbsp;&nbsp;";
85                                 echo "</td></tr><tr><td colspan=3>";
86                                 echo "</td></tr></table>";
87                         }
88                         echo "</td></tr></table>";
89
90                         if ($no_menu)
91                         {       // ajax indicator for installer and popups
92                                 echo "<center><table class='tablestyle_noborder'>"
93                                         ."<tr><td><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;' alt='ajaxmark'></td></tr>"
94                                         ."</table></center>";
95                         } elseif ($title && !$is_index)
96                         {
97                                 echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
98                                 ."<td align=right>"
99                                 .(user_hints() ? "<span id='hints'></span>" : '')
100                                 ."</td>"
101                                 ."</tr></table></center>";
102                         }
103                 }
104
105                 function menu_footer($no_menu, $is_index)
106                 {
107                         global $version, $path_to_root, $Pagehelp, $Ajax, $SysPrefs;
108
109                         include_once($path_to_root . "/includes/date_functions.inc");
110
111                         echo "</td></tr></table>\n"; // 'main_page'
112                         if ($no_menu == false) // bottom status line
113                         {
114                                 if ($is_index)
115                                         echo "<table class='bottomBar'>\n";
116                                 else
117                                         echo "<table class='bottomBar2'>\n";
118                                 echo "<tr>";
119                                 if (isset($_SESSION['wa_current_user'])) {
120                                         $phelp = implode('; ', $Pagehelp);
121                                         echo "<td class='bottomBarCell'>" . Today() . " | " . Now() . "</td>\n";
122                                         $Ajax->addUpdate(true, 'hotkeyshelp', $phelp);
123                                         echo "<td id='hotkeyshelp'>".$phelp."</td>";
124                                 }
125                                 echo "</tr></table>\n";
126                         }
127                         echo "</td></tr> </table>\n"; // 'callout_main'
128                         if ($no_menu == false)
129                         {
130                                 echo "<table align='center' id='footer'>\n";
131                                 echo "<tr>\n";
132                                 echo "<td align='center' class='footer'><a target='_blank' href='".$SysPrefs->power_url."' tabindex='-1'><font color='#ffffff'>".$SysPrefs->app_title
133                                         ." $version - " . _("Theme:") . " " . user_theme() . " - ".show_users_online()."</font></a></td>\n";
134                                 echo "</tr>\n";
135                                 echo "<tr>\n";
136                                 echo "<td align='center' class='footer'><a target='_blank' href='".$SysPrefs->power_url
137                                         ."' tabindex='-1'><font color='#ffff00'>".$SysPrefs->power_by."</font></a></td>\n";
138                                 echo "</tr>\n";
139                                 if ($SysPrefs->allow_demo_mode)
140                                 {
141                                         echo "<tr>\n";
142                                         //echo "<td><br><div align='center'><a href='http://sourceforge.net'><img src='http://sourceforge.net/sflogo.php?group_id=89967&amp;type=5' alt='SourceForge.net Logo' width='210' height='62' border='0' align='center' /></a></div></td>\n";
143                                         echo "</tr>\n";
144                                 }
145                                 echo "</table><br><br>\n";
146                         }
147                 }
148
149                 function display_applications(&$waapp)
150                 {
151                         global $path_to_root;
152
153                         $selected_app = $waapp->get_selected_application();
154                         if (!$_SESSION["wa_current_user"]->check_application_access($selected_app))
155                                 return;
156
157                         if (method_exists($selected_app, 'render_index'))
158                         {
159                                 $selected_app->render_index();
160                                 return;
161                         }
162
163                         echo "<table width='100%' cellpadding='0' cellspacing='0'>";
164                         foreach ($selected_app->modules as $module)
165                         {
166                         if (!$_SESSION["wa_current_user"]->check_module_access($module))
167                                 continue;
168                                 // image
169                                 echo "<tr>";
170                                 // values
171                                 echo "<td valign='top' class='menu_group'>";
172                                 echo "<table border=0 width='100%'>";
173                                 echo "<tr><td class='menu_group'>";
174                                 echo $module->name;
175                                 echo "</td></tr><tr>";
176                                 echo "<td class='menu_group_items'>";
177
178                                 foreach ($module->lappfunctions as $appfunction)
179                                 {
180                                         $img = $this->get_icon($appfunction->category);
181                                         if ($appfunction->label == "")
182                                                 echo "&nbsp;<br>";
183                                         elseif ($_SESSION["wa_current_user"]->can_access_page($appfunction->access)) 
184                                         {
185                                                         echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
186                                         }
187                                         elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
188                                         {
189                                                         echo $img.'<span class="inactive">'
190                                                                 .access_string($appfunction->label, true)
191                                                                 ."</span><br>\n";
192                                         }
193                                 }
194                                 echo "</td>";
195                                 if (sizeof($module->rappfunctions) > 0)
196                                 {
197                                         echo "<td width='50%' class='menu_group_items'>";
198                                         foreach ($module->rappfunctions as $appfunction)
199                                         {
200                                                 $img = $this->get_icon($appfunction->category);
201                                                 if ($appfunction->label == "")
202                                                         echo "&nbsp;<br>";
203                                                 elseif ($_SESSION["wa_current_user"]->can_access_page($appfunction->access)) 
204                                                 {
205                                                                 echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
206                                                 }
207                                                 elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
208                                                 {
209                                                                 echo $img.'<span class="inactive">'
210                                                                         .access_string($appfunction->label, true)
211                                                                         ."</span><br>\n";
212                                                 }
213                                         }
214                                         echo "</td>";
215                                 }
216
217                                 echo "</tr></table></td></tr>";
218                         }
219                         echo "</table>";
220                 }
221         }