Enhance modulebuilder
This commit is contained in:
parent
f6ab691c08
commit
13cd203502
@ -4736,19 +4736,6 @@ abstract class CommonObject
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is array
|
||||
*
|
||||
@ -4781,13 +4768,26 @@ abstract class CommonObject
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function test if type is date
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
public function isDate($info)
|
||||
{
|
||||
if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function test if type is integer
|
||||
*
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isInt($info)
|
||||
public function isInt($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
@ -4803,7 +4803,7 @@ abstract class CommonObject
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFloat($info)
|
||||
public function isFloat($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
@ -4819,7 +4819,7 @@ abstract class CommonObject
|
||||
* @param array $info content informations of field
|
||||
* @return bool
|
||||
*/
|
||||
protected function isText($info)
|
||||
public function isText($info)
|
||||
{
|
||||
if(is_array($info))
|
||||
{
|
||||
|
||||
@ -50,6 +50,7 @@ HooksFile=File for hooks code
|
||||
WidgetFile=Widget file
|
||||
ReadmeFile=Readme file
|
||||
ChangeLog=ChangeLog file
|
||||
TestClassFile=File for PHP Unit Test class
|
||||
SqlFile=Sql file
|
||||
SqlFileExtraFields=Sql file for complementary attributes
|
||||
SqlFileKey=Sql file for keys
|
||||
|
||||
@ -1210,6 +1210,7 @@ elseif (! empty($module))
|
||||
$pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php';
|
||||
$pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php';
|
||||
$pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.php';
|
||||
$pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php';
|
||||
$pathtosql = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.sql';
|
||||
$pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($tabobj).'_extrafields.sql';
|
||||
$pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($tabobj).'.key.sql';
|
||||
@ -1220,6 +1221,9 @@ elseif (! empty($module))
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.$pathtoapi.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtoapi).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("TestClassFile").' : <strong>'.$pathtophpunit.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtophpunit).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("SqlFile").' : <strong>'.$pathtosql.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=sql&file='.urlencode($pathtosql).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
|
||||
@ -82,9 +82,10 @@ class MyObject extends CommonObject
|
||||
'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'index'=>true, 'position'=>1000),
|
||||
'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValid', 'enabled'=>1, 'visible'=>-1, 'position'=>500),
|
||||
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>true, 'position'=>500),
|
||||
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-1, 'index'=>true, 'position'=>1000, 'nullifempty'=>1),
|
||||
);
|
||||
|
||||
@ -216,7 +216,8 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
$sql.= " WHERE t.entity IN (".getEntity('myobject').")";
|
||||
foreach($search as $key => $val)
|
||||
{
|
||||
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0)));
|
||||
$mode=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0);
|
||||
if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode));
|
||||
}
|
||||
if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||
// Add where from extra fields
|
||||
@ -404,6 +405,7 @@ foreach($object->fields as $key => $val)
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print '<td class="liste_titre'.($align?' '.$align:'').'"><input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'"></td>';
|
||||
}
|
||||
// Action column
|
||||
@ -451,6 +453,7 @@ foreach($object->fields as $key => $val)
|
||||
$align='';
|
||||
if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center';
|
||||
if (in_array($val['type'], array('timestamp'))) $align.=' nowrap';
|
||||
if ($key == 'status') $align.=($align?' ':'').'center';
|
||||
if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n";
|
||||
}
|
||||
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user