Merge branch '4.0' of git@github.com:Dolibarr/dolibarr.git into 5.0

Conflicts:
	htdocs/comm/action/card.php
This commit is contained in:
Laurent Destailleur 2017-02-23 02:54:40 +01:00
commit e981e719a1
7 changed files with 47 additions and 37 deletions

View File

@ -852,7 +852,9 @@ if ($id > 0)
$result4=$object->fetch_userassigned(); $result4=$object->fetch_userassigned();
$result5=$object->fetch_optionals($id,$extralabels); $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"]); $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"]); $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 // Status
print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">'; print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
$percent=GETPOST("percentage")?GETPOST("percentage"):$object->percentage; $percent = GETPOST("percentage") ? GETPOST("percentage"): $object->percentage;
$formactions->form_select_status_action('formaction',$percent,1); $formactions->form_select_status_action('formaction',$percent,1);
print '</td></tr>'; print '</td></tr>';

View File

@ -1166,14 +1166,9 @@ class Propal extends CommonObject
} }
$clonedObj->id=0; $clonedObj->id=0;
$clonedObj->ref='';
$clonedObj->statut=self::STATUS_DRAFT; $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 // Clear fields
$clonedObj->user_author = $user->id; $clonedObj->user_author = $user->id;
$clonedObj->user_valid = ''; $clonedObj->user_valid = '';
@ -1182,12 +1177,6 @@ class Propal extends CommonObject
$clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600); $clonedObj->fin_validite = $clonedObj->date + ($clonedObj->duree_validite * 24 * 3600);
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $clonedObj->ref_client = ''; 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 // Create clone
$result=$clonedObj->create($user); $result=$clonedObj->create($user);

View File

@ -125,9 +125,9 @@ class Contact extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
if (!$user->rights->societe->client->voir && !$user->societe_id) 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.= ", ".MAIN_DB_PREFIX."societe as s";
$sql.= " OUTER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE sc.fk_user = " .$user->id; $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
$clause = "AND"; $clause = "AND";
} }
$sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')'; $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element, 1).')';

View File

@ -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.= " 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.= " p.rowid as product_id, p.ref as product_ref";
$sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."contrat as c"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql.= ", ".MAIN_DB_PREFIX."contratdet as cd"; $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"; $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.= ")";
$sql.= " WHERE c.entity = ".$conf->entity; $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; if($user->societe_id) $sql.= " AND s.rowid = ".$user->societe_id;
$sql.= $db->order("c.tms","DESC"); $sql.= $db->order("c.tms","DESC");
$sql.= $db->plimit($max, 0); $sql.= $db->plimit($max, 0);

View File

@ -97,7 +97,7 @@ function tree_showpad(&$fulltree,$key,$silent=0)
// ------------------------------- Used by menu editor, category view, ... ----------------- // ------------------------------- Used by menu editor, category view, ... -----------------
/** /**
* Recursive function to output menu tree. <ul id="iddivjstree"><li>...</li></ul> * Recursive function to output a tree. <ul id="iddivjstree"><li>...</li></ul>
* It is also used for the tree of categories. * 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. * 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', * $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. * TODO Replace with jstree plugin instead of treeview plugin.
* *
* @param array $tab Array of all elements * @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 int $rang Level of element
* @param string $iddivjstree Id to use for parent ul 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 * @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 '<ul id="'.$iddivjstree.'">'; print '<ul id="'.$iddivjstree.'">';
} }
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 //ballayage du tableau
$sizeoftab=count($tab); $sizeoftab=count($tab);

View File

@ -1670,7 +1670,6 @@ class User extends CommonObject
// Define $urlwithroot // Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); $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=$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) 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); dol_syslog(get_class($this)."::get_full_tree call to build_path_from_id_user", LOG_DEBUG);
foreach($this->users as $key => $val) 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 // Exclude leaf including $deleteafterid from tree
@ -2643,10 +2647,10 @@ class User extends CommonObject
* Function called by get_full_tree(). * Function called by get_full_tree().
* *
* @param int $id_user id_user entry to update * @param int $id_user id_user entry to update
* @param int $protection Deep counter to avoid infinite loop * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound)
* @return void * @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); 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 // Already defined
dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING); dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING);
return; return 0;
} }
// Define fullpath and fullname // Define fullpath and fullname
@ -2662,9 +2666,16 @@ class User extends CommonObject
$this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname']; $this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname'];
$i=0; $cursor_user=$id_user; $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']; $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname'];
$i++; $cursor_user=$this->parentof[$cursor_user]; $i++; $cursor_user=$this->parentof[$cursor_user];
} }
@ -2672,7 +2683,7 @@ class User extends CommonObject
// We count number of _ to have level // We count number of _ to have level
$this->users[$id_user]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->users[$id_user]['fullpath'])); $this->users[$id_user]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->users[$id_user]['fullpath']));
return; return 1;
} }
/** /**

View File

@ -71,9 +71,15 @@ print load_fiche_titre($langs->trans("ListOfUsers"). ' ('.$langs->trans("Hierarc
// Load hierarchy of users // Load hierarchy of users
$user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); $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 // Define fulltree array
$fulltree=$user_arbo; $fulltree=$user_arbo;
//var_dump($fulltree);
// Define data (format for treeview) // Define data (format for treeview)
$data=array(); $data=array();
$data[] = array('rowid'=>0,'fk_menu'=>-1,'title'=>"racine",'mainmenu'=>'','leftmenu'=>'','fk_mainmenu'=>'','fk_leftmenu'=>''); $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 '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
@ -185,6 +192,7 @@ else
print "</table>"; print "</table>";
print "</form>\n"; print "</form>\n";
}
// //
/*print '<script type="text/javascript" language="javascript"> /*print '<script type="text/javascript" language="javascript">