]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-email_details.php
More rewrites/templates swapped out:
[mailer.git] / inc / modules / admin / what-email_details.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
4  * ===================                          Last change: 10/29/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-email_details.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : See all email details of ordered mails           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Details einer gebuchten Mail ansehen        *
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  *           Moded What-email_details.php   / also Editet !             *
40  * Auf langsammen Servern (wie mein z.B Dauert das Laden)               *
41  * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die       *
42  * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN )          *
43  * oder noch als TEMP gespecihert sind                                  *
44  * der rest der schon als SEND sich melden darf wird per                *
45  * what-email_archiv .php aufgerufen                                    *
46  * beste gruesse Robert Niedziela / www.personal-webserver.de           *
47  * oder auch www.mc-p.org                                               *
48  ************************************************************************/
49
50 // Some security stuff...
51 if ((!defined('__SECURITY')) || (!isAdmin())) {
52         die();
53 }
54
55 // Add description as navigation point
56 addMenuDescription('admin', __FILE__);
57
58 // Normal mails ordered by your members
59 $sql = "SELECT
60         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
61 FROM
62         `{?_MYSQL_PREFIX?}_pool`
63 WHERE
64         `data_type` IN('ADMIN','TEMP','NEW','ACTIVE')
65 ORDER BY
66         `timestamp` DESC";
67
68 $WHO = getMessage('_ALL');
69 $SQL2 = '';
70
71 if (isGetRequestParameterSet(('mid'))) {
72         // Only a specific mail shall be displayed
73         $sql = "SELECT
74         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
75 FROM
76         `{?_MYSQL_PREFIX?}_pool`
77 WHERE
78         `id`='".bigintval(getRequestParameter('mid'))."'
79 LIMIT 1";
80         $WHO = getMessage('MAIL_ID') . ': ' . getRequestParameter('mid');
81 } elseif (isGetRequestParameterSet('userid')) {
82         // All mails by a specific member shall be displayed
83         $sql = "SELECT
84         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
85 FROM
86         `{?_MYSQL_PREFIX?}_pool`
87 WHERE
88         `sender`='".bigintval(getRequestParameter('userid'))."'
89 ORDER BY
90         `timestamp` DESC";
91         $WHO = getMessage('USER_ID') . ': ' . getRequestParameter('userid');
92 }
93
94 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
95         // Check for maximum pages
96         $result_bonus = SQL_QUERY("SELECT
97         `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`
98         (`mails_sent` - `clicks`) AS `unconfirmed`
99 FROM
100         `{?_MYSQL_PREFIX?}_bonus`
101 WHERE
102         `is_notify`='N'
103 ORDER BY
104         `timestamp` DESC", __FILE__, __LINE__);
105 }
106
107 // Check for maximum pages
108 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
109
110 // Set offset an current page to default values
111 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page', 1);
112
113 if (!isGetRequestParameterSet('offset')) {
114         if (isConfigEntrySet('mails_page')) {
115                 // Set config entry
116                 setGetRequestParameter('offset', getConfig('mails_page'));
117         } else {
118                 // Set default one
119                 setGetRequestParameter('offset', 10);
120         }
121 } // END - if
122
123 // Add limitation to SQL string
124 if (!isGetRequestParameterSet(('mid'))) {
125         // Create limitation line
126         $add = ' LIMIT ' . (bigintval(getRequestParameter('offset')) * bigintval(getRequestParameter('page')) - bigintval(getRequestParameter('offset'))) . ', ' . bigintval(getRequestParameter('offset'));
127
128         // For normal mails
129         $sql .= $add;
130
131         // For bonus mails
132         if (!empty($SQL2)) $SQL2 .= $add;
133 } // END - if
134
135 // Run SQL query for normal mails
136 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
137 if ((!empty($SQL2)) && ($WHO == getMessage('_ALL'))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
138
139 // Calculate pages
140 $PAGES = '0';
141 if (isConfigEntrySet('mails_page')) {
142         $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
143 } // END - if
144
145 // Free result
146 SQL_FREERESULT($result_normal);
147
148 $MAIL = false;
149 if (SQL_NUMROWS($result_list) > 0) {
150         // Init rows
151         $OUT = '';
152
153         // Walk through all entries
154         while ($content = SQL_FETCHARRAY($result_list)) {
155                 // Unconfirmed mails and sent mails
156                 $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
157                         array(bigintval($content['id'])), __FILE__, __LINE__);
158
159                 // Load and merge data
160                 $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
161
162                 // Free result
163                 SQL_FREERESULT($result_uncon);
164
165                 // Unconfirmed mails
166                 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'mid');
167
168                 // Prepare content
169                 $content['timestamp']   = generateDateTime($content['timestamp'], 0);
170
171                 // Load row template
172                 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
173         } // END - while
174
175         // Free memory
176         SQL_FREERESULT($result_list);
177
178         // Add navigation (with change box and colspan=3)
179         $content['nav'] = '';
180         if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
181
182         // Prepare content
183         $content['rows'] = $OUT;
184         $content['who'] = $WHO;
185
186         // Mail orders are in pool so we can display them
187         loadTemplate('admin_list_emails', false, $content);
188
189         $MAIL = true;
190         if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
191                 // Check only if bonus extension is active
192                 if (SQL_NUMROWS($result_bonus) > 0) outputHtml('<br /><br />');
193         } // END - if
194 }
195
196 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
197         // Load bonus mails only when extension is active
198         if (SQL_NUMROWS($result_bonus) > 0) {
199                 // Calculate pages
200                 $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
201
202                 // List emails
203                 $OUT = '';
204                 while ($content = SQL_FETCHARRAY($result_bonus)) {
205                         // Add link to list_unconfirmed what-file
206                         $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']);
207
208                         // Prepare content
209                         $content['timestamp']   = generateDateTime($content['timestamp'], 0);
210
211                         // Load row template
212                         $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
213                 } // END - while
214
215                 // Add navigation (without change box but with colspan=3)
216                 $content['nav'] = '';
217                 if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
218
219                 // Prepare content
220                 $content['rows'] = $OUT;
221
222                 // Load main template
223                 loadTemplate('admin_list_bonus_emails', false, $content);
224                 $MAIL = true;
225         } // END - if
226 } // END - if
227
228 if ($MAIL === false) {
229         // No mail orders fond
230         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));
231 } // END - if
232
233 // [EOF]
234 ?>