PHP 7.X produces A non-numeric value encountered in \includes\date_functions.inc...
[fa-stable.git] / themes / canvas / 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
13         class renderer
14         {
15                 function wa_header()
16                 {
17                         page(_($help_context = "Main Menu"), false, true);
18                 }
19
20                 function wa_footer()
21                 {
22                         end_page(false, true);
23                 }
24                 function shortcut($url, $label) 
25                 {
26                         echo "<li>";
27                         $pars = access_string($label);
28                         echo "<a href='$url' class='menu_option' $pars[1]>$pars[0]</a>";
29                         echo "</li>";
30                 }
31                 
32                 function menu_header($title, $no_menu, $is_index)
33                 {
34                         global $path_to_root, $SysPrefs, $version;
35
36                         $sel_app = $_SESSION['sel_app'];
37                         echo "<div class='fa-main'>\n";
38                         if (!$no_menu)
39                         {
40                                 $applications = $_SESSION['App']->applications;
41                                 $local_path_to_root = $path_to_root;
42                                 $img = "<img src='$path_to_root/themes/".user_theme()."/images/login.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Logout')."'>&nbsp;&nbsp;";
43                                 $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')."'>&nbsp;&nbsp;";
44                                 $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')."'>&nbsp;&nbsp;";
45                                 $himg = "<img src='$path_to_root/themes/".user_theme()."/images/help.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Help')."'>&nbsp;&nbsp;";
46                                 echo "<div id='header'>\n";
47                                 echo "<ul>\n";
48                                 echo "  <li><a class='shortcut' href='$path_to_root/admin/display_prefs.php?'>$pimg" . _("Preferences") . "</a></li>\n";
49                                 echo "  <li><a class='shortcut' href='$path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>$limg" . _("Change password") . "</a></li>\n";
50                                 if ($SysPrefs->help_base_url != null)
51                                         echo "  <li><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='". 
52                                                 help_url()."'>$himg" . _("Help") . "</a></li>";
53                                 echo "  <li><a class='shortcut' href='$path_to_root/access/logout.php?'>$img" . _("Logout") . "</a></li>";
54                                 echo "</ul>\n";
55                                 $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
56                                 echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
57                                 echo "</div>\n"; // header
58                                 echo "<div class='fa-menu'>";
59                                 echo "<ul>\n";
60                                 foreach($applications as $app)
61                                 {
62                     if ($_SESSION["wa_current_user"]->check_application_access($app))
63                     {
64                                                 $acc = access_string($app->name);
65                                                 echo "<li ".($sel_app == $app->id ? "class='active' " : "") . "><a class='"
66                                                         .($sel_app == $app->id ? 'selected' : 'menu_tab')
67                                                         ."' href='$path_to_root/index.php?application=" . $app->id
68                                                         ."'$acc[1]><b>" . $acc[0] . "</b></a></li>\n";
69                                         }               
70                                 }
71                                 echo "</ul>\n"; 
72                                 echo "</div>\n"; // menu
73                                 echo "<div class='clear'></div>\n";
74
75                         }                               
76                         echo "<div class='fa-body'>\n";
77                         if (!$no_menu)
78                         {               
79                                 echo "<div id='fa-submenu'>\n";
80                                 echo "<ul>\n";
81                                 switch ($sel_app) // Shortcuts
82                                 {
83                                         case "orders":
84                                                 $this->shortcut($local_path_to_root."/sales/sales_order_entry.php?NewOrder=Yes'",_("Sales Order"));
85                                                 $this->shortcut($local_path_to_root."/sales/sales_order_entry.php?NewInvoice=0",_("Direct Invoice"));
86                                                 $this->shortcut($local_path_to_root."/sales/customer_payments.php?", _("Payments"));
87                                                 $this->shortcut($local_path_to_root."/sales/inquiry/sales_orders_view.php?", _("Sales Order Inquiry"));
88                                                 $this->shortcut($local_path_to_root."/sales/inquiry/customer_inquiry.php?", _("Transactions"));
89                                                 $this->shortcut($local_path_to_root."/sales/manage/customers.php?", _("Customers"));
90                                                 $this->shortcut($local_path_to_root."/sales/manage/customer_branches.php?", _("Branch"));
91                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=0", _("Reports and Analysis"));
92                                                 break;
93                                         case "AP":      
94                                                 $this->shortcut($local_path_to_root."/purchasing/po_entry_items.php?NewOrder=0", _("Purchase Order"));
95                                                 $this->shortcut($local_path_to_root."/purchasing/inquiry/po_search.php?", _("Receive"));
96                                                 $this->shortcut($local_path_to_root."/purchasing/supplier_invoice.php?New=1", _("Supplier Invoice"));
97                                                 $this->shortcut($local_path_to_root."/purchasing/supplier_payment.php?", _("Payments"));
98                                                 $this->shortcut($local_path_to_root."/purchasing/inquiry/supplier_inquiry.php?", _("Transactions"));
99                                                 $this->shortcut($local_path_to_root."/purchasing/manage/suppliers.php?", _("Suppliers"));
100                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=1", _("Reports and Analysis"));
101                                                 break;
102                                         case "stock":   
103                                                 $this->shortcut($local_path_to_root."/inventory/adjustments.php?NewAdjustment=1", _("Inventory Adjustments"));
104                                                 $this->shortcut($local_path_to_root."/inventory/inquiry/stock_movements.php?", _("Inventory Movements"));
105                                                 $this->shortcut($local_path_to_root."/inventory/manage/items.php?", _("Items"));
106                                                 $this->shortcut($local_path_to_root."/inventory/prices.php?", _("Sales Pricing"));
107                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=2", _("Reports and Analysis"));
108                                                 break;
109                                         case "manuf":   
110                                                 $this->shortcut($local_path_to_root."/manufacturing/work_order_entry.php?", _("Work Order Entry"));
111                                                 $this->shortcut($local_path_to_root."/manufacturing/search_work_orders.php?outstanding_only=1", _("Ourstanding Work Orders"));
112                                                 $this->shortcut($local_path_to_root."/manufacturing/search_work_orders.php?", _("Work Order Inquiry"));
113                                                 $this->shortcut($local_path_to_root."/manufacturing/manage/bom_edit.php?", _("Bills Of Material"));
114                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=3", _("Reports and Analysis"));
115                                                 break;
116                                         case "assets":  
117                                                 $this->shortcut($local_path_to_root."/purchasing/po_entry_items.php?NewInvoice=Yes&FixedAsset=1", _("Fixed Assets Purchase"));
118                                                 $this->shortcut($local_path_to_root."/fixed_assets/inquiry/stock_inquiry.php?", _("Fixed Assets Inquiry"));
119                                                 $this->shortcut($local_path_to_root."/inventory/manage/items.php?FixedAsset=1", _("Fixed Assets"));
120                                                 $this->shortcut($local_path_to_root."/fixed_assets/process_depreciation.php?", _("Depreciations"));
121                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=7", _("Reports and Analysis"));
122                                                 break;
123                                         case "proj":    
124                                                 $this->shortcut($local_path_to_root."/dimensions/dimension_entry.php?", _("Dimension Entry"));
125                                                 $this->shortcut($local_path_to_root."/dimensions/inquiry/search_dimensions.php?", _("Dimension Inquiry"));
126                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=4", _("Reports and Analysis"));
127                                                 break;
128                                         case "GL":      
129                                                 $this->shortcut($local_path_to_root."/gl/gl_bank.php?NewPayment=Yes",_("Payments"));
130                                                 $this->shortcut($local_path_to_root."/gl/gl_bank.php?NewDeposit=Yes",_("Deposits"));
131                                                 $this->shortcut($local_path_to_root."/gl/gl_journal.php?NewJournal=Yes",_("Journal Entry"));
132                                                 $this->shortcut($local_path_to_root."/gl/inquiry/bank_inquiry.php?",_("Bank Account Inquiry"));
133                                                 //$this->shortcut($local_path_to_root."/gl/inquiry/gl_account_inquiry.php?",_("GL Account Inquiry"));
134                                                 $this->shortcut($local_path_to_root."/gl/inquiry/gl_trial_balance.php?",_("Trial Balance"));
135                                                 $this->shortcut($local_path_to_root."/gl/manage/exchange_rates.php?",_("Exchange Rates"));
136                                                 $this->shortcut($local_path_to_root."/gl/manage/gl_accounts.php?",_("GL Accounts"));
137                                                 $this->shortcut($local_path_to_root."/reporting/reports_main.php?Class=6",_("Reports and Analysis"));
138                                                 break;
139                                         case "system":  
140                                                 $this->shortcut($local_path_to_root."/admin/company_preferences.php?",_("Company Setup"));
141                                                 $this->shortcut($local_path_to_root."/admin/gl_setup.php?",_("General GL"));
142                                                 $this->shortcut($local_path_to_root."/taxes/tax_types.php?",_("Taxes"));
143                                                 $this->shortcut($local_path_to_root."/taxes/tax_groups.php?",_("Tax Groups"));
144                                                 $this->shortcut($local_path_to_root."/admin/forms_setup.php?",_("Forms Setup"));
145                                                 $this->shortcut($local_path_to_root."/admin/backups.php?",_("Backup and Restore"));
146                                                 break;
147                                 }       
148                                 $this->shortcut($local_path_to_root."/admin/dashboard.php?sel_app=$sel_app", _("Dashboard"));
149                                 echo "</ul>\n";
150                                 echo "</div>\n"; // fa-submenu
151                                 echo "<div class='clear'></div>\n";
152                                 echo "<div class='fa-content'>\n";
153                         }
154                         if ($no_menu)
155                                 echo "<br>";
156                         elseif ($title && !$no_menu && !$is_index)
157                         {
158                                 echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
159                                 ."<td align=right>"
160                                 .(user_hints() ? "<span id='hints'></span>" : '')
161                                 ."</td>"
162                                 ."</tr></table></center>";
163                         }
164                 }
165
166                 function menu_footer($no_menu, $is_index)
167                 {
168                         global $path_to_root, $SysPrefs, $version, $db_connections;
169                         include_once($path_to_root . "/includes/date_functions.inc");
170
171                         if (!$no_menu)
172                                 echo "</div>\n"; // fa-content
173                         echo "</div>\n"; // fa-body
174                         if (!$no_menu)
175                         {
176                                 echo "<div class='fa-footer'>\n";
177                                 if (isset($_SESSION['wa_current_user']))
178                                 {
179                                         echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
180                                         echo "<span class='date'>".Today() . "&nbsp;" . Now()."</span>\n";
181                                         echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
182                                         echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
183                                         echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
184                                         echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
185                                         echo "<span class='date'>".show_users_online()."</span>\n";
186                                 }
187                                 echo "</div>\n"; // footer
188                         }
189                         echo "</div>\n"; // fa-main
190                 }
191
192                 function display_applications(&$waapp)
193                 {
194                         global $path_to_root;
195                         $i = 0;
196                         $sel_app = $waapp->get_selected_application();
197                         if (!$_SESSION["wa_current_user"]->check_application_access($sel_app))
198                                 return;
199                         if ($sel_app->id == "system")
200                                 $imgs2 = array("page_edit.png", "page_edit.png", "page_edit.png", "page_edit.png", "folder.gif");
201                         else    
202                                 $imgs2 = array("folder.gif", "report.png", "page_edit.png", "money.png", "folder.gif");
203                         foreach ($sel_app->modules as $module)
204                         {
205                         if (!$_SESSION["wa_current_user"]->check_module_access($module))
206                                 continue;
207                                 // image
208                                 echo "<table width='95%' align='center'><tr>";
209                                 echo "<td valign='top' class='menu_group'>";
210                                 echo "<table border=0 width='100%'>";
211                                 echo "<tr><td class='menu_group'>";
212                                 echo $module->name;
213                                 echo "</td></tr><tr>";
214                                 echo "<td width='50%' class='menu_group_items'>";
215                                 $img = "<img src='$path_to_root/themes/".user_theme()."/images/".$imgs2[$i]."' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;'>&nbsp;&nbsp;";
216                                 if ($_SESSION["language"]->dir == "rtl")
217                                         $class = "right";
218                                 else
219                                         $class = "left";
220                                 foreach ($module->lappfunctions as $appfunction)
221                                 {
222                                         if ($appfunction->label == "")
223                                                 echo "<div class='empty'>&nbsp;<br></div>\n";
224                                         elseif ($_SESSION["wa_current_user"]->can_access_page($appfunction->access))
225                                                 echo "<div>".$img.menu_link($appfunction->link, $appfunction->label."</div>");
226                                         elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())  
227                                                 echo "<div>".$img."<span class='inactive'>".access_string($appfunction->label, true)."</span></div>\n";
228                                 }
229                                 echo "</td>\n";
230                                 if (sizeof($module->rappfunctions) > 0)
231                                 {
232                                         echo "<td width='50%' class='menu_group_items'>";
233                                         foreach ($module->rappfunctions as $appfunction)
234                                         {
235                                                 if ($appfunction->label == "")
236                                                         echo "<div class='empty'>&nbsp;<br></div>\n";
237                                                 elseif ($_SESSION["wa_current_user"]->can_access_page($appfunction->access))
238                                                         echo "<div>".$img.menu_link($appfunction->link, $appfunction->label."</div>");
239                                                 elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())  
240                                                         echo "<div>".$img."<span class='inactive'>".access_string($appfunction->label, true)."</span></div>\n";
241                                         }
242                                         echo "</td>\n";
243                                 }
244                                 echo "</tr></table></td></tr></table>\n";
245                                 $i++;
246                         }       
247                 }
248         }
249