+ if (isset($_POST['coas']))
+ foreach($_POST['coas'] as $package => $ok) {
+ $ret &= install_extension($package);
+ }
+ if ($ret) {
+ if (file_exists($path_to_root . '/installed_extensions.php'))
+ include($path_to_root.'/installed_extensions.php');
+ $_POST['Page'] = 5;
+ }
+} elseif (isset($_POST['set_admin'])) {
+ // check company settings
+ if (get_post('name')=='') {
+ display_error(_('Company name cannot be empty.'));
+ set_focus('name');
+ }
+ elseif (get_post('admin')=='') {
+ display_error(_('Company admin name cannot be empty.'));
+ set_focus('admin');
+ }
+ elseif (get_post('pass')=='') {
+ display_error(_('Company admin password cannot be empty.'));
+ set_focus('pass');
+ }
+ elseif (get_post('pass')!=get_post('repass')) {
+ display_error(_('Company admin passwords differ.'));
+ unset($_POST['pass'],$_POST['repass']);
+ set_focus('pass');
+ }
+ else {
+
+ $_SESSION['inst_set'] = array_merge($_SESSION['inst_set'], array(
+ 'coa' => $_POST['coa'],
+ 'pass' => $_POST['pass'],
+ 'name' => $_POST['name'],
+ 'admin' => $_POST['admin'],
+ 'lang' => $_POST['lang']
+ ));
+ if (do_install()) {
+ $_POST['Page'] = 6;
+ }
+ }
+}
+
+if (list_updated('inst_lang')) {
+ $_SESSION['inst_set']['inst_lang'] = get_post('inst_lang');
+ $Ajax->setEncoding($inst_langs[get_post('inst_lang')]['encoding']);
+ $Ajax->activate('welcome');
+}
+
+start_form();
+ switch(@$_POST['Page']) {
+ default:
+ case '1':
+ div_start('welcome');
+ subpage_title(_('System Diagnostics'));
+ start_table();
+ instlang_list_row(_("Select install wizard language:"), 'inst_lang',
+ $_SESSION['inst_set']['inst_lang']);
+ end_table(1);
+ $_POST['Tests'] = display_system_tests(true);
+ br();
+ if (@$_POST['Tests']) {
+ display_notification(_('All application preliminary requirements seems to be correct. Please press Continue button below.'));
+ submit_center('continue', _('Continue >>'));
+ } else {
+ display_error(_('Application cannot be installed. Please fix problems listed below in red, and press Refresh button.'));
+ submit_center('refresh', _('Refresh'));
+ }
+ div_end();
+ break;
+
+ case '2':
+ if (!isset($_POST['host'])) {
+ foreach($_SESSION['inst_set'] as $name => $val)
+ $_POST[$name] = $val;
+ }
+ subpage_title(_('Database Server Settings'));
+ start_table(TABLESTYLE);
+ text_row_ex(_("Server Host:"), 'host', 30, 60);
+ text_row_ex(_("Server Port:"), 'port', 30, 60);
+ text_row_ex(_("Database Name:"), 'dbname', 30);
+ text_row_ex(_("Database User:"), 'dbuser', 30);
+ password_row(_("Database Password:"), 'dbpassword', '');
+ collations_list_row(_("Database Collation:"), 'collation');
+ yesno_list_row(_("Use '0_' Table Prefix:"), 'tbpref', 1, _('Yes'), _('No'), false);
+ check_row(_("Install Additional Language Packs from FA Repository:"), 'sel_langs');
+ check_row(_("Install Additional COAs from FA Repository:"), 'sel_coas');
+ end_table(1);
+ display_note(_("Use database user/password with permissions to create new database, or use proper credentials for previously created empty database."));
+ display_note(_("Select collation you want to use. If you are unsure or you will use various languages, select unicode collation."));
+ display_note(_("Use table prefix if you share selected database for more than one FA company using the same collation."));
+ display_note(_("Do not select additional langs nor COAs if you have no working internet connection right now. You can install them later."));
+ display_note(_("Set Only Port value if you cannot use the default port 3306."));
+ submit_center_first('back', _('<< Back'));
+ submit_center_last('db_test', _('Continue >>'));
+ break;
+
+ case '3': // select langauges
+ subpage_title(_('User Interface Languages Selection'));
+ display_langs();
+ submit_center_first('back', _('<< Back'));
+ submit_center_last('install_langs', _('Continue >>'));
+ break;
+
+ case '4': // select COA
+ subpage_title(_('Charts of Accounts Selection'));
+ display_coas();
+ submit_center_first('back', _('<< Back'));
+ submit_center_last('install_coas', _('Continue >>'));
+ break;
+
+ case '5':
+ if (!isset($_POST['name'])) {
+ foreach($_SESSION['inst_set'] as $name => $val)
+ $_POST[$name] = $val;
+ set_focus('name');
+ }
+ if (!isset($installed_extensions)) {
+ $installed_extensions = array();
+ update_extensions($installed_extensions);
+ }
+
+ subpage_title(_('Company Settings'));
+ start_table(TABLESTYLE);
+ text_row_ex(_("Company Name:"), 'name', 30);
+ text_row_ex(_("Admin Login:"), 'admin', 30);
+ password_row(_("Admin Password:"), 'pass', @$_POST['pass']);
+ password_row(_("Reenter Password:"), 'repass', @$_POST['repass']);
+ coa_list_row(_("Select Chart of Accounts:"), 'coa');
+ languages_list_row(_("Select Default Language:"), 'lang');
+ end_table(1);
+ submit_center_first('back', _('<< Back'));
+ submit_center_last('set_admin', _('Install'), _('Start installation process'), 'default nonajax');
+ break;
+
+ case '6': // final screen
+ subpage_title(_('FrontAccounting ERP has been installed successsfully.'));
+ display_note(_('Please do not forget to remove install wizard folder.'));
+ session_unset();
+ session_destroy();
+ hyperlink_no_params($path_to_root.'/index.php', _('Click here to start.'));
+ break;
+
+ }
+
+ hidden('Tests');
+ hidden('Page');
+end_form(1);
+
+end_page(false, false, true);
+