05165fbf5c5c97fcaec168d0a731b559a7e7d13a
[fa-stable.git] / admin / inst_chart.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 $page_security = 'SA_CREATEMODULES';
13 $path_to_root="..";
14 include_once($path_to_root . "/includes/session.inc");
15 include_once($path_to_root."/includes/packages.inc");
16
17 if ($SysPrefs->use_popup_windows) {
18         $js = get_js_open_window(900, 500);
19 }
20 page(_($help_context = "Install Charts of Accounts"), false, false, '', $js);
21
22 include_once($path_to_root . "/includes/date_functions.inc");
23 include_once($path_to_root . "/admin/db/company_db.inc");
24 include_once($path_to_root . "/admin/db/maintenance_db.inc");
25 include_once($path_to_root . "/includes/ui.inc");
26
27 //---------------------------------------------------------------------------------------------
28
29 if ($id = find_submit('Delete', false))
30 {
31         $extensions = get_company_extensions();
32         if (($extensions[$id]['type']=='chart') && uninstall_package($extensions[$id]['package'])) {
33                 unset($extensions[$id]);
34                 if (update_extensions($extensions)) {
35                         display_notification(_("Selected chart has been successfully deleted"));
36                         meta_forward($_SERVER['PHP_SELF']);
37                 }
38         }
39 }
40
41 if ($id = find_submit('Update', false))
42         install_extension($id);
43
44 //---------------------------------------------------------------------------------------------
45 start_form(true);
46
47         div_start('ext_tbl');
48
49         $mods = get_charts_list();
50
51         if (!$mods)
52                 display_note(_("No optional chart of accounts is currently available."));
53         else
54         {
55                 $th = array(_("Chart"),  _("Installed"), _("Available"), _("Encoding"), "", "");
56                 $k = 0;
57
58                 start_table(TABLESTYLE);
59                 table_header($th);
60                 foreach($mods as $pkg_name => $ext)
61                 {
62                         $available = @$ext['available'];
63                         $installed = @$ext['version'];
64                         $id = @$ext['local_id'];
65                         $encoding = @$ext['encoding'];
66
67                         alt_table_row_color($k);
68
69                         label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
70
71                         label_cell($id === null ? _("None") :
72                                 ($available && $installed ? $installed : _("Unknown")));
73                         label_cell($available ? $available : _("None"));
74                         label_cell($encoding ? $encoding : _("Unknown"));
75
76                         if ($available && check_pkg_upgrade($installed, $available)) // outdated or not installed theme in repo
77                                 button_cell('Update'.$pkg_name, $installed ? _("Update") : _("Install"),
78                                         _('Upload and install latest extension package'), ICON_DOWN);
79                         else
80                                 label_cell('');
81
82                         if ($id !== null) {
83                                 delete_button_cell('Delete'.$id, _('Delete'));
84                                 submit_js_confirm('Delete'.$id, 
85                                         sprintf(_("You are about to remove package \'%s\'.\nDo you want to continue ?"), 
86                                                 $ext['name']));
87                         } else
88                                 label_cell('');
89
90                         end_row();
91                 }
92         end_table(1);
93         }
94         div_end();
95
96 //---------------------------------------------------------------------------------------------
97 end_form();
98
99 end_page();