2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/25/2005 *
4 * =================== Last change: 05/19/2008 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_sponsor.php *
8 * -------------------------------------------------------------------- *
9 * Short description : List all sponsors and their details *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Sponsoren und deren Details auflisten *
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')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 if (isGetRequestElementSet('id')) {
47 // Show detailed informations to a sponsor
48 $result = sqlQueryEscaped("SELECT
49 `company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
50 `phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
52 UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
53 UNIX_TIMESTAMP(`last_online`) AS `last_online`,
54 UNIX_TIMESTAMP(`last_change`) AS `last_change`,
56 `points_amount`, `points_used`, `remote_addr`, `warning_interval`, `refid`, `ref_count`
58 `{?_MYSQL_PREFIX?}_sponsor_data`
61 array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
63 if (sqlNumRows($result) == 1) {
64 // Load sponsor details
65 $content = sqlFetchArray($result);
67 // Check if an entry is empty
68 foreach ($content as $k => $v) {
69 if ((empty($v)) && ($v != 0)) $content[$k] = '---';
72 // Prepare all data for the template
74 $content['id'] = getRequestElement('id');
76 $content['email_link'] = generateEmailLink($content['email'], 'sponsor_data');
78 $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
79 $content['last_online'] = generateDateTime($content['last_online'], 2);
80 $content['last_change'] = generateDateTime($content['last_change'], 2);
82 $content['orders'] = countSumTotalData(bigintval(getRequestElement('id')), 'sponsor_orders', 'id', 'sponsor_id', TRUE);
85 loadTemplate('admin_list_sponsor_details', FALSE, $content);
88 displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('id')) . '%}');
92 sqlFreeResult($result);
93 } elseif (isGetRequestElementSet('refid')) {
95 $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
96 array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
97 if (sqlNumRows($result) == 1) {
99 sqlFreeResult($result);
101 // Sponsor found so let's list all his referrals
102 $result = sqlQueryEscaped("SELECT
109 UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
110 UNIX_TIMESTAMP(`last_online`) AS `last_online`,
116 `{?_MYSQL_PREFIX?}_sponsor_data`
121 array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
123 if (!ifSqlHasZeroNums($result)) {
126 sqlFreeResult($result);
128 // No refs made so far
129 displayMessage(getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&what=list_sponsor&id=' . bigintval(getRequestElement('refid')) . '%}">' . bigintval(getRequestElement('refid')) . '</a>'));
133 displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('refid')) . '%}');
137 $result_main = sqlQuery("SELECT
138 `id`, `gender`, `surname`, `family`, `email`, `status`,
139 UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
140 UNIX_TIMESTAMP(`last_online`) AS `last_online`,
141 `points_amount`, `points_used`,
142 (`points_amount` + `points_used`) AS `points`,
145 `{?_MYSQL_PREFIX?}_sponsor_data`
147 `id` ASC", __FILE__, __LINE__);
149 if (!ifSqlHasZeroNums($result_main)) {
150 // At least one sponsor found
152 while ($content = sqlFetchArray($result_main)) {
153 // Transfer data to array
154 $content['email'] = generateEmailLink($content['email'], 'sponsor_data');
155 $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
156 $content['last_online'] = generateDateTime($content['last_online'], 2);
159 $OUT .= loadTemplate('admin_list_sponsor_row', TRUE, $content);
163 sqlFreeResult($result_main);
165 // Load final template
166 loadTemplate('admin_list_sponsor', FALSE, $OUT);
168 // No sponsors registered so far
169 displayMessage('{--ADMIN_SPONSOR_NONE_REGISTERED--}');