2
0
forked from Wavyzz/dolibarr

Merge branch '10.0' of git@github.com:Dolibarr/dolibarr.git into 11.0

Conflicts:
	htdocs/holiday/class/holiday.class.php
	htdocs/product/index.php
This commit is contained in:
Laurent Destailleur
2020-02-05 14:38:19 +01:00
3 changed files with 37 additions and 29 deletions

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2016 Juan José Menent <jmenent@2byte.es> * Copyright (C) 2016 Juan José Menent <jmenent@2byte.es>
* Copyright (C) 2020 Pierre Ardoin <mapiolca@me.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -97,7 +98,8 @@ class box_project extends ModeleBoxes
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " WHERE p.fk_statut = 1"; // Only open projects $sql.= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok
$sql.= " AND p.fk_statut = 1"; // Only open projects
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
$sql.= " ORDER BY p.datec DESC"; $sql.= " ORDER BY p.datec DESC";

View File

@@ -1654,21 +1654,24 @@ class Holiday extends CommonObject
{ {
if ($type) if ($type)
{ {
// Si utilisateur de Dolibarr // If user of Dolibarr
$sql = "SELECT";
$sql = "SELECT u.rowid"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " DISTINCT";
}
$sql.= " u.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE (ug.fk_user = u.rowid"; $sql .= " WHERE ((ug.fk_user = u.rowid";
$sql .= " AND ug.entity = ".$conf->entity.")"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
$sql .= " OR u.admin = 1"; $sql .= " OR u.entity = 0)"; // Show always superadmin
} }
else else
{ {
$sql .= " WHERE u.entity IN (0,".$conf->entity.")"; $sql .= " WHERE u.entity IN (".getEntity('user').")";
} }
$sql .= " AND u.statut > 0"; $sql .= " AND u.statut > 0";
if ($filters) $sql .= $filters; if ($filters) $sql .= $filters;
@@ -1709,7 +1712,7 @@ class Holiday extends CommonObject
// We want only list of vacation balance for user ids // We want only list of vacation balance for user ids
$sql = "SELECT DISTINCT cpu.fk_user"; $sql = "SELECT DISTINCT cpu.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE cpu.fk_user = u.user"; $sql .= " WHERE cpu.fk_user = u.rowid";
if ($filters) $sql .= $filters; if ($filters) $sql .= $filters;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@@ -1750,17 +1753,24 @@ class Holiday extends CommonObject
// List for Dolibarr users // List for Dolibarr users
if ($type) if ($type)
{ {
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user"; // If user of Dolibarr
$sql = "SELECT";
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= " DISTINCT";
}
$sql.= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{ {
$sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE (ug.fk_user = u.rowid"; $sql .= " WHERE ((ug.fk_user = u.rowid";
$sql.= " AND ug.entity = ".$conf->entity.")"; $sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
$sql.= " OR u.admin = 1"; $sql .= " OR u.entity = 0)"; // Show always superadmin
} else { }
$sql.= " WHERE u.entity IN (0,".$conf->entity.")"; else
{
$sql .= " WHERE u.entity IN (".getEntity('user').")";
} }
$sql.= " AND u.statut > 0"; $sql.= " AND u.statut > 0";

View File

@@ -247,21 +247,17 @@ class HolidayTest extends PHPUnit\Framework\TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
//$localobject->fetch($localobject->id); $result = $localobject->fetchUsers(true, true, '');
$this->assertNotEquals($result, -1);
/* $result = $localobject->fetchUsers(true, false, '');
$result=$localobject->getNomUrl(1); $this->assertNotEquals($result, -1);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, '');
$result=$localobject->getFullAddress(1); $result = $localobject->fetchUsers(false, true, '');
print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertNotEquals($result, -1);
$this->assertContains("New address\nNew zip New town\nBelgium", $result);
$localobject->info($localobject->id); $result = $localobject->fetchUsers(false, false, '');
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; $this->assertNotEquals($result, -1);
$this->assertNotEquals($localobject->date_creation, '');
*/
return $localobject->id; return $localobject->id;
} }