public void logoutMessage(WaiterPadResponse result, String fromWhere) {
    if (result != null) {
      if (result.isError() && result.getErrorMessage().toLowerCase().contains("invalid")) {
        String message = mLanguageManager.getInvalidUser();
        showMessage(message);

        if (editEnterPinToExit != null) {
          editEnterPinToExit.setText("");
        }
      } else if (result.isError()
          && result.getErrorMessage().toLowerCase().contains("device not registred")) {

        /*String message = mLanguageManager.getDeviceNotRegistered();
        showMessage(message);

        if (editEnterPinToExit != null) {
        	editEnterPinToExit.setText("");
        }*/

        // only when the valid pin is entered
        // this will be reached
        // so exit user, since device not registered will only happen
        // when iiko is restarted.

        // changes as on 22nd Jan 2014
        Intent intent = new Intent(SettingsActivity.this, ExitActivity.class);
        intent.setFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_CLEAR_TASK
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        // intent.putExtra(Global.FROM_ACTIVITY,
        // Global.FROM_SPLASH);
        startActivity(intent);
        finish();
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        // changes end here

      } else {
        if (builderEnterPin != null) {
          builderEnterPin.dismiss();
        }

        // Remove from sharedpreferences
        String[] keys =
            new String[] {Prefs.WAITER_CODE, Prefs.WAITER_ID, Prefs.WAITER_NAME, Prefs.USER_PIN};

        Prefs.removeKeys(SettingsActivity.this, keys);
        Prefs.addKey(SettingsActivity.this, Prefs.LANGUAGE_SELECTED, langSelection);

        stopService(SettingsActivity.this);

        Global.logd(TAG + " From : " + fromWhere);
        if (fromWhere != null) {
          if (fromWhere.equalsIgnoreCase(Global.FROM_CHANGE_WAITER_CODE)) {
            Intent intent = new Intent(SettingsActivity.this, LoginActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra(Global.FROM_ACTIVITY, Global.FROM_SPLASH);
            startActivity(intent);
            finish();
            Global.activityStartAnimationRightToLeft(SettingsActivity.this);
          } else if (fromWhere.equalsIgnoreCase(Global.FROM_EXIT)) {
            Log.d("Home", "exit else if condition");
            Intent intent = new Intent(SettingsActivity.this, ExitActivity.class);
            intent.setFlags(
                Intent.FLAG_ACTIVITY_CLEAR_TOP
                    | Intent.FLAG_ACTIVITY_CLEAR_TASK
                    | Intent.FLAG_ACTIVITY_NEW_TASK);
            // intent.putExtra(Global.FROM_ACTIVITY,
            // Global.FROM_SPLASH);
            startActivity(intent);
            finish();
            Global.activityStartAnimationRightToLeft(SettingsActivity.this);
          }
        }
      }
    } else {
      // commenting this, as Nick wants the ability to logout when
      // the server is not reachable
      /*String message = mLanguageManager.getServerUnreachable();
      showMessage(message);

      if (editEnterPinToExit != null) {
      	editEnterPinToExit.setText("");
      }*/

      // exiting the app since it would have been called only when the correct pin is entered
      // so instead of displaying the message the app will exit normally
      Intent intent = new Intent(SettingsActivity.this, ExitActivity.class);
      intent.setFlags(
          Intent.FLAG_ACTIVITY_CLEAR_TOP
              | Intent.FLAG_ACTIVITY_CLEAR_TASK
              | Intent.FLAG_ACTIVITY_NEW_TASK);
      // intent.putExtra(Global.FROM_ACTIVITY,
      // Global.FROM_SPLASH);
      startActivity(intent);
      finish();
      Global.activityStartAnimationRightToLeft(SettingsActivity.this);
    }
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.txtLeftMenuLink:
        Intent browserIntent =
            new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + getString(R.string.site)));

        // changes as on 2nd Jan 2014
        StartActivity.currentIntent = browserIntent;
        // changes end here

        startActivity(browserIntent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

        // changes as on 15th July 2013
        // added this because of design changes
      case R.id.menuIcon:
        toggle();
        setSelectedView();
        break;

      case R.id.txtLanguage:
        setSelectedView();
        languageCall();
        break;

      case R.id.txtSectionSelection:
        setSelectedView();
        showSectionBox();
        break;

      case R.id.txtConfigureSettings:
        setSelectedView();
        Intent intent = new Intent(SettingsActivity.this, ConfigureServiceActivity.class);
        intent.putExtra(Global.FROM_ACTIVITY, TAG);
        startActivity(intent);
        // activity in animation
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtForceSync:
        setSelectedView();
        // sync all data
        GetAllDataAsyncTask getAllDataAsyncTask =
            new GetAllDataAsyncTask(SettingsActivity.this, Global.SETTINGS);
        getAllDataAsyncTask.execute();
        break;

      case R.id.txtSendLog:
        setSelectedView();
        InputStream is = mUtils.readFromLogFile();

        if (is != null) {
          sendLogAsyncTask = new SendLogAsyncTask(SettingsActivity.this, is);
          sendLogAsyncTask.execute();
        }

        break;

      case R.id.txtLogout:
        setSelectedView();
        callDialog(Global.FROM_EXIT);
        break;

      case R.id.lnrSectionSelection:
        showSectionBox();
        setSelectedView();
        break;

      case R.id.lnrLanguage:
        languageCall();
        setSelectedView();
        break;

      case R.id.txtSyncMenu:
        // sync just the menu
        showSyncDialogBox();
        setSelectedView();
        break;

      case R.id.btnPlaceOrderLeftMenu:
        // lead to the table selection list
        Prefs.addKey(Prefs.MENU_SELECTED, Global.TABLES);
        setSelectedView();
        intent = new Intent(this, TableListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtSettingsLeftMenu:
        toggle();
        Prefs.addKey(Prefs.MENU_SELECTED, Global.SETTINGS);
        setSelectedView();
        break;

      case R.id.txtOrdersLeftMenu:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.ORDERS);
        setSelectedView();
        finish();
        intent = new Intent(this, MyOrderActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.txtNotificationsLeftMenu:
        // take to the notification screen
        Prefs.addKey(Prefs.MENU_SELECTED, Global.NOTIFICATIONS);
        setSelectedView();
        intent = new Intent(this, NotificationListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.relNotificationCentre:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.NOTIFICATIONS);
        setSelectedView();
        intent = new Intent(this, NotificationListActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.activity_in_anim, R.anim.activity_out_anim);
        break;

      case R.id.txtTablesLeftMenu:
        Prefs.addKey(Prefs.MENU_SELECTED, Global.TABLES);
        setSelectedView();
        intent = new Intent(this, TableListActivity.class);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.btnLeftMenuLock:
        intent = new Intent(this, LoginActivity.class);
        intent.putExtra(Global.ACTION, Global.FROM_LOCK);
        startActivity(intent);
        Global.activityStartAnimationRightToLeft(SettingsActivity.this);
        break;

      case R.id.btnLeftMenuWaiterChange:
        callDialog(Global.FROM_CHANGE_WAITER_CODE);
        break;

      default:
        break;
    }
  }