+ $content['refid'] = bigintval(getConfig('wernis_refid'));
+ $content['wds66_id'] = 0;
+
+ // Get WDS66 id
+ $result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+
+ // Are there some entries?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch ID
+ list($content['wds66_id']) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+
+ // Is there an ID?
+ if ((!empty($content['wds66_id'])) && (!isset($_GET['mode']))) {
+ // Then use an other "mode"
+ $_GET['mode'] = "list";
+
+ // And load all rows!
+ $result = SQL_QUERY_ESC("SELECT `id`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type` FROM `{!_MYSQL_PREFIX!}_user_wernis` WHERE `userid` = %s ORDER BY `wernis_timestamp` DESC",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+
+ // Load all rows
+ $content['rows'] = ""; $SW = 2;
+ while ($data = SQL_FETCHARRAY($result)) {
+ // Prepare data for output
+ $rowContent = array(
+ 'stamp' => MAKE_DATETIME($data['wernis_timestamp'], "2"),
+ 'points' => TRANSLATE_COMMA($data['wernis_amount']),
+ 'acc' => bigintval($data['wernis_account']),
+ 'status' => WERNIS_TRANSFER_STATUS($data['wernis_type']),
+ 'raw_type' => strtolower($data['wernis_type']),
+ 'sw' => $SW,
+ );
+
+ // Load row template
+ $content['rows'] .= LOAD_TEMPLATE("member_wernis_mode_list_row", true, $rowContent);
+ $SW = 3 - $SW;
+ }
+
+ // Free result
+ SQL_FREERESULT($result);
+ } else {
+ // Default links are not active!
+ $content['payout_link'] = "<em>".WERNIS_MEMBER_PAYOUT_DISABLED."</em>";
+ $content['withdraw_link'] = "<em>".WERNIS_MEMBER_WITHDRAW_DISABLED."</em>";
+
+ // Is the payout mode active?
+ if (getConfig('wernis_payout_active') == "Y") {
+ // Add link
+ $content['payout_link'] = "<a class=\"menu_blur\" style=\"height: 40px\" href=\"{!URL!}/modules.php?module=login&what=wernis&mode=payout\"><div style=\"padding-top: 10px\">".MEMBER_WERNIS_MODE_PAYOUT."</div></a>";
+ } // END - if
+
+ // Is the withdraw mode active?
+ if (getConfig('wernis_withdraw_active') == "Y") {
+ // Add link
+ $content['withdraw_link'] = "<a class=\"menu_blur\" style=\"height: 40px\" href=\"{!URL!}/modules.php?module=login&what=wernis&mode=withdraw\"><div style=\"padding-top: 10px\">".MEMBER_WERNIS_MODE_WITHDRAW."</div></a>";
+ } // END - if
+
+ // Mode chooser! ;-)
+ $_GET['mode'] = "choose";
+ }
+} elseif (($_GET['mode'] == "payout") && (getConfig('wernis_payout_active') == "Y")) {
+ // Get total points and check if the user can request a payout
+ $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+
+ // Remove the registration fee
+ $points = $points - getConfig('points_register');
+
+ // Is there a percentage or fixed fee?
+ $points = WERNIS_TAKE_FEE($points, "payout");
+
+ // Is this enougth for a payout?
+ if ($points < getConfig('wernis_min_payout')) {
+ // No, then abort here
+ LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_MIN_PAYOUT, TRANSLATE_COMMA(getConfig('wernis_min_payout'))));
+ return;
+ } // END - if
+
+ // No dots here...
+ $points = explode(".", $points);
+ $points = bigintval($points[0]);
+
+ // Add points to content array
+ $content['points'] = TRANSLATE_COMMA($points);
+ $content['min_points'] = TRANSLATE_COMMA(getConfig('wernis_min_payout'));
+
+ // Add fees to array
+ WERNIS_ADD_FEES_TO_ARRAY($content);
+
+ // Get WDS66 id
+ $content['wds66_id'] = "";
+ $result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+
+ // Are there some entries?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch ID
+ list($content['wds66_id']) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+} elseif (($_GET['mode'] == "withdraw") && (getConfig('wernis_withdraw_active') == "Y")) {
+ // Get total points for just displaying them
+ $points = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
+
+ // Prepare data for the template
+ $content['points'] = TRANSLATE_COMMA($points);
+ $content['min_points'] = TRANSLATE_COMMA(getConfig('wernis_min_withdraw'));
+ $content['wds66_id'] = "";
+
+ // Add fees to array
+ WERNIS_ADD_FEES_TO_ARRAY($content);
+
+ // Get WDS66 id
+ $result = SQL_QUERY_ESC("SELECT wernis_userid FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
+ array($GLOBALS['userid']), __FILE__, __LINE__);
+
+ // Are there some entries?
+ if (SQL_NUMROWS($result) == 1) {
+ // Fetch ID
+ list($content['wds66_id']) = SQL_FETCHROW($result);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+} else {
+ // Invalid mode!
+ LOAD_TEMPLATE("admin_settings_saved", false, sprintf(WERNIS_MEMBER_MODE_INVALID, SQL_ESCAPE($_GET['mode'])));
+ return;