27 |
|
|
28 |
if ($_POST["action"] == 'addtarif') |
if ($_POST["action"] == 'addtarif') |
29 |
{ |
{ |
30 |
|
$error = 0; |
31 |
$saisieok = 1; |
$saisieok = 1; |
32 |
|
|
33 |
if (strlen(trim($_POST["temporel"])) == 0 OR strlen(trim($_POST["fixe"])) == 0) |
if (strlen(trim($_POST["temporel"])) == 0 OR strlen(trim($_POST["fixe"])) == 0) |
58 |
if ($saisieok) |
if ($saisieok) |
59 |
{ |
{ |
60 |
|
|
61 |
|
$db->begin(); |
62 |
|
|
63 |
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; |
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client"; |
64 |
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; |
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES "; |
65 |
$sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.")"; |
$sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.")"; |
66 |
|
|
67 |
if ( $db->query($sql) ) |
if (! $db->query($sql) ) |
68 |
|
{ |
69 |
|
$error++; |
70 |
|
} |
71 |
|
|
72 |
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log"; |
73 |
|
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES "; |
74 |
|
$sql .= " (".$_POST["tarifid"].",".$_GET["id"].",'".$temporel."','".$fixe."',".$user->id.",now())"; |
75 |
|
|
76 |
|
if (! $db->query($sql) ) |
77 |
|
{ |
78 |
|
$error++; |
79 |
|
} |
80 |
|
|
81 |
|
if ( $error == 0 ) |
82 |
{ |
{ |
83 |
|
$db->commit(); |
84 |
Header("Location: tarifs.php?id=".$_GET["id"]); |
Header("Location: tarifs.php?id=".$_GET["id"]); |
85 |
} |
} |
86 |
else |
else |
87 |
{ |
{ |
88 |
|
$db->rollback(); |
89 |
print $db->error(); |
print $db->error(); |
90 |
} |
} |
91 |
} |
} |