Works on module hook integration

This commit is contained in:
Regis Houssin 2010-09-08 09:38:17 +00:00
parent e824078fbe
commit e27c4da39f
5 changed files with 34 additions and 22 deletions

View File

@ -86,9 +86,9 @@ if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
/******************************************************************************/ /******************************************************************************/
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($propal->objModules)) if (! empty($propal->hooks))
{ {
foreach($propal->objModules as $module) foreach($propal->hooks as $module)
{ {
$module->doActions($propal); $module->doActions($propal);
$mesg = $module->error; $mesg = $module->error;
@ -1388,9 +1388,9 @@ if ($id > 0 || ! empty($ref))
} }
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($propal->objModules)) if (! empty($propal->hooks))
{ {
foreach($propal->objModules as $module) foreach($propal->hooks as $module)
{ {
$var=!$var; $var=!$var;
$module->formAddObject($propal); $module->formAddObject($propal);

View File

@ -427,7 +427,7 @@ class Propal extends CommonObject
* \param info_bits Miscellanous informations * \param info_bits Miscellanous informations
* \return int 0 en cas de succes * \return int 0 en cas de succes
*/ */
function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0) function updateline($rowid, $pu, $qty, $remise_percent=0, $txtva, $txlocaltax1=0, $txlocaltax2=0, $desc='', $price_base_type='HT', $info_bits=0, $special_code=0)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
@ -456,6 +456,8 @@ class Propal extends CommonObject
$total_ttc = $tabprice[2]; $total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9]; $total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10]; $total_localtax2 = $tabprice[10];
if (empty($qty) && empty($special_code)) $special_code=3;
// Anciens indicateurs: $price, $remise (a ne plus utiliser) // Anciens indicateurs: $price, $remise (a ne plus utiliser)
@ -481,8 +483,7 @@ class Propal extends CommonObject
$sql.= " , total_localtax2=".price2num($total_localtax2); $sql.= " , total_localtax2=".price2num($total_localtax2);
$sql.= " , total_ttc=".price2num($total_ttc); $sql.= " , total_ttc=".price2num($total_ttc);
$sql.= " , info_bits=".$info_bits; $sql.= " , info_bits=".$info_bits;
//if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) $sql.= " , special_code=".$special_code;
$sql.= " , special_code=".(empty($qty)?"3":"0");
$sql.= " WHERE rowid = '".$rowid."'"; $sql.= " WHERE rowid = '".$rowid."'";
$result=$this->db->query($sql); $result=$this->db->query($sql);

View File

@ -1920,7 +1920,7 @@ class Commande extends CommonObject
$sql.= ",localtax1_tx='".price2num($txlocaltax1)."'"; $sql.= ",localtax1_tx='".price2num($txlocaltax1)."'";
$sql.= ",localtax2_tx='".price2num($txlocaltax2)."'"; $sql.= ",localtax2_tx='".price2num($txlocaltax2)."'";
$sql.= ",qty='".price2num($qty)."'"; $sql.= ",qty='".price2num($qty)."'";
$sql.= ",product_type='".$type."'"; if (! empty($type)) $sql.= ",product_type='".$type."'";
$sql.= ",info_bits='".$info_bits."'"; $sql.= ",info_bits='".$info_bits."'";
$sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_ht='".price2num($total_ht)."'";
$sql.= ",total_tva='".price2num($total_tva)."'"; $sql.= ",total_tva='".price2num($total_tva)."'";

View File

@ -76,9 +76,9 @@ if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules))
/******************************************************************************/ /******************************************************************************/
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($commande->objModules)) if (! empty($commande->hooks))
{ {
foreach($commande->objModules as $module) foreach($commande->hooks as $module)
{ {
$module->doActions($commande); $module->doActions($commande);
$mesg = $module->error; $mesg = $module->error;
@ -1672,9 +1672,9 @@ else
} }
// Hook of thirdparty module // Hook of thirdparty module
if (! empty($commande->objModules)) if (! empty($commande->hooks))
{ {
foreach($commande->objModules as $module) foreach($commande->hooks as $module)
{ {
$var=!$var; $var=!$var;
$module->formAddObject($commande); $module->formAddObject($commande);

View File

@ -33,8 +33,8 @@
class CommonObject class CommonObject
{ {
// Instantiate classes of thirdparty module // Instantiate hook classe of thirdparty module
var $objModules=array(); var $hooks=array();
/** /**
* \brief Check if ref is used. * \brief Check if ref is used.
@ -1246,18 +1246,29 @@ class CommonObject
if ($conf->$module->enabled && in_array($type,$hooks)) if ($conf->$module->enabled && in_array($type,$hooks))
{ {
// Include class and library of thirdparty module // Include class and library of thirdparty module
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/'.$module.'.class.php')) if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/actions_'.$module.'.class.php') &&
file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/class/dao_'.$module.'.class.php'))
{ {
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/'.$module.'.class.php'); // Include actions class (controller)
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/actions_'.$module.'.class.php');
// Include dataservice class (model)
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/class/dao_'.$module.'.class.php');
// Instantiate actions class (controller)
$controlclassname = 'Actions'.ucfirst($module);
$objModule = new $controlclassname($this->db);
$this->hooks[$objModule->module_number] = $objModule;
// Instantiate dataservice class (model)
$modelclassname = 'Dao'.ucfirst($module);
$this->hooks[$objModule->module_number]->object = new $modelclassname($this->db);
} }
if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php')) if (file_exists(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php'))
{ {
require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/'.$module.'/lib/'.$module.'.lib.php');
} }
$classname = ucfirst($module);
$obj_module = new $classname($this->db);
$this->objModules[$obj_module->module_number] = $obj_module;
} }
} }
} }
@ -1356,7 +1367,7 @@ class CommonObject
if ($line->product_type == 9 && ! empty($line->special_code)) if ($line->product_type == 9 && ! empty($line->special_code))
{ {
$this->objModules[$line->special_code]->printObjectLine($this,$line,$num,$i); $this->hooks[$line->special_code]->printObjectLine($this,$line,$num,$i);
} }
else else
{ {