+// Log the transfer
+function WERNIS_LOG_TRANSFER ($wdsId, $amount, $type = 'FAILED', $message = '', $status = '') {
+ // Register this wernis movement
+ SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`,`wernis_account`,`wernis_amount`,`wernis_timestamp`,`wernis_type`,`wernis_api_message`,`wernis_api_status`) VALUES (%d, %d, %d, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
+ array(getMemberId(), bigintval($wdsId), bigintval($amount), $type, $message, $status), __FUNCTION__, __LINE__);
+}
+
+// Take fees and factor
+function WERNIS_TAKE_FEE ($points, $mode) {
+ // Payout or withdraw are allowed modes!
+ //* DEBUG: */ debugOutput('mode='.$mode.',points='.$points);
+ if (!in_array($mode, array('payout', 'withdraw'))) {
+ // Log error and abort
+ logDebugMessage(__FUNCTION__, __LINE__, "userid={getMemberId()},mode={$mode},points={$points}");
+ return false;
+ } // END - if
+
+ // Is there a percentage or fixed fee?
+ if (getConfig('wernis_'.$mode.'_fee_percent') > 0) {
+ // Percentage fee
+ $points -= $points * getConfig('wernis_'.$mode.'_fee_percent') / 100;
+ } elseif (getConfig('wernis_'.$mode.'_fee_fix') > 0) {
+ // Fixed fee
+ $points -= getConfig('wernis_'.$mode.'_fee_fix');
+ }
+
+ // Divide/multiply the factor
+ if ($mode == 'payout') {
+ // Divide for payout
+ $points = $points / getConfig('wernis_payout_factor');
+ } else {
+ // Multiply for withdraw
+ $points = $points * getConfig('wernis_withdraw_factor');
+ }
+
+ // Return value
+ //* DEBUG: */ debugOutput('mode='.$mode.',points='.$points);
+ return $points;
+}
+
+// Add withdraw fees and factor
+function WERNIS_ADD_WITHDRAW_FEE ($points) {
+ // Is there a percentage or fixed fee?
+ if (getConfig('wernis_withdraw_fee_percent') > 0) {
+ // Percentage fee
+ $points += $points * getConfig('wernis_withdraw_fee_percent') / 100;
+ } elseif (getConfig('wernis_withdraw_fee_fix') > 0) {
+ // Fixed fee
+ $points += getConfig('wernis_withdraw_fee_fix');
+ }
+
+ // Return value
+ return $points;
+}
+
+// [EOF]