diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 7a83c09b73434..9e4b9b0bf18a2 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4736,19 +4736,6 @@ public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_pro
-
- /**
- * 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 @@ protected function isNull($info)
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 @@ protected function isInt($info)
* @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 @@ protected function isFloat($info)
* @param array $info content informations of field
* @return bool
*/
- protected function isText($info)
+ public function isText($info)
{
if(is_array($info))
{
diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang
index c2f267c20ee6b..4fc9b54bfa3ef 100644
--- a/htdocs/langs/en_US/modulebuilder.lang
+++ b/htdocs/langs/en_US/modulebuilder.lang
@@ -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
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index e1e3f41f85949..f6a89f43444ad 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -1210,6 +1210,7 @@
$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 @@
print ' '.$langs->trans("ApiClassFile").' : '.$pathtoapi.'';
print ' '.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
+ print ' '.$langs->trans("TestClassFile").' : '.$pathtophpunit.'';
+ print ' '.img_picto($langs->trans("Edit"), 'edit').'';
+ print '
';
print ' '.$langs->trans("SqlFile").' : '.$pathtosql.'';
print ' '.img_picto($langs->trans("Edit"), 'edit').'';
print '
';
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 3322a7f1fa404..7b3d675e9bea3 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -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),
);
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index e75d37024208c..198e199ce10ba 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -216,7 +216,8 @@
$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 @@ function init_myfunc()
$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 '