New: Utilisation de niveaux plus fin des droits de compta sur le même modèles que les autres modules (Lire, Modifier...).
Optim: La fonction de chargement des droits n'est réalisée qu'une fois même si appelé plusieurs fois. New: Possibilité de tri sur la liste des user.
This commit is contained in:
parent
2341e994db
commit
5af0f1616d
@ -25,7 +25,7 @@ require("./pre.inc.php");
|
|||||||
$user->getrights('facture');
|
$user->getrights('facture');
|
||||||
$user->getrights('compta');
|
$user->getrights('compta');
|
||||||
|
|
||||||
if (!$user->admin && !$user->rights->compta->charges)
|
if (!$user->admin && !$user->rights->compta->charges->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
@ -83,11 +83,6 @@ $filtre=$_GET["filtre"];
|
|||||||
print_fiche_titre("Charges sociales",($year?"<a href='$PHP_SELF?year=".($year-1)."'>".img_previous()."</a> Année $year <a href='$PHP_SELF?year=".($year+1)."'>".img_next()."</a>":""));
|
print_fiche_titre("Charges sociales",($year?"<a href='$PHP_SELF?year=".($year-1)."'>".img_previous()."</a> Année $year <a href='$PHP_SELF?year=".($year+1)."'>".img_next()."</a>":""));
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
//if ($filtre) {
|
|
||||||
// print_titre("Filtre : ".$_GET["filtrelib"]);
|
|
||||||
// print "<br>\n";
|
|
||||||
//}
|
|
||||||
|
|
||||||
if ($mesg) {
|
if ($mesg) {
|
||||||
print "$mesg<br>";
|
print "$mesg<br>";
|
||||||
}
|
}
|
||||||
@ -173,8 +168,14 @@ if ( $db->query($sql) )
|
|||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
} else {
|
} else {
|
||||||
print '<td align="center"><a class="impayee" href="'.$PHP_SELF.'?filtre=paye:0">Impayé</a></td>';
|
print '<td align="center"><a class="impayee" href="'.$PHP_SELF.'?filtre=paye:0">Impayé</a></td>';
|
||||||
print '<td align="center"><a href="charges.php?id='.$obj->id.'">'.img_edit().'</a>';
|
print '<td align="center" nowrap>';
|
||||||
print ' <a href="'.$PHP_SELF.'?action=del&id='.$obj->id.'">'.img_delete().'</a></td>';
|
if ($user->rights->compta->charges->creer) {
|
||||||
|
print '<a href="charges.php?id='.$obj->id.'">'.img_edit().'</a>';
|
||||||
|
}
|
||||||
|
if ($user->rights->compta->charges->supprimer) {
|
||||||
|
print ' <a href="'.$PHP_SELF.'?action=del&id='.$obj->id.'">'.img_delete().'</a>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
@ -189,19 +190,20 @@ else
|
|||||||
* Forumalaire d'ajout d'une charge
|
* Forumalaire d'ajout d'une charge
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
print '<tr class="form" valign="top"><form method="post" action="index.php">';
|
if ($user->rights->compta->charges->creer) {
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<tr class="form" valign="top"><form method="post" action="index.php">';
|
||||||
print '<td> </td>';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<td><input type="text" size="8" name="date"><br>YYYYMMDD</td>';
|
print '<td> </td>';
|
||||||
print '<td><input type="text" size="8" name="periode"><br>YYYYMMDD</td>';
|
print '<td><input type="text" size="8" name="date"><br>YYYYMMDD</td>';
|
||||||
|
print '<td><input type="text" size="8" name="periode"><br>YYYYMMDD</td>';
|
||||||
|
|
||||||
print '<td align="left"><select name="type">';
|
print '<td align="left"><select name="type">';
|
||||||
|
|
||||||
$sql = "SELECT c.id, c.libelle as type FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
$sql = "SELECT c.id, c.libelle as type FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||||
$sql .= " ORDER BY lower(c.libelle) ASC";
|
$sql .= " ORDER BY lower(c.libelle) ASC";
|
||||||
|
|
||||||
if ( $db->query($sql) )
|
if ( $db->query($sql) )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
@ -211,15 +213,16 @@ if ( $db->query($sql) )
|
|||||||
print '<option value="'.$obj->id.'">'.$obj->type;
|
print '<option value="'.$obj->id.'">'.$obj->type;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td align="left"><input type="text" size="24" name="libelle"></td>';
|
print '<td align="left"><input type="text" size="24" name="libelle"></td>';
|
||||||
print '<td align="right"><input type="text" size="6" name="amount"></td>';
|
print '<td align="right"><input type="text" size="6" name="amount"></td>';
|
||||||
print '<td> </td>';
|
print '<td> </td>';
|
||||||
|
|
||||||
print '<td><input type="submit" value="Ajouter"></form></td>';
|
print '<td><input type="submit" value="Ajouter"></form></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class User
|
|||||||
$this->compta = 1;
|
$this->compta = 1;
|
||||||
$this->limite_liste = 0;
|
$this->limite_liste = 0;
|
||||||
|
|
||||||
$this->permissions_are_loaded = 0;
|
$this->all_permissions_are_loaded = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
Function getrights($module='')
|
Function getrights($module='')
|
||||||
{
|
{
|
||||||
if ($this->permissions_are_loaded) {
|
if ($this->all_permissions_are_loaded) {
|
||||||
// Si les permissions ont déja été chargé pour ce user, on quitte
|
// Si les permissions ont déja été chargé pour ce user, on quitte
|
||||||
// Cela évite de faire n fois le select quand la fonction est appelée plusieurs fois
|
// Cela évite de faire n fois le select quand la fonction est appelée plusieurs fois
|
||||||
// pour charger les droits de différents modules. On les charges tous la
|
// pour charger les droits de différents modules. On les charges tous la
|
||||||
@ -196,12 +196,11 @@ class User
|
|||||||
$sql = "SELECT fk_user, fk_id FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user= $this->id";
|
$sql = "SELECT fk_user, fk_id FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user= $this->id";
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
{
|
{
|
||||||
$rr=array();
|
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($i);
|
$obj = $this->db->fetch_object();
|
||||||
|
|
||||||
if ($module == 'facture' or $module == '')
|
if ($module == 'facture' or $module == '')
|
||||||
{
|
{
|
||||||
@ -362,10 +361,13 @@ class User
|
|||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
|
|
||||||
$this->permissions_are_loaded=1;
|
if ($module == '') {
|
||||||
|
// Si module etait non defini, alors on a tout chargé, on peut donc considérer
|
||||||
|
// que les droits sont cachés (car tous chargés) pour cet instance de user
|
||||||
|
$this->all_permissions_are_loaded=1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user