Skip to content

Commit

Permalink
🔨 Form create OK
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Mar 18, 2018
1 parent 15da02e commit a1cbe81
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
3 changes: 2 additions & 1 deletion classes/Message.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class Message {
const GEN02_CREATED_MENU = 'Criado arquivo de menu.';
const GEN02_CREATED_INDEX = 'Criado arquivo index do sistema.';

const GEN03_TITLE = 'Etapa 03 de 03';
const GEN03_TITLE = 'Etapa 03 de 03';
const GEN03_NEW_SYSTEM_OK = 'Sistema Criado com Sucesso';
}
?>
66 changes: 53 additions & 13 deletions classes/TGeneratorHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ public static function copySystemSkeletonToNewSystem(){
//echo ' SubPath: ' . $it->getSubPath()."<br>";
self::mkDir($pathNewSystem.DS.$it->getSubPath());
copy($pathSkeleton.DS.$it->getSubPathName(),$pathNewSystem.DS.$it->getSubPathName());

}
}
}
Expand All @@ -179,7 +178,7 @@ public static function createFileIndex(){
$file->saveFile();
}

public static function getTDAOConect($tableName){
private static function getTDAOConect($tableName){
$dbType = $_SESSION[APLICATIVO]['DBMS']['TYPE'];
$user = $_SESSION[APLICATIVO]['DBMS']['USER'];
$password = $_SESSION[APLICATIVO]['DBMS']['PASSWORD'];
Expand All @@ -204,25 +203,66 @@ public static function loadTablesFromDatabase(){
public static function loadFieldsFromDatabase(){
$listTables = self::loadTablesFromDatabase();
$listTableNames = $listTables['TABLE_NAME'];
foreach ($listTableNames as $key=>$value){
$dao = self::getTDAOConect($value);
foreach ($listTableNames as $key=>$table){
$dao = self::getTDAOConect($table);
$dados = $dao->loadFieldsOneTableFromDatabase();
d($dados);
self::createFilesDaoVoFromTable($table, $dados['COLUMN_NAME']);
self::createFilesForms($table, $dados['COLUMN_NAME']);
}
//return $dados;
}

public static function createDaoVoFromTable($tableName, $listColumns){
$gerador = new TDAOCreate($frm->get('tabela'), $coluna_chave, $diretorio);
private static function getConfigByDBMS($DBMS){
switch( $DBMS ) {
case DBMS_MYSQL:
$SCHEMA = false;
$TPGRID = GRID_SQL_PAGINATION;
break;
case DBMS_SQLSERVER:
$SCHEMA = true;
$TPGRID = GRID_SQL_PAGINATION;
break;
//--------------------------------------------------------------------------------
default:
$SCHEMA = false;
$TPGRID = GRID_SCREEN_PAGINATION;
}
$config['SCHEMA'] = $SCHEMA;
$config['TPGRID'] = $TPGRID;
return $config;
}

public static function createFilesDaoVoFromTable($tableName, $listColumns){
$DBMS = $_SESSION[APLICATIVO]['DBMS']['TYPE'];
$configDBMS = self::getConfigByDBMS($DBMS);
$folder = self::getPathNewSystem().DS.'dao'.DS;
$columnPrimaryKey = $listColumns[0];
$generatorDao = new TCreateDAO($tableName, $columnPrimaryKey, $folder);
foreach($listColumns as $k=>$v) {
$gerador->addColumn($v);
$generatorDao->addColumn($v);
}
$showSchema = $frm->get('sit_const_schema');
$gerador->setShowSchema($showSchema);
$gerador->setWithSqlPagination($TPGRID);
$gerador->setDatabaseManagementSystem($TPBANCO);
$gerador->saveVO();
$gerador->saveDAO();
$generatorDao->setDatabaseManagementSystem($DBMS);
$generatorDao->setWithSqlPagination($configDBMS['TPGRID']);
$generatorDao->setShowSchema($configDBMS['SCHEMA']);
$generatorDao->saveVO();
$generatorDao->saveDAO();
}

public static function createFilesForms($tableName, $listColumns){
$DBMS = $_SESSION[APLICATIVO]['DBMS']['TYPE'];
$configDBMS = self::getConfigByDBMS($DBMS);
$folder = self::getPathNewSystem().DS.'modulos'.DS;
$columnPrimaryKey = $listColumns[0];
$geradorForm = new TCreateForm();
$geradorForm->setFormTitle( $tableName );
$geradorForm->setFormPath( $folder );
$geradorForm->setFormFileName( $tableName );
$geradorForm->setPrimaryKeyTable( $columnPrimaryKey );
$geradorForm->setTableRef( $tableName );
$geradorForm->setListColunnsName( $listColumns );
$geradorForm->setGridType( $configDBMS['TPGRID'] );
$geradorForm->saveForm();
}

}
Expand Down
2 changes: 2 additions & 0 deletions modulos/gen03.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
try {
TGeneratorHelper::loadFieldsFromDatabase();

$html->add(TGeneratorHelper::showMsg(true,Message::GEN03_NEW_SYSTEM_OK));

$listTables = null;
$gride = new TGrid( 'gd' // id do gride
,'Lista de Tabelas' // titulo do gride
Expand Down

0 comments on commit a1cbe81

Please sign in to comment.