diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index f46a0fffb9fb56eee789d88f921b2232348c0924..8dc08d4ed4ab092bafdd14df43eb95b0adeaef3c 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -27,8 +27,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -1138,6 +1136,8 @@ class Adherent extends CommonObject { global $langs; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; + $sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,"; $sql.= " c.tms as datem,"; $sql.= " c.datec as datec,"; @@ -1207,6 +1207,8 @@ class Adherent extends CommonObject { global $conf,$langs,$user; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; + $error=0; // Clean parameters @@ -1890,4 +1892,4 @@ class Adherent extends CommonObject } } -?> +?> \ No newline at end of file diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 27b3403efa092dc3ba4a4933a42441828a1d60fc..6c0b0dc401958b4f773b2de3da61db66d2bd5cb8 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -27,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/adherents/class/cotisation.class.php'; $langs->load("companies"); $langs->load("members"); diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 89a1c49738828a463467cb0e9c89393e655defdc..f9edbb47c052da015a43d3b240f300e41f439dcf 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -577,14 +577,14 @@ if ($action == 'create') // Project if (! empty($conf->projet->enabled)) { - + $formproject=new FormProjets($db); - + // Projet associe $langs->load("project"); print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>'; - + $numproject=$formproject->select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid'); if ($numproject==0) { @@ -808,9 +808,9 @@ if ($id > 0) // Project if (! empty($conf->projet->enabled)) { - + $formproject=new FormProjets($db); - + // Projet associe $langs->load("project"); @@ -831,8 +831,9 @@ if ($id > 0) // Object linked if (! empty($act->fk_element) && ! empty($act->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print '<tr><td>'.$langs->trans("LinkedObject").'</td>'; - print '<td colspan="3">'.$act->getElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>'; + print '<td colspan="3">'.dolGetElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>'; } // Description @@ -1015,8 +1016,9 @@ if ($id > 0) // Object linked if (! empty($act->fk_element) && ! empty($act->elementtype)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print '<tr><td>'.$langs->trans("LinkedObject").'</td>'; - print '<td colspan="3">'.$act->getElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>'; + print '<td colspan="3">'.dolGetElementUrl($act->fk_element,$act->elementtype,1).'</td></tr>'; } // Description diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b8c2ab9ea35450d178f08d2b46be8b04ab6baf02..4a07469c0cea1dc44ef1eb6faad57defcbb734ae 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2461,87 +2461,6 @@ abstract class CommonObject // TODO: All functions here must be redesigned and moved as they are not business functions but output functions // -------------------- - - /** - * List urls of element - * - * @param int $objectid Id of record - * @param string $objecttype Type of object - * @param int $withpicto Picto to show - * @param string $option More options - * @return void - */ - function getElementUrl($objectid,$objecttype,$withpicto=0,$option='') - { - global $conf; - - // Parse element/subelement (ex: project_task) - $module = $element = $subelement = $objecttype; - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) - { - $module = $element = $regs[1]; - $subelement = $regs[2]; - } - - $classpath = $element.'/class'; - - // To work with non standard path - if ($objecttype == 'facture' || $objecttype == 'invoice') { - $classpath = 'compta/facture/class'; $module='facture'; $subelement='facture'; - } - if ($objecttype == 'commande' || $objecttype == 'order') { - $classpath = 'commande/class'; $module='commande'; $subelement='commande'; - } - if ($objecttype == 'propal') { - $classpath = 'comm/propal/class'; - } - if ($objecttype == 'shipping') { - $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; - } - if ($objecttype == 'delivery') { - $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; - } - if ($objecttype == 'invoice_supplier') { - $classpath = 'fourn/class'; - } - if ($objecttype == 'order_supplier') { - $classpath = 'fourn/class'; - } - if ($objecttype == 'contract') { - $classpath = 'contrat/class'; $module='contrat'; $subelement='contrat'; - } - if ($objecttype == 'member') { - $classpath = 'adherents/class'; $module='adherent'; $subelement='adherent'; - } - if ($objecttype == 'cabinetmed_cons') { - $classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons'; - } - if ($objecttype == 'fichinter') { - $classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter'; - } - - //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; - - $classfile = strtolower($subelement); $classname = ucfirst($subelement); - if ($objecttype == 'invoice_supplier') { - $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; - } - if ($objecttype == 'order_supplier') { - $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; - } - - if (! empty($conf->$module->enabled)) - { - $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - if ($res) - { - $object = new $classname($this->db); - $ret=$object->fetch($objectid); - if ($ret > 0) return $object->getNomUrl($withpicto,$option); - } - } - } - /* This is to show linked object block */ /** diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 145049c999c049bbef09eb3be3ae8f5c2a2d74f6..469b9f2ac9455250f0b159ed88c53f23707cee01 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -24,6 +24,10 @@ * This file contains all rare functions. */ +// Enable this line to trace path when function is called. +//print xdebug_print_function_stack('Functions2.lib was called');exit; + + /** * Same function than javascript unescape() function but in PHP. * @@ -1418,3 +1422,88 @@ function getSoapParams() } return $params; } + + +/** + * List urls of element + * + * @param int $objectid Id of record + * @param string $objecttype Type of object ('invoice', 'order', 'expedition_bon', ...) + * @param int $withpicto Picto to show + * @param string $option More options + * @return string URL of link to object id/type + */ +function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') +{ + global $db,$conf; + + $ret=''; + + // Parse element/subelement (ex: project_task) + $module = $element = $subelement = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) + { + $module = $element = $regs[1]; + $subelement = $regs[2]; + } + + $classpath = $element.'/class'; + + // To work with non standard path + if ($objecttype == 'facture' || $objecttype == 'invoice') { + $classpath = 'compta/facture/class'; $module='facture'; $subelement='facture'; + } + if ($objecttype == 'commande' || $objecttype == 'order') { + $classpath = 'commande/class'; $module='commande'; $subelement='commande'; + } + if ($objecttype == 'propal') { + $classpath = 'comm/propal/class'; + } + if ($objecttype == 'shipping') { + $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; + } + if ($objecttype == 'delivery') { + $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; + } + if ($objecttype == 'invoice_supplier') { + $classpath = 'fourn/class'; + } + if ($objecttype == 'order_supplier') { + $classpath = 'fourn/class'; + } + if ($objecttype == 'contract') { + $classpath = 'contrat/class'; $module='contrat'; $subelement='contrat'; + } + if ($objecttype == 'member') { + $classpath = 'adherents/class'; $module='adherent'; $subelement='adherent'; + } + if ($objecttype == 'cabinetmed_cons') { + $classpath = 'cabinetmed/class'; $module='cabinetmed'; $subelement='cabinetmedcons'; + } + if ($objecttype == 'fichinter') { + $classpath = 'fichinter/class'; $module='ficheinter'; $subelement='fichinter'; + } + + //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; + + $classfile = strtolower($subelement); $classname = ucfirst($subelement); + if ($objecttype == 'invoice_supplier') { + $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; + } + if ($objecttype == 'order_supplier') { + $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; + } + + if (! empty($conf->$module->enabled)) + { + $res=dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + if ($res) + { + $object = new $classname($db); + $res=$object->fetch($objectid); + if ($res > 0) $ret=$object->getNomUrl($withpicto,$option); + unset($object); + } + } + return $ret; +} \ No newline at end of file