Sales invoice voiding is blocked when sales credit was issued against the invoice.
[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($path_to_root.'/tmp/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
67 $uptodate = true;
68 foreach($site_status as $i => $comp)
69 {
70         $status = $comp['version']==$db_version;
71
72         alt_table_row_color($k);
73
74         label_cell($comp['name']);
75         label_cell($comp['table_set']);
76
77         label_cell($comp['version'], 'align=center' .($status ? '':' class=redfg')/*, 'class='.( $status ? 'ok' : 'error')*/);
78
79         $log = $path_to_root.'/tmp/upgrade.'.$i.'.log';
80         if (file_exists($log))
81         {
82                 label_cell(viewer_link(_('View log'), "admin/view/view_upgrade_log.php?id=$i", null, $i, 'log.png')
83                   .button('Clear'.$i, _('Clear'), _('Clear log'), ICON_DELETE), 'align=center');
84                 submit_js_confirm('Clear'.$i, _("Do you really want to clear this upgrade log?"));
85         } else
86                 label_cell('-', 'align=center');
87
88
89         if (!$status)
90         {
91                 label_cell(radio(null, 'select_comp', $i, null, true), 'align=center');
92                 $uptodate = false;
93         } else
94                 label_cell(_('Up to date'));
95         end_row();
96 }
97
98 end_table();
99 br();
100
101 div_start('upgrade_args');
102 if (get_post('select_comp') !== '')
103 {
104         $patch = @$installers[$site_status[get_post('select_comp')]['version']];
105         if ($patch)
106                 $patch->show_params(get_post('select_comp'));
107 }
108 div_end();
109
110 if ($uptodate)
111         display_note(_('All company database schemes are up to date.'));
112 else {
113         if (get_post('select_comp') === '')
114                 display_note(_("Select company for incremental upgrade."), 0, 1, "class='stockmankofg'");
115         submit_center('Upgrade', _('Upgrade'), true, _('Save database and perform upgrade'), 'process');
116 }
117 end_form();
118
119 end_page();
120