X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_sponsor.php;h=713c1219fdf915dd56ef8dbeb4f250995db00f75;hb=8d0ed5ed9a9ca0e07b9582f2311b44bdcc5a95ea;hp=9e4b676bb95c2a30a52768f20e513776ce3cda5e;hpb=d495bd859975d08ee459d03c9b1cd51dd9b9304d;p=mailer.git
diff --git a/inc/modules/admin/what-list_sponsor.php b/inc/modules/admin/what-list_sponsor.php
index 9e4b676bb9..713c1219fd 100644
--- a/inc/modules/admin/what-list_sponsor.php
+++ b/inc/modules/admin/what-list_sponsor.php
@@ -1,7 +1,7 @@
$v) {
- if (empty($v)) $content[$k] = '---';
- }
-
- // Check for sponsor's orders (only count)
- $result_orders = SQL_QUERY_ESC("SELECT COUNT(id) FROM `{?_MYSQL_PREFIX?}_sponsor_orders` WHERE sponsorid='%s'",
- array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
- list($orders) = SQL_FETCHROW($result_orders);
- SQL_FREERESULT($result_orders);
- if (empty($orders)) $orders = '0';
+ if ((empty($v)) && ($v != 0)) $content[$k] = '---';
+ } // END - foreach
// Prepare all data for the template
// Sponsor's id
- $content['id'] = getRequestElement('id');
- // Personal data
- $content['gender'] = translateGender($content['gender']);
+ $content['id'] = getRequestParameter('id');
// Contact data
- $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data');
- $content['url'] = generateDerefererUrl($content['url']);
- // Timestamps
- $content['created'] = generateDateTime($content['sponsor_created'], 2);
- $content['last_online'] = generateDateTime($content['last_online'], 2);
- $content['last_change'] = generateDateTime($content['last_change'], 2);
- // Sponsor points
- $content['points_amount'] = translateComma($content['points_amount']);
- $content['points_used'] = translateComma($content['points_used']);
- // Warning because low points
- $content['receive_warnings'] = translateYesNo($content['receive_warnings']);
- $content['warning_interval'] = createFancyTime($content['warning_interval']);
+ $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data');
+ // Epoche times
+ $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
+ $content['last_online'] = generateDateTime($content['last_online'], 2);
+ $content['last_change'] = generateDateTime($content['last_change'], 2);
// Orders total
- $content['orders'] = $orders;
- // Other data
- $content['status'] = sponsorTranslateUserStatus($content['status']);
+ $content['orders'] = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsor_id', true);
// Load template
loadTemplate('admin_list_sponsor_details', false, $content);
} else {
// Sponsor not found
- loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_404'), getRequestElement('id')));
+ displayMessage(getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id'))));
}
-} elseif (isGetRequestElementSet('rid')) {
+
+ // Free result
+ SQL_FREERESULT($result);
+} elseif (isGetRequestParameterSet('refid')) {
// Search for sponsor
- $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`='%s' LIMIT 1",
- array(bigintval(getRequestElement('rid'))), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('refid'))), __FILE__, __LINE__);
if (SQL_NUMROWS($result) == 1) {
// Free memory
SQL_FREERESULT($result);
@@ -108,7 +101,9 @@ WHERE `id`='%s' LIMIT 1",
// Sponsor found so let's list all his referals
$result = SQL_QUERY_ESC("SELECT
`id`, `gender`, `surname`, `family`, `email`, `status`,
- `sponsor_created`, `last_online`, `points_amount`, `points_used`,
+ UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
+ UNIX_TIMESTAMP(`last_online`) AS `last_online`,
+ `points_amount`, `points_used`,
`remote_addr`, `ref_count`
FROM
`{?_MYSQL_PREFIX?}_sponsor_data`
@@ -116,54 +111,46 @@ WHERE
`refid`='%s'
ORDER BY
`id` ASC",
- array(bigintval(getRequestElement('rid'))), __FILE__, __LINE__);
+ array(bigintval(getRequestParameter('refid'))), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) > 0) {
+ if (!SQL_HASZERONUMS($result)) {
// List refs now
// Free memory
SQL_FREERESULT($result);
} else {
// No refs made so far
- loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_REFS_404'), "".bigintval(getRequestElement('rid')).""));
+ displayMessage(getMaskedMessage('ADMIN_SPONSOR_REFS_404', '' . bigintval(getRequestParameter('refid')) . ''));
}
} else {
// Sponsor not found
- loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval(getRequestElement('rid'))));
+ displayMessage(getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('refid'))));
}
} else {
// List all sponsors
$result_main = SQL_QUERY("SELECT
`id`, `gender`, `surname`, `family`, `email`, `status`,
- `sponsor_created`, `last_online`, `points_amount`, `points_used`, `remote_addr`
+ UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
+ UNIX_TIMESTAMP(`last_online`) AS `last_online`,
+ `points_amount`, `points_used`,
+ (`points_amount` + `points_used`) AS `points`,
+ `remote_addr`
FROM
`{?_MYSQL_PREFIX?}_sponsor_data`
ORDER BY
`id` ASC", __FILE__, __LINE__);
- if (SQL_NUMROWS($result_main) > 0) {
- // At least one sponsor found!
- $OUT = ''; $SW = 2;
+ if (!SQL_HASZERONUMS($result_main)) {
+ // At least one sponsor found
+ $OUT = '';
while ($content = SQL_FETCHARRAY($result_main)) {
// Transfer data to array
- // @TODO Rewritings: surname->surname,family->family,ip->remote_addr in template
- $content = array(
- 'id' => $content['id'],
- 'sw' => $SW,
- 'gender' => translateGender($content['gender']),
- 'surname' => $content['surname'],
- 'family' => $content['family'],
- 'email' => generateEmailLink($content['email'], 'sponsor_data'),
- 'status' => sponsorTranslateUserStatus($content['status']),
- 'created' => generateDateTime($content['sponsor_created'], 2),
- 'last_online' => generateDateTime($content['last_online'], 2),
- 'points' => translateComma($content['points_amount'] - $content['points_used']),
- 'ip' => $content['remote_addr'],
- );
+ $content['email'] = generateEmailLink($content['email'], 'sponsor_data');
+ $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
+ $content['last_online'] = generateDateTime($content['last_online'], 2);
// Load row template
$OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
- $SW = 3 - $SW;
- }
+ } // END - while
// Free memory
SQL_FREERESULT($result_main);
@@ -172,7 +159,7 @@ ORDER BY
loadTemplate('admin_list_sponsor', false, $OUT);
} else {
// No sponsors registered so far
- loadTemplate('admin_settings_saved', false, getMessage('ADMIN_SPONSOR_NONE_REGISTERED'));
+ displayMessage('{--ADMIN_SPONSOR_NONE_REGISTERED--}');
}
}