diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index d49ea34e92c..67d1b468927 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -238,46 +238,49 @@ print ''; /* - * Derniers clients enregsitrés + * Derniers clients enregistrés */ -$sql = "SELECT s.idp,s.nom,".$db->pdate("datec")." as datec"; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= " WHERE s.client = 1"; -if ($user->societe_id > 0) +if ($user->rights->societe->lire) { - $sql .= " AND s.idp = $user->societe_id"; -} -$sql .= " ORDER BY s.datec DESC "; -$sql .= $db->plimit($max, 0); - -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - if ($num) + $sql = "SELECT s.idp,s.nom,".$db->pdate("datec")." as datec"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE s.client = 1"; + if ($user->societe_id > 0) { - $langs->load("boxes"); - - print ''; - print ''; - print ''; - - $i = 0; - $var=false; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - print ""; - print ""; - print '"; - print ''; - $i++; - $var=!$var; - - } - print "
'.$langs->trans("BoxTitleLastCustomers",$max).'
idp."\">".img_object($langs->trans("ShowCustomer"),"company")." ".$objp->nom."'.dolibarr_print_date($objp->datec)."

"; + $sql .= " AND s.idp = $user->societe_id"; + } + $sql .= " ORDER BY s.datec DESC "; + $sql .= $db->plimit($max, 0); - $db->free($resql); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + if ($num) + { + $langs->load("boxes"); + + print ''; + print ''; + print ''; + + $i = 0; + $var=false; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ""; + print ""; + print '"; + print ''; + $i++; + $var=!$var; + + } + print "
'.$langs->trans("BoxTitleLastCustomers",$max).'
idp."\">".img_object($langs->trans("ShowCustomer"),"company")." ".$objp->nom."'.dolibarr_print_date($objp->datec)."

"; + + $db->free($resql); + } } }