multicompany enhancement (in progress)

This commit is contained in:
Regis Houssin
2011-08-20 09:03:38 +00:00
parent d01d8021b7
commit ebfc75b0b3
5 changed files with 41 additions and 21 deletions

View File

@@ -31,7 +31,7 @@
* \file htdocs/core/class/html.form.class.php
* \ingroup core
* \brief File of class with all html predefined components
* \version $Id: html.form.class.php,v 1.199 2011/08/19 22:15:22 hregis Exp $
* \version $Id: html.form.class.php,v 1.200 2011/08/20 09:03:38 hregis Exp $
*/
@@ -763,10 +763,11 @@ class Form
* @param disabled If select list must be disabled
* @param include Array list of users id to include
* @param enableonly Array list of users id to be enabled. All other must be disabled
* @param force_entity Possibility to force entity
*/
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='')
function select_users($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly);
print $this->select_dolusers($selected,$htmlname,$show_empty,$exclude,$disabled,$include,$enableonly,$force_entity);
}
/**
@@ -778,8 +779,9 @@ class Form
* @param disabled If select list must be disabled
* @param include Array list of users id to include
* @param enableonly Array list of users id to be enabled. All other must be disabled
* @param force_entity Possibility to force entity
*/
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='')
function select_dolusers($selected='',$htmlname='userid',$show_empty=0,$exclude='',$disabled=0,$include='',$enableonly='',$force_entity=0)
{
global $conf,$user,$langs;
@@ -803,7 +805,8 @@ class Form
if($conf->multicompany->enabled && $conf->entity == 1 && $user->admin && ! $user->entity)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."entity as e on e.rowid=u.entity";
$sql.= " WHERE u.entity IS NOT NULL";
if ($force_entity) $sql.= " WHERE u.entity IN (0,".$force_entity.")";
else $sql.= " WHERE u.entity IS NOT NULL";
}
else
{

View File

@@ -28,7 +28,7 @@
* \file htdocs/lib/functions.lib.php
* \brief A set of functions for Dolibarr
* This file contains all frequently used functions.
* \version $Id: functions.lib.php,v 1.559 2011/08/19 22:15:22 hregis Exp $
* \version $Id: functions.lib.php,v 1.560 2011/08/20 09:03:38 hregis Exp $
*/
// For compatibility during upgrade
@@ -2208,11 +2208,11 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
{
$sql='';
$check = array('banque','user','usergroup','produit','service','produit|service'); // Test on entity only (Objects with no link to company)
$check = array('banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
$checksoc = array('societe'); // Test for societe object
$checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
$checkproject = array('projet'); // Test for project object
$nocheck = array('categorie','barcode','stock','fournisseur'); // No test
$nocheck = array('barcode','stock','fournisseur'); // No test
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
// If dbtable not defined, we use same name for table than module name

View File

@@ -21,7 +21,7 @@
/**
* \file htdocs/user/group/fiche.php
* \brief Onglet groupes utilisateurs
* \version $Id: fiche.php,v 1.74 2011/08/19 22:15:23 hregis Exp $
* \version $Id: fiche.php,v 1.75 2011/08/20 09:03:38 hregis Exp $
*/
require("../../main.inc.php");
@@ -374,7 +374,7 @@ else
print '<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td class="liste_titre" width="25%">'.$langs->trans("NonAffectedUsers").'</td>'."\n";
print '<td>';
print $form->select_users('','user',1,$exclude);
print $form->select_users('','user',1,$exclude,0,'','',$object->entity);
print ' &nbsp; ';
// Multicompany
if ($conf->multicompany->enabled)
@@ -521,5 +521,5 @@ else
$db->close();
llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.74 $');
llxFooter('$Date: 2011/08/20 09:03:38 $ - $Revision: 1.75 $');
?>

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011 Herve Prot <herve.prot@symeos.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
* \file htdocs/user/group/index.php
* \ingroup core
* \brief Page of user groups
* \version $Id: index.php,v 1.28 2011/08/19 22:15:23 hregis Exp $
* \version $Id: index.php,v 1.29 2011/08/20 09:03:38 hregis Exp $
*/
require("../../main.inc.php");
@@ -59,7 +59,7 @@ print_fiche_titre($langs->trans("ListOfGroups"));
$sql = "SELECT g.rowid, g.nom, g.entity, g.datec, COUNT(ugu.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid";
if($conf->multicompany->enabled && $conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1)
if($conf->multicompany->enabled && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{
$sql.= " WHERE g.entity IS NOT NULL";
}
@@ -82,7 +82,7 @@ if ($resql)
$i = 0;
$param="search_group=$search_group&amp;sall=$sall";
print "<table class=\"noborder\" width=\"100%\">";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder);
//multicompany
@@ -129,6 +129,6 @@ else
$db->close();
llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.28 $');
llxFooter('$Date: 2011/08/20 09:03:38 $ - $Revision: 1.29 $');
?>

View File

@@ -19,7 +19,7 @@
/**
* \file htdocs/user/home.php
* \brief Home page of users and groups management
* \version $Id: home.php,v 1.50 2011/08/19 22:15:23 hregis Exp $
* \version $Id: home.php,v 1.51 2011/08/20 09:03:38 hregis Exp $
*/
require("../main.inc.php");
@@ -197,16 +197,25 @@ if ($canreadperms)
$sql = "SELECT g.rowid, g.nom, g.note, g.entity, g.datec";
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g";
if($conf->multicompany->enabled && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity)))
{
$sql.= " WHERE g.entity IS NOT NULL";
}
else
{
$sql.= " WHERE g.entity IN (0,".$conf->entity.")";
}
$sql.= $db->order("g.datec","DESC");
$sql.= $db->plimit($max);
$resql=$db->query($sql);
if ($resql)
{
$colspan=2;
if ($conf->multicompany->enabled) $colspan++;
$num = $db->num_rows($resql);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("LastGroupsCreated",($num ? $num : $max)).'</td></tr>';
print '<tr class="liste_titre"><td colspan="'.$colspan.'">'.$langs->trans("LastGroupsCreated",($num ? $num : $max)).'</td></tr>';
$var = true;
$i = 0;
@@ -217,11 +226,19 @@ if ($canreadperms)
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/user/group/fiche.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.'</a>';
if (!$obj->entity)
if (! $obj->entity)
{
print img_picto($langs->trans("GlobalGroup"),'redstar');
}
print "</td>";
if ($conf->multicompany->enabled)
{
$mc = new ActionsMulticompany($db);
$mc->getInfo($obj->entity);
print '<td>';
print $mc->label;
print '</td>';
}
print '<td nowrap="nowrap" align="right">'.dol_print_date($db->jdate($obj->datec),'dayhour').'</td>';
print "</tr>";
$i++;
@@ -242,5 +259,5 @@ print '</table>';
$db->close();
llxFooter('$Date: 2011/08/19 22:15:23 $ - $Revision: 1.50 $');
llxFooter('$Date: 2011/08/20 09:03:38 $ - $Revision: 1.51 $');
?>