withdraw != payout and SQL error in wernis extension fixed
[mailer.git] / inc / modules / member / what-wernis.php
index 09dfd4a..13fb648 100644 (file)
@@ -280,19 +280,15 @@ if ((isset($_POST['ok'])) && (isset($_GET['mode']))) {
                                        }
 
                                        // Remove the points from the account
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `points_used` = `points_used` + %d WHERE userid=%d LIMIT 1",
-                                               array(bigintval($_POST['amount']), $GLOBALS['userid']), __FILE__, __LINE__);
+                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `used_points` = `used_points` + %d, `wernis_userid`=%d WHERE userid=%d LIMIT 1",
+                                               array(bigintval($_POST['amount']), bigintval($_POST['wds66_id']), $GLOBALS['userid']), __FILE__, __LINE__);
 
                                        // Register this wernis movement
                                        $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_wernis (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`) VALUES(%d, %d, %d, UNIX_TIMESTAMP(), 'OUT')",
                                                array($GLOBALS['userid'], bigintval($_POST['wds66_id']), bigintval($_POST['amount'])), __FILE__, __LINE__);
 
-                                       // Update the user data as well..
-                                       $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET `wernis_userid`=%d WHERE userid=%d LIMIT 1",
-                                               array(bigintval($_POST['wds66_id']), $GLOBALS['userid']), __FILE__, __LINE__);
-
                                        // All done!
-                                       LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_WITHDRAW_DONE);
+                                       LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_MEMBER_PAYOUT_DONE);
                                        return;
                                } elseif ((GET_WERNIS_ERROR_CODE() == "user_failed") || (GET_WERNIS_ERROR_CODE() == "own_failed") || (GET_WERNIS_ERROR_CODE() == "amount_failed") || (GET_WERNIS_ERROR_CODE() == "api_amount_failed")) {
                                        // Wrong login data