From 2a133f4a3f5de2e15da737efa48f107512d829ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 22 Jul 2017 20:12:00 +0200 Subject: [PATCH] Generate table for extrafields --- htdocs/langs/en_US/modulebuilder.lang | 1 + htdocs/modulebuilder/index.php | 18 +++++++++++---- .../template/sql/llx_myobject_extrafields.sql | 23 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index a3ba8a7455b..063e1c8d332 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -51,6 +51,7 @@ WidgetFile=Widget file ReadmeFile=Readme file ChangeLog=ChangeLog file SqlFile=Sql file +SqlFileExtraFields=Sql file for complementary attributes SqlFileKey=Sql file for keys AnObjectAlreadyExistWithThisNameAndDiffCase=An object already exists with this name and a different case UseAsciiDocFormat=You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown) \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 239126b061e..0b5c1da7039 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -110,8 +110,9 @@ if ($dirins && $action == 'initmodule' && $modulename) dol_delete_file($destdir.'/myobject_card.php'); dol_delete_file($destdir.'/myobject_list.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); dol_delete_file($destdir.'/sql/llx_myobject.sql'); + dol_delete_file($destdir.'/sql/llx_myobject_extrafields.sql'); + dol_delete_file($destdir.'/sql/llx_myobject.key.sql'); dol_delete_file($destdir.'/scripts/myobject.php'); dol_delete_file($destdir.'/img/object_myobject.png'); dol_delete_file($destdir.'/class/myobject.class.php'); @@ -189,9 +190,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname) 'myobject_card.php'=>strtolower($objectname).'_card.php', 'myobject_list.php'=>strtolower($objectname).'_list.php', 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', @@ -377,9 +379,10 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) 'myobject_card.php'=>strtolower($objectname).'_card.php', 'myobject_list.php'=>strtolower($objectname).'_list.php', 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php', - 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', 'sql/llx_myobject.sql'=>'sql/llx_'.strtolower($objectname).'.sql', - 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', + 'sql/llx_myobject_extrafields.sql'=>'sql/llx_'.strtolower($objectname).'_extrafields.sql', + 'sql/llx_myobject.key.sql'=>'sql/llx_'.strtolower($objectname).'.key.sql', + 'scripts/myobject.php'=>'scripts/'.strtolower($objectname).'.php', 'img/object_myobject.png'=>'img/object_'.strtolower($objectname).'.png', 'class/myobject.class.php'=>'class/'.strtolower($objectname).'.class.php', 'class/api_myobject.class.php'=>'class/api_'.strtolower($objectname).'.class.php', @@ -423,6 +426,7 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey) // File of sql $fileforsql = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.sql'; + $fileforsqlextra = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'_extrafields.sql'; $fileforsqlkey = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.key.sql'; @@ -1179,6 +1183,7 @@ elseif (! empty($module)) $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php'; $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php'; $pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql'; + $pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql'; $pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql'; print '<div class="fichehalfleft">'; print '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.$pathtoclass.'</strong>'; @@ -1190,6 +1195,9 @@ elseif (! empty($module)) print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.$pathtosql.'</strong>'; print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; print '<br>'; + print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileExtraFields").' : <strong>'.$pathtosqlextra.'</strong>'; + print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; + print '<br>'; print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileKey").' : <strong>'.$pathtosqlkey.'</strong>'; print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>'; print '</div>'; diff --git a/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql b/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql new file mode 100644 index 00000000000..72c672a92f8 --- /dev/null +++ b/htdocs/modulebuilder/template/sql/llx_myobject_extrafields.sql @@ -0,0 +1,23 @@ +-- Copyright (C) ---Put here your own copyright and developer email--- +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +create table llx_myobject_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + -- GitLab