From bc7861852667396cd0477a57d4d7216f24288c3a Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 27 Jul 2005 15:31:34 +0000 Subject: [PATCH] Ajout modif des tarifs effectives --- .../tools/correction-tarifs-clients.php | 62 ++++++++++++++++++- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/htdocs/telephonie/script/tools/correction-tarifs-clients.php b/htdocs/telephonie/script/tools/correction-tarifs-clients.php index 53ed744f80e..31039ea3191 100644 --- a/htdocs/telephonie/script/tools/correction-tarifs-clients.php +++ b/htdocs/telephonie/script/tools/correction-tarifs-clients.php @@ -87,6 +87,9 @@ foreach ($tarifs as $tarif) if ($num == 0) { array_push($corrections[$tarif], $client); + + correct_tarif($db, $client, $tarif); + } $db->free($resql); @@ -102,9 +105,64 @@ foreach ($tarifs as $tarif) foreach ($tarifs as $tarif) { print "Tarif $tarif : ".sizeof($corrections[$tarif])."\n"; - - var_dump($corrections[$tarif]); } +function correct_tarif($db, $client, $tarif) +{ + $error = 0; + + $sql = "SELECT temporel, fixe FROM ".MAIN_DB_PREFIX."telephonie_tarif_client"; + $sql .= " WHERE fk_tarif = 1289"; + $sql .= " AND fk_client = $client"; + + $resql = $db->query($sql); + + if ($resql) + { + $row = $db->fetch_row($resql); + + $temporel = $row[0]; + $fixe = $row[1]; + } + else + { + print $db->error(); + $error++; + } + + $db->begin(); + + $sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; + $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; + $sql .= " (".$tarif.",".$client.",'".$temporel."','".$fixe."',1)"; + + if (! $db->query($sql) ) + { + $error++; + print $db->error(); + } + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; + $sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; + $sql .= " (".$tarif.",".$client.",'".$temporel."','".$fixe."',1,now())"; + + if (! $db->query($sql) ) + { + $error++; + print $db->error(); + } + + if ( $error == 0 ) + { + $db->commit(); + } + else + { + $db->rollback(); + print $db->error(); + } +} + + $db->close(); ?>