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

This commit is contained in:
Laurent Destailleur 2018-03-07 13:04:27 +01:00
commit f8d8c5c658
8 changed files with 96 additions and 41 deletions

View File

@ -48,7 +48,7 @@ class BookKeeping extends CommonObject
*/
public $table_element = 'accounting_bookkeeping';
public $entity = 1;
public $entity;
/**
* @var BookKeepingLine[] Lines
@ -295,7 +295,7 @@ class BookKeeping extends CommonObject
$sql .= ",'" . $this->db->escape($this->code_journal) . "'";
$sql .= ",'" . $this->db->escape($this->journal_label) . "'";
$sql .= "," . $this->db->escape($this->piece_num);
$sql .= ", " . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ", " . (! isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ")";
dol_syslog(get_class($this) . ":: create sql=" . $sql, LOG_DEBUG);
@ -363,6 +363,8 @@ class BookKeeping extends CommonObject
* @return int <0 if KO, Id of created object if OK
*/
public function createStd(User $user, $notrigger = false, $mode='') {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
@ -486,7 +488,7 @@ class BookKeeping extends CommonObject
$sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ',';
$sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ',';
$sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->db->escape($this->piece_num)).',';
$sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity);
$sql .= ' ' . (! isset($this->entity) ? $conf->entity : $this->entity);
$sql .= ')';
$this->db->begin();

View File

@ -7,20 +7,22 @@ class Comment extends CommonObject
public $element='comment'; //!< Id that identify managed objects
public $table_element='comment'; //!< Name of table without prefix where object is stored
var $fk_element;
var $element_type;
public $fk_element;
public $element_type;
var $description;
public $description;
var $tms;
public $tms;
var $datec;
public $datec;
var $fk_user_author;
public $fk_user_author;
var $entity;
public $entity;
var $import_key;
public $import_key;
public $comments = array();
public $oldcopy;
@ -289,10 +291,10 @@ class Comment extends CommonObject
* @param int $fk_element Id of element
* @return array Comment array
*/
public static function fetchAllFor($element_type, $fk_element)
public function fetchAllFor($element_type, $fk_element)
{
global $db,$conf;
$TComments = array();
$this->comments = array();
if(!empty($element_type) && !empty($fk_element)) {
$sql = "SELECT";
$sql.= " c.rowid";
@ -302,7 +304,7 @@ class Comment extends CommonObject
$sql.= " AND c.entity = ".$conf->entity;
$sql.= " ORDER BY c.tms DESC";
dol_syslog("Comment::fetchAllFor", LOG_DEBUG);
dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
@ -313,12 +315,17 @@ class Comment extends CommonObject
{
$comment = new self($db);
$comment->fetch($obj->rowid);
$TComments[] = $comment;
$this->comments[] = $comment;
}
}
$db->free($resql);
} else {
$error++; $this->errors[]="Error ".$this->db->lasterror();
return -1;
}
}
return $TComments;
return count($this->comments);
}
}

View File

@ -6528,8 +6528,14 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
$comment = new Comment($this->db);
$this->comments = Comment::fetchAllFor($this->element, $this->id);
return 1;
$result=$comment->fetchAllFor($this->element, $this->id);
if ($result<0) {
$this->errors=array_merge($this->errors,$comment->errors);
return -1;
} else {
$this->comments = $comment->comments;
}
return count($this->comments);
}
/**

View File

@ -43,7 +43,7 @@ print '<td colspan="3">';
$desc = GETPOST('comment_description');
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%');
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, true, true, ROWS_3, '100%');
print $doleditor->Create(1);
print '</td>';

View File

@ -97,7 +97,11 @@ if ($id > 0 || ! empty($ref))
{
if ($object->fetch($id,$ref) > 0)
{
$res=$object->fetch_optionals($object->id,$extralabels);
$result=$object->fetchComments();
if ($result<0){
setEventMessages($object->error,$object->errors,'errors');
}
$result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();

View File

@ -2744,12 +2744,24 @@ class User extends CommonObject
// Init $this->users array
$sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
{
$sql.= " WHERE u.entity IS NOT NULL";
}
else
{
// TODO add hook
if (! empty($conf->multicompany->enabled)) {
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (! empty($user->admin) && empty($user->entity)) {
if ($conf->entity == 1) {
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
if ($filter) $sql.=" AND ".$filter;

View File

@ -89,7 +89,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
*/
$max=10;
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut";
$sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut";
$sql.= ", u.entity";
$sql.= ", u.ldap_sid";
$sql.= ", u.photo";
@ -101,13 +101,25 @@ $sql.= ", s.code_client";
$sql.= ", s.canvas";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{
$sql.= " WHERE u.entity IS NOT NULL";
}
else
{
$sql.= " WHERE u.entity IN (0,".$conf->entity.")";
// TODO add hook
if (! empty($conf->multicompany->enabled)) {
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (! empty($user->admin) && empty($user->entity)) {
if ($conf->entity == 1) {
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
if (!empty($socid)) $sql.= " AND u.fk_soc = ".$socid;
$sql.= $db->order("u.datec","DESC");

View File

@ -175,7 +175,7 @@ $user2=new User($db);
$buttonviewhierarchy='<form action="'.DOL_URL_ROOT.'/user/hierarchy.php'.(($search_statut != '' && $search_statut >= 0) ? '?search_statut='.$search_statut : '').'" method="POST"><input type="submit" class="button" style="width:120px" name="viewcal" value="'.dol_escape_htmltag($langs->trans("HierarchicView")).'"></form>';
$sql = "SELECT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.email, u.accountancy_code, u.gender, u.employee, u.photo,";
$sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.email, u.accountancy_code, u.gender, u.employee, u.photo,";
$sql.= " u.datelastlogin, u.datepreviouslogin,";
$sql.= " u.ldap_sid, u.statut, u.entity,";
$sql.= " u.tms as date_update, u.datec as date_creation,";
@ -191,12 +191,24 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity))))
{
$sql.= " WHERE u.entity IS NOT NULL";
}
else
{
// TODO add hook
if (! empty($conf->multicompany->enabled)) {
if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (! empty($user->admin) && empty($user->entity)) {
if ($conf->entity == 1) {
$sql.= " WHERE u.entity IS NOT NULL";
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE ug.fk_user = u.rowid";
$sql.= " AND ug.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
} else {
$sql.= " WHERE u.entity IN (".getEntity('user').")";
}
if ($socid > 0) $sql.= " AND u.fk_soc = ".$socid;