diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang
index 8fab0a7b07f..5a3470aebce 100644
--- a/htdocs/langs/en_US/modulebuilder.lang
+++ b/htdocs/langs/en_US/modulebuilder.lang
@@ -38,3 +38,5 @@ PathToModulePackage=Path to zip of module/application package
PathToModuleDocumentation=Path to file of module/application documentation
SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed.
FileNotYetGenerated=File not yet generated
+SpecificationFile=File with business rules
+ConfirmDeleteProperty=Are you sure you want to delete the property %s ? This will change code in PHP class but also remove column from table definition of object.
\ No newline at end of file
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 2547b893055..a1c30b7c94a 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -37,9 +37,10 @@ $cancel=GETPOST('cancel','alpha');
$module=GETPOST('module','alpha');
$tab=GETPOST('tab','aZ09');
$tabobj=GETPOST('tabobj','alpha');
+$propertykey=GETPOST('propertykey','alpha');
if (empty($module)) $module='initmodule';
if (empty($tab)) $tab='description';
-if (empty($tabobj)) $tabobj='newobject';
+if (empty($tabobj)) $tabobj='newobjectifnoobj';
$file=GETPOST('file','alpha');
$modulename=dol_sanitizeFileName(GETPOST('modulename','alpha'));
@@ -58,6 +59,7 @@ $FILEFLAG='modulebuilder.txt';
$now=dol_now();
+
/*
* Actions
*/
@@ -320,6 +322,29 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname)
$tabobj = 'deleteobject';
}
+if ($dirins && $action == 'confirm_deleteproperty' && $propertykey)
+{
+ if (! $error)
+ {
+ $modulelowercase=strtolower($module);
+ $objectlowercase=strtolower($objectname);
+
+ // File of class
+ $fileforclass = $dirins.'/'.$modulelowercase.'/class/'.$objectlowercase.'.class.php';
+
+ // TODO
+
+ // File of sql
+ $fileforsql = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.sql';
+ $fileforsqlkey = $dirins.'/'.$modulelowercase.'/sql/'.$objectlowercase.'.key.sql';
+
+
+ // TODO
+ }
+}
+
+
+
if ($dirins && $action == 'generatepackage')
{
$modulelowercase=strtolower($module);
@@ -838,9 +863,11 @@ elseif (! empty($module))
$h++;
$listofobject = dol_dir_list($dir, 'files', 0, '\.txt$');
+ $firstobjectname='';
foreach($listofobject as $fileobj)
{
$objectname = preg_replace('/\.txt$/', '', $fileobj['name']);
+ if (empty($firstobjectname)) $firstobjectname = $objectname;
$head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname;
$head3[$h][1] = $objectname;
@@ -853,6 +880,12 @@ elseif (! empty($module))
$head3[$h][2] = 'deleteobject';
$h++;
+ // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects.
+ if ($tabobj == 'newobjectifnoobj')
+ {
+ if ($firstobjectname) $tabobj=$firstobjectname;
+ else $tabobj = 'newobject';
+ }
dol_fiche_head($head3, $tabobj, '', -1, '');
@@ -888,92 +921,168 @@ elseif (! empty($module))
}
else
{
- try {
- $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php';
- $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php';
- $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.class.php';
- $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.class.php';
- print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.'
';
- print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'
';
- print ' '.$langs->trans("PageForList").' : '.$pathtolist.'
';
- print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'
';
+ if ($action == 'deleteproperty')
+ {
+ $formconfirm = $form->formconfirm(
+ $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey','alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj),
+ $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey','alpha')), 'confirm_deleteproperty', '', 0, 1
+ );
- $result = dol_include_once($pathtoclass);
- $tmpobjet = new $tabobj($db);
+ // Print form confirm
+ print $formconfirm;
+ }
- $reflector = new ReflectionClass($tabobj);
- $properties = $reflector->getProperties(); // Can also use get_object_vars
- $propdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars
- //$propstat = $reflector->getStaticProperties();
+ if ($action != 'editfile' || empty($file))
+ {
+ try {
+ $pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php';
+ $pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php';
+ $pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php';
+ $pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php';
+ print ' '.$langs->trans("ClassFile").' : '.$pathtoclass.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
+ print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
+ print ' '.$langs->trans("PageForList").' : '.$pathtolist.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
+ print ' '.$langs->trans("PageForCreateEditView").' : '.$pathtocard.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
- print load_fiche_titre($langs->trans("Properties"), '', '');
+ $result = dol_include_once($pathtoclass);
+ $tmpobjet = new $tabobj($db);
- print '