87 |
if ($num == 0) |
if ($num == 0) |
88 |
{ |
{ |
89 |
array_push($corrections[$tarif], $client); |
array_push($corrections[$tarif], $client); |
90 |
|
|
91 |
|
correct_tarif($db, $client, $tarif); |
92 |
|
|
93 |
} |
} |
94 |
|
|
95 |
$db->free($resql); |
$db->free($resql); |
105 |
foreach ($tarifs as $tarif) |
foreach ($tarifs as $tarif) |
106 |
{ |
{ |
107 |
print "Tarif $tarif : ".sizeof($corrections[$tarif])."\n"; |
print "Tarif $tarif : ".sizeof($corrections[$tarif])."\n"; |
108 |
|
} |
109 |
|
|
110 |
|
function correct_tarif($db, $client, $tarif) |
111 |
|
{ |
112 |
|
$error = 0; |
113 |
|
|
114 |
|
$sql = "SELECT temporel, fixe FROM ".MAIN_DB_PREFIX."telephonie_tarif_client"; |
115 |
|
$sql .= " WHERE fk_tarif = 1289"; |
116 |
|
$sql .= " AND fk_client = $client"; |
117 |
|
|
118 |
|
$resql = $db->query($sql); |
119 |
|
|
120 |
|
if ($resql) |
121 |
|
{ |
122 |
|
$row = $db->fetch_row($resql); |
123 |
|
|
124 |
var_dump($corrections[$tarif]); |
$temporel = $row[0]; |
125 |
|
$fixe = $row[1]; |
126 |
|
} |
127 |
|
else |
128 |
|
{ |
129 |
|
print $db->error(); |
130 |
|
$error++; |
131 |
|
} |
132 |
|
|
133 |
|
$db->begin(); |
134 |
|
|
135 |
|
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; |
136 |
|
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; |
137 |
|
$sql .= " (".$tarif.",".$client.",'".$temporel."','".$fixe."',1)"; |
138 |
|
|
139 |
|
if (! $db->query($sql) ) |
140 |
|
{ |
141 |
|
$error++; |
142 |
|
print $db->error(); |
143 |
|
} |
144 |
|
|
145 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; |
146 |
|
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; |
147 |
|
$sql .= " (".$tarif.",".$client.",'".$temporel."','".$fixe."',1,now())"; |
148 |
|
|
149 |
|
if (! $db->query($sql) ) |
150 |
|
{ |
151 |
|
$error++; |
152 |
|
print $db->error(); |
153 |
|
} |
154 |
|
|
155 |
|
if ( $error == 0 ) |
156 |
|
{ |
157 |
|
$db->commit(); |
158 |
|
} |
159 |
|
else |
160 |
|
{ |
161 |
|
$db->rollback(); |
162 |
|
print $db->error(); |
163 |
|
} |
164 |
} |
} |
165 |
|
|
166 |
|
|
167 |
$db->close(); |
$db->close(); |
168 |
?> |
?> |