';
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 50e0372adce..439820a5ac5 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1534,13 +1534,13 @@ abstract class CommonObject
$sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
$sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
}
- //print $sql;
+ print $sql;
dol_syslog(get_class($this)."::fetchObjectLink sql=".$sql);
$resql = $this->db->query($sql);
if ($resql)
{
- $num = $this->db->num_rows($resql);
+ $num = $this->db->num_rows($resql); echo 'num='.$num.' ';
$i = 0;
while ($i < $num)
{
@@ -1549,13 +1549,14 @@ abstract class CommonObject
{
$this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target;
}
+ echo 'fk_target='.$obj->fk_target.' targetid='.$targetid.' ';
if ($obj->fk_target == $targetid)
{
$this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source;
}
$i++;
}
-
+var_dump($this->linkedObjectsIds);
if (! empty($this->linkedObjectsIds))
{
foreach($this->linkedObjectsIds as $objecttype => $objectids)
@@ -1685,8 +1686,10 @@ abstract class CommonObject
function deleteObjectLinked()
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
- $sql.= " WHERE fk_target = ".$this->id;
- $sql.= " AND targettype = '".$this->element."'";
+ $sql.= " WHERE";
+ $sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->element."')";
+ $sql.= " OR";
+ $sql.= " (fk_target = ".$this->id." AND targettype = '".$this->element."')";
dol_syslog(get_class($this)."::deleteObjectLinked sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql))
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index ac3e018c411..8d5fb4ffabd 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -235,7 +235,13 @@ class Conf
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
- if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1) $rootfordata.='/'.$this->entity;
+ if (! empty($this->global->MAIN_MODULE_MULTICOMPANY) && ! empty($this->entity) && $this->entity > 1)
+ {
+ $rootfordata.='/'.$this->entity;
+ var_dump($mc->sharings);
+ //var_dump($mc->referent);
+ var_dump($mc->entities);
+ }
// For backward compatibility
// TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index cd105ecc066..b9ef43a31ba 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -35,322 +35,320 @@
/**
- * Class to manage generation of HTML components
- * Only common components must be here.
+ * \class Form
+ * \brief Class to manage generation of HTML components
+ * \remarks Only common components must be here.
*/
class Form
{
- var $db;
- var $error;
+ var $db;
+ var $error;
- // Cache arrays
- var $cache_types_paiements=array();
- var $cache_conditions_paiements=array();
- var $cache_availability=array();
- var $cache_demand_reason=array();
- var $cache_type_fees=array();
+ // Cache arrays
+ var $cache_types_paiements=array();
+ var $cache_conditions_paiements=array();
+ var $cache_availability=array();
+ var $cache_demand_reason=array();
+ var $cache_type_fees=array();
- var $tva_taux_value;
- var $tva_taux_libelle;
+ var $tva_taux_value;
+ var $tva_taux_libelle;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
- /**
- * Output key field for an editable field
- *
- * @param string $text Text of label or key to translate
- * @param string $htmlname Name of select field
- * @param string $preselected Name of Value to show/edit (not used in this function)
- * @param object $object Object
- * @param boolean $perm Permission to allow button to edit parameter
- * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
- * @return string HTML edit field
- */
- function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string')
- {
- global $conf,$langs;
+ /**
+ * Output key field for an editable field
+ *
+ * @param string $text Text of label or key to translate
+ * @param string $htmlname Name of select field
+ * @param string $preselected Name of Value to show/edit (not used in this function)
+ * @param object $object Object
+ * @param boolean $perm Permission to allow button to edit parameter
+ * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...)
+ * @return string HTML edit field
+ */
+ function editfieldkey($text,$htmlname,$preselected,$object,$perm,$typeofdata='string')
+ {
+ global $conf,$langs;
- $ret='';
+ $ret='';
- if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
- {
- if ($perm)
- {
- $tmp=explode(':',$typeofdata);
- $ret.= '
'."\n";
+ }
+ else
+ {
+ $out = $value;
+ }
- return $out;
- }
+ return $out;
+ }
- /**
- * Show a text and picto with tooltip on text or picto
- *
- * @param string $text Text to show
- * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded.
- * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2
- * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres
- * @param string $img Code img du picto (use img_xxx() function to get it)
- * @param string $extracss Add a CSS style to td tags
- * @param int $notabs Do not include table and tr tags
- * @param string $incbefore Include code before the text
- * @param int $noencodehtmltext Do not encode into html entity the htmltext
- * @return string Code html du tooltip (texte+picto)
- * @see Use function textwithpicto if you can.
- */
- function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0)
- {
- global $conf;
+ /**
+ * Show a text and picto with tooltip on text or picto
+ *
+ * @param string $text Text to show
+ * @param string $htmltext Content html of tooltip. Must be HTML/UTF8 encoded.
+ * @param int $tooltipon 1=tooltip sur texte, 2=tooltip sur picto, 3=tooltip sur les 2
+ * @param int $direction -1=Le picto est avant, 0=pas de picto, 1=le picto est apres
+ * @param string $img Code img du picto (use img_xxx() function to get it)
+ * @param string $extracss Add a CSS style to td tags
+ * @param int $notabs Do not include table and tr tags
+ * @param string $incbefore Include code before the text
+ * @param int $noencodehtmltext Do not encode into html entity the htmltext
+ * @return string Code html du tooltip (texte+picto)
+ * @see Use function textwithpicto if you can.
+ */
+ function textwithtooltip($text,$htmltext,$tooltipon=1,$direction=0,$img='',$extracss='',$notabs=0,$incbefore='',$noencodehtmltext=0)
+ {
+ global $conf;
- if ($incbefore) $text = $incbefore.$text;
- if (! $htmltext) return $text;
+ if ($incbefore) $text = $incbefore.$text;
+ if (! $htmltext) return $text;
- // Sanitize tooltip
- $htmltext=str_replace("\\","\\\\",$htmltext);
- $htmltext=str_replace("\r","",$htmltext);
- $htmltext=str_replace("\n","",$htmltext);
+ // Sanitize tooltip
+ $htmltext=str_replace("\\","\\\\",$htmltext);
+ $htmltext=str_replace("\r","",$htmltext);
+ $htmltext=str_replace("\n","",$htmltext);
- $htmltext=str_replace('"',""",$htmltext);
- if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip
- else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
- if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip
- else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
+ $htmltext=str_replace('"',""",$htmltext);
+ if ($tooltipon == 2 || $tooltipon == 3) $paramfortooltipimg=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td img tag to store tooltip
+ else $paramfortooltipimg =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
+ if ($tooltipon == 1 || $tooltipon == 3) $paramfortooltiptd=' class="classfortooltip'.($extracss?' '.$extracss:'').'" title="'.($noencodehtmltext?$htmltext:dol_escape_htmltag($htmltext,1)).'"'; // Attribut to put on td tag to store tooltip
+ else $paramfortooltiptd =($extracss?' class="'.$extracss.'"':''); // Attribut to put on td text tag
- $s="";
- if (empty($notabs)) $s.='
';
- if ($direction > 0)
- {
- if ($text != '')
- {
- $s.='
'.$text;
- if ($direction) $s.=' ';
- $s.='
';
- }
- if ($direction) $s.='
'.$img.'
';
- }
- else
- {
- if ($direction) $s.='
'.$img.'
';
- if ($text != '')
- {
- $s.='
';
- if ($direction) $s.=' ';
- $s.=$text.'
';
- }
- }
- if (empty($notabs)) $s.='
';
+ $s="";
+ if (empty($notabs)) $s.='
';
+ if ($direction > 0)
+ {
+ if ($text != '')
+ {
+ $s.='
'.$text;
+ if ($direction) $s.=' ';
+ $s.='
';
+ }
+ if ($direction) $s.='
'.$img.'
';
+ }
+ else
+ {
+ if ($direction) $s.='
'.$img.'
';
+ if ($text != '')
+ {
+ $s.='
';
+ if ($direction) $s.=' ';
+ $s.=$text.'
';
+ }
+ }
+ if (empty($notabs)) $s.='
';
- return $s;
- }
+ return $s;
+ }
/**
* Show a text with a picto and a tooltip on picto
@@ -374,8 +372,7 @@ class Form
if (empty($conf->use_javascript_ajax))
{
if ($type == 'info' || $type == 'help') return $text;
- else { $alt=$htmltext; $htmltext='';
- }
+ else { $alt=$htmltext; $htmltext=''; }
}
// If info or help with smartphone, show only text
if (! empty($conf->browser->phone))
@@ -394,25 +391,24 @@ class Form
}
/**
- * Return combo list of activated countries, into language of user
+ * Return combo list of activated countries, into language of user
*
- * @param string $selected Id or Code or Label of preselected country
- * @param string $htmlname Name of html select object
- * @param string $htmloption Options html on select object
- * @return void
+ * @param selected Id or Code or Label of preselected country
+ * @param htmlname Name of html select object
+ * @param htmloption Options html on select object
*/
function select_pays($selected='',$htmlname='pays_id',$htmloption='')
{
- print $this->select_country($selected,$htmlname,$htmloption);
+ print $this->select_country($selected,$htmlname,$htmloption);
}
/**
- * Return combo list of activated countries, into language of user
+ * Return combo list of activated countries, into language of user
*
- * @param string $selected Id or Code or Label of preselected country
- * @param string $htmlname Name of html select object
- * @param string $htmloption Options html on select object
- * @return string HTML string with select
+ * @param selected Id or Code or Label of preselected country
+ * @param htmlname Name of html select object
+ * @param htmloption Options html on select object
+ * @return string HTML string with select
*/
function select_country($selected='',$htmlname='pays_id',$htmloption='')
{
@@ -440,13 +436,13 @@ class Form
{
$foundselected=false;
- while ($i < $num)
- {
+ while ($i < $num)
+ {
$obj = $this->db->fetch_object($resql);
$countryArray[$i]['rowid'] = $obj->rowid;
$countryArray[$i]['code_iso'] = $obj->code_iso;
$countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso)!="Country".$obj->code_iso?$langs->transnoentitiesnoconv("Country".$obj->code_iso):($obj->label!='-'?$obj->label:''));
- $label[$i] = $countryArray[$i]['label'];
+ $label[$i] = $countryArray[$i]['label'];
$i++;
}
@@ -454,10 +450,10 @@ class Form
foreach ($countryArray as $row)
{
- //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].' ';
- if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
- {
- $foundselected=true;
+ //print 'rr'.$selected.'-'.$row['label'].'-'.$row['code_iso'].' ';
+ if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['label']) )
+ {
+ $foundselected=true;
$out.= '
';
- print $value;
- print '
';
+ print '
';
+ print $value;
+ print '
';
}
print '';
@@ -610,15 +711,29 @@ class Form
}
/**
- * Output html form to select a third party
+ * Output html form to select a third party
*
- * @param string $selected Preselected type
- * @param string $htmlname Name of field in form
- * @param string $filter Optionnal filters criteras
- * @param int $showempty Add an empty field
- * @param int $showtype Show third party type in combolist (customer, prospect or supplier)
- * @param int $forcecombo Force to use combo box
- * @return string HTML string with
+ * @param selected Preselected type
+ * @param htmlname Name of field in form
+ * @param filter Optionnal filters criteras
+ * @param showempty Add an empty field
+ * @param showtype Show third party type in combolist (customer, prospect or supplier)
+ * @param forcecombo Force to use combo box
+ */
+ function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
+ {
+ print $this->select_company($selected,$htmlname,$filter,$showempty,$showtype,$forcecombo);
+ }
+
+ /**
+ * Output html form to select a third party
+ *
+ * @param selected Preselected type
+ * @param htmlname Name of field in form
+ * @param filter Optionnal filters criteras
+ * @param showempty Add an empty field
+ * @param showtype Show third party type in combolist (customer, prospect or supplier)
+ * @param forcecombo Force to use combo box
*/
function select_company($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0, $forcecombo=0)
{
@@ -635,7 +750,7 @@ class Form
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= " ORDER BY nom ASC";
- dol_syslog(get_class($this)."::select_company sql=".$sql);
+ dol_syslog("Form::select_societes sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
@@ -643,7 +758,7 @@ class Form
{
//$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
- $out.= ajax_combobox($htmlname);
+ $out.= ajax_combobox($htmlname);
}
$out.= '