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