Feature 5388: Print Invoices (documents) list gets too long. Fixed by default 180...
[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
46 function sortByOption($a, $b) {
47     return strcmp($a['name'], $b['name']);
48 }
49
50 start_form(true);
51
52         div_start('ext_tbl');
53
54         $mods = get_charts_list();
55
56         if (!$mods)
57                 display_note(_("No optional chart of accounts is currently available."));
58         else
59         {
60         uasort($mods, 'sortByOption');
61
62                 $th = array(_("Chart"),  _("Installed"), _("Available"), _("Encoding"), "", "");
63                 $k = 0;
64
65                 start_table(TABLESTYLE);
66                 table_header($th);
67                 foreach($mods as $pkg_name => $ext)
68                 {
69                         $available = @$ext['available'];
70                         $installed = @$ext['version'];
71                         $id = @$ext['local_id'];
72                         $encoding = @$ext['encoding'];
73
74                         alt_table_row_color($k);
75
76                         label_cell($available ? get_package_view_str($pkg_name, $ext['name']) : $ext['name']);
77
78                         label_cell($id === null ? _("None") :
79                                 ($available && $installed ? $installed : _("Unknown")));
80                         label_cell($available ? $available : _("None"));
81                         label_cell($encoding ? $encoding : _("Unknown"));
82
83                         if ($available && check_pkg_upgrade($installed, $available)) // outdated or not installed theme in repo
84                                 button_cell('Update'.$pkg_name, $installed ? _("Update") : _("Install"),
85                                         _('Upload and install latest extension package'), ICON_DOWN);
86                         else
87                                 label_cell('');
88
89                         if ($id !== null) {
90                                 delete_button_cell('Delete'.$id, _('Delete'));
91                                 submit_js_confirm('Delete'.$id, 
92                                         sprintf(_("You are about to remove package \'%s\'.\nDo you want to continue ?"), 
93                                                 $ext['name']));
94                         } else
95                                 label_cell('');
96
97                         end_row();
98                 }
99         end_table(1);
100         }
101         div_end();
102
103 //---------------------------------------------------------------------------------------------
104 end_form();
105
106 end_page();