Fix modulebuilder template
This commit is contained in:
parent
6602a7046e
commit
9729b3a1c7
@ -898,6 +898,64 @@ class MyObject extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the reference to the following non used object depending on the active numbering module.
|
||||||
|
*
|
||||||
|
* @return string Object free reference
|
||||||
|
*/
|
||||||
|
public function getNextNumRef()
|
||||||
|
{
|
||||||
|
global $langs, $conf;
|
||||||
|
$langs->load("mymodule@myobject");
|
||||||
|
|
||||||
|
if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) {
|
||||||
|
$conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_mymobject_standard';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON))
|
||||||
|
{
|
||||||
|
$mybool = false;
|
||||||
|
|
||||||
|
$file = $conf->global->MYMODULE_MYOBJECT_ADDON.".php";
|
||||||
|
$classname = $conf->global->MYMODULE_MYOBJECT_ADDON;
|
||||||
|
|
||||||
|
// Include file with class
|
||||||
|
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||||
|
foreach ($dirmodels as $reldir)
|
||||||
|
{
|
||||||
|
$dir = dol_buildpath($reldir."core/modules/mymodule/");
|
||||||
|
|
||||||
|
// Load file with numbering class (if found)
|
||||||
|
$mybool |= @include_once $dir.$file;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mybool === false)
|
||||||
|
{
|
||||||
|
dol_print_error('', "Failed to include file ".$file);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$obj = new $classname();
|
||||||
|
$numref = $obj->getNextValue($this);
|
||||||
|
|
||||||
|
if ($numref != "")
|
||||||
|
{
|
||||||
|
return $numref;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error = $obj->error;
|
||||||
|
//dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("Error")." ".$langs->trans("Error_MYMODULE_MYOBJECT_ADDON_NotDefined");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a document onto disk according to template module.
|
* Create a document onto disk according to template module.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -118,11 +118,10 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
|
|||||||
/**
|
/**
|
||||||
* Return next free value
|
* Return next free value
|
||||||
*
|
*
|
||||||
* @param Product $objprod Object product
|
|
||||||
* @param Object $object Object we need next value for
|
* @param Object $object Object we need next value for
|
||||||
* @return string Value if KO, <0 if KO
|
* @return string Value if KO, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objprod, $object)
|
public function getNextValue($object)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
|
|||||||
@ -109,11 +109,10 @@ class mod_myobject_standard extends ModeleNumRefMyObject
|
|||||||
/**
|
/**
|
||||||
* Return next free value
|
* Return next free value
|
||||||
*
|
*
|
||||||
* @param Product $objprod Object product
|
|
||||||
* @param Object $object Object we need next value for
|
* @param Object $object Object we need next value for
|
||||||
* @return string Value if KO, <0 if KO
|
* @return string Value if KO, <0 if KO
|
||||||
*/
|
*/
|
||||||
public function getNextValue($objprod, $object)
|
public function getNextValue($object)
|
||||||
{
|
{
|
||||||
global $db,$conf;
|
global $db,$conf;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user