diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 894c5b6cfed839681ecd3be17a06ca5d5902f0c5..64bdb9d201d97773f8e68e617d733e167d382f7c 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -86,9 +86,9 @@ if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) /******************************************************************************/ // 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); $mesg = $module->error; @@ -1388,9 +1388,9 @@ if ($id > 0 || ! empty($ref)) } // Hook of thirdparty module - if (! empty($propal->objModules)) + if (! empty($propal->hooks)) { - foreach($propal->objModules as $module) + foreach($propal->hooks as $module) { $var=!$var; $module->formAddObject($propal); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 77fa461ccdad259de0023a47a9dd6165c2163de4..a3b4c0081237c2c2514198fe633210c9cee226ff 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -427,7 +427,7 @@ class Propal extends CommonObject * \param info_bits Miscellanous informations * \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; @@ -456,6 +456,8 @@ class Propal extends CommonObject $total_ttc = $tabprice[2]; $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; + + if (empty($qty) && empty($special_code)) $special_code=3; // Anciens indicateurs: $price, $remise (a ne plus utiliser) @@ -481,8 +483,7 @@ class Propal extends CommonObject $sql.= " , total_localtax2=".price2num($total_localtax2); $sql.= " , total_ttc=".price2num($total_ttc); $sql.= " , info_bits=".$info_bits; - //if ($conf->global->PROPALE_USE_OPTION_LINE && !$qty) - $sql.= " , special_code=".(empty($qty)?"3":"0"); + $sql.= " , special_code=".$special_code; $sql.= " WHERE rowid = '".$rowid."'"; $result=$this->db->query($sql); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2622e8c93a83d7184fc8c9cbedf0e97653c2d44c..afce96eb17d2394e79eca50df707004d02f0618c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1920,7 +1920,7 @@ class Commande extends CommonObject $sql.= ",localtax1_tx='".price2num($txlocaltax1)."'"; $sql.= ",localtax2_tx='".price2num($txlocaltax2)."'"; $sql.= ",qty='".price2num($qty)."'"; - $sql.= ",product_type='".$type."'"; + if (! empty($type)) $sql.= ",product_type='".$type."'"; $sql.= ",info_bits='".$info_bits."'"; $sql.= ",total_ht='".price2num($total_ht)."'"; $sql.= ",total_tva='".price2num($total_tva)."'"; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 076573aabcc758d880ee15258398d9882c8984d4..9451c7fdc6d03bcaa4430b4c4e1fccec85214016 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -76,9 +76,9 @@ if (is_array($conf->hooks_modules) && !empty($conf->hooks_modules)) /******************************************************************************/ // 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); $mesg = $module->error; @@ -1672,9 +1672,9 @@ else } // Hook of thirdparty module - if (! empty($commande->objModules)) + if (! empty($commande->hooks)) { - foreach($commande->objModules as $module) + foreach($commande->hooks as $module) { $var=!$var; $module->formAddObject($commande); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 42399a4029e446f44e7304d1f2d7e657ae12b5df..768b927968973e680b929bb48964ffffaede3754 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -33,8 +33,8 @@ class CommonObject { - // Instantiate classes of thirdparty module - var $objModules=array(); + // Instantiate hook classe of thirdparty module + var $hooks=array(); /** * \brief Check if ref is used. @@ -1246,18 +1246,29 @@ class CommonObject if ($conf->$module->enabled && in_array($type,$hooks)) { // 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')) { 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)) { - $this->objModules[$line->special_code]->printObjectLine($this,$line,$num,$i); + $this->hooks[$line->special_code]->printObjectLine($this,$line,$num,$i); } else {