diff --git a/htdocs/telephonie/tarifs/permissions.php b/htdocs/telephonie/tarifs/permissions.php new file mode 100644 index 00000000000..336bf89f74b --- /dev/null +++ b/htdocs/telephonie/tarifs/permissions.php @@ -0,0 +1,271 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("./pre.inc.php"); + +if (!$user->rights->telephonie->tarif->permission) + accessforbidden(); + +if ($_POST["action"] == 'perms') +{ + + if ($_POST["perms"] == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights"; + $sql .= " WHERE fk_user = '".$_POST["user"]."'"; + $sql .= " AND fk_grille = '".$_POST["grille"]."';"; + $db->query($sql); + } + + if ($_POST["perms"] == 1) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights"; + $sql .= " SET pread= 1, pwrite = 0 WHERE fk_user = '".$_POST["user"]."'"; + $sql .= " AND fk_grille = '".$_POST["grille"]."';"; + if ( $db->query($sql) ) + { + if ($db->affected_rows($resql) == 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights"; + $sql .= " (pread,pwrite, fk_user, fk_grille) VALUES "; + $sql .= " (1,0,'".$_POST["user"]."','".$_POST["grille"]."');"; + if ( $db->query($sql) ) + { + + } + } + + } + } + + if ($_POST["perms"] == 2) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights"; + $sql .= " SET pread= 1, pwrite = 1 WHERE fk_user = '".$_POST["user"]."'"; + $sql .= " AND fk_grille = '".$_POST["grille"]."';"; + if ( $db->query($sql) ) + { + + if ($db->affected_rows($resql) == 0) + { + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights"; + $sql .= " (pread,pwrite, fk_user, fk_grille) VALUES "; + $sql .= " (1,1,'".$_POST["user"]."','".$_POST["grille"]."');"; + if ( $db->query($sql) ) + { + + } + else + { + print $sql; + } + } + + } + } + +} + + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + + + +/* + * + * + */ +$grilles = array(); +$sql = "SELECT d.rowid, d.libelle FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille as d"; +$resql = $db->query($sql); +if ($resql) +{ + while ($row = $db->fetch_row($resql)) + { + $grilles[$row[0]] = $row[1]; + } + $db->free($resql); +} + +$users = array(); + +$sql = "SELECT u.rowid, u.firstname, u.name FROM ".MAIN_DB_PREFIX."user as u"; +$resql = $db->query($sql); +if ($resql) +{ + while ($row = $db->fetch_row($resql)) + { + $users[$row[0]] = $row[1] . ' '.$row[2]; + } + $db->free($resql); +} + +$form = new Form($db); +print '