[0004212] Work Order Entry: fixed error when voided WO refence is reused.
[fa-stable.git] / admin / inst_upgrade.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_SOFTWAREUPGRADE';
13 $path_to_root="..";
14 include_once($path_to_root . "/includes/session.inc");
15
16 if ($SysPrefs->use_popup_windows) {
17         $js = get_js_open_window(900, 500);
18 }
19 page(_($help_context = "Software Upgrade"), false, false, "", $js);
20
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");
26
27 $site_status = get_site_status($db_connections);
28 $installers = get_installers();
29
30 if (get_post('Upgrade')) 
31 {
32         $comp = get_post('select_comp');
33
34     if ($comp === '')
35                 display_error(_('Select company to be upgraded.'));
36         else {
37                 $patch = @$installers[$site_status[$comp]['version']];
38                 if ($patch)
39                 {
40                         if (!$patch->upgrade_company($comp, check_value('force')))
41                                 display_error(implode('<hr>', $patch->errors));
42                         else
43                                 display_notification(_("Company upgraded successfully."));
44
45                         $site_status = get_site_status($db_connections); // update info
46                     $Ajax->activate('_page_body');
47                 }
48         }
49 }
50 $i = find_submit('Clear');
51 if ($i != -1)
52 {
53   unlink(VARLOG_PATH.'/upgrade.'.$i.'.log');
54   $Ajax->activate('_page_body');
55 }
56 if (get_post('_select_comp_update'))
57 {
58   $Ajax->activate('_page_body');
59 }
60
61 start_form();
62
63 $th = array(_("Company"), _("Table set"), _("Current version"), _("Last log"), _('Upgrade'));
64 start_table(TABLESTYLE);
65 table_header($th);
66 $k = 0; //row colour counter
67
68 $uptodate = true;
69 foreach($site_status as $i => $comp)
70 {
71         $status = $comp['version']==$db_version;
72
73         alt_table_row_color($k);
74
75         label_cell($comp['name']);
76         label_cell($comp['table_set']);
77
78         label_cell($comp['version'], 'align=center' .($status ? '':' class=redfg')/*, 'class='.( $status ? 'ok' : 'error')*/);
79
80         $log = VARLOG_PATH.'/upgrade.'.$i.'.log';
81         if (file_exists($log))
82         {
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?"));
86         } else
87                 label_cell('-', 'align=center');
88
89
90         if (!$status)
91         {
92                 label_cell(radio(null, 'select_comp', $i, null, true), 'align=center');
93                 $uptodate = false;
94         } else
95                 label_cell(_('Up to date'));
96         end_row();
97 }
98
99 end_table();
100 br();
101
102 div_start('upgrade_args');
103 if (get_post('select_comp') !== '')
104 {
105         $patch = @$installers[$site_status[get_post('select_comp')]['version']];
106         if ($patch)
107                 $patch->show_params(get_post('select_comp'));
108 }
109 div_end();
110
111 if ($uptodate)
112         display_note(_('All company database schemes are up to date.'));
113 else {
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');
117 }
118 end_form();
119
120 end_page();
121