Ajout fonctions pour la configuration par l'interface
This commit is contained in:
parent
b31d968e79
commit
42c204e098
@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
/* Copyright (C) 2005-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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
|
||||
@ -36,7 +36,8 @@
|
||||
|
||||
|
||||
class TelephonieTarifGrille {
|
||||
|
||||
//! Identifiant de la grille
|
||||
var $id;
|
||||
var $_DB;
|
||||
var $tableau_tarif;
|
||||
var $prefixes;
|
||||
@ -49,8 +50,88 @@ class TelephonieTarifGrille {
|
||||
function TelephonieTarifGrille($_DB)
|
||||
{
|
||||
$this->db = $_DB;
|
||||
}
|
||||
|
||||
function CreateGrille($user, $name, $type)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille";
|
||||
$sql .= "(libelle, type_tarif)";
|
||||
$sql .= " VALUES ('".addslashes($name)."','".$type."');";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'telephonie_tarif_grille');
|
||||
|
||||
$this->Perms($user, 2, $user->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function Perms($user, $perms, $user_grille)
|
||||
{
|
||||
|
||||
if ($perms == 0)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights";
|
||||
$sql .= " WHERE fk_user = '".$user_grille."'";
|
||||
$sql .= " AND fk_grille = '".$this->id."';";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
if ($perms == 1)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights";
|
||||
$sql .= " SET pread= 1, pwrite = 0, fk_user_creat ='".$user->id."' WHERE fk_user = '".$user_grille."'";
|
||||
$sql .= " AND fk_grille = '".$this->id."';";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
if ($this->db->affected_rows($resql) == 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights";
|
||||
$sql .= " (pread,pwrite, fk_user, fk_grille, fk_user_creat) VALUES ";
|
||||
$sql .= " (1,0,'".$user_grille."','".$this->id."','".$user->id."');";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($perms == 2)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights";
|
||||
$sql .= " SET pread= 1, pwrite = 1, fk_user_creat ='".$user->id."' WHERE fk_user = '".$user_grille."'";
|
||||
$sql .= " AND fk_grille = '".$this->id."';";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
if ($this->db->affected_rows($resql) == 0)
|
||||
{
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille_rights";
|
||||
$sql .= " (pread,pwrite, fk_user, fk_grille, fk_user_creat) VALUES ";
|
||||
$sql .= " (1,1,'".$user_grille."','".$this->id."','".$user->id."');";
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $sql;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
117
htdocs/telephonie/telephonie.tarif.prefix.class.php
Normal file
117
htdocs/telephonie/telephonie.tarif.prefix.class.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?PHP
|
||||
/* Copyright (C) 2005-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $Id$
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/telephonie.tarif.class.php
|
||||
\ingroup facture
|
||||
\brief Fichier de la classe des tarifs telephonies
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
/**
|
||||
\class TelephonieTarif
|
||||
\brief Classe permettant la gestion des prefix de tarifs de telephonie
|
||||
*/
|
||||
|
||||
class TelephonieTarifPrefix {
|
||||
//! Identifiant de la prefix
|
||||
var $id;
|
||||
var $_DB;
|
||||
|
||||
/*
|
||||
* Constructeur
|
||||
*
|
||||
*/
|
||||
function TelephonieTarifPrefix($_DB)
|
||||
{
|
||||
$this->db = $_DB;
|
||||
}
|
||||
|
||||
function Create($user, $prefix, $tarif_id, $force='off')
|
||||
{
|
||||
if ($force == 'on')
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_prefix";
|
||||
$sql .= " SET fk_tarif='".$tarif_id."'";
|
||||
$sql .= " WHERE prefix = '".$prefix."';";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'telephonie_prefix');
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->fetch($prefix);
|
||||
|
||||
if ($this->tarif_id == 0 && strlen(trim($prefix)) > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_prefix";
|
||||
$sql .= "(prefix, fk_tarif)";
|
||||
$sql .= " VALUES ('".$prefix."','".$tarif_id."');";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'telephonie_prefix');
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Fetch($prefix)
|
||||
{
|
||||
$this->tarif_id = 0;
|
||||
|
||||
$sql = "SELECT fk_tarif FROM ".MAIN_DB_PREFIX."telephonie_prefix";
|
||||
$sql .= " WHERE prefix = '".$prefix."';";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
|
||||
if ( $resql )
|
||||
{
|
||||
if ($row = $this->db->fetch_row($resql) )
|
||||
{
|
||||
$this->tarif_id = $row[0];
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user