diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 47c2a4e102f..10f0f8375e3 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -364,7 +364,7 @@ if ($mode == 'overwrite') {
print '';
print '
';
print '';
- print '';
+ print '';
print " | \n";
print '';
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 70632751b03..aa92a74eb4e 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1345,6 +1345,7 @@ TransKeyWithoutOriginalValue=You forced a new translation for the translation ke
TitleNumberOfActivatedModules=Activated modules
TotalNumberOfActivatedModules=Activated modules: %s / %s
YouMustEnableOneModule=You must at least enable 1 module
+YouMustEnableTranslationOverwriteBefore=You must first enable translation overwriting to be allowed to replace a translation
ClassNotFoundIntoPathWarning=Class %s not found in PHP path
YesInSummer=Yes in summer
OnlyFollowingModulesAreOpenedToExternalUsers=Note, only the following modules are available to external users (irrespective of the permissions of such users) and only if permissions are granted:
diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang
index c32e0dce7f8..416ff013219 100644
--- a/htdocs/langs/en_US/modulebuilder.lang
+++ b/htdocs/langs/en_US/modulebuilder.lang
@@ -127,9 +127,9 @@ UseSpecificEditorURL = Use a specific editor URL
UseSpecificFamily = Use a specific family
UseSpecificAuthor = Use a specific author
UseSpecificVersion = Use a specific initial version
-IncludeRefGeneration=The reference of object must be generated automatically
-IncludeRefGenerationHelp=Check this if you want to include code to manage the generation automatically of the reference
-IncludeDocGeneration=I want to generate some documents from the object
+IncludeRefGeneration=The reference of object must be generated automatically by custom numbering rules
+IncludeRefGenerationHelp=Check this if you want to include code to manage the generation of the reference automatically using custom numbering rules
+IncludeDocGeneration=I want to generate some documents from templates for the object
IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record.
ShowOnCombobox=Show value into combobox
KeyForTooltip=Key for tooltip
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index bf680ad40b3..c0c9bf2dde5 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -305,22 +305,20 @@ if ($dirins && $action == 'initmodule' && $modulename) {
'---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
);
- if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
- if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
- $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
- }
- if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
- $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
- }
- if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
- $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
- }
- if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
- $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
- }
- if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
- $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
- }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
+ $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
+ $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
+ $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
+ $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
+ $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
}
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
@@ -353,15 +351,48 @@ if ($dirins && $action == 'initmodule' && $modulename) {
}
-// init API
-if ($dirins && $action == 'initapi' && !empty($module)) {
+// init API, PHPUnit
+if ($dirins && in_array($action, array('initapi', 'initphpunit', 'initpagecontact', 'initpagedocument', 'initpagenote', 'initpageagenda')) && !empty($module)) {
$modulename = ucfirst($module); // Force first letter in uppercase
$objectname = $tabobj;
+ $varnametoupdate = '';
+
+ if ($action == 'initapi') {
+ dol_mkdir($dirins.'/'.strtolower($module).'/class');
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/class/api_mymodule.class.php';
+ $destfile = $dirins.'/'.strtolower($module).'/class/api_'.strtolower($module).'.class.php';
+ } elseif ($action == 'initphpunit') {
+ dol_mkdir($dirins.'/'.strtolower($module).'/test/phpunit');
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/test/phpunit/MyObjectTest.php';
+ $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php';
+ } elseif ($action == 'initpagecontact') {
+ dol_mkdir($dirins.'/'.strtolower($module));
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/myobject_contact.php';
+ $destfile = $dirins.'/'.strtolower($module).'/'.strtolower($objectname).'_contact.php';
+ $varnametoupdate = 'showtabofpagecontact';
+ } elseif ($action == 'initpagedocument') {
+ dol_mkdir($dirins.'/'.strtolower($module));
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/myobject_document.php';
+ $destfile = $dirins.'/'.strtolower($module).'/'.strtolower($objectname).'_document.php';
+ $varnametoupdate = 'showtabofpagedocument';
+ } elseif ($action == 'initpagenote') {
+ dol_mkdir($dirins.'/'.strtolower($module));
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/myobject_note.php';
+ $destfile = $dirins.'/'.strtolower($module).'/'.strtolower($objectname).'_note.php';
+ $varnametoupdate = 'showtabofpagenote';
+ } elseif ($action == 'initpageagenda') {
+ dol_mkdir($dirins.'/'.strtolower($module));
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/myobject_agenda.php';
+ $destfile = $dirins.'/'.strtolower($module).'/'.strtolower($objectname).'_agenda.php';
+ $varnametoupdate = 'showtabofpageagenda';
+ }
- dol_mkdir($dirins.'/'.strtolower($module).'/class');
- $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
- $srcfile = $srcdir.'/class/api_mymodule.class.php';
- $destfile = $dirins.'/'.strtolower($module).'/class/api_'.strtolower($module).'.class.php';
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy($srcfile, $destfile, 0, 0);
@@ -383,42 +414,13 @@ if ($dirins && $action == 'initapi' && !empty($module)) {
);
dolReplaceInFile($destfile, $arrayreplacement);
- } else {
- $langs->load("errors");
- setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors');
- }
-}
-
-// init PHPUnit
-if ($dirins && $action == 'initphpunit' && !empty($module)) {
- $modulename = ucfirst($module); // Force first letter in uppercase
- $objectname = $tabobj;
-
- dol_mkdir($dirins.'/'.strtolower($module).'/test/phpunit');
- $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
- $srcfile = $srcdir.'/test/phpunit/MyObjectTest.php';
- $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php';
- $result = dol_copy($srcfile, $destfile, 0, 0);
-
- if ($result > 0) {
- //var_dump($phpfileval['fullname']);
- $arrayreplacement = array(
- 'mymodule'=>strtolower($modulename),
- 'MyModule'=>$modulename,
- 'MYMODULE'=>strtoupper($modulename),
- 'My module'=>$modulename,
- 'my module'=>$modulename,
- 'Mon module'=>$modulename,
- 'mon module'=>$modulename,
- 'htdocs/modulebuilder/template'=>strtolower($modulename),
- 'myobject'=>strtolower($objectname),
- 'MyObject'=>$objectname,
- 'MYOBJECT'=>strtoupper($objectname),
- '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
- );
-
- dolReplaceInFile($destfile, $arrayreplacement);
+ if ($varnametoupdate) {
+ // Now we update the object file to set $$varnametoupdate to 1
+ $srcfile = $dirins.'/'.strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php';
+ $arrayreplacement = array('/\$'.$varnametoupdate.' = 0;/' => '$'.$varnametoupdate.' = 1;');
+ dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
+ }
} else {
$langs->load("errors");
setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile), null, 'errors');
@@ -474,7 +476,7 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) {
}
}
- // Now we update the object file to set $isextrafieldmanaged to 0
+ // Now we update the object file to set $isextrafieldmanaged to 1
$srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
$arrayreplacement = array('/\$isextrafieldmanaged = 0;/' => '$isextrafieldmanaged = 1;');
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
@@ -791,7 +793,7 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
if (!$result) {
setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors');
} else {
- // If we delete a sql file
+ // If we delete a .sql file, we delete also the other .sql file
if (preg_match('/\.sql$/', $relativefilename)) {
if (preg_match('/\.key\.sql$/', $relativefilename)) {
$relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename);
@@ -815,10 +817,23 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
}
- // Now we update the object file to set $isextrafieldmanaged to 0
- $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
- $arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;');
- dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
+ if (preg_match('/_extrafields/', $relativefilename)) {
+ // Now we update the object file to set $isextrafieldmanaged to 0
+ $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
+ $arrayreplacement = array('/\$isextrafieldmanaged = 1;/' => '$isextrafieldmanaged = 0;');
+ dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
+ }
+
+ // Now we update the lib file to set $showtabofpagexxx to 0
+ $varnametoupdate = '';
+ if (preg_match('/_([a-z]+)\.php$/', $relativefilename, $reg)) {
+ $varnametoupdate = 'showtabofpage'.$reg[1];
+ }
+ if ($varnametoupdate) {
+ $srcfile = $dirins.'/'.strtolower($module).'/class/'.strtolower($objectname).'.class.php';
+ $arrayreplacement = array('/\$'.$varnametoupdate.' = 1;/' => '$'.$varnametoupdate.' = 0;');
+ dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1);
+ }
}
}
}
@@ -1265,9 +1280,26 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
'htdocs/modulebuilder/template/'=>strtolower($modulename),
'myobject'=>strtolower($objectname),
'MyObject'=>$objectname,
- 'MYOBJECT'=>strtoupper($objectname)
+ 'MYOBJECT'=>strtoupper($objectname),
+ '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email ? ' <'.$user->email.'>' : '')
);
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) {
+ $arrayreplacement['Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) {
+ $arrayreplacement['https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) {
+ $arrayreplacement['---Put here your own copyright and developer email---'] = dol_print_date($now, '%Y').' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) {
+ $arrayreplacement['1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
+ }
+ if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) {
+ $arrayreplacement['other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
+ }
+
$result = dolReplaceInFile($phpfileval['fullname'], $arrayreplacement);
//var_dump($result);
if ($result < 0) {
@@ -2513,14 +2545,14 @@ if ($module == 'initmodule') {
print ''.$langs->trans("EnterNameOfObjectDesc").'
';
- print '
';
+ print '
';
print '
';
print '
';
print '';
print '
';
print '
';
print '
';
- print $langs->trans("or");
+ print ''.$langs->trans("or").'';
print '
';
print '
';
//print ' ';
@@ -2608,11 +2640,12 @@ if ($module == 'initmodule') {
$urlofcard = dol_buildpath('/'.$pathtocard, 1);
print '';
- print '
'.$langs->trans("ClassFile").' :
'.($realpathtoclass ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).($realpathtoclass ? '' : '').'';
+ // Main DAO class file
+ print '
'.$langs->trans("ClassFile").' :
'.(dol_is_file($realpathtoclass) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).(dol_is_file($realpathtoclass) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
// API file
print '
';
- print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi ? '' : '').(dol_is_file($realpathtoapi)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').($realpathtoapi ? '' : '').'';
+ print '
'.$langs->trans("ApiClassFile").' :
'.(dol_is_file($realpathtoapi) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').'';
if (dol_is_file($realpathtoapi)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2624,45 +2657,43 @@ if ($module == 'initmodule') {
print '
'.$langs->trans("GoToApiExplorer").'';
}
} else {
- //print '
'.$langs->trans("FileNotYetGenerated").' ';
print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
// PHPUnit
print '
';
- print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit ? '' : '').(dol_is_file($realpathtophpunit)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').($realpathtophpunit ? '' : '').'';
+ print '
'.$langs->trans("TestClassFile").' :
'.(dol_is_file($realpathtophpunit) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').'';
if (dol_is_file($realpathtophpunit)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').'';
} else {
- //print '
'.$langs->trans("FileNotYetGenerated").' ';
print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
print '
';
print '
';
- print '
'.$langs->trans("PageForLib").' :
'.($realpathtolib ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolib).($realpathtolib ? '' : '').'';
+ print '
'.$langs->trans("PageForLib").' :
'.(dol_is_file($realpathtolib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolib).(dol_is_file($realpathtolib) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
- print '
'.$langs->trans("PageForObjLib").' :
'.($realpathtoobjlib ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).($realpathtoobjlib ? '' : '').'';
+ print '
'.$langs->trans("PageForObjLib").' :
'.(dol_is_file($realpathtoobjlib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
- print '
'.$langs->trans("Image").' :
'.($realpathtopicto ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).($realpathtopicto ? '' : '').'';
+ print '
'.$langs->trans("Image").' :
'.(dol_is_file($realpathtopicto) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '').'';
//print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
print '
';
- print '
'.$langs->trans("SqlFile").' :
'.($realpathtosql ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).($realpathtosql ? '' : '').'';
+ print '
'.$langs->trans("SqlFile").' :
'.(dol_is_file($realpathtosql) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
'.$langs->trans("DropTableIfEmpty").'';
//print '
'.$langs->trans("RunSql").'';
print '
';
- print '
'.$langs->trans("SqlFileKey").' :
'.($realpathtosqlkey ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlkey).($realpathtosqlkey ? '' : '').'';
+ print '
'.$langs->trans("SqlFileKey").' :
'.(dol_is_file($realpathtosqlkey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlkey).(dol_is_file($realpathtosqlkey) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
//print '
'.$langs->trans("RunSql").'';
print '
';
- print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextra ? '' : '').'';
+ print '
'.$langs->trans("SqlFileExtraFields").' :
'.(dol_is_file($realpathtosqlextra) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').'';
if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2674,7 +2705,7 @@ if ($module == 'initmodule') {
}
//print '
'.$langs->trans("RunSql").'';
print '
';
- print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextrakey ? '' : '').'';
+ print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.(dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').'';
if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2686,38 +2717,50 @@ if ($module == 'initmodule') {
print '
';
print '';
- print '
'.$langs->trans("PageForList").' :
'.($realpathtolist ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolist).($realpathtolist ? '' : '').'';
+ print '
'.$langs->trans("PageForList").' :
'.(dol_is_file($realpathtolist) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolist).(dol_is_file($realpathtolist) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
- print '
'.$langs->trans("PageForCreateEditView").' :
'.($realpathtocard ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocard).($realpathtocard ? '' : '').'?action=create';
+ print '
'.$langs->trans("PageForCreateEditView").' :
'.(dol_is_file($realpathtocard) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocard).(dol_is_file($realpathtocard) ? '' : '').'?action=create';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
- print '
'.$langs->trans("PageForContactTab").' :
'.($realpathtocontact ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocontact).($realpathtocontact ? '' : '').'';
+ // Page contact
+ print '
'.$langs->trans("PageForContactTab").' :
'.(dol_is_file($realpathtocontact) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocontact).(dol_is_file($realpathtocontact) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
if (dol_is_file($realpathtocontact)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').'';
+ } else {
+ print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
print '
';
- print '
'.$langs->trans("PageForDocumentTab").' :
'.($realpathtodocument ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtodocument).($realpathtodocument ? '' : '').'';
+ // Page document
+ print '
'.$langs->trans("PageForDocumentTab").' :
'.(dol_is_file($realpathtodocument) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtodocument).(dol_is_file($realpathtodocument) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
if (dol_is_file($realpathtodocument)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').'';
+ } else {
+ print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
print '
';
- print '
'.$langs->trans("PageForNoteTab").' :
'.($realpathtonote ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtonote).($realpathtonote ? '' : '').'';
+ // Page notes
+ print '
'.$langs->trans("PageForNoteTab").' :
'.(dol_is_file($realpathtonote) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtonote).(dol_is_file($realpathtonote) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
if (dol_is_file($realpathtonote)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').'';
+ } else {
+ print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
print '
';
- print '
'.$langs->trans("PageForAgendaTab").' :
'.($realpathtoagenda ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoagenda).($realpathtoagenda ? '' : '').'';
+ // Page agenda
+ print '
'.$langs->trans("PageForAgendaTab").' :
'.(dol_is_file($realpathtoagenda) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoagenda).(dol_is_file($realpathtoagenda) ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
if (dol_is_file($realpathtoagenda)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').'';
+ } else {
+ print '
'.img_picto('Generate', 'generate', 'class="paddingleft"').'';
}
print '
';
print '
';
diff --git a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php
index e3117d88303..d75f69a47f5 100644
--- a/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php
+++ b/htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php
@@ -33,6 +33,11 @@ function myobjectPrepareHead($object)
$langs->load("mymodule@mymodule");
+ $showtabofpagecontact = 1;
+ $showtabofpagenote = 1;
+ $showtabofpagedocument = 1;
+ $showtabofpageagenda = 1;
+
$h = 0;
$head = array();
@@ -41,40 +46,53 @@ function myobjectPrepareHead($object)
$head[$h][2] = 'card';
$h++;
- if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
- $nbNote = 0;
- if (!empty($object->note_private)) {
- $nbNote++;
- }
- if (!empty($object->note_public)) {
- $nbNote++;
- }
- $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans('Notes');
- if ($nbNote > 0) {
- $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '
'.$nbNote.'' : '');
- }
- $head[$h][2] = 'note';
+ if ($showtabofpagecontact) {
+ $head[$h][0] = dol_buildpath("/mymodule/myobject_contact.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("Contacts");
+ $head[$h][2] = 'contact';
$h++;
}
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
- $upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref);
- $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
- $nbLinks = Link::count($db, $object->element, $object->id);
- $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans('Documents');
- if (($nbFiles + $nbLinks) > 0) {
- $head[$h][1] .= '
'.($nbFiles + $nbLinks).'';
+ if ($showtabofpagenote) {
+ if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
+ $nbNote = 0;
+ if (!empty($object->note_private)) {
+ $nbNote++;
+ }
+ if (!empty($object->note_public)) {
+ $nbNote++;
+ }
+ $head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans('Notes');
+ if ($nbNote > 0) {
+ $head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '
'.$nbNote.'' : '');
+ }
+ $head[$h][2] = 'note';
+ $h++;
+ }
}
- $head[$h][2] = 'document';
- $h++;
- $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
- $head[$h][1] = $langs->trans("Events");
- $head[$h][2] = 'agenda';
- $h++;
+ if ($showtabofpagedocument) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+ $upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref);
+ $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+ $nbLinks = Link::count($db, $object->element, $object->id);
+ $head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans('Documents');
+ if (($nbFiles + $nbLinks) > 0) {
+ $head[$h][1] .= '
'.($nbFiles + $nbLinks).'';
+ }
+ $head[$h][2] = 'document';
+ $h++;
+ }
+
+ if ($showtabofpageagenda) {
+ $head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("Events");
+ $head[$h][2] = 'agenda';
+ $h++;
+ }
// Show more tabs from modules
// Entries must be declared in modules descriptor with line