diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index b4a9f8b5395..7378e35db80 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -852,8 +852,10 @@ if ($id > 0)
$result4=$object->fetch_userassigned();
$result5=$object->fetch_optionals($id,$extralabels);
- if ($listUserAssignedUpdated || $donotclearsession) {
-
+ if ($listUserAssignedUpdated || $donotclearsession)
+ {
+ $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
+
$datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]);
$datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]);
@@ -1028,7 +1030,7 @@ if ($id > 0)
// Status
print '
| '.$langs->trans("Status").' / '.$langs->trans("Percentage").' | ';
- $percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage;
+ $percent = GETPOST("percentage") ? GETPOST("percentage"): $object->percentage;
$formactions->form_select_status_action('formaction',$percent,1);
print ' |
';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index aabb64d289c..de88cf0efdf 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1166,14 +1166,9 @@ class Propal extends CommonObject
}
$clonedObj->id=0;
+ $clonedObj->ref='';
$clonedObj->statut=self::STATUS_DRAFT;
- if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
- {
- $this->error='ErrorSetupNotComplete';
- return -1;
- }
-
// Clear fields
$clonedObj->user_author = $user->id;
$clonedObj->user_valid = '';
@@ -1182,12 +1177,6 @@ class Propal extends CommonObject
$clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600);
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = '';
- // Set ref
- require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
- $obj = $conf->global->PROPALE_ADDON;
- $modPropale = new $obj;
- $clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj);
-
// Create clone
$result=$clonedObj->create($user);
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 3b4fa942f81..de491744d57 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -125,9 +125,9 @@ class Contact extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
- $sql.= " OUTER JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
- $sql.= " OUTER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
+ $sql.= ", ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$clause = "AND";
}
$sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')';
diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php
index 9f71a98e77f..752509a0616 100644
--- a/htdocs/core/boxes/box_services_contracts.php
+++ b/htdocs/core/boxes/box_services_contracts.php
@@ -70,15 +70,12 @@ class box_services_contracts extends ModeleBoxes
$sql.= " cd.rowid as cdid, cd.tms as datem, cd.statut, cd.label, cd.description, cd.product_type as type,";
$sql.= " p.rowid as product_id, p.ref as product_ref";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s";
- $sql.= ", ".MAIN_DB_PREFIX."contrat as c";
- $sql.= ", ".MAIN_DB_PREFIX."contratdet as cd";
+ $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
+ $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
- if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$sql.= ")";
$sql.= " WHERE c.entity = ".$conf->entity;
- $sql.= " AND s.rowid = c.fk_soc";
- $sql.= " AND c.rowid = cd.fk_contrat";
- if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= $db->order("c.tms","DESC");
$sql.= $db->plimit($max, 0);
diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php
index 6fc0c9f013f..db0fcd07fae 100644
--- a/htdocs/core/lib/treeview.lib.php
+++ b/htdocs/core/lib/treeview.lib.php
@@ -97,7 +97,7 @@ function tree_showpad(&$fulltree,$key,$silent=0)
// ------------------------------- Used by menu editor, category view, ... -----------------
/**
- * Recursive function to output menu tree.
+ * Recursive function to output a tree.
* It is also used for the tree of categories.
* Note: To have this function working, check you have loaded the js and css for treeview.
* $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js',
@@ -106,7 +106,7 @@ function tree_showpad(&$fulltree,$key,$silent=0)
* TODO Replace with jstree plugin instead of treeview plugin.
*
* @param array $tab Array of all elements
- * @param int $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
+ * @param array $pere Array with parent ids ('rowid'=>,'mainmenu'=>,'leftmenu'=>,'fk_mainmenu=>,'fk_leftmenu=>)
* @param int $rang Level of element
* @param string $iddivjstree Id to use for parent ul element
* @param int $donoresetalreadyloaded Do not reset global array $donoresetalreadyloaded used to avoid to go down on an aleady processed record
@@ -139,7 +139,10 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal
print '';
}
- if ($rang > 50) return; // Protect against infinite loop. Max 50 depth
+ if ($rang > 50)
+ {
+ return; // Protect against infinite loop. Max 50 depth
+ }
//ballayage du tableau
$sizeoftab=count($tab);
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index a3f213ff417..6e4d033e093 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1670,7 +1670,6 @@ class User extends CommonObject
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
- //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
if (! $changelater)
{
@@ -2573,7 +2572,12 @@ class User extends CommonObject
dol_syslog(get_class($this)."::get_full_tree call to build_path_from_id_user", LOG_DEBUG);
foreach($this->users as $key => $val)
{
- $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent)
+ $result = $this->build_path_from_id_user($key,0); // Process a branch from the root user key (this user has no parent)
+ if ($result < 0)
+ {
+ $this->error='ErrorLoopInHierarchy';
+ return -1;
+ }
}
// Exclude leaf including $deleteafterid from tree
@@ -2643,10 +2647,10 @@ class User extends CommonObject
* Function called by get_full_tree().
*
* @param int $id_user id_user entry to update
- * @param int $protection Deep counter to avoid infinite loop
- * @return void
+ * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound)
+ * @return int < 0 if KO (infinit loop), >= 0 if OK
*/
- function build_path_from_id_user($id_user,$protection=1000)
+ function build_path_from_id_user($id_user,$protection=0)
{
dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG);
@@ -2654,7 +2658,7 @@ class User extends CommonObject
{
// Already defined
dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING);
- return;
+ return 0;
}
// Define fullpath and fullname
@@ -2662,9 +2666,16 @@ class User extends CommonObject
$this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname'];
$i=0; $cursor_user=$id_user;
- while ((empty($protection) || $i < $protection) && ! empty($this->parentof[$cursor_user]))
+ $useridfound=array($id_user);
+ while (! empty($this->parentof[$cursor_user]))
{
- $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
+ if (in_array($this->parentof[$cursor_user], $useridfound))
+ {
+ dol_syslog("The hierarchy of user has a recursive loop", LOG_WARNING);
+ return -1; // Should not happen. Protection against looping hierarchy
+ }
+ $useridfound[]=$this->parentof[$cursor_user];
+ $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
$this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname'];
$i++; $cursor_user=$this->parentof[$cursor_user];
}
@@ -2672,7 +2683,7 @@ class User extends CommonObject
// We count number of _ to have level
$this->users[$id_user]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->users[$id_user]['fullpath']));
- return;
+ return 1;
}
/**
diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php
index 9c5dd745347..bb558bd56b3 100644
--- a/htdocs/user/hierarchy.php
+++ b/htdocs/user/hierarchy.php
@@ -71,9 +71,15 @@ print load_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("Hierarc
// Load hierarchy of users
$user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : '');
+if (! is_array($user_arbo) && $user_arbo < 0)
+{
+ setEventMessages($userstatic->error, $userstatic->errors, 'warnings');
+}
+else
+{
// Define fulltree array
$fulltree=$user_arbo;
-
+//var_dump($fulltree);
// Define data (format for treeview)
$data=array();
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>'');
@@ -131,6 +137,7 @@ foreach($fulltree as $key => $val)
);
}
+//var_dump($data);
print '
\n";
+}
//
/*print '