From a1cbe8181051f2eb0006d932591859a56f4c33fc Mon Sep 17 00:00:00 2001 From: Bjverde Date: Sat, 17 Mar 2018 22:36:23 -0300 Subject: [PATCH] :hammer: Form create OK --- classes/Message.class.php | 3 +- classes/TGeneratorHelper.class.php | 66 ++++++++++++++++++++++++------ modulos/gen03.php | 2 + 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/classes/Message.class.php b/classes/Message.class.php index 51fda27..17f6d26 100644 --- a/classes/Message.class.php +++ b/classes/Message.class.php @@ -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'; } ?> \ No newline at end of file diff --git a/classes/TGeneratorHelper.class.php b/classes/TGeneratorHelper.class.php index 745291d..49a97ff 100644 --- a/classes/TGeneratorHelper.class.php +++ b/classes/TGeneratorHelper.class.php @@ -153,7 +153,6 @@ public static function copySystemSkeletonToNewSystem(){ //echo ' SubPath: ' . $it->getSubPath()."
"; self::mkDir($pathNewSystem.DS.$it->getSubPath()); copy($pathSkeleton.DS.$it->getSubPathName(),$pathNewSystem.DS.$it->getSubPathName()); - } } } @@ -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']; @@ -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(); } } diff --git a/modulos/gen03.php b/modulos/gen03.php index 5650457..1646a61 100644 --- a/modulos/gen03.php +++ b/modulos/gen03.php @@ -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