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_SOFTWAREUPGRADE';
14 include_once($path_to_root . "/includes/session.inc");
16 if ($SysPrefs->use_popup_windows) {
17 $js = get_js_open_window(900, 500);
19 page(_($help_context = "Software Upgrade"), false, false, "", $js);
21 include_once($path_to_root . "/includes/date_functions.inc");
22 include_once($path_to_root . "/admin/db/company_db.inc");
23 include_once($path_to_root . "/admin/db/maintenance_db.inc");
24 include_once($path_to_root . "/includes/ui.inc");
25 include_once($path_to_root . "/admin/includes/fa_patch.class.inc");
27 $site_status = get_site_status($db_connections);
28 $installers = get_installers();
30 if (get_post('Upgrade'))
32 $comp = get_post('select_comp');
35 display_error(_('Select company to be upgraded.'));
37 $patch = @$installers[$site_status[$comp]['version']];
40 if (!$patch->upgrade_company($comp, check_value('force')))
41 display_error(implode('<hr>', $patch->errors));
43 display_notification(_("Company upgraded successfully."));
45 $site_status = get_site_status($db_connections); // update info
46 $Ajax->activate('_page_body');
50 $i = find_submit('Clear');
53 unlink($path_to_root.'/tmp/upgrade.'.$i.'.log');
54 $Ajax->activate('_page_body');
56 if (get_post('_select_comp_update'))
58 $Ajax->activate('_page_body');
63 $th = array(_("Company"), _("Table set"), _("Current version"), _("Last log"), _('Upgrade'));
64 start_table(TABLESTYLE);
66 $k = 0; //row colour counter
69 foreach($site_status as $i => $comp)
71 $status = $comp['version']==$db_version;
73 alt_table_row_color($k);
75 label_cell($comp['name']);
76 label_cell($comp['table_set']);
78 label_cell($comp['version'], 'align=center' .($status ? '':' class=redfg')/*, 'class='.( $status ? 'ok' : 'error')*/);
80 $log = $path_to_root.'/tmp/upgrade.'.$i.'.log';
81 if (file_exists($log))
83 label_cell(viewer_link(_('View log'), "admin/view/view_upgrade_log.php?id=$i", null, $i, 'log.png')
84 .button('Clear'.$i, _('Clear'), _('Clear log'), ICON_DELETE), 'align=center');
85 submit_js_confirm('Clear'.$i, _("Do you really want to clear this upgrade log?"));
87 label_cell('-', 'align=center');
92 label_cell(radio(null, 'select_comp', $i, null, true), 'align=center');
95 label_cell(_('Up to date'));
102 div_start('upgrade_args');
103 if (get_post('select_comp') !== '')
105 $patch = @$installers[$site_status[get_post('select_comp')]['version']];
107 $patch->show_params(get_post('select_comp'));
112 display_note(_('All company database schemes are up to date.'));
114 if (get_post('select_comp') === '')
115 display_note(_("Select company for incremental upgrade."), 0, 1, "class='stockmankofg'");
116 submit_center('Upgrade', _('Upgrade'), true, _('Save database and perform upgrade'), 'nonajax');