diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index f46a0fffb9f..8dc08d4ed4a 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 27b3403efa0..6c0b0dc4019 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 89a1c497388..f9edbb47c05 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 '
| '.$langs->trans("Project").' | ';
-
+
$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 ' |
| '.$langs->trans("LinkedObject").' | ';
- print ''.$act->getElementUrl($act->fk_element,$act->elementtype,1).' |
';
+ print ''.dolGetElementUrl($act->fk_element,$act->elementtype,1).' | ';
}
// 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 '| '.$langs->trans("LinkedObject").' | ';
- print ''.$act->getElementUrl($act->fk_element,$act->elementtype,1).' |
';
+ print ''.dolGetElementUrl($act->fk_element,$act->elementtype,1).' | ';
}
// Description
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index b8c2ab9ea35..4a07469c0ce 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 145049c999c..469b9f2ac94 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