X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_sponsor.php;h=713c1219fdf915dd56ef8dbeb4f250995db00f75;hb=8d0ed5ed9a9ca0e07b9582f2311b44bdcc5a95ea;hp=fa00a1cc30ee6040504f436788aa2a00a66a0c04;hpb=41f83d889de7bb9290e5bfb1d9fa1a0bcd16897a;p=mailer.git
diff --git a/inc/modules/admin/what-list_sponsor.php b/inc/modules/admin/what-list_sponsor.php
index fa00a1cc30..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)) $DATA[$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($_GET['id'])), __FILE__, __LINE__);
- list($orders) = SQL_FETCHROW($result_orders);
- SQL_FREERESULT($result_orders);
- if (empty($orders)) $orders = 0;
+ foreach ($content as $k => $v) {
+ if ((empty($v)) && ($v != 0)) $content[$k] = '---';
+ } // END - foreach
// Prepare all data for the template
- // Sponsor's ID
- define('__SPONSOR_ID' , $_GET['id']);
- // Company's data
- define('__SPONSOR_COMPANY' , $DATA['company']);
- define('__SPONSOR_POSITION' , $DATA['position']);
- define('__SPONSOR_TAX_IDENT' , $DATA['tax_ident']);
- // Personal data
- define('__SPONSOR_GENDER' , TRANSLATE_GENDER($DATA['gender']));
- define('__SPONSOR_SURNAME' , $DATA['surname']);
- define('__SPONSOR_FAMILY' , $DATA['family']);
- define('__SPONSOR_STREET1' , $DATA['street_nr1']);
- define('__SPONSOR_STREET2' , $DATA['street_nr2']);
- define('__SPONSOR_ZIP' , $DATA['zip']);
- define('__SPONSOR_CITY' , $DATA['city']);
- define('__SPONSOR_COUNTRY' , $DATA['country']);
+ // Sponsor's id
+ $content['id'] = getRequestParameter('id');
// Contact data
- define('__SPONSOR_PHONE' , $DATA['phone']);
- define('__SPONSOR_FAX' , $DATA['fax']);
- define('__SPONSOR_CELL' , $DATA['cell']);
- define('__SPONSOR_EMAIL' , "mailto:".$DATA['email']);
- define('__SPONSOR_EMAIL_VALUE', $DATA['email']);
- define('__SPONSOR_URL' , DEREFERER($DATA['url']));
- // Timestamps
- define('__SPONSOR_CREATED' , MAKE_DATETIME($DATA['sponsor_created'], "2"));
- define('__SPONSOR_LAST_ONLINE', MAKE_DATETIME($DATA['last_online'], "2"));
- define('__SPONSOR_LAST_CHANGE', MAKE_DATETIME($DATA['last_change'], "2"));
- // Sponsor points
- define('__SPONSOR_AMOUNT' , TRANSLATE_COMMA($DATA['points_amount']));
- define('__SPONSOR_USED' , TRANSLATE_COMMA($DATA['points_used']));
- // Warning because low points
- define('__SPONSOR_REC_WARNING', TRANSLATE_YESNO($DATA['receive_warnings']));
- define('__SPONSOR_INTERVAL' , CREATE_FANCY_TIME($DATA['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
- define('__SPONSOR_ORDERS' , $orders);
- // Other data
- define('__SPONSOR_STATUS' , SPONSOR_TRANSLATE_STATUS($DATA['status']));
- define('__SPONSOR_REFID' , $DATA['refid']);
- define('__SPONSOR_REMOTE_ADR' , $DATA['remote_addr']);
- define('__SPONSOR_REFS' , $DATA['ref_count']);
+ $content['orders'] = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsor_id', true);
// Load template
- LOAD_TEMPLATE("admin_list_sponsor_details");
+ loadTemplate('admin_list_sponsor_details', false, $content);
} else {
// Sponsor not found
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_404'), $_GET['id']));
+ displayMessage(getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id'))));
}
-} elseif (!empty($_GET['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($_GET['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);
// 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, remote_addr, ref_count
-FROM `{!_MYSQL_PREFIX!}_sponsor_data`
-WHERE refid='%s' ORDER BY `id`",
- array(bigintval($_GET['rid'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT
+ `id`, `gender`, `surname`, `family`, `email`, `status`,
+ 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`
+WHERE
+ `refid`='%s'
+ORDER BY
+ `id` ASC",
+ 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
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_REFS_404'), "".bigintval($_GET['rid']).""));
+ displayMessage(getMaskedMessage('ADMIN_SPONSOR_REFS_404', '' . bigintval(getRequestParameter('refid')) . ''));
}
} else {
// Sponsor not found
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_SPONSOR_404'), bigintval($_GET['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
-FROM `{!_MYSQL_PREFIX!}_sponsor_data` ORDER BY `id`", __FILE__, __LINE__);
- if (SQL_NUMROWS($result_main) > 0) {
- // At least one sponsor found!
- $OUT = ""; $SW = 2;
- while (list($id, $gender, $sname, $fname, $email, $status, $created, $last, $amount, $used, $ip) = SQL_FETCHROW($result_main)) {
+ $result_main = SQL_QUERY("SELECT
+ `id`, `gender`, `surname`, `family`, `email`, `status`,
+ 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_HASZERONUMS($result_main)) {
+ // At least one sponsor found
+ $OUT = '';
+ while ($content = SQL_FETCHARRAY($result_main)) {
// Transfer data to array
- $content = array(
- 'id' => $id,
- 'sw' => $SW,
- 'gender' => TRANSLATE_GENDER($gender),
- 'sname' => $sname,
- 'fname' => $fname,
- 'email' => "mailto:".$email,
- 'status' => SPONSOR_TRANSLATE_STATUS($status),
- 'created' => MAKE_DATETIME($created, "2"),
- 'last' => MAKE_DATETIME($last, "2"),
- 'points' => TRANSLATE_COMMA($amount - $used),
- 'ip' => $ip,
- );
+ $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 .= LOAD_TEMPLATE("admin_list_sponsor_row", true, $content);
- $SW = 3 - $SW;
- }
+ $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
+ } // END - while
// Free memory
SQL_FREERESULT($result_main);
- define('__SPONSOR_ROWS', $OUT);
// Load final template
- LOAD_TEMPLATE("admin_list_sponsor");
+ loadTemplate('admin_list_sponsor', false, $OUT);
} else {
// No sponsors registered so far
- LOAD_TEMPLATE("admin_settings_saved", false, getMessage('ADMIN_SPONSOR_NONE_REGISTERED'));
+ displayMessage('{--ADMIN_SPONSOR_NONE_REGISTERED--}');
}
}
-//
+// [EOF]
?>