export class InstallWizardController extends BaseWizardController {
constructor( options = {} ) {
_.defaults( options, {
el: '.install-wizard',
type_array: null,
country_array: null,
time_zone_array: null,
external_installer: null,
company_id: null,
user_id: null,
edit_view_error_ui_dic: {},
} );
super( options );
}
init( options ) {
//this._super('initialize', options );
this.title_1 = $( this.el ).find( '.title-1' );
this.steps = 5;
this.script_name = 'wizard_install';
this.wizard_id = 'InstallWizard';
this.api = TTAPI.APIInstall;
ServiceCaller.extra_url = '&disable_db=1';
if ( _.size( LocalCacheData.getAllURLArgs() ) > 0 ) {
var url_args = LocalCacheData.getAllURLArgs();
this.current_step = url_args.a;
this.external_installer = url_args.external_installer;
} else {
this.current_step = 'license';
this.external_installer = 0;
}
this.render();
}
render() {
var $this = this;
var title = $( this.el ).find( '.title' );
this.next_btn = $( this.el ).find( '.forward-btn' );
this.back_btn = $( this.el ).find( '.back-btn' );
this.done_btn = $( this.el ).find( '.done-btn' );
title.text( $.i18n._( 'Install Wizard' ) );
this.initCurrentStep();
}
initCurrentStep( step ) {
var $this = this;
if ( step ) {
} else {
step = this.current_step;
}
ProgressBar.showOverlay();
switch ( step ) {
case 'license':
this.api.getLicense( {
onResult: function( res ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
}
} );
break;
case 'requirements':
this.api.getRequirements( this.external_installer, {
onResult: function( res ) {
if ( res.isValid() ) {
if ( res.getResult().action ) {
$this.onNextClick();
} else {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
}
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'databaseSchema':
ServiceCaller.extra_url = false;
this.api.getDatabaseSchema( {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'databaseConfig':
this.api.getDatabaseConfig( {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this.type_array = res.getResult().type_options;
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'postUpgrade':
this.api.postUpgrade( {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'systemSettings':
this.api.getSystemSettings( {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this.time_zone_array = res.getResult().time_zone_options;
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'company':
this.api.getCompany( this.company_id, {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'user':
var company_id = '';
if ( Global.isSet( this.stepsDataDic[this.current_step] ) ) {
company_id = this.stepsDataDic[this.current_step]['company_id'];
}
this.api.getUser( company_id, this.user_id, {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'installDone':
var upgrade = '';
if ( Global.isSet( $this.stepsDataDic[$this.current_step] ) ) {
upgrade = $this.stepsDataDic[$this.current_step]['upgrade'];
}
this.api.installDone( upgrade, {
onResult: function( res ) {
if ( res.isValid() ) {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
case 'maintenanceJobs':
this.api.getMaintenanceJobs( {
onResult: function( res ) {
if ( res.isValid() ) {
if ( res.getResult() === true ) {
$this.current_step = 'installDone';
$this.initCurrentStep();
} else {
$this.stepsDataDic[$this.current_step] = res.getResult();
$this._initCurrentStep();
}
} else {
$this.current_step = 'license';
$this.initCurrentStep();
}
}
} );
break;
}
}
_initCurrentStep( step ) {
var $this = this;
$this.setButtonsStatus(); // set button enabled or disabled
$this.buildCurrentStepUI();
$this.buildCurrentStepData();
$this.setCurrentStepValues();
}
setButtonsStatus() {
if ( this.current_step === 'license' ) {
Global.setWidgetEnabled( this.back_btn, false );
Global.setWidgetEnabled( this.next_btn, false );
} else {
Global.setWidgetEnabled( this.back_btn, true );
Global.setWidgetEnabled( this.next_btn, true );
}
if ( this.current_step !== 'installDone' ) {
Global.setWidgetEnabled( this.done_btn, false );
// Global.setWidgetEnabled( this.next_btn, true );
} else {
Global.setWidgetEnabled( this.done_btn, true );
Global.setWidgetEnabled( this.next_btn, false );
}
}
//Create each page UI
buildCurrentStepUI() {
var $this = this;
var step_title = this.content_div.find( '.step-title > .wizard-label' );
var license = this.content_div.find( '.license' );
var requirements = this.content_div.find( '.requirements' );
var databaseConfig = this.content_div.find( '.databaseConfig' );
var databaseSchema = this.content_div.find( '.databaseSchema' );
var postUpgrade = this.content_div.find( '.postUpgrade' );
var systemSettings = this.content_div.find( '.systemSettings' );
var company = this.content_div.find( '.company' );
var user = this.content_div.find( '.user' );
var installDone = this.content_div.find( '.installDone' );
var maintenanceJobs = this.content_div.find( '.maintenanceJobs' );
var form_item_input;
var stepData = this.stepsDataDic[this.current_step];
this.content_div.find( '.step' ).hide();
this.content_div.find( '.content-handle-btn' ).empty();
if ( Global.isSet( this.stepsWidgetDic[this.current_step] ) ) {
} else {
this.stepsWidgetDic[this.current_step] = {};
}
switch ( this.current_step ) {
case 'license':
license.empty();
this.title_1.text( $.i18n._( 'License Acceptance' ) );
if ( stepData['install_mode'] ) {
if ( stepData['license_text'] ) {
step_title.text( $.i18n._( 'Please read through the following license and if you agree and accept it, click the ' + '"' + $.i18n._( 'I Accept' ) + '"' + 'checkbox at the bottom.' ) );
form_item_input = Global.loadWidgetByName( FormItemType.TEXT_AREA );
form_item_input.TTextArea( { field: 'license_text', width: '65%', height: '80%' } );
this.stepsWidgetDic[this.current_step][form_item_input.getField()] = form_item_input;
license.append( form_item_input );
} else {
license.append( stepData['error_message'] );
}
license.append( '
' );
form_item_input = Global.loadWidgetByName( FormItemType.CHECKBOX );
form_item_input.TCheckbox( { field: 'license_accept' } );
form_item_input.unbind( 'formItemChange' ).bind( 'formItemChange', function( e, target ) {
if ( target.getValue() ) {
Global.setWidgetEnabled( $this.next_btn, true );
} else {
Global.setWidgetEnabled( $this.next_btn, false );
}
} );
this.stepsWidgetDic[this.current_step][form_item_input.getField()] = form_item_input;
license.append( form_item_input );
var accept_label = ' ' + $.i18n._( 'I Accept' ) + '';
license.append( accept_label );
} else {
var license_html = $.i18n._( 'The installer has already been run, as a safety measure it has been disabled from running again. If you are absolutely sure you want to run it again, or upgrade your system, please go to your timetrex.ini.php file and set "installer_enabled" to "TRUE". The line should look like' ) + ':';
license_html = license_html + '
';
license_html = license_html + '
';
license_html = license_html + '"' + 'installer_enabled = TRUE' + '"';
license_html = license_html + '
';
license_html = license_html + '
';
license_html = license_html + $.i18n._( 'After this change has been made, you can click the "Re-Check" button below to begin your installation.' );
license_html = license_html + '
';
license_html = license_html + '
';
license_html = license_html + $.i18n._( 'For help, please visit' ) + ' www.timetrex.com ';
license.append( license_html );
var ribbon_button_box = this.getRibbonButtonBox();
var ribbon_btn = $( '
' + $.i18n._( 'For installation assistance, please contact' ) + ' ' + '' + $.i18n._( 'TimeTrex support' ) + ''; } else if ( stepData.tt_product_edition == 10 ) { step_title_htm = step_title_htm + '
' + $.i18n._( 'For installation assistance, please join our community' ) + ' ' + '' + $.i18n._( 'forums' ) + '' + ' ' + $.i18n._( 'or contact a TimeTrex support expert for' ) + ' ' + '' + $.i18n._( 'Implementation Support Services' ) + '
'; } } if ( stepData.check_all_requirements == 1 ) { Global.setWidgetEnabled( this.next_btn, false ); } if ( _.size( stepData.extended_error_messages ) > 0 ) { Global.setWidgetEnabled( this.next_btn, false ); } step_title.html( step_title_htm ); this.title_1.text( $.i18n._( 'System Check Acceptance' ) ); // timetrex version, php version. var requirements_column1 = requirements.find( '.first-column' ); requirements_column1.empty(); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'timetrex_version' } ); this.addEditFieldToColumn( $.i18n._( 'TimeTrex Version' ), form_item_input, requirements_column1, '' ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'php_version' } ); this.addEditFieldToColumn( $.i18n._( 'PHP Version' ), form_item_input, requirements_column1, '' ); requirements.find( '.first-label' ).empty(); form_item_input = Global.loadWidgetByName( FormItemType.SEPARATED_BOX ); form_item_input.SeparatedBox( { label: $.i18n._( 'PHP Requirements' ) } ); this.addEditFieldToColumn( null, form_item_input, requirements.find( '.first-label' ) ); var requirements_column2 = requirements.find( '.second-column' ); requirements_column2.empty(); if ( stepData.check_all_requirements == 0 ) { requirements_column2.html( $.i18n._( 'All System Requirements have been met successfully' ) + '!' ); requirements_column2.addClass( 'all-ok' ); } else { // php requirements requirements_column2.removeClass( 'all-ok' ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'database_engine' } ); this.addEditFieldToColumn( $.i18n._( 'PostgreSQL Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'bcmath' } ); this.addEditFieldToColumn( $.i18n._( 'BCMATH Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'mbstring' } ); this.addEditFieldToColumn( $.i18n._( 'MBSTRING Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'gettext' } ); this.addEditFieldToColumn( $.i18n._( 'GETTEXT Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'intl' } ); this.addEditFieldToColumn( $.i18n._( 'INTL Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'soap' } ); this.addEditFieldToColumn( $.i18n._( 'SOAP Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'gd' } ); this.addEditFieldToColumn( $.i18n._( 'GD Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'json' } ); this.addEditFieldToColumn( $.i18n._( 'JSON Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'simplexml' } ); this.addEditFieldToColumn( $.i18n._( 'SimpleXML Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'curl' } ); this.addEditFieldToColumn( $.i18n._( 'CURL Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'zip' } ); this.addEditFieldToColumn( $.i18n._( 'ZIP Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'mail' } ); this.addEditFieldToColumn( $.i18n._( 'MAIL Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'openssl' } ); this.addEditFieldToColumn( $.i18n._( 'OpenSSL Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'pear' } ); this.addEditFieldToColumn( $.i18n._( 'PEAR Enabled' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'safe_mode' } ); this.addEditFieldToColumn( $.i18n._( 'Safe Mode Turned Off' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'disabled_functions' } ); this.addEditFieldToColumn( $.i18n._( 'PHP DISABLE_FUNCTIONS' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'allow_fopen_url' } ); this.addEditFieldToColumn( $.i18n._( 'ALLOW_FOPEN_URL Turned Off' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'disk_space' } ); this.addEditFieldToColumn( $.i18n._( 'Disk Space' ), form_item_input, requirements_column2, '', null, true, true ); // other requirements form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'memory_limit' } ); this.addEditFieldToColumn( $.i18n._( 'Memory Limit' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'post_size' } ); this.addEditFieldToColumn( $.i18n._( 'Max Post Size' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'upload_size' } ); this.addEditFieldToColumn( $.i18n._( 'Max Upload Size' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'base_url' } ); this.addEditFieldToColumn( $.i18n._( 'Base URL' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'system_timezone' } ); this.addEditFieldToColumn( $.i18n._( 'System TimeZone' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'php_int_size' } ); this.addEditFieldToColumn( $.i18n._( 'PHP 64-bit Support' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'base_dir' } ); this.addEditFieldToColumn( $.i18n._( 'PHP Open BaseDir' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'cli_executable' } ); this.addEditFieldToColumn( $.i18n._( 'PHP CLI Executable' ), form_item_input, requirements_column2, '', null, true, true ); form_item_input = Global.loadWidgetByName( FormItemType.TEXT ); form_item_input.TText( { field: 'config_file' } ); this.addEditFieldToColumn( $.i18n._( 'Writable' ) + ' ' + $.i18n._( stepData.application_name ) + ' ' + $.i18n._( 'Configuration File' ) + '' + stepData['config_file_loc'] + '
'; columns_html = columns_html + '' + stepData['php_config_file'] + '' + ', ' + $.i18n._( 'the include path is' ) + ': ' + '"' + '' + stepData['php_include_path'] + '' + '"' + '
'; } else { columns_html = columns_html + '' + stepData['php_config_file'] + '' + ', ' + $.i18n._( 'the include path is' ) + ': ' + '""' + '
'; } columns_html = columns_html + $.i18n._( 'Detailed' ) + ' '; columns_html = columns_html + '' + $.i18n._( 'PHP Information' ) + ''; if ( stepData.check_all_requirements == 0 ) { } else { requirements_column5.html( columns_html ); } var ribbon_button_box = this.getRibbonButtonBox(); // ribbon_button_box.css( 'width', '96%' ); var ribbon_btn = $( '' ); ribbon_btn.unbind( 'click' ).bind( 'click', function() { ProgressBar.showOverlay(); $this.api.getRequirements( $this.external_installer, { onResult: function( res ) { if ( res.getResult().action ) { $this.onNextClick(); } else if ( res.isValid() ) { $this.stepsDataDic[$this.current_step] = res.getResult(); $this._initCurrentStep(); } } } ); } ); ribbon_button_box.children().eq( 0 ).append( ribbon_btn ); this.content_div.find( '.content-handle-btn' ).html( ribbon_button_box ); requirements.show(); break; case 'user': step_title.html( $.i18n._( 'Please enter the administrator user name and password' ) + '' + '' + $.i18n._( 'This is extremely important and without these maintenance jobs running' ) + ' ' + $.i18n._( stepData.application_name ) + ' ' + $.i18n._( 'will fail to operate correctly.' ) + '' + '
' + '' + $.i18n._( 'Database version check' ) + ' ' + '' + $.i18n._( 'FAILED' ) + '' + '!' + ' ' + $.i18n._( 'Please upgrade your database to meet the minimum version requirements and try again.' ) + '
'; TAlertManager.showAlert( step_title_htm ); return false; } else { step_title_htm = step_title_htm + '' + $.i18n._( 'Connection test to your database as a non-privileged user has' ) + ' ' + '' + $.i18n._( 'SUCCEEDED' ) + '' + '!' + ' ' + $.i18n._( 'You may continue.' ) + '
'; if ( showTrue ) { TAlertManager.showAlert( step_title_htm ); } return true; } } else if ( result.test_connection === false ) { step_title_htm = step_title_htm + '' + $.i18n._( 'Connection test to your database as a non-privileged user has' ) + ' ' + '' + $.i18n._( 'FAILED' ) + '' + '!' + ' ' + $.i18n._( 'Please correct your settings and try again.' ) + '
'; TAlertManager.showAlert( step_title_htm ); return false; } } if ( result.test_priv_connection !== null ) { if ( result.test_priv_connection === false ) { step_title_htm = step_title_htm + '' + $.i18n._( 'Connection test to your database as a privileged user has' ) + ' ' + '' + $.i18n._( 'FAILED' ) + '' + '!' + ' ' + $.i18n._( 'Please correct the user name/password and try again.' ) + '
'; TAlertManager.showAlert( step_title_htm ); } } } } onFormItemChange( target ) { var widgets = this.stepsWidgetDic[this.current_step]; var key = target.getField(); var c_value = target.getValue(); switch ( key ) { case 'country': this.api.getProvinceOptions( c_value, { onResult: function( res ) { if ( res.isValid() ) { widgets.province.setSourceData( [] ); widgets.province.setSourceData( res.getResult() ); } } } ); break; case 'type': break; } } onBackClick() { var $this = this; this.saveCurrentStep(); switch ( this.current_step ) { case 'license': break; case 'requirements': this.current_step = 'license'; this.initCurrentStep(); break; case 'databaseConfig': this.current_step = 'requirements'; this.initCurrentStep(); break; case 'postUpgrade': case 'systemSettings': this.current_step = 'databaseConfig'; this.initCurrentStep(); break; case 'company': this.current_step = 'systemSettings'; this.initCurrentStep(); break; case 'maintenanceJobs': case 'installDone': this.current_step = 'user'; this.initCurrentStep(); break; case 'user': this.current_step = 'company'; this.initCurrentStep(); break; } } onNextClick() { var $data; var $this = this; this.saveCurrentStep(); switch ( this.current_step ) { case 'license': // the next interface is system requirements, so set the current step to the requirements this.current_step = 'requirements'; this.initCurrentStep(); break; case 'requirements': if ( this.external_installer == 1 ) { this.current_step = 'databaseSchema'; this.initCurrentStep(); } else { this.current_step = 'databaseConfig'; this.initCurrentStep(); } break; case 'databaseConfig': // need to save the database configure first. $data = {}; for ( var key in this.stepsWidgetDic[this.current_step] ) { var widget = this.stepsWidgetDic[this.current_step][key]; $data[key] = widget.getValue(); } if ( this.onTestDatabaseConnectionClick( this, false ) ) { TAlertManager.showConfirmAlert( $.i18n._( 'Installing/Upgrading the TimeTrex database may take up to 10 minutes. Please do not stop the process in any way, including pressing STOP or BACK in your web browser, doing so may leave your database in an unusable state.' ), null, function( result ) { if ( result ) { $this.api.createDatabase( $data, { onResult: function( res ) { if ( res.isValid() ) { if ( res.getResult().next_page ) { $this.current_step = res.getResult().next_page; $this.initCurrentStep(); } else { $this.stepsDataDic[$this.current_step] = res.getResult(); $this._initCurrentStep(); } } } } ); } } ); } break; case 'postUpgrade': this.current_step = 'installDone'; this.stepsDataDic[this.current_step] = { upgrade: 1 }; this.initCurrentStep(); break; case 'maintenanceJobs': this.current_step = 'installDone'; this.initCurrentStep(); break; case 'systemSettings': $data = {}; for ( var key in this.stepsWidgetDic[this.current_step] ) { var widget = this.stepsWidgetDic[this.current_step][key]; $data[key] = widget.getValue(); } this.api.setSystemSettings( $data, this.external_installer, { onResult: function( res ) { if ( res.isValid() ) { $this.current_step = 'company'; $this.initCurrentStep(); } } } ); break; case 'company': $data = {}; $data['company_id'] = $this.company_id; for ( var key in this.stepsWidgetDic[this.current_step] ) { var widget = this.stepsWidgetDic[this.current_step][key]; $data[key] = widget.getValue(); } this.api.setCompany( $data, { onResult: function( res ) { if ( res.isValid() ) { var company_id = res.getResult(); $this.current_step = 'user'; $this.company_id = company_id; $this.stepsDataDic[$this.current_step] = { company_id: company_id }; $this.initCurrentStep(); } else { $this.setErrorTips( res ); } } } ); break; case 'user': $data = {}; $data['user_id'] = this.user_id; for ( var key in this.stepsWidgetDic[this.current_step] ) { var widget = this.stepsWidgetDic[this.current_step][key]; $data[key] = widget.getValue(); } $data = $.extend( {}, $data, this.stepsDataDic[$this.current_step] ); this.api.setUser( $data, this.external_installer, { onResult: function( res ) { if ( res.isValid() ) { var next_page = res.getResult().next_page; $this.user_id = res.getResult().user_id; $this.current_step = next_page; $this.initCurrentStep(); } else { $this.setErrorTips( res ); } } } ); break; } } buildCurrentStepData() { var args = {}; var $this = this; var stepData = this.stepsDataDic[this.current_step]; var widgets = this.stepsWidgetDic[this.current_step]; switch ( this.current_step ) { case 'systemSettings': case 'databaseConfig': case 'license': case 'user': for ( var key in widgets ) { if ( stepData[key] ) { widgets[key].setValue( stepData[key] ); } } ProgressBar.closeOverlay(); break; case 'company': for ( var key in widgets ) { if ( stepData[key] ) { widgets[key].setValue( stepData[key] ); } } var country = widgets.country.getValue(); this.api.getProvinceOptions( country, { onResult: function( res ) { if ( res.isValid() ) { widgets.province.setSourceData( res.getResult() ); widgets.province.setValue( stepData['province'] ); } ProgressBar.closeOverlay(); } } ); break; case 'requirements': for ( var key in widgets ) { var edit_view_form_item_dic = $( this.edit_view_form_item_dic[key] ); if ( stepData[key] == 0 ) { } else { edit_view_form_item_dic.show(); } var widget = widgets[key]; widget.removeClass( 't-text' ); widget.removeClass( 'dataError' ); widget.removeClass( 'dataWarning' ); widget.addClass( 'custom-t-text' ); switch ( key ) { case 'timetrex_version': if ( stepData[key].check_timetrex_version == 0 ) { widget.html( $.i18n._( 'OK' ) + '(v' + stepData[key].current_timetrex_version + ')' ); } else if ( stepData[key].check_timetrex_version == 1 ) { widget.html( $.i18n._( 'Unable to Check Latest Version' ) ); widget.addClass( 'dataWarning' ); } else if ( stepData[key].check_timetrex_version == 2 ) { widget.html( $.i18n._( 'A Newer Version of TimeTrex is Available.' ) + ' ' + '' + $.i18n._( 'Download' ) + ' v' + stepData[key].latest_timetrex_version + ' ' + $.i18n._( 'Now' ) + '' ); widget.addClass( 'dataWarning' ); } break; case 'php_version': if ( stepData[key].check_php_version == 0 ) { widget.html( $.i18n._( 'OK' ) + ' (v' + stepData[key].php_version + ')' ); } else if ( stepData[key].check_php_version == 1 ) { widget.html( $.i18n._( 'Invalid' ) + ' (v' + stepData[key].php_version + ')' ); widget.addClass( 'dataError' ); } else if ( stepData[key].check_php_version == 2 ) { widget.html( $.i18n._( 'Unsupported' ) + ' (v' + stepData[key].php_version + ')' ); widget.addClass( 'dataWarning' ); } break; case 'php_int_size': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Invalid (Only 32-bit)' ) ); widget.addClass( 'dataError' ); } break; case 'database_engine': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else { widget.html( $.i18n._( 'Not Installed. (PGSQL extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'bcmath': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (BCMATH extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'mbstring': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (MBSTRING extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'gettext': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (GETTEXT extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'intl': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (INTL extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'soap': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (SOAP extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'gd': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (GD extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'json': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (JSON extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'mcrypt': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (MCRYPT extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'simplexml': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (SimpleXML extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'curl': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (CURL extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'zip': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (ZIP extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'mail': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (MAIL extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'openssl': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not Installed. (OpenSSL extension must be enabled)' ) ); widget.addClass( 'dataError' ); } break; case 'pear': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { if ( stepData.php_os == 'WINNT' ) { widget.html( $.i18n._( 'Not Installed.' ) + '(' + $.i18n._( 'try running' ) + ': ' + '"go-pear.bat"' + ')' ); } else { widget.html( $.i18n._( 'Not Installed.' ) + '(' + $.i18n._( 'install the PEAR RPM or package from' ) + ' ' + 'http://pear.php.net' + ')' ); } widget.addClass( 'dataError' ); } break; case 'safe_mode': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Safe Mode is On. (Please disable it in php.ini)' ) ); widget.addClass( 'dataError' ); } break; case 'allow_fopen_url': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'ALLOW_FOPEN_URL is Off. (Please enable it in php.ini)' ) ); widget.addClass( 'dataError' ); } break; case 'disk_space': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'Not enough disk space available, please free up disk space and try again.' ) ); widget.addClass( 'dataError' ); } break; case 'memory_limit': if ( stepData[key].check_php_memory_limit == 0 ) { var str = $.i18n._( 'OK' ); if ( stepData[key].memory_limit > 0 ) { str += '(' + stepData[key].memory_limit + ' bytes' + ')'; } widget.html( str ); edit_view_form_item_dic.hide(); } else if ( stepData[key].check_php_memory_limit == 1 ) { widget.html( stepData[key].memory_limit + ' bytes' + ' (' + $.i18n._( 'Set this to 512M or higher' ) + ')' ); widget.addClass( 'dataError' ); } break; case 'post_size': if ( stepData[key].check_php_post_size == 0 ) { var str = $.i18n._( 'OK' ); if ( stepData[key].post_size > 0 ) { str += '(' + stepData[key].post_size + ' bytes' + ')'; } widget.html( str ); edit_view_form_item_dic.hide(); } else if ( stepData[key].check_php_post_size == 1 ) { widget.html( stepData[key].post_size + ' bytes' + ' (' + $.i18n._( 'Set this to 25M or higher, recommend 128M' ) + ')' ); widget.addClass( 'dataError' ); } break; case 'upload_size': if ( stepData[key].check_php_upload_size == 0 ) { var str = $.i18n._( 'OK' ); if ( stepData[key].upload_size > 0 ) { str += '(' + stepData[key].post_size + ' bytes' + ')'; } widget.html( str ); edit_view_form_item_dic.hide(); } else if ( stepData[key].check_php_upload_size == 1 ) { widget.html( stepData[key].upload_size + ' bytes' + ' (' + $.i18n._( 'Set this to 25M or higher, recommend 128M' ) + ')' ); widget.addClass( 'dataError' ); } break; case 'disabled_functions': if ( stepData[key].check_disabled_functions == 0 ) { widget.html( $.i18n._( 'OK' ) ); edit_view_form_item_dic.hide(); } else if ( stepData[key].check_disabled_functions == 1 ) { widget.html( $.i18n._( 'Critical functions disabled' ) + ': ' + stepData[key].disabled_function_list + ' (' + $.i18n._( 'Please enable them in php.ini' ) + ')' ); widget.addClass( 'dataError' ); } break; case 'base_url': if ( stepData[key].check_base_url == 0 ) { widget.html( $.i18n._( 'OK' ) ); edit_view_form_item_dic.hide(); } else { widget.html( key + ' ' + $.i18n._( 'in' ) + ' timetrex.ini.php ' + $.i18n._( 'is incorrect, perhaps it should be' ) + ' ' + stepData[key].recommended_base_url + ' ' + $.i18n._( 'instead' ) ); widget.addClass( 'dataError' ); } break; case 'base_dir': if ( stepData[key].check_php_open_base_dir == 0 ) { widget.html( $.i18n._( 'OK' ) ); edit_view_form_item_dic.hide(); } else { widget.html( $.i18n._( 'PHP OPEN_BASEDIR setting' ) + ' ' + '(' + stepData[key].php_open_base_dir + ') ' + $.i18n._( 'does not include directory of PHP CLI binary' ) + ' ' + '(' + stepData[key].php_cli_directory + ')' ); widget.addClass( 'dataError' ); } break; case 'system_timezone': if ( stepData[key] == 0 ) { widget.html( $.i18n._( 'OK' ) ); } else if ( stepData[key] == 1 ) { widget.html( $.i18n._( 'system_timezone in timetrex.ini.php is invalid!' ) ); widget.addClass( 'dataError' ); } break; case 'cli_executable': if ( stepData[key].check_php_cli_binary == 0 ) { widget.html( $.i18n._( 'OK' ) ); edit_view_form_item_dic.hide(); } else { widget.html( $.i18n._( 'PHP CLI' ) + ' ' + '(' + stepData[key].php_cli + ')' + ' ' + $.i18n._( 'does not exist or is not executable.' ) ); widget.addClass( 'dataError' ); } break; case 'cli_requirements': if ( stepData[key].check_php_cli_requirements == 0 ) { widget.html( $.i18n._( 'OK' ) ); edit_view_form_item_dic.hide(); } else { widget.html( $.i18n._( 'PHP CLI requirements failed while executing' ) + ':