]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-list_sponsor.php
A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / modules / admin / what-list_sponsor.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 04/25/2005 *
4  * ===================                          Last change: 05/19/2008 *
5  *                                                                      *
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  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (isGetRequestParameterSet('id')) {
49         // Show detailed informations to a sponsor
50         $result = SQL_QUERY_ESC("SELECT
51         `company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
52         `phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
53         `status`,
54         UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
55         UNIX_TIMESTAMP(`last_online`) AS `last_online`,
56         UNIX_TIMESTAMP(`last_change`) AS `last_change`,
57         `receive_warnings`,
58         `points_amount`, `points_used`, `remote_addr`, `warning_interval`, `refid`, `ref_count`
59 FROM
60         `{?_MYSQL_PREFIX?}_sponsor_data`
61 WHERE
62         `id`=%s LIMIT 1",
63         array(bigintval(getRequestParameter('id'))), __FILE__, __LINE__);
64
65         if (SQL_NUMROWS($result) == 1) {
66                 // Load sponsor details
67                 $content = SQL_FETCHARRAY($result);
68
69                 // Check if an entry is empty
70                 foreach ($content as $k => $v) {
71                         if ((empty($v)) && ($v != 0)) $content[$k] = '---';
72                 } // END - foreach
73
74                 // Prepare all data for the template
75                 //  Sponsor's id
76                 $content['id']              = getRequestParameter('id');
77                 //  Contact data
78                 $content['email_link']      = generateEmailLink($content['email'], 'sponsor_data');
79                 //  Timestamps
80                 $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
81                 $content['last_online']     = generateDateTime($content['last_online'], 2);
82                 $content['last_change']     = generateDateTime($content['last_change'], 2);
83                 //  Orders total
84                 $content['orders']          = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsor_id', true);
85
86                 // Load template
87                 loadTemplate('admin_list_sponsor_details', false, $content);
88         } else {
89                 // Sponsor not found
90                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id'))));
91         }
92
93         // Free result
94         SQL_FREERESULT($result);
95 } elseif (isGetRequestParameterSet('refid')) {
96         // Search for sponsor
97         $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
98                 array(bigintval(getRequestParameter('refid'))), __FILE__, __LINE__);
99         if (SQL_NUMROWS($result) == 1) {
100                 // Free memory
101                 SQL_FREERESULT($result);
102
103                 // Sponsor found so let's list all his referals
104                 $result = SQL_QUERY_ESC("SELECT
105         `id`, `gender`, `surname`, `family`, `email`, `status`,
106         UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
107         UNIX_TIMESTAMP(`last_online`) AS `last_online`,
108         `points_amount`, `points_used`,
109         `remote_addr`, `ref_count`
110 FROM
111         `{?_MYSQL_PREFIX?}_sponsor_data`
112 WHERE
113         `refid`='%s'
114 ORDER BY
115         `id` ASC",
116                 array(bigintval(getRequestParameter('refid'))), __FILE__, __LINE__);
117
118                 if (!SQL_HASZERONUMS($result)) {
119                         // List refs now
120                         // Free memory
121                         SQL_FREERESULT($result);
122                 } else {
123                         // No refs made so far
124                         loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&amp;what=list_sponsor&amp;id=' . bigintval(getRequestParameter('refid')) . '%}">' . bigintval(getRequestParameter('refid')) . '</a>'));
125                 }
126         } else {
127                 // Sponsor not found
128                 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('refid'))));
129         }
130 } else {
131         // List all sponsors
132         $result_main = SQL_QUERY("SELECT
133         `id`, `gender`, `surname`, `family`, `email`, `status`,
134         UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
135         UNIX_TIMESTAMP(`last_online`) AS `last_online`,
136         `points_amount`, `points_used`, `remote_addr`
137 FROM
138         `{?_MYSQL_PREFIX?}_sponsor_data`
139 ORDER BY
140         `id` ASC", __FILE__, __LINE__);
141
142         if (!SQL_HASZERONUMS($result_main)) {
143                 // At least one sponsor found!
144                 $OUT = '';
145                 while ($content = SQL_FETCHARRAY($result_main)) {
146                         // Transfer data to array
147                         $content['email']           = generateEmailLink($content['email'], 'sponsor_data');
148                         $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
149                         $content['last_online']     = generateDateTime($content['last_online'], 2);
150                         $content['points']          = ($content['points_amount'] - $content['points_used']);
151
152                         // Load row template
153                         $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
154                 } // END - while
155
156                 // Free memory
157                 SQL_FREERESULT($result_main);
158
159                 // Load final template
160                 loadTemplate('admin_list_sponsor', false, $OUT);
161         } else {
162                 // No sponsors registered so far
163                 loadTemplate('admin_settings_saved', false, '{--ADMIN_SPONSOR_NONE_REGISTERED--}');
164         }
165 }
166
167 // [EOF]
168 ?>