#!/usr/bin/perl
# ----------------------------------------------------------------------------
# This software is Copyright (C) 2007, All Rights Reserved
# ----------------------------------------------------------------------------
# This program is protected by local and international copyright laws. Any
# use of this program is subject to the the terms of the license agreement
# included as part of this distribution archive. Any other uses are strictly
# prohibited without the written permission of the Vendor and all
# other rights are reserved.
# -----------------------------------------------------------------------------
# Warning : Modifying this program violates your license agreement!
# -----------------------------------------------------------------------------

package IT::App::Menu::Admin::DatabaseEditor;

use IT::Globals;

use strict;

# ------------------------------------------------------------------------------
# Function    : main
# Description :
# Usage       : &IT::App::Menu::Admin::DatabaseEditor::main($action);
# ------------------------------------------------------------------------------

sub main {
  my $action = shift || die "no action specified!";

  my $menuName = 'databaseEditor';
  unless ($action =~ /^$menuName/) { last; }

  if    ($action eq "${menuName}")                              { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::listTables(); }
  elsif ($action eq "${menuName}_insertFakeRecords")            { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::insertFakeRecords(); } # for debugging
  elsif ($action eq "${menuName}_noDatabaseActionSelected")     { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::noDatabaseActionSelected(); }
  elsif ($action eq "${menuName}_editTablePrefix")              { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::showDatabaseActionForm("changeTablePrefix"); }
  elsif ($action eq "${menuName}_saveTablePrefix")              { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::saveTablePrefix(); }
  elsif ($action eq "${menuName}_moveDataForm")                 { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::MoveData::moveDataForm(); }
  elsif ($action eq "${menuName}_moveData")                     { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::MoveData::moveData(); }
  elsif ($action eq "${menuName}_moveDataTimeout")              { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::MoveData::moveDataTimeout(); }
  elsif ($action eq "${menuName}_editDataSourceLocation")       { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::showDatabaseActionForm("changeDataSource"); }
  elsif ($action eq "${menuName}_saveDataSourceLocation")       { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::saveDataSourceLocation(); }
  elsif ($action eq "${menuName}_createNewTablesForm")          { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::showDatabaseActionForm("createNewTables"); }
  elsif ($action eq "${menuName}_createNewTables")              { &IT::App::Menu::Admin::DatabaseEditor::DatabaseActions::createNewTables(); }

  elsif ($action eq "${menuName}_listTables")                   { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::listTables(); }
  elsif ($action eq "${menuName}_addTable")                     { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::addTableForm(); }
  elsif ($action eq "${menuName}_addTableSubmit")               { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::addTableSubmit(); }
  elsif ($action eq "${menuName}_confirmEraseTable")            { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::confirmEraseTables_form(); }
  elsif ($action eq "${menuName}_confirmEraseTableSubmit")      { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::confirmEraseTables_submit(); }
  elsif ($action eq "${menuName}_renameTable")                  { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::renameTable_form(); }
  elsif ($action eq "${menuName}_renameTableSubmit")            { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::renameTable_submit(); }
  elsif ($action eq "${menuName}_editTable")                    { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::editTable(); }
  elsif ($action eq "${menuName}_saveTable")                    { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::saveTable(); }
  elsif ($action eq "${menuName}_saveTableAndUpdateFieldOrder") { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::saveTable('updateFieldOrder'); }
  elsif ($action eq "${menuName}_enableSystemFieldEditing")     { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::setSystemFieldEditingTo('enabled'); }
  elsif ($action eq "${menuName}_disableSystemFieldEditing")    { &IT::App::Menu::Admin::DatabaseEditor::TableEditor::setSystemFieldEditingTo('disabled'); }

  elsif ($action eq "${menuName}_addSeparator")                 { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::addSeparator(); }
  elsif ($action eq "${menuName}_editSeparator")                { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::editSeparator(); }
  elsif ($action eq "${menuName}_saveSeparator")                { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::saveSeparator(); }

  elsif ($action eq "${menuName}_addField")                     { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::addField(); }
  elsif ($action eq "${menuName}_editField")                    { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::editField(); }
  elsif ($action eq "${menuName}_saveField")                    { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::saveField(); }
  elsif ($action eq "${menuName}_confirmEraseField")            { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::confirmEraseField(); }
  elsif ($action eq "${menuName}_eraseField")                   { &IT::App::Menu::Admin::DatabaseEditor::FieldEditor::eraseField(); }

}

# ----------------------------------------------------------------------------
# end of file
1;

