X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_sponsor.php;h=43cf12da70440c3b36c3a24e02eeb6bc62eacf84;hp=717664472904b6529c764ca9c722b57b0f3f7b49;hb=6914ebaaae909093df86d010e4c754a43d1a1aed;hpb=222b9cab2b3fb3c8fb01ff524f5d1d7cfbcb61e7 diff --git a/inc/modules/admin/what-list_sponsor.php b/inc/modules/admin/what-list_sponsor.php index 7176644729..43cf12da70 100644 --- a/inc/modules/admin/what-list_sponsor.php +++ b/inc/modules/admin/what-list_sponsor.php @@ -47,32 +47,41 @@ addMenuDescription('admin', __FILE__); if (isGetRequestParameterSet('id')) { // Show detailed informations to a sponsor - $result = SQL_QUERY_ESC("SELECT company, position, gender, surname, family, street_nr1, street_nr2, zip, city, country, phone, fax, cell, email, url, tax_ident, status, sponsor_created, last_online, last_change, receive_warnings, points_amount, points_used, remote_addr, warning_interval, refid, ref_count -FROM `{?_MYSQL_PREFIX?}_sponsor_data` -WHERE `id`='%s' LIMIT 1", + $result = SQL_QUERY_ESC("SELECT + `company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`, + `phone`, `fax`, `cell`, `email`, `url`, `tax_ident`, + `status`, + UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`, + UNIX_TIMESTAMP(`last_online`) AS `last_online`, + UNIX_TIMESTAMP(`last_change`) AS `last_change`, + `receive_warnings`, + `points_amount`, `points_used`, `remote_addr`, `warning_interval`, `refid`, `ref_count` +FROM + `{?_MYSQL_PREFIX?}_sponsor_data` +WHERE + `id`=%s LIMIT 1", array(bigintval(getRequestParameter('id'))), __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Load sponsor details $content = SQL_FETCHARRAY($result); - SQL_FREERESULT($result); // Check if an entry is empty foreach ($content as $k => $v) { - if (empty($v)) $content[$k] = '---'; + if ((empty($v)) && ($v != 0)) $content[$k] = '---'; } // END - foreach // Prepare all data for the template // Sponsor's id - $content['id'] = getRequestParameter('id'); + $content['id'] = getRequestParameter('id'); // Contact data - $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data'); + $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data'); // Timestamps - $content['created'] = generateDateTime($content['sponsor_created'], 2); - $content['last_online'] = generateDateTime($content['last_online'], 2); - $content['last_change'] = generateDateTime($content['last_change'], 2); + $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'] = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsorid', true); + $content['orders'] = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsor_id', true); // Load template loadTemplate('admin_list_sponsor_details', false, $content); @@ -80,10 +89,13 @@ WHERE `id`='%s' LIMIT 1", // Sponsor not found loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id')))); } -} elseif (isGetRequestParameterSet('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(getRequestParameter('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); @@ -91,7 +103,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` @@ -99,53 +113,45 @@ WHERE `refid`='%s' ORDER BY `id` ASC", - array(bigintval(getRequestParameter('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, getMaskedMessage('ADMIN_SPONSOR_REFS_404', '' . bigintval(getRequestParameter('rid')) . '')); + loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_REFS_404', '' . bigintval(getRequestParameter('refid')) . '')); } } else { // Sponsor not found - loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('rid')))); + loadTemplate('admin_settings_saved', false, 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`, `remote_addr` FROM `{?_MYSQL_PREFIX?}_sponsor_data` ORDER BY `id` ASC", __FILE__, __LINE__); - if (SQL_NUMROWS($result_main) > 0) { + if (!SQL_HASZERONUMS($result_main)) { // At least one sponsor found! - $OUT = ''; $SW = 2; + $OUT = ''; while ($content = SQL_FETCHARRAY($result_main)) { // Transfer data to array - $content = array( - 'id' => $content['id'], - 'sw' => $SW, - 'gender' => $content['gender'], - 'surname' => $content['surname'], - 'family' => $content['family'], - 'email' => generateEmailLink($content['email'], 'sponsor_data'), - 'status' => $content['status'], - 'created' => generateDateTime($content['sponsor_created'], 2), - 'last_online' => generateDateTime($content['last_online'], 2), - 'points' => translateComma($content['points_amount'] - $content['points_used']), - 'remote_addr' => $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); + $content['points'] = ($content['points_amount'] - $content['points_used']); // Load row template $OUT .= loadTemplate('admin_list_sponsor_row', true, $content); - $SW = 3 - $SW; - } + } // END - while // Free memory SQL_FREERESULT($result_main); @@ -154,7 +160,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')); + loadTemplate('admin_settings_saved', false, '{--ADMIN_SPONSOR_NONE_REGISTERED--}'); } }