diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 8052b80da20..de6189c946a 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -325,6 +325,62 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
dol_fiche_end();
+
+ /*
+ * Lines
+ */
+
+ if (! empty($object->table_element_line))
+ {
+ // Show object lines
+ $result = $object->getLinesArray();
+
+ print '
'."\n";
diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php
index 2ee6399ba65..6ada9b167f9 100644
--- a/htdocs/bom/class/bom.class.php
+++ b/htdocs/bom/class/bom.class.php
@@ -850,6 +850,31 @@ class BOM extends CommonObject
}
}
+ /**
+ * Create an array of lines
+ *
+ * @return array|int array of lines if OK, <0 if KO
+ */
+ public function getLinesArray()
+ {
+ $this->lines=array();
+
+ $objectline = new BOMLine($this->db);
+ $result = $objectline->fetchAll('', '', 0, 0, array('fk_bom'=>$this->id));
+
+ if (is_numeric($result))
+ {
+ $this->error = $this->error;
+ $this->errors = $this->errors;
+ return $result;
+ }
+ else
+ {
+ $this->lines = $result;
+ return $this->lines();
+ }
+ }
+
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 21fb23f017c..e5024f6949f 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -163,7 +163,10 @@ if ($dirins && $action == 'initmodule' && $modulename)
dol_delete_file($destdir.'/myobject_agenda.php');
dol_delete_file($destdir.'/myobject_list.php');
dol_delete_file($destdir.'/lib/'.strtolower($modulename).'_myobject.lib.php');
+ dol_delete_file($destdir.'/test/phpunit/MyObjectFunctionnalTest.php');
dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php');
+ dol_delete_file($destdir.'/test/phpunit');
+ dol_delete_file($destdir.'/test');
dol_delete_file($destdir.'/sql/llx'.strtolower($modulename).'_myobject.sql');
dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject_extrafields.sql');
dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject.key.sql');
@@ -223,6 +226,9 @@ if ($dirins && $action == 'initmodule' && $modulename)
if ($dirins && $action == 'initapi' && !empty($module))
{
+ $modulename = ucfirst($module); // Force first letter in uppercase
+ $objectname = $tabobj;
+
dol_mkdir($dirins.'/'.strtolower($module).'/class');
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
$srcfile = $srcdir.'/class/api_mymodule.class.php';
@@ -232,9 +238,6 @@ if ($dirins && $action == 'initapi' && !empty($module))
if ($result > 0)
{
- $modulename = ucfirst($module); // Force first letter in uppercase
- $objectname = $tabobj;
-
//var_dump($phpfileval['fullname']);
$arrayreplacement=array(
'mymodule'=>strtolower($modulename),
@@ -254,6 +257,46 @@ if ($dirins && $action == 'initapi' && !empty($module))
dolReplaceInFile($destfile, $arrayreplacement);
}
}
+
+if ($dirins && $action == 'initphpunit' && !empty($module))
+{
+ $modulename = ucfirst($module); // Force first letter in uppercase
+ $objectname = $tabobj;
+
+ dol_mkdir($dirins.'/'.strtolower($module).'/class');
+ $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
+ $srcfile = $srcdir.'/test/phpunit/MyObjectTest.php';
+ $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($objectname).'Test.php';
+ $result = dol_copy($srcfile, $destfile, 0, 0);
+ /*$srcfile = $srcdir.'/test/phpunit/MyModuleFunctionnalTest.class.php';
+ $destfile = $dirins.'/'.strtolower($module).'/test/phpunit/'.strtolower($module).'FunctionnalTest.class.php';
+ $result = dol_copy($srcfile, $destfile, 0, 0);*/
+ if ($result > 0)
+ {
+ //var_dump($phpfileval['fullname']);
+ $arrayreplacement=array(
+ 'mymodule'=>strtolower($modulename),
+ 'MyModule'=>$modulename,
+ 'MYMODULE'=>strtoupper($modulename),
+ 'My module'=>$modulename,
+ 'my module'=>$modulename,
+ 'Mon module'=>$modulename,
+ 'mon module'=>$modulename,
+ 'htdocs/modulebuilder/template'=>strtolower($modulename),
+ 'myobject'=>strtolower($objectname),
+ 'MyObject'=>$objectname,
+ 'MYOBJECT'=>strtoupper($objectname),
+ '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'')
+ );
+
+ dolReplaceInFile($destfile, $arrayreplacement);
+ }
+ else
+ {
+
+ }
+}
+
if ($dirins && $action == 'inithook' && !empty($module))
{
dol_mkdir($dirins.'/'.strtolower($module).'/class');
@@ -518,7 +561,6 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
dol_mkdir($destdir.'/lib');
dol_mkdir($destdir.'/scripts');
dol_mkdir($destdir.'/sql');
- dol_mkdir($destdir.'/test/phpunit');
// Scan dir class to find if an object with same name already exists.
if (! $error)
@@ -548,7 +590,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
'myobject_agenda.php'=>strtolower($objectname).'_agenda.php',
'myobject_list.php'=>strtolower($objectname).'_list.php',
'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php',
- 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
+ //'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php',
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
@@ -912,7 +954,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname)
'myobject_list.php'=>strtolower($objectname).'_list.php',
'lib/mymodule.lib.php'=>'lib/'.strtolower($module).'.lib.php',
'lib/mymodule_myobject.lib.php'=>'lib/'.strtolower($module).'_'.strtolower($objectname).'.lib.php',
- 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.$objectname.'Test.php',
+ 'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php',
'sql/llx_mymodule_myobject.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql',
'sql/llx_mymodule_myobject_extrafields.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'_extrafields.sql',
'sql/llx_mymodule_myobject.key.sql'=>'sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql',
@@ -1803,17 +1845,17 @@ elseif (! empty($module))
$pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php';
$pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php';
$pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php';
- $pathtophpunit = strtolower($module).'/test/phpunit/'.$tabobj.'Test.php';
+ $pathtophpunit = strtolower($module).'/test/phpunit/'.strtolower($tabobj).'Test.php';
$pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.sql';
$pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'_extrafields.sql';
$pathtosqlkey = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.key.sql';
+ $pathtosqlextrakey = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'_extrafields.key.sql';
$pathtolib = strtolower($module).'/lib/'.strtolower($module).'.lib.php';
$pathtoobjlib = strtolower($module).'/lib/'.strtolower($module).'_'.strtolower($tabobj).'.lib.php';
$pathtopicto = strtolower($module).'/img/object_'.strtolower($tabobj).'.png';
$pathtoscript = strtolower($module).'/scripts/'.strtolower($tabobj).'.php';
//var_dump($pathtolib);
-
$realpathtoclass = dol_buildpath($pathtoclass, 0, 2);
$realpathtoapi = dol_buildpath($pathtoapi, 0, 2);
$realpathtoagenda = dol_buildpath($pathtoagenda, 0, 2);
@@ -1825,6 +1867,7 @@ elseif (! empty($module))
$realpathtosql = dol_buildpath($pathtosql, 0, 2);
$realpathtosqlextra = dol_buildpath($pathtosqlextra, 0, 2);
$realpathtosqlkey = dol_buildpath($pathtosqlkey, 0, 2);
+ $realpathtosqlextrakey = dol_buildpath($pathtosqlextrakey, 0, 2);
$realpathtolib = dol_buildpath($pathtolib, 0, 2);
$realpathtoobjlib = dol_buildpath($pathtoobjlib, 0, 2);
$realpathtopicto = dol_buildpath($pathtopicto, 0, 2);
@@ -1855,9 +1898,21 @@ elseif (! empty($module))
//print '
'.$langs->trans("FileNotYetGenerated").' ';
print '
';
}
+ // PHPUnit
print '
';
print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit?'':'').$pathtophpunit.($realpathtophpunit?'':'').'';
- print '
'.img_picto($langs->trans("Edit"), 'edit').'';
+
+ if ($realpathtophpunit)
+ {
+ print '
'.img_picto($langs->trans("Edit"), 'edit').'';
+ print ' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').'';
+ }
+ else
+ {
+ //print '
'.$langs->trans("FileNotYetGenerated").' ';
+ print '
';
+ }
print '
';
print '
';
@@ -1887,6 +1942,10 @@ elseif (! empty($module))
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
//print '
'.$langs->trans("RunSql").'';
print '
';
+ print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey?'':'').$pathtosqlextrakey.($realpathtosqlextrakey?'':'').'';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').'';
+ //print '
'.$langs->trans("RunSql").'';
+ print '
';
print '
';
print '
';
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 74b2c6b50c0..06658b71576 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -644,6 +644,30 @@ class MyObject extends CommonObject
$this->initAsSpecimenCommon();
}
+ /**
+ * Create an array of lines
+ *
+ * @return array|int array of lines if OK, <0 if KO
+ */
+ public function getLinesArray()
+ {
+ $this->lines=array();
+
+ $objectline = new BOMLine($this->db);
+ $result = $objectline->fetchAll('', '', 0, 0, array('fk_myobject'=>$this->id));
+
+ if (is_numeric($result))
+ {
+ $this->error = $this->error;
+ $this->errors = $this->errors;
+ return $result;
+ }
+ else
+ {
+ $this->lines = $result;
+ return $this->lines();
+ }
+ }
/**
* Action executed by scheduler