diff --git a/ChangeLog b/ChangeLog
index 3cfc257bbb2..154222d599a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -147,8 +147,12 @@ Following changes may create regression for some external modules, but were nece
* Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used.
* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still
exists, but if an external module need action on it, it must provides itself its trigger file.
-* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode
+* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var
+ $multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into
+ the Home - setup - other admin page.
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
+* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can
+ retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
* The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
hook specifications so you must return output into "resprint".
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 70b2acb86b7..84e75e06cbd 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -1194,7 +1194,7 @@ class ActionComm extends CommonObject
{
$libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':'');
}
- $result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend;
+ $result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="valigntextbottom"':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend;
}
if ($withpicto==1) $result.=' ';
$result.=$linkstart.$libelleshort.$linkend;
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 508f71fdc86..598616798b6 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -748,6 +748,15 @@ class Facture extends CommonInvoice
// Charge facture source
$facture=new Facture($this->db);
+
+ $this->fetch_optionals();
+ if(!empty($this->array_options)){
+ $facture->array_options = $this->array_options;
+ }
+
+ foreach($this->lines as &$line){
+ $line->fetch_optionals();//fetch extrafields
+ }
$facture->fk_facture_source = $this->fk_facture_source;
$facture->type = $this->type;
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index c13571dd6cb..90ec4c7edba 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1482,7 +1482,7 @@ else
$sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,";
$sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
$sql.= " cd.fk_unit,";
- $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity";
+ $sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity";
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql.= " WHERE cd.rowid = ".$object->lines[$cursorline-1]->id;
@@ -1513,7 +1513,7 @@ else
if ($action != 'editline' || GETPOST('rowid') != $objp->rowid)
{
print '
';
@@ -541,7 +541,7 @@ if ($showweather)
$boxwork.='';
}
-$boxwork.='
';
+$boxwork.='
';
// Show dashboard
$nbworkboardempty=0;
diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang
index 38a40315985..a62db9c7158 100644
--- a/htdocs/langs/en_US/agenda.lang
+++ b/htdocs/langs/en_US/agenda.lang
@@ -78,6 +78,11 @@ InvoiceDeleted=Invoice deleted
PRODUCT_CREATEInDolibarr=Product %s created
PRODUCT_MODIFYInDolibarr=Product %s modified
PRODUCT_DELETEInDolibarr=Product %s deleted
+EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created
+EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated
+EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved
+EXPENSE_REPORT_DELETEInDolibarr=Expense report %s deleted
+EXPENSE_REPORT_REFUSEDInDolibarr=Expense report %s refused
##### End agenda events #####
AgendaModelModule=Document templates for event
DateActionStart=Start date
diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang
index d940555f206..a30768709f9 100644
--- a/htdocs/langs/en_US/projects.lang
+++ b/htdocs/langs/en_US/projects.lang
@@ -23,7 +23,7 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st
ClosedProjectsAreHidden=Closed projects are not visible.
TasksPublicDesc=This view presents all projects and tasks you are allowed to read.
TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything).
-AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it.
+AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it.
OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it.
ImportDatasetTasks=Tasks of projects
ProjectCategories=Project tags/categories
diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php
index 7bea4bf3213..8418561aa30 100644
--- a/htdocs/projet/activity/index.php
+++ b/htdocs/projet/activity/index.php
@@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
+$search_project_user = GETPOST('search_project_user','int');
+$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0;
+if ($search_project_user == $user->id) $mine = 1;
// Security check
$socid=0;
@@ -73,7 +75,7 @@ $morehtml='';
$morehtml.='
';
$projectstatic->id=$row->rowid;
@@ -205,7 +207,7 @@ if ( $resql )
while ($row = $db->fetch_object($resql))
{
-
+
print '
';
print '
';
$projectstatic->id=$row->rowid;
@@ -237,14 +239,14 @@ print "";
if ($db->type != 'pgsql')
{
print ' ';
-
+
// Affichage de la liste des projets de la semaine
print '
';
print '
';
print '
'.$langs->trans("ActivityOnProjectThisWeek").'
';
print '
'.$langs->trans("Time").'
';
print "
\n";
-
+
$sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
@@ -256,16 +258,16 @@ if ($db->type != 'pgsql')
$sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ...";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
-
+
$resql = $db->query($sql);
if ( $resql )
{
$total = 0;
$var=true;
-
+
while ($row = $db->fetch_object($resql))
{
-
+
print '
';
print "\n";
-
+
}
$db->free($resql);
}
@@ -430,12 +432,12 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
}
else dol_print_error($db);
if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
-
+
// Tasks for all resources of all opened projects and time spent for each task/resource
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list
-
+
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
$sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,";
@@ -489,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($resql);
-
+
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
@@ -509,7 +511,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$projectstatic->public = $obj->public;
$projectstatic->dateo = $db->jdate($obj->projdateo);
$projectstatic->datee = $db->jdate($obj->projdatee);
-
+
print $projectstatic->getNomUrl(1,'',0,'',' ');
print '';
if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
@@ -536,7 +538,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S
$taskstatic->datee = $db->jdate($obj->datee);
print '
';
if ($obj->socid)
@@ -217,9 +218,9 @@ if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA))
{
// This list can be very long, so we don't show it by default on task area. We prefer to use the list page.
// Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list
-
+
print ' ';
-
+
print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array());
}
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 9e2971195e3..7ee41fcd024 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -261,8 +261,8 @@ if ($search_project_user > 0)
}
$sql.= " WHERE p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
-// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
-if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
+// No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser
+if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")";
if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ);
if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL";
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
@@ -487,19 +487,25 @@ print '
';
if (! empty($arrayfields['p.ref']['checked']))
{
print '
';
- print '';
+ print '';
print '
';
}
if (! empty($arrayfields['p.title']['checked']))
{
print '
';
- print '';
+ print '';
print '
';
}
if (! empty($arrayfields['s.nom']['checked']))
{
print '
';
}
diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php
index 3ca058acb8a..725aea8825d 100644
--- a/htdocs/public/cron/cron_run_jobs.php
+++ b/htdocs/public/cron/cron_run_jobs.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2013-2015 Laurent Destailleur
+/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013-2015 Laurent Destailleur
+ * Copyright (C) 2017 Regis Houssin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,6 +31,11 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOLOGIN')) define('NOLOGIN','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+// For MultiCompany module.
+// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
+$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
+if (is_numeric($entity)) define("DOLENTITY", $entity);
+
// librarie core
// Dolibarr environment
$res = @include("../../main.inc.php"); // From htdocs directory
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index d6dad12a139..d7e9990cb7a 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -63,7 +63,7 @@ require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined)
-if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']);
+if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1);
// Define css type
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index 20e8596d8b3..0e3e620da58 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -64,7 +64,7 @@ require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined)
-if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']);
+if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1);
// Define css type
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index 2ff98899462..e03bdd8ccd5 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -223,7 +223,7 @@ class User extends CommonObject
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
$sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
else
- $sql.= " WHERE u.entity IN (0, ".($entity!=''?$entity:$conf->entity).")"; // search in entity provided in parameter
+ $sql.= " WHERE u.entity IN (0, ".(($entity!='' && $entity >= 0)?$entity:$conf->entity).")"; // search in entity provided in parameter
}
if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba
@@ -238,8 +238,8 @@ class User extends CommonObject
{
$sql.= " AND u.rowid = ".$id;
}
- $sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
-
+ $sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
+
$result = $this->db->query($sql);
if ($result)
{
@@ -667,7 +667,14 @@ class User extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
$sql.= ", ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = ur.fk_id";
- $sql.= " AND ur.entity = ".$conf->entity;
+ if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY))
+ {
+ $sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?"1,":"").$conf->entity.")";
+ }
+ else
+ {
+ $sql.= " AND ur.entity = ".$conf->entity;
+ }
$sql.= " AND ur.fk_user= ".$this->id;
$sql.= " AND r.perms IS NOT NULL";
if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'";
@@ -713,8 +720,19 @@ class User extends CommonObject
$sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
$sql.= " ".MAIN_DB_PREFIX."rights_def as r";
$sql.= " WHERE r.id = gr.fk_id";
- $sql.= " AND gr.entity = ".$conf->entity;
- $sql.= " AND r.entity = ".$conf->entity;
+ if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY))
+ {
+ if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
+ $sql.= " AND gu.entity IN (0,".$conf->entity.")";
+ } else {
+ $sql.= " AND r.entity = ".$conf->entity;
+ }
+ }
+ else
+ {
+ $sql.= " AND gr.entity = ".$conf->entity;
+ $sql.= " AND r.entity = ".$conf->entity;
+ }
$sql.= " AND gr.fk_usergroup = gu.fk_usergroup";
$sql.= " AND gu.fk_user = ".$this->id;
$sql.= " AND r.perms IS NOT NULL";
diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php
index 96c0ac881be..49739fa7c77 100644
--- a/htdocs/user/ldap.php
+++ b/htdocs/user/ldap.php
@@ -70,12 +70,12 @@ if (empty($reshook)) {
$result = $ldap->update($dn, $info, $user, $olddn);
- if ($result >= 0)
+ if ($result >= 0)
{
setEventMessages($langs->trans("UserSynchronized"), null, 'mesgs');
$db->commit();
- }
- else
+ }
+ else
{
setEventMessages($ldap->error, $ldap->errors, 'errors');
$db->rollback();
@@ -104,6 +104,7 @@ if ($user->rights->user->user->lire || $user->admin) {
dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin);
+print '