2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 02/12/2004 *
4 * =================== Last change: 01/07/2004 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2013 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (!isMember()) {
42 redirectToIndexMemberOnlyModule();
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
48 // Continue only if the proper extension is active (admins can always continue)
49 if ((!isExtensionActive('transaction')) && (!isAdmin())) {
50 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=transaction%}');
56 'current_day' => generateDateTime(time(), '3'),
57 'next_year' => generateDateTime(mktime(0, 0, 0, 1, 1, (getCurrentYear() + 1)), '3'),
58 'transaction_holding_fee' => '0.00000'
61 // Get user's open transaction fees
62 $result = sqlQueryEscaped("SELECT
63 COUNT(`transaction_fee_receiver`) AS `transaction_receiver_count`,
64 SUM(`transaction_fee_receiver`) AS `transaction_receiver_fee`
66 `" . $GLOBALS['db_table']['translog'] . "`
68 `transaction_receiver`=%s AND
69 `transaction_fee_collected`='N' AND
70 `transaction_confirmed`='N' AND
71 `transaction_captcha_failed`='N'
79 $data = array_merge($data, sqlFetchArray($result));
82 sqlFreeResult($result);
84 // Get user's open transaction fees
85 $result = sqlQueryEscaped("SELECT
86 COUNT(`transaction_fee_sender`) AS `transaction_sender_count`,
87 SUM(`transaction_fee_sender`) AS `transaction_sender_fee`
89 `" . $GLOBALS['db_table']['translog'] . "`
91 `transaction_sender`=%s AND
92 `transaction_fee_collected`='N' AND
93 `transaction_confirmed`='N' AND
94 `transaction_captcha_failed`='N'
102 $data = array_merge($data, sqlFetchArray($result));
105 sqlFreeResult($result);
107 // Get user's saved transaction fees
108 $result = sqlQueryEscaped("SELECT
109 COUNT(`transaction_fee_receiver`) AS `transaction_receiver_saved_count`,
110 SUM(`transaction_fee_receiver`) AS `transaction_receiver_saved_fee`
112 `" . $GLOBALS['db_table']['translog'] . "`
114 `transaction_receiver`=%s AND
115 `transaction_fee_collected`='N' AND
117 `transaction_confirmed`='Y' OR
118 `transaction_captcha_failed`='Y'
123 ), __FILE__, __LINE__
127 $data = array_merge($data, sqlFetchArray($result));
130 sqlFreeResult($result);
132 // Get user's saved transaction fees
133 $result = sqlQueryEscaped("SELECT
134 COUNT(`transaction_fee_sender`) AS `transaction_sender_saved_count`,
135 SUM(`transaction_fee_sender`) AS `transaction_sender_saved_fee`
137 `" . $GLOBALS['db_table']['translog'] . "`
139 `transaction_sender`=%s AND
140 `transaction_fee_collected`='N' AND
142 `transaction_confirmed`='Y' OR
143 `transaction_captcha_failed`='Y'
148 ), __FILE__, __LINE__
152 $data = array_merge($data, sqlFetchArray($result));
155 sqlFreeResult($result);
157 // Total fees from config as it contains all transaction fees
158 $data['total_fee'] = getConfig('transaction_pot');
160 // Get total confirmed
161 $result = sqlQuery("SELECT
162 SUM(`transaction_count`) AS `total_transaction_count`
164 `" . $GLOBALS['db_table']['user'] . "`
167 LIMIT 1", __FILE__, __LINE__);
170 list($data['total_transaction_sum']) = sqlFetchRow($result);
173 sqlFreeResult($result);
176 $data['transaction_count_sum'] = getMemberData('transaction_count');
178 // Is the user's own count > 0? (This fixes a division by zero)
179 if ($data['total_transaction_sum'] > 0) {
180 // Calulcate how much the user would get if today is 01-01 (new year)
181 $data['transaction_holding_fee'] = $data['total_fee'] / $data['total_transaction_sum'] * $data['transaction_count_sum'];
184 // "Translate" all fields
185 foreach ($data as $key => $value) {
186 // What suffix has $key?
187 if (substr($key, -6, 6) == '_count') {
189 $data[$key] = translateComma($value, TRUE);
190 } elseif ((substr($key, -4, 4) == '_fee') || (substr($key, -4, 4) == '_sum')) {
192 $data[$key] = translateComma($value);
196 // Get all related config entries
197 // @TODO Make this working
198 $result = sqlGetResultFromLikeColumnsType('config', 'transaction_count_%%', 'decimal(3,1)');
201 $data['config_rows'] = ''; $SW = 1;
202 while ($row = sqlFetchArray($result)) {
205 'field' => translateField('data', $row['Field']),
206 'value' => translateComma(getConfig($row['Field'])),
210 // Load row template + switch color
211 $data['config_rows'] .= loadTemplate('member_transaction_fees_config_row', TRUE, $content);
216 sqlFreeResult($result);
219 loadTemplate('member_transaction_fees', FALSE, $data);