sub PreCreateForm ()
{
   my $cTable;
   my $oConfigFile;
   my @lTables;

   @lTables = $oDbSessionGL->getDbHandle()->tables();

   push @lTables, "UserFormat\\," . i18n("UserFormat");

   foreach (@lTables)
   {
	   $_ = "".$_ . "\\," . "".$_;
   }

   &MySetVal("Layout Field DbTable", "Values",
             join "\n", @lTables);

   $cTable = $oSessionGL->getState("CreateAppRc,DbTable");

   if(&GetAttr("LastBtn") ne "BtnNext")
   {
      &SetField("DbTable", $cTable);
   }

}



sub Check_AppRc_DbTable()
{
   &AddError("DbTable", "No database-table, please select one!!")
       if(!&GetField("DbTable"));
}



sub MyBtnNext ()
{
   &CheckRecord();

   if(!&GetField("DbTable"))
   {
      &GenPage();
   }
   else
   {
      if (&GetField("ForceCreation"))
      {
         foreach (".rc", ".pl")
         {
            # remove the existing config-file
            unlink(&GetAttr("BaseDir") .
                   "/lib/WWWdb/tmp/" .
                   GetField("DbTable") . $_);
         }
      }

      $oSessionGL->setState("CreateAppRc,DbTable",
                            &GetField("DbTable"));
      $oSessionGL->setState("CreateAppRc,ConfigFile",
                            "/tmp/" . &GetField("DbTable") . "$$.rc");

      print &Redirect(&GetAttr("SessionId"),
                      "WWWdb:Wiz:CreateAppRc_2");
   }
}

1;
