forked from Wavyzz/dolibarr
Debug modulebuilder
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
* @param string $readdir Directory source (use $destdir when not defined)
|
||||
* @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure')
|
||||
* @param string $delfieldentry Id of field to remove
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
* @return int|object <=0 if KO, Object if OK
|
||||
*/
|
||||
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='')
|
||||
{
|
||||
@@ -43,6 +43,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
if (empty($objectname)) return -1;
|
||||
if (empty($readdir)) $readdir=$destdir;
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
{
|
||||
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (count($addfieldentry) > 0)
|
||||
{
|
||||
@@ -94,6 +100,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
{
|
||||
$name=$addfieldentry['name'];
|
||||
unset($addfieldentry['name']);
|
||||
|
||||
$object->fields[$name]=$addfieldentry;
|
||||
}
|
||||
if (! empty($delfieldentry))
|
||||
@@ -114,6 +121,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
|
||||
if (count($object->fields))
|
||||
{
|
||||
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
$i++;
|
||||
@@ -127,11 +135,24 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
if ($val['comment']) $texttoinsert.= " 'comment'=>'".$val['comment']."',";
|
||||
if ($val['isameasure']) $texttoinsert.= " 'isameasure'=>'".$val['isameasure']."',";
|
||||
if ($val['help']) $texttoinsert.= " 'help'=>'".$val['help']."',";
|
||||
if ($val['arrayofkeyval'])
|
||||
{
|
||||
$texttoinsert.= " 'arrayofkeyval'=>array(";
|
||||
$i=0;
|
||||
foreach($val['arrayofkeyval'] as $key2 => $val2)
|
||||
{
|
||||
if ($i) $texttoinsert.=", ";
|
||||
$texttoinsert.="'".$key2."'=>'".$val2."'";
|
||||
$i++;
|
||||
}
|
||||
$texttoinsert.= ")";
|
||||
}
|
||||
$texttoinsert.= "),\n";
|
||||
}
|
||||
}
|
||||
|
||||
$texttoinsert.= "\t".');'."\n";
|
||||
//print ($texttoinsert);exit;
|
||||
|
||||
if (count($object->fields))
|
||||
{
|
||||
@@ -162,7 +183,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
|
||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||
|
||||
return 1;
|
||||
return $object;
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
@@ -179,12 +200,15 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
* @param string $objectname Name of object
|
||||
* @param string $newmask New mask
|
||||
* @param string $readdir Directory source (use $destdir when not defined)
|
||||
* @param Object $object If object was already loaded/known, it is pass to avaoid another include and new.
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null)
|
||||
{
|
||||
global $db, $langs;
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($objectname)) return -1;
|
||||
if (empty($readdir)) $readdir=$destdir;
|
||||
|
||||
@@ -200,12 +224,16 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Load object from myobject.class.php
|
||||
try
|
||||
{
|
||||
if (! is_object($object))
|
||||
{
|
||||
include_once $pathoffiletoclasssrc;
|
||||
if (class_exists($objectname)) $object=new $objectname($db);
|
||||
else return -1;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
print $e->getMessage();
|
||||
@@ -235,9 +263,15 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
||||
|
||||
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
|
||||
|
||||
file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||
if ($result)
|
||||
{
|
||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Edit .key.sql file
|
||||
$pathoffiletoeditsrc=$destdir.'/sql/llx_'.strtolower($objectname).'.key.sql';
|
||||
@@ -265,10 +299,17 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='')
|
||||
|
||||
dol_mkdir(dirname($pathoffiletoedittarget));
|
||||
|
||||
file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
|
||||
if ($result)
|
||||
{
|
||||
@chmod($pathoffiletoedittarget, octdec($newmask));
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return $error ? -1 : 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ DatabaseIndex=Database index
|
||||
FileAlreadyExists=File %s already exists
|
||||
TriggersFile=File for triggers code
|
||||
HooksFile=File for hooks code
|
||||
ArrayOfKeyValues=Array of key-val
|
||||
ArrayOfKeyValuesDesc=Array of keys and values if field is a combo list with fixed values
|
||||
WidgetFile=Widget file
|
||||
ReadmeFile=Readme file
|
||||
ChangeLog=ChangeLog file
|
||||
|
||||
@@ -337,13 +337,13 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
if (! $error)
|
||||
{
|
||||
// Edit the class file to write properties
|
||||
$result=rebuildObjectClass($destdir, $module, $objectname, $newmask);
|
||||
if ($result < 0) $error++;
|
||||
$object=rebuildObjectClass($destdir, $module, $objectname, $newmask);
|
||||
if (is_numeric($object) && $object < 0) $error++;
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
// Edit sql with new properties
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask);
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask, '', $object);
|
||||
if ($result < 0) $error++;
|
||||
}
|
||||
|
||||
@@ -362,25 +362,28 @@ if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
|
||||
dol_mkdir($destdir);
|
||||
|
||||
$addfieldentry = array(
|
||||
'name'=>GETPOST('propname','aZ09'),'type'=>GETPOST('proptype','alpha'),'label'=>GETPOST('proplabel','alpha'),'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'),
|
||||
'name'=>GETPOST('propname','aZ09'),'label'=>GETPOST('proplabel','alpha'),'type'=>GETPOST('proptype','alpha'),
|
||||
'arrayofkeyval'=>GETPOST('proparrayofkeyval','none'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
|
||||
'visible'=>GETPOST('propvisible','int'),'enabled'=>GETPOST('propenabled','int'),
|
||||
'position'=>GETPOST('propposition','int'),'notnull'=>GETPOST('propnotnull','int'),'index'=>GETPOST('propindex','int'),'searchall'=>GETPOST('propsearchall','int'),
|
||||
'isameasure'=>GETPOST('propisameasure','int'), 'comment'=>GETPOST('propcomment','alpha'),'help'=>GETPOST('prophelp'));
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
{
|
||||
$addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true);
|
||||
}
|
||||
|
||||
// Edit the class file to write properties
|
||||
if (! $error)
|
||||
{
|
||||
$result=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry);
|
||||
// var_dump($result);exit;
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
$object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry);
|
||||
if (is_numeric($result) && $result <= 0) $error++;
|
||||
}
|
||||
|
||||
// Edit sql with new properties
|
||||
if (! $error)
|
||||
{
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir);
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
@@ -412,14 +415,14 @@ if ($dirins && $action == 'confirm_deleteproperty' && $propertykey)
|
||||
// Edit the class file to write properties
|
||||
if (! $error)
|
||||
{
|
||||
$result=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey);
|
||||
if ($result <= 0) $error++;
|
||||
$object=rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey);
|
||||
if (is_numeric($object) && $object <= 0) $error++;
|
||||
}
|
||||
|
||||
// Edit sql with new properties
|
||||
if (! $error)
|
||||
{
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir);
|
||||
$result=rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
|
||||
if ($result <= 0) $error++;
|
||||
}
|
||||
|
||||
@@ -1410,28 +1413,28 @@ elseif (! empty($module))
|
||||
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.($realpathtoclass?'':'<strike>').$pathtoclass.($realpathtoclass?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoclass).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.($realpathtoapi?'':'<strike>').$pathtoapi.($realpathtoapi?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.DOL_URL_ROOT.'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans("GoToApiExplorer").'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.($realpathtophpunit?'':'<strike>').$pathtophpunit.($realpathtophpunit?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.($realpathtosql?'':'<strike>').$pathtosql.($realpathtosql?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("DropTableIfEmpty").'</a>';
|
||||
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileExtraFields").' : <strong>'.($realpathtosqlextra?'':'<strike>').$pathtosqlextra.($realpathtosqlextra?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&file='.urlencode($pathtosqlextra).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFileKey").' : <strong>'.($realpathtosqlkey?'':'<strike>').$pathtosqlkey.($realpathtosqlkey?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
|
||||
print '<br>';
|
||||
|
||||
@@ -1443,19 +1446,19 @@ elseif (! empty($module))
|
||||
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong><a href="'.$urloflist.'" target="_test">'.($realpathtosql?'':'<strike>').$pathtolist.($realpathtosql?'':'</strike>').'</a></strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolist).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtolist).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForCreateEditView").' : <strong><a href="'.$urlofcard.'?action=create" target="_test">'.($realpathtocard?'':'<strike>').$pathtocard.($realpathtocard?'':'</strike>').'?action=create</a></strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtocard).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtocard).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForAgendaTab").' : <strong>'.($realpathtoagenda?'':'<strike>').$pathtoagenda.($realpathtoagenda?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoagenda).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoagenda).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForDocumentTab").' : <strong>'.($realpathtodocument?'':'<strike>').$pathtodocument.($realpathtodocument?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtodocument).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtodocument).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForNoteTab").' : <strong>'.($realpathtonote?'':'<strike>').$pathtonote.($realpathtonote?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtonote).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtonote).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '</div>';
|
||||
|
||||
print '<br><br><br>';
|
||||
@@ -1506,6 +1509,7 @@ elseif (! empty($module))
|
||||
print $form->textwithpicto($langs->trans("Label"), $langs->trans("YouCanUseTranslationKey"));
|
||||
print '</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td>'.$form->textwithpicto($langs->trans("ArrayOfKeyValues"), $langs->trans("ArrayOfKeyValuesDesc")).'</td>';
|
||||
print '<td class="center">'.$langs->trans("NotNull").'</td>';
|
||||
//print '<td>'.$langs->trans("DefaultValue").'</td>';
|
||||
print '<td class="center">'.$langs->trans("DatabaseIndex").'</td>';
|
||||
@@ -1524,18 +1528,19 @@ elseif (! empty($module))
|
||||
{
|
||||
// Line to add a property
|
||||
print '<tr>';
|
||||
print '<td><input class="text" name="propname" value="'.GETPOST('propname','alpha').'"></td>';
|
||||
print '<td><input class="text" name="proplabel" value="'.GETPOST('proplabel','alpha').'"></td>';
|
||||
print '<td><input class="text" name="proptype" value="'.GETPOST('proptype','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propnotnull" value="'.GETPOST('propnotnull','alpha').'"></td>';
|
||||
print '<td><input class="text" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>';
|
||||
print '<td><input class="text" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>';
|
||||
print '<td><input class="text" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>';
|
||||
print '<td><input class="text" name="proparrayofkeyval" value="'.dol_escape_htmltag(GETPOST('proparrayofkeyval','none')).'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propnotnull" value="'.dol_escape_htmltag(GETPOST('propnotnull','alpha')).'"></td>';
|
||||
//print '<td><input class="text" name="propdefault" value=""></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propindex" value="'.GETPOST('propindex','alpha').'"></td>';
|
||||
print '<td class="right"><input class="text right" size="2" name="propposition" value="'.GETPOST('propposition','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propenabled" value="'.GETPOST('propenabled','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propvisible" value="'.GETPOST('propvisible','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propisameasure" value="'.GETPOST('propisameasure','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propsearchall" value="'.GETPOST('propsearchall','alpha').'"></td>';
|
||||
print '<td><input class="text" name="propcomment" value="'.GETPOST('propcomment','alpha').'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propindex" value="'.dol_escape_htmltag(GETPOST('propindex','alpha')).'"></td>';
|
||||
print '<td class="right"><input class="text right" size="2" name="propposition" value="'.dol_escape_htmltag(GETPOST('propposition','alpha')).'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propenabled" value="'.dol_escape_htmltag(GETPOST('propenabled','alpha')).'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propvisible" value="'.dol_escape_htmltag(GETPOST('propvisible','alpha')).'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propisameasure" value="'.dol_escape_htmltag(GETPOST('propisameasure','alpha')).'"></td>';
|
||||
print '<td class="center"><input class="text" size="2" name="propsearchall" value="'.dol_escape_htmltag(GETPOST('propsearchall','alpha')).'"></td>';
|
||||
print '<td><input class="text" name="propcomment" value="'.dol_escape_htmltag(GETPOST('propcomment','alpha')).'"></td>';
|
||||
print '<td align="center">';
|
||||
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
@@ -1559,6 +1564,7 @@ elseif (! empty($module))
|
||||
$propname=$propkey;
|
||||
$proplabel=$propval['label'];
|
||||
$proptype=$propval['type'];
|
||||
$proparrayofkeyval=$propval['arrayofkeyval'];
|
||||
$propnotnull=$propval['notnull'];
|
||||
$propsearchall=$propval['searchall'];
|
||||
//$propdefault=$propval['default'];
|
||||
@@ -1580,6 +1586,12 @@ elseif (! empty($module))
|
||||
print '<td>';
|
||||
print $proptype;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($proparrayofkeyval)
|
||||
{
|
||||
print json_encode($proparrayofkeyval);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print $propnotnull;
|
||||
print '</td>';
|
||||
@@ -1652,6 +1664,7 @@ elseif (! empty($module))
|
||||
print '<input type="hidden" name="action" value="savefile">';
|
||||
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
|
||||
print '<input type="hidden" name="module" value="'.$module.($forceddirread?'@'.$dirread:'').'">';
|
||||
|
||||
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
|
||||
@@ -83,7 +83,6 @@ class MyObject extends CommonObject
|
||||
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'index'=>1, 'position'=>20),
|
||||
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1),
|
||||
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Amount'),
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
@@ -91,6 +90,7 @@ class MyObject extends CommonObject
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'position'=>500),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>1, 'position'=>1000),
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
|
||||
);
|
||||
|
||||
public $rowid;
|
||||
|
||||
@@ -270,22 +270,30 @@ if ($action == 'create')
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
||||
print '<tr id="field_'.$key.'"><td';
|
||||
print '<tr id="field_'.$key.'">';
|
||||
print '<td';
|
||||
print ' class="titlefieldcreate';
|
||||
if ($val['notnull'] > 0) print ' fieldrequired';
|
||||
if ($val['type'] == 'text') print ' tdtop';
|
||||
print '"';
|
||||
print '>'.$langs->trans($val['label']).'</td>';
|
||||
print '>';
|
||||
print $langs->trans($val['label']);
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if ($val['type'] == 'text')
|
||||
{
|
||||
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
|
||||
print GETPOST($key,'none');
|
||||
print '</textarea>';
|
||||
}
|
||||
elseif (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int'));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
$cssforinput = 'minwidth100';
|
||||
print '<input class="flat" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
@@ -329,10 +337,15 @@ if (($id || $ref) && $action == 'edit')
|
||||
print '<textarea class="flat quatrevingtpercent" rows="'.ROWS_4.'" name="'.$key.'">';
|
||||
print GETPOST($key,'none');
|
||||
print '</textarea>';
|
||||
}
|
||||
elseif (is_array($val['arrayofkeyval']))
|
||||
{
|
||||
print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int'));
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input class="flat" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
$cssforinput = 'minwidth100';
|
||||
print '<input class="flat" class="'.$cssforinput.'" type="text" name="'.$key.'" value="'.(GETPOST($key,'alpha')?GETPOST($key,'alpha'):'').'">';
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
Reference in New Issue
Block a user