';
}
@@ -336,19 +340,21 @@ switch ($mode) {
$content['rows'] = $OUT;
// Remeber total amount
- $content['total'] = translateComma($totalPoints);
+ $content['total_points'] = $totalPoints;
// Load final template
loadTemplate('member_transfer_list', false, $content);
break;
case 'list_all': // List all transactions
- // We fill a temporary table with data from both tables. This is much easier
- // to code and unstand by you as sub-SELECT queries. I know this is not the
- // fastest way but it shall be fine for now.
- //
- // First of all create the temporary table
- $result = SQL_QUERY("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_transfers_tmp` (
+ /*
+ * Fill a temporary table with data from both tables. This is much
+ * easier to code and unstandable by you as sub-SELECT queries. I know
+ * this is not the fastest way but it shall be fine for now.
+ */
+
+ // First of all create the per-user temporary table
+ $result = SQL_QUERY_ESC("CREATE TEMPORARY TABLE `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (
`trans_id` VARCHAR(12) NOT NULL DEFAULT '',
`party_userid` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
@@ -356,7 +362,7 @@ switch ($mode) {
`time_trans` VARCHAR(10) NOT NULL DEFAULT 0,
`trans_type` ENUM('IN','OUT') NOT NULL DEFAULT 'IN',
KEY (`party_userid`)
-) TYPE=HEAP", __FILE__, __LINE__);
+) TYPE = HEAP COMMENT = 'Temporary transfer table'", array(getMemberId()), __FILE__, __LINE__);
// Let's begin with the incoming list
$result = SQL_QUERY_ESC("SELECT `trans_id`, `from_userid`, `points`, `reason`, `time_trans` FROM `{?_MYSQL_PREFIX?}_user_transfers_in` WHERE `userid`=%s ORDER BY `id` ASC LIMIT {?transfer_max?}",
@@ -364,7 +370,7 @@ KEY (`party_userid`)
while ($DATA = SQL_FETCHROW($result)) {
$DATA[] = 'IN';
$DATA = implode("','", $DATA);
- $res_temp = SQL_QUERY("INSERT INTO `{?_MYSQL_PREFIX?}_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", __FILE__, __LINE__);
+ $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
@@ -376,27 +382,28 @@ KEY (`party_userid`)
while ($DATA = SQL_FETCHROW($result)) {
$DATA[] = 'OUT';
$DATA = implode("','", $DATA);
- $res_temp = SQL_QUERY("INSERT INTO `{?_MYSQL_PREFIX?}_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", __FILE__, __LINE__);
+ $res_temp = SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_%s_transfers_tmp` (`trans_id`, `party_userid`, `points`, `reason`, `time_trans`, `trans_type`) VALUES ('" . $DATA . "')", array(getMemberId()), __FILE__, __LINE__);
} // END - while
// Free memory
SQL_FREERESULT($result);
+ // Search for entries
+ $result = SQL_QUERY_ESC("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_%s_transfers_tmp` ORDER BY `time_trans` DESC",
+ array(getMemberId()), __FILE__, __LINE__);
+
$total = '0';
if (!SQL_HASZERONUMS($result)) {
- // Search for entries
- $result = SQL_QUERY("SELECT `party_userid`, `trans_id`, `points`, `reason`, `time_trans`, `trans_type` FROM `{?_MYSQL_PREFIX?}_transfers_tmp` ORDER BY `time_trans` DESC",
- __FILE__, __LINE__);
-
// Output rows
$OUT = '';
while ($content = SQL_FETCHARRAY($result)) {
- // Rewrite points
- if ($content['trans_type'] == 'OUT') $content['points'] = '-'.$content['points']."";
+ // Rewrite points if OUT
+ if ($content['trans_type'] == 'OUT') {
+ $content['points'] = $content['points'] * -1;
+ } // END - if
// Prepare content for template
$content['time'] = generateDateTime($content['time_trans'], 3);
- $content['points'] = translateComma($content['points']);
// Load row template
$OUT .= loadTemplate('member_transfer_row', true, $content);
@@ -404,23 +411,23 @@ KEY (`party_userid`)
// Add points and switch color
$total += $content['points'];
} // END - while
-
- // Free memory
- SQL_FREERESULT($result);
} else {
// Nothing for in and out
$OUT = '