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