From d28dd394842f2819713e3a75b063f5f9b767b704 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 16 Apr 2007 14:13:43 +0000 Subject: [PATCH] Gestion de la copie d'une grille --- .../telephonie.tarif.grille.class.php | 44 +++++++++++++++++-- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/htdocs/telephonie/telephonie.tarif.grille.class.php b/htdocs/telephonie/telephonie.tarif.grille.class.php index 7c057bb15fc..ec5788fef2f 100644 --- a/htdocs/telephonie/telephonie.tarif.grille.class.php +++ b/htdocs/telephonie/telephonie.tarif.grille.class.php @@ -51,10 +51,11 @@ class TelephonieTarifGrille { { $this->db = $_DB; } - - function CreateGrille($user, $name, $type) - { - + /* + \brief Creation d'une nouvelle grille + */ + function CreateGrille($user, $name, $type, $copy=0) + { $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille"; $sql .= "(libelle, type_tarif)"; $sql .= " VALUES ('".addslashes($name)."','".$type."');"; @@ -70,9 +71,44 @@ class TelephonieTarifGrille { dolibarr_syslog($this->db->error()); } + if ($copy > 0 && $type == 'vente') + { + $this->CopieGrille($user,$copy); + } + return $result; } + function CopieGrille($user, $ori) + { + $sql = "SELECT fk_tarif,temporel,fixe FROM ".MAIN_DB_PREFIX."telephonie_tarif_montant"; + $sql .= " WHERE fk_tarif_desc= '".$ori."'"; + + $resql = $this->db->query($sql); + + if ($resql) + { + $i = 0; + while ($row = $this->db->fetch_row($resql) ) + { + $tarifs[$i] = $row; + $i++; + } + $this->db->free($resql); + } + else + { + dolibarr_syslog($this->db->error()); + } + + + foreach($tarifs as $tarif) + { + $this->_DBUpdateTarif($this->id, $tarif[0], $tarif[1], $tarif[2], $user); + } + + } + function Perms($user, $perms, $user_grille) {