NEW ModuleBuilder can generate code of class from an existing SQL table
This commit is contained in:
parent
edaa111461
commit
fe6dcb2269
@ -294,6 +294,7 @@ ErrorFailedToLoadThirdParty=Failed to find/load thirdparty from id=%s, email=%s,
|
|||||||
ErrorThisPaymentModeIsNotSepa=This payment mode is not a bank account
|
ErrorThisPaymentModeIsNotSepa=This payment mode is not a bank account
|
||||||
ErrorStripeCustomerNotFoundCreateFirst=Stripe customer is not set for this thirdparty (or set to a value deleted on Stripe side). Create (or re-attach) it first.
|
ErrorStripeCustomerNotFoundCreateFirst=Stripe customer is not set for this thirdparty (or set to a value deleted on Stripe side). Create (or re-attach) it first.
|
||||||
ErrorCharPlusNotSupportedByImapForSearch=IMAP search is not able to search into sender or recipient for a string containing the character +
|
ErrorCharPlusNotSupportedByImapForSearch=IMAP search is not able to search into sender or recipient for a string containing the character +
|
||||||
|
ErrorTableNotFound=Table <b>%s</b> not found
|
||||||
|
|
||||||
# Warnings
|
# Warnings
|
||||||
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
|
||||||
|
|||||||
@ -133,9 +133,9 @@ UseSpecificEditorURL = Use a specific editor URL
|
|||||||
UseSpecificFamily = Use a specific family
|
UseSpecificFamily = Use a specific family
|
||||||
UseSpecificAuthor = Use a specific author
|
UseSpecificAuthor = Use a specific author
|
||||||
UseSpecificVersion = Use a specific initial version
|
UseSpecificVersion = Use a specific initial version
|
||||||
IncludeRefGeneration=The reference of object must be generated automatically by custom numbering rules
|
IncludeRefGeneration=The reference of this 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
|
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
|
IncludeDocGeneration=I want the feature to generate some documents (PDF, ODT) from templates for this object
|
||||||
IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record.
|
IncludeDocGenerationHelp=If you check this, some code will be generated to add a "Generate document" box on the record.
|
||||||
ShowOnCombobox=Show value into combobox
|
ShowOnCombobox=Show value into combobox
|
||||||
KeyForTooltip=Key for tooltip
|
KeyForTooltip=Key for tooltip
|
||||||
@ -157,3 +157,6 @@ ListOfTabsEntries=List of tab entries
|
|||||||
TabsDefDesc=Define here the tabs provided by your module
|
TabsDefDesc=Define here the tabs provided by your module
|
||||||
TabsDefDescTooltip=The tabs provided by your module/application are defined into the array <strong>$this->tabs</strong> into the module descriptor file. You can edit manually this file or use the embedded editor.
|
TabsDefDescTooltip=The tabs provided by your module/application are defined into the array <strong>$this->tabs</strong> into the module descriptor file. You can edit manually this file or use the embedded editor.
|
||||||
BadValueForType=Bad value for type %s
|
BadValueForType=Bad value for type %s
|
||||||
|
DefinePropertiesFromExistingTable=Define properties from an existing table
|
||||||
|
DefinePropertiesFromExistingTableDesc=If a table in the database (for the object to create) already exists, you can use it to define the properties of the object.
|
||||||
|
DefinePropertiesFromExistingTableDesc2=Keep empty if not table exists. The code generator will use different kinds of fields to build an example of table that you can edit later.
|
||||||
|
|||||||
@ -894,12 +894,58 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init an object
|
||||||
|
if ($dirins && $action == 'initobject' && $module && $objectname) {
|
||||||
|
$objectname = ucfirst($objectname);
|
||||||
|
|
||||||
// Build the $fields array from SQL table (initfromtablename)
|
$dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
|
||||||
if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) {
|
$moduletype = $listofmodules[strtolower($module)]['moduletype'];
|
||||||
|
|
||||||
|
if (preg_match('/[^a-z0-9_]/i', $objectname)) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors');
|
||||||
|
$tabobj = 'newobject';
|
||||||
|
}
|
||||||
|
if (class_exists($objectname)) {
|
||||||
|
// TODO Add a more efficient detection. Scan disk ?
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("AnObjectWithThisClassNameAlreadyExists"), null, 'errors');
|
||||||
|
$tabobj = 'newobject';
|
||||||
|
}
|
||||||
|
|
||||||
|
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
|
||||||
|
$destdir = $dirins.'/'.strtolower($module);
|
||||||
|
|
||||||
|
// The dir was not created by init
|
||||||
|
dol_mkdir($destdir.'/class');
|
||||||
|
dol_mkdir($destdir.'/img');
|
||||||
|
dol_mkdir($destdir.'/lib');
|
||||||
|
dol_mkdir($destdir.'/scripts');
|
||||||
|
dol_mkdir($destdir.'/sql');
|
||||||
|
|
||||||
|
// Scan dir class to find if an object with same name already exists.
|
||||||
|
if (!$error) {
|
||||||
|
$dirlist = dol_dir_list($destdir.'/class', 'files', 0, '\.txt$');
|
||||||
|
$alreadyfound = false;
|
||||||
|
foreach ($dirlist as $key => $val) {
|
||||||
|
$filefound = preg_replace('/\.txt$/', '', $val['name']);
|
||||||
|
if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
|
||||||
|
$alreadyfound = true;
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we must reuse a table for properties, define $stringforproperties
|
||||||
|
$stringforproperties = '';
|
||||||
$tablename = GETPOST('initfromtablename', 'alpha');
|
$tablename = GETPOST('initfromtablename', 'alpha');
|
||||||
|
if ($tablename) {
|
||||||
$_results = $db->DDLDescTable($tablename);
|
$_results = $db->DDLDescTable($tablename);
|
||||||
if (empty($_results)) {
|
if (empty($_results)) {
|
||||||
|
$error++;
|
||||||
|
$langs->load("errors");
|
||||||
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
|
setEventMessages($langs->trans("ErrorTableNotFound", $tablename), null, 'errors');
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
@ -949,8 +995,8 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
|||||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
|
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
|
||||||
);*/
|
);*/
|
||||||
|
|
||||||
$string = 'public $fields=array('."\n";
|
$stringforproperties = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
|
||||||
$string .= "<br>";
|
$stringforproperties .= 'public $fields=array('."\n";
|
||||||
$i = 10;
|
$i = 10;
|
||||||
while ($obj = $db->fetch_object($_results)) {
|
while ($obj = $db->fetch_object($_results)) {
|
||||||
// fieldname
|
// fieldname
|
||||||
@ -1057,6 +1103,10 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
|||||||
if ($fieldname == 'import_key') {
|
if ($fieldname == 'import_key') {
|
||||||
$position = 900;
|
$position = 900;
|
||||||
}
|
}
|
||||||
|
// $alwayseditable
|
||||||
|
if ($fieldname == 'label') {
|
||||||
|
$alwayseditable = 1;
|
||||||
|
}
|
||||||
// index
|
// index
|
||||||
$index = 0;
|
$index = 0;
|
||||||
if ($fieldname == 'entity') {
|
if ($fieldname == 'entity') {
|
||||||
@ -1076,6 +1126,9 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
|||||||
if (in_array($fieldname, array('note_public', 'note_private'))) {
|
if (in_array($fieldname, array('note_public', 'note_private'))) {
|
||||||
$cssview = 'wordbreak';
|
$cssview = 'wordbreak';
|
||||||
}
|
}
|
||||||
|
if (in_array($fieldname, array('ref', 'label')) || preg_match('/integer:/', $type)) {
|
||||||
|
$csslist = 'tdoverflowmax150';
|
||||||
|
}
|
||||||
|
|
||||||
// type
|
// type
|
||||||
$picto = $obj->Picto;
|
$picto = $obj->Picto;
|
||||||
@ -1087,85 +1140,42 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the property string
|
// Build the property string
|
||||||
$string .= "'".$obj->Field."'=>array('type'=>'".$type."', 'label'=>'".$label."',";
|
$stringforproperties .= "'".$obj->Field."'=>array('type'=>'".$type."', 'label'=>'".$label."',";
|
||||||
if ($default != '') {
|
if ($default != '') {
|
||||||
$string .= " 'default'=>".$default.",";
|
$stringforproperties .= " 'default'=>".$default.",";
|
||||||
}
|
}
|
||||||
$string .= " 'enabled'=>".$enabled.",";
|
$stringforproperties .= " 'enabled'=>".$enabled.",";
|
||||||
$string .= " 'visible'=>".$visible;
|
$stringforproperties .= " 'visible'=>".$visible;
|
||||||
if ($notnull) {
|
if ($notnull) {
|
||||||
$string .= ", 'notnull'=>".$notnull;
|
$stringforproperties .= ", 'notnull'=>".$notnull;
|
||||||
|
}
|
||||||
|
if ($alwayseditable) {
|
||||||
|
$stringforproperties .= ", 'alwayseditable'=>1";
|
||||||
}
|
}
|
||||||
if ($fieldname == 'ref' || $fieldname == 'code') {
|
if ($fieldname == 'ref' || $fieldname == 'code') {
|
||||||
$string .= ", 'showoncombobox'=>1";
|
$stringforproperties .= ", 'showoncombobox'=>1";
|
||||||
}
|
}
|
||||||
$string .= ", 'position'=>".$position;
|
$stringforproperties .= ", 'position'=>".$position;
|
||||||
if ($index) {
|
if ($index) {
|
||||||
$string .= ", 'index'=>".$index;
|
$stringforproperties .= ", 'index'=>".$index;
|
||||||
}
|
}
|
||||||
if ($picto) {
|
if ($picto) {
|
||||||
$string .= ", 'picto'=>'".$picto."'";
|
$stringforproperties .= ", 'picto'=>'".$picto."'";
|
||||||
}
|
}
|
||||||
if ($css) {
|
if ($css) {
|
||||||
$string .= ", 'css'=>".$css;
|
$stringforproperties .= ", 'css'=>'".$css."'";
|
||||||
}
|
}
|
||||||
if ($cssview) {
|
if ($cssview) {
|
||||||
$string .= ", 'cssview'=>".$cssview;
|
$stringforproperties .= ", 'cssview'=>'".$cssview."'";
|
||||||
}
|
}
|
||||||
if ($csslist) {
|
if ($csslist) {
|
||||||
$string .= ", 'csslist'=>".$csslist;
|
$stringforproperties .= ", 'csslist'=>'".$csslist."'";
|
||||||
}
|
}
|
||||||
$string .= "),\n";
|
$stringforproperties .= "),\n";
|
||||||
$string .= "<br>";
|
|
||||||
$i += 5;
|
$i += 5;
|
||||||
}
|
}
|
||||||
$string .= ');'."\n";
|
$stringforproperties .= ');'."\n";
|
||||||
$string .= "<br>";
|
$stringforproperties .= '// END MODULEBUILDER PROPERTIES'."\n";
|
||||||
print $string;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dirins && $action == 'initobject' && $module && $objectname) {
|
|
||||||
$objectname = ucfirst($objectname);
|
|
||||||
|
|
||||||
$dirins = $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
|
|
||||||
$moduletype = $listofmodules[strtolower($module)]['moduletype'];
|
|
||||||
|
|
||||||
if (preg_match('/[^a-z0-9_]/i', $objectname)) {
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors');
|
|
||||||
$tabobj = 'newobject';
|
|
||||||
}
|
|
||||||
if (class_exists($objectname)) {
|
|
||||||
// TODO Add a more efficient detection. Scan disk ?
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("AnObjectWithThisClassNameAlreadyExists"), null, 'errors');
|
|
||||||
$tabobj = 'newobject';
|
|
||||||
}
|
|
||||||
|
|
||||||
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
|
|
||||||
$destdir = $dirins.'/'.strtolower($module);
|
|
||||||
|
|
||||||
// The dir was not created by init
|
|
||||||
dol_mkdir($destdir.'/class');
|
|
||||||
dol_mkdir($destdir.'/img');
|
|
||||||
dol_mkdir($destdir.'/lib');
|
|
||||||
dol_mkdir($destdir.'/scripts');
|
|
||||||
dol_mkdir($destdir.'/sql');
|
|
||||||
|
|
||||||
// Scan dir class to find if an object with same name already exists.
|
|
||||||
if (!$error) {
|
|
||||||
$dirlist = dol_dir_list($destdir.'/class', 'files', 0, '\.txt$');
|
|
||||||
$alreadyfound = false;
|
|
||||||
foreach ($dirlist as $key => $val) {
|
|
||||||
$filefound = preg_replace('/\.txt$/', '', $val['name']);
|
|
||||||
if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
|
|
||||||
$alreadyfound = true;
|
|
||||||
$error++;
|
|
||||||
setEventMessages($langs->trans("AnObjectAlreadyExistWithThisNameAndDiffCase"), null, 'errors');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1209,6 +1219,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
foreach ($filetogenerate as $srcfile => $destfile) {
|
foreach ($filetogenerate as $srcfile => $destfile) {
|
||||||
$result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0);
|
$result = dol_copy($srcdir.'/'.$srcfile, $destdir.'/'.$destfile, $newmask, 0);
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
@ -1222,6 +1234,17 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace property section with $stringforproperties
|
||||||
|
if (!$error && $stringforproperties) {
|
||||||
|
//var_dump($stringforproperties);exit;
|
||||||
|
$arrayreplacement = array(
|
||||||
|
'/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
|
||||||
|
);
|
||||||
|
|
||||||
|
dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Edit the class 'class/'.strtolower($objectname).'.class.php'
|
// Edit the class 'class/'.strtolower($objectname).'.class.php'
|
||||||
if (GETPOST('includerefgeneration', 'aZ09')) {
|
if (GETPOST('includerefgeneration', 'aZ09')) {
|
||||||
@ -1405,6 +1428,8 @@ if ($dirins && $action == 'initobject' && $module && $objectname) {
|
|||||||
if (!$error) {
|
if (!$error) {
|
||||||
setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null);
|
setEventMessages($langs->trans('FilesForObjectInitialized', $objectname), null);
|
||||||
$tabobj = $objectname;
|
$tabobj = $objectname;
|
||||||
|
} else {
|
||||||
|
$tabobj = 'newobject';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2285,6 +2310,8 @@ if ($module == 'initmodule') {
|
|||||||
$head2[$h][2] = 'buildpackage';
|
$head2[$h][2] = 'buildpackage';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
|
$MAXTABFOROBJECT = 15;
|
||||||
|
|
||||||
print '<!-- Section for a given module -->';
|
print '<!-- Section for a given module -->';
|
||||||
|
|
||||||
// Note module is inside $dirread
|
// Note module is inside $dirread
|
||||||
@ -2296,7 +2323,7 @@ if ($module == 'initmodule') {
|
|||||||
$pathtochangelog = $modulelowercase.'/ChangeLog.md';
|
$pathtochangelog = $modulelowercase.'/ChangeLog.md';
|
||||||
|
|
||||||
if ($action != 'editfile' || empty($file)) {
|
if ($action != 'editfile' || empty($file)) {
|
||||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Description - level 2
|
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', $MAXTABFOROBJECT, 'formodulesuffix'); // Description - level 2
|
||||||
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc".$tab).'</span>';
|
print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc".$tab).'</span>';
|
||||||
$infoonmodulepath = '';
|
$infoonmodulepath = '';
|
||||||
@ -2456,7 +2483,7 @@ if ($module == 'initmodule') {
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', 0, 'formodulesuffix'); // Level 2
|
print dol_get_fiche_head($head2, $tab, '', -1, '', 0, '', '', $MAXTABFOROBJECT, 'formodulesuffix'); // Level 2
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tab == 'languages') {
|
if ($tab == 'languages') {
|
||||||
@ -2603,12 +2630,38 @@ if ($module == 'initmodule') {
|
|||||||
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans("EnterNameOfObjectDesc").'</span><br><br>';
|
print '<span class="opacitymedium">'.$langs->trans("EnterNameOfObjectDesc").'</span><br><br>';
|
||||||
|
|
||||||
print '<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOST('objectname', 'alpha') ? GETPOST('objectname', 'alpha') : $modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ObjectKey")).'" autofocus><br>';
|
print '<div class="tagtable">';
|
||||||
print '<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label for="includerefgeneration">'.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'</label><br>';
|
|
||||||
|
print '<div class="tagtr"><div class="tagtd">';
|
||||||
|
print '<span class="opacitymedium">'.$langs->trans("ObjectKey").'</span> ';
|
||||||
|
print '</div><div class="tagtd">';
|
||||||
|
print '<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOST('objectname', 'alpha') ? GETPOST('objectname', 'alpha') : $modulename).'" autofocus><br>';
|
||||||
|
print '</div></div>';
|
||||||
|
|
||||||
|
print '<div class="tagtr"><div class="tagtd">';
|
||||||
|
print '<span class="opacitymedium">'.$langs->trans("Picto").'</span> ';
|
||||||
|
print '</div><div class="tagtd">';
|
||||||
|
print '<input type="text" name="idpicto" value="fa-generic" placeholder="'.dol_escape_htmltag($langs->trans("Picto")).'">';
|
||||||
|
print $form->textwithpicto('', $langs->trans("Example").': fa-generic, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
|
||||||
|
print '</div></div>';
|
||||||
|
|
||||||
|
print '<div class="tagtr"><div class="tagtd">';
|
||||||
|
print '<span class="opacitymedium">'.$langs->trans("DefinePropertiesFromExistingTable").'</span> ';
|
||||||
|
print '</div><div class="tagtd">';
|
||||||
|
print '<input type="text" name="initfromtablename" value="'.GETPOST('initfromtablename').'" placeholder="'.$langs->trans("TableName").'">';
|
||||||
|
print $form->textwithpicto('', $langs->trans("DefinePropertiesFromExistingTableDesc").'<br>'.$langs->trans("DefinePropertiesFromExistingTableDesc2"));
|
||||||
|
print '</div></div>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print '<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label class="margintoponly" for="includerefgeneration">'.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'</label><br>';
|
||||||
print '<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'</label><br>';
|
print '<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'</label><br>';
|
||||||
print '<input type="submit" class="button smallpaddingimp" name="create" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
print '<br>';
|
||||||
|
print '<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
/*
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<span class="opacitymedium">'.$langs->trans("or").'</span>';
|
print '<span class="opacitymedium">'.$langs->trans("or").'</span>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
@ -2618,6 +2671,7 @@ if ($module == 'initmodule') {
|
|||||||
print '<input type="text" name="initfromtablename" value="" placeholder="'.$langs->trans("TableName").'">';
|
print '<input type="text" name="initfromtablename" value="" placeholder="'.$langs->trans("TableName").'">';
|
||||||
print '<input type="submit" class="button smallpaddingimp" name="createtablearray" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
print '<input type="submit" class="button smallpaddingimp" name="createtablearray" value="'.dol_escape_htmltag($langs->trans("GenerateCode")).'"'.($dirins ? '' : ' disabled="disabled"').'>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
*/
|
||||||
|
|
||||||
print '</form>';
|
print '</form>';
|
||||||
} elseif ($tabobj == 'deleteobject') {
|
} elseif ($tabobj == 'deleteobject') {
|
||||||
@ -2679,7 +2733,7 @@ if ($module == 'initmodule') {
|
|||||||
}
|
}
|
||||||
if (class_exists($tabobj)) {
|
if (class_exists($tabobj)) {
|
||||||
try {
|
try {
|
||||||
$tmpobjet = @new $tabobj($db);
|
$tmpobject = @new $tabobj($db);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
|
dol_syslog('Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
|
||||||
}
|
}
|
||||||
@ -2752,13 +2806,22 @@ if ($module == 'initmodule') {
|
|||||||
$urlofcard = dol_buildpath('/'.$pathtocard, 1);
|
$urlofcard = dol_buildpath('/'.$pathtocard, 1);
|
||||||
|
|
||||||
|
|
||||||
|
print '<!-- section for object -->';
|
||||||
|
|
||||||
|
|
||||||
print '<div class="fichehalfleft smallxxx">';
|
print '<div class="fichehalfleft smallxxx">';
|
||||||
// Main DAO class file
|
// Main DAO class file
|
||||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ClassFile").' : <strong>'.(dol_is_file($realpathtoclass) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).(dol_is_file($realpathtoclass) ? '' : '</strike>').'</strong>';
|
print '<span class="fa fa-file-o"></span> '.$langs->trans("ClassFile").' : <strong>'.(dol_is_file($realpathtoclass) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).(dol_is_file($realpathtoclass) ? '' : '</strike>').'</strong>';
|
||||||
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||||
|
print '<br>';
|
||||||
|
// Image
|
||||||
|
if (dol_is_file($realpathtopicto)) {
|
||||||
|
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>';
|
||||||
|
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||||
|
print '<br>';
|
||||||
|
} elseif (!empty($tmpobject)) {
|
||||||
|
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : '.img_picto('', $tmpobject->picto, 'class="pictofixedwidth"');
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
// API file
|
// API file
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'</span></strike>').'</strong>';
|
print '<span class="fa fa-file-o"></span> '.$langs->trans("ApiClassFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtoapi) ? '' : '<strike><span class="opacitymedium">').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'</span></strike>').'</strong>';
|
||||||
@ -2795,12 +2858,6 @@ if ($module == 'initmodule') {
|
|||||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("PageForObjLib").' : <strong class="wordbreak">'.(dol_is_file($realpathtoobjlib) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '</strike>').'</strong>';
|
print '<span class="fa fa-file-o"></span> '.$langs->trans("PageForObjLib").' : <strong class="wordbreak">'.(dol_is_file($realpathtoobjlib) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '</strike>').'</strong>';
|
||||||
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoobjlib).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
print ' <a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtoobjlib).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
// Image
|
|
||||||
if (dol_is_file($realpathtopicto)) {
|
|
||||||
print '<span class="fa fa-file-image-o"></span> '.$langs->trans("Image").' : <strong>'.(dol_is_file($realpathtopicto) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '</strike>').'</strong>';
|
|
||||||
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
|
||||||
print '<br>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("SqlFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtosql) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '</strike>').'</strong>';
|
print '<span class="fa fa-file-o"></span> '.$langs->trans("SqlFile").' : <strong class="wordbreak">'.(dol_is_file($realpathtosql) ? '' : '<strike>').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '</strike>').'</strong>';
|
||||||
@ -2888,7 +2945,7 @@ if ($module == 'initmodule') {
|
|||||||
|
|
||||||
print '<br><br><br>';
|
print '<br><br><br>';
|
||||||
|
|
||||||
if (!empty($tmpobjet)) {
|
if (!empty($tmpobject)) {
|
||||||
$reflector = new ReflectionClass($tabobj);
|
$reflector = new ReflectionClass($tabobj);
|
||||||
$reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars
|
$reflectorproperties = $reflector->getProperties(); // Can also use get_object_vars
|
||||||
$reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars
|
$reflectorpropdefault = $reflector->getDefaultProperties(); // Can also use get_object_vars
|
||||||
@ -2942,9 +2999,9 @@ if ($module == 'initmodule') {
|
|||||||
print '<th class="none"></th>';
|
print '<th class="none"></th>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been
|
// We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobject->fields may have been
|
||||||
// modified during the constructor and we want value into head of class before constructor is called.
|
// modified during the constructor and we want value into head of class before constructor is called.
|
||||||
//$properties = dol_sort_array($tmpobjet->fields, 'position');
|
//$properties = dol_sort_array($tmpobject->fields, 'position');
|
||||||
$properties = dol_sort_array($reflectorpropdefault['fields'], 'position');
|
$properties = dol_sort_array($reflectorpropdefault['fields'], 'position');
|
||||||
|
|
||||||
if (!empty($properties)) {
|
if (!empty($properties)) {
|
||||||
@ -2984,7 +3041,7 @@ if ($module == 'initmodule') {
|
|||||||
{
|
{
|
||||||
$propname=$propval->getName();
|
$propname=$propval->getName();
|
||||||
$comment=$propval->getDocComment();
|
$comment=$propval->getDocComment();
|
||||||
$type=gettype($tmpobjet->$propname);
|
$type=gettype($tmpobject->$propname);
|
||||||
$default=$propdefault[$propname];
|
$default=$propdefault[$propname];
|
||||||
// Discard generic properties
|
// Discard generic properties
|
||||||
if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
if (in_array($propname, array('element', 'childtables', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
||||||
|
|||||||
@ -116,19 +116,19 @@ class MyObject extends CommonObject
|
|||||||
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'),
|
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'),
|
||||||
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>10),
|
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>10),
|
||||||
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object', 'validate'=>1),
|
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'noteditable'=>0, 'default'=>'', 'notnull'=> 1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object', 'validate'=>1),
|
||||||
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2, 'validate'=>1),
|
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>'Help text', 'showoncombobox'=>2, 'validate'=>1, 'alwayseditable'=>1),
|
||||||
'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1),
|
'amount' => array('type'=>'price', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount', 'validate'=>1),
|
||||||
'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1),
|
'qty' => array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp', 'validate'=>1),
|
||||||
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx'),
|
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'picto'=>'company', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'OrganizationEventLinkToThirdParty', 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'),
|
||||||
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx'),
|
'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'validate'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150'),
|
||||||
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1),
|
'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60, 'validate'=>1),
|
||||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1, 'cssview'=>'wordbreak'),
|
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61, 'validate'=>1, 'cssview'=>'wordbreak'),
|
||||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1, 'cssview'=>'wordbreak'),
|
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62, 'validate'=>1, 'cssview'=>'wordbreak'),
|
||||||
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
|
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>500),
|
||||||
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
|
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 0, 'position'=>501),
|
||||||
//'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
//'date_validation ' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
|
||||||
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid'),
|
'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=> 1, 'position'=>510, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax150'),
|
||||||
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511),
|
'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'picto'=>'user', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511, 'csslist'=>'tdoverflowmax150'),
|
||||||
//'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
//'fk_user_valid' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
|
||||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
|
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'notnull'=>0, 'position'=>600),
|
||||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
|
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user