Modulebuilde fix sort of fields, fix generation of files
This commit is contained in:
parent
bc2009874d
commit
926683763b
@ -5723,6 +5723,7 @@ class Form
|
||||
$lis='';
|
||||
$listcheckedstring='';
|
||||
|
||||
$array = dol_sort_array($array, 'position');
|
||||
foreach($array as $key => $val)
|
||||
{
|
||||
/* var_dump($val);
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
* @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|object <=0 if KO, Object if OK
|
||||
* @see rebuildObjectSql
|
||||
*/
|
||||
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array() ,$delfieldentry='')
|
||||
{
|
||||
@ -202,6 +203,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
|
||||
* @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
|
||||
* @see rebuildObjectClass
|
||||
*/
|
||||
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', $object=null)
|
||||
{
|
||||
|
||||
@ -43,6 +43,8 @@ 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
|
||||
RegenerateClassAndSql=Erase and regenerate class and sql files
|
||||
RegenerateMissingFiles=Generate missing files
|
||||
SpecificationFile=File with business rules
|
||||
LanguageFile=File for language
|
||||
ConfirmDeleteProperty=Are you sure you want to delete the property <strong>%s</strong> ? This will change code in PHP class but also remove column from table definition of object.
|
||||
|
||||
@ -419,22 +419,53 @@ if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') &&
|
||||
|
||||
if ($dirins && $action == 'addproperty' && !empty($module) && ! empty($tabobj))
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$objectname = $tabobj;
|
||||
|
||||
$srcdir = $dirread.'/'.strtolower($module);
|
||||
$destdir = $dirins.'/'.strtolower($module);
|
||||
dol_mkdir($destdir);
|
||||
|
||||
$addfieldentry = array(
|
||||
'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','alpha'));
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
// We click on add property
|
||||
if (! GETPOST('regenerateclasssql') && ! GETPOST('regeneratemissing'))
|
||||
{
|
||||
$addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true);
|
||||
if (! GETPOST('propname','aZ09'))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Name")), null, 'errors');
|
||||
}
|
||||
if (! GETPOST('proplabel','alpha'))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
||||
}
|
||||
if (! GETPOST('proptype','alpha'))
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Type")), null, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$addfieldentry = array(
|
||||
'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','alpha'));
|
||||
|
||||
if (! empty($addfieldentry['arrayofkeyval']) && ! is_array($addfieldentry['arrayofkeyval']))
|
||||
{
|
||||
$addfieldentry['arrayofkeyval'] = dol_json_decode($addfieldentry['arrayofkeyval'], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('regeneratemissing'))
|
||||
{
|
||||
setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings');
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Edit the class file to write properties
|
||||
@ -1431,6 +1462,7 @@ elseif (! empty($module))
|
||||
$pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.key.sql';
|
||||
$pathtolib = strtolower($module).'/lib/'.strtolower($tabobj).'.lib.php';
|
||||
$pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png';
|
||||
$pathtoscript = strtolower($module).'/scripts/'.strtolower($tabobj).'.php';
|
||||
|
||||
$realpathtoclass = dol_buildpath($pathtoclass, 0, 1);
|
||||
$realpathtoapi = dol_buildpath($pathtoapi, 0, 1);
|
||||
@ -1445,6 +1477,7 @@ elseif (! empty($module))
|
||||
$realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 1);
|
||||
$realpathtolib = dol_buildpath($pathtolib, 0, 1);
|
||||
$realpathtopicto = dol_buildpath($pathtopicto, 0, 1);
|
||||
$realpathtoscript = dol_buildpath($pathtoscript, 0, 1);
|
||||
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ClassFile").' : <strong>'.($realpathtoclass?'':'<strike>').$pathtoclass.($realpathtoclass?'':'</strike>').'</strong>';
|
||||
@ -1506,6 +1539,11 @@ elseif (! empty($module))
|
||||
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 '<br>';
|
||||
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file-o"></span> '.$langs->trans("ScriptFile").' : <strong>'.($realpathtoscript?'':'<strike>').$pathtoscript.($realpathtoscript?'':'</strike>').'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtoscript).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
print '</div>';
|
||||
@ -1539,9 +1577,15 @@ elseif (! empty($module))
|
||||
//$propstat = $reflector->getStaticProperties();
|
||||
//var_dump($reflectorpropdefault);
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
|
||||
print '<input class="button" type="submit" name="regenerateclasssql" value="'.$langs->trans("RegenerateClassAndSql").'">';
|
||||
print '<input class="button" type="submit" name="regeneratemissing" value="'.$langs->trans("RegenerateMissingFiles").'">';
|
||||
print '<br><br>';
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("Properties"), '', '');
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addproperty">';
|
||||
@ -1581,19 +1625,19 @@ elseif (! empty($module))
|
||||
{
|
||||
// Line to add a property
|
||||
print '<tr>';
|
||||
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><input class="text maxwidth75" name="propname" value="'.dol_escape_htmltag(GETPOST('propname','alpha')).'"></td>';
|
||||
print '<td><input class="text maxwidth75" name="proplabel" value="'.dol_escape_htmltag(GETPOST('proplabel','alpha')).'"></td>';
|
||||
print '<td><input class="text maxwidth75" name="proptype" value="'.dol_escape_htmltag(GETPOST('proptype','alpha')).'"></td>';
|
||||
print '<td><input class="text maxwidth75" 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="'.dol_escape_htmltag(GETPOST('propdefault','alpha')).'"></td>';
|
||||
print '<td><input class="text maxwidth50" name="propdefault" value="'.dol_escape_htmltag(GETPOST('propdefault','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><input class="text maxwidth100" 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>';
|
||||
|
||||
@ -124,7 +124,7 @@ $arrayfields=array();
|
||||
foreach($object->fields as $key => $val)
|
||||
{
|
||||
// If $val['visible']==0, then we never show the field
|
||||
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']);
|
||||
if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user