Fix for the fix
[mailer.git] / inc / modules / admin / what-email_archiv.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
4  * ===================                          Last change: 04/03/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-email_archiv .php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : See send emails details of ordered mails         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle  Mails ansehen die versand wurden           *
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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  * -------------------------------------------------------------------- *
38  * Mod-Copyright (c) 2004 by Robert Niedziela                           *
39  * www.megacomputing.de                                                 *
40  ************************************************************************/
41
42 // Some security stuff...
43 if ((!defined('__SECURITY')) || (!isAdmin())) {
44         die();
45 } // END - if
46
47 // Add description as navigation point
48 addMenuDescription('admin', __FILE__);
49
50 // Init SQL string
51 $sql = "SELECT
52         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
53 FROM
54         `{?_MYSQL_PREFIX?}_pool`
55 WHERE
56         `data_type`='SEND' OR `data_type`='DELETED'
57 ORDER BY
58         `timestamp` DESC";
59
60 // Check for maximum pages
61 $result_maximum = SQL_QUERY($sql, __FILE__, __LINE__);
62
63 // Set offset an current page to default values
64 if (!isGetRequestElementSet('page'))   setRequestGetElement('page'  , 1);
65 if (!isGetRequestElementSet('offset')) setRequestGetElement('offset', getConfig('mails_page'));
66
67 // Add limitation to SQL string
68 $sql .= " LIMIT ".(getRequestElement('offset') * getRequestElement('page') - getRequestElement('offset')) . ', ' . getRequestElement('offset');
69
70 // Run SQL query for normal mails
71 $result = SQL_QUERY($sql, __FILE__, __LINE__);
72
73 // Calculate pages
74 $pages = round(SQL_NUMROWS($result_maximum) / getConfig('mails_page') + 0.5);
75
76 // Free the result which we don't need
77 SQL_FREERESULT($result_maximum);
78
79 if (SQL_NUMROWS($result) > 0) {
80         // Mail orders are in pool so we can display them
81
82         // Add navigation table rows
83         $content['top_email_nav']    = '';
84         $content['bottom_email_nav'] = '';
85         if ($pages > 1) {
86                 $content['top_email_nav']    = addEmailNavigation($pages, getConfig('mails_page'), true , 3, true);
87                 $content['bottom_email_nav'] = addEmailNavigation($pages, getConfig('mails_page'), false, 3, true);
88         } // END - if
89
90         // List all entries
91         $OUT = ''; $SW = 2;
92         while ($pool = SQL_FETCHARRAY($result)) {
93                 // Check sent mails and clicks
94                 $result_mails = SQL_QUERY_ESC("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
95                         array(bigintval($pool['id'])), __FILE__, __LINE__);
96
97                 // Load entries
98                 $pool = merge_array($pool, SQL_FETCHARRAY($result_mails));
99
100                 // Merge result
101                 SQL_FREERESULT($result_mails);
102
103                 // Unconfirmed mails
104                 $pool['unconfirmed'] = $pool['max_rec'] - $pool['clicks'];
105                 if ($pool['unconfirmed'] > 0) {
106                         // Add link to list_unconfirmed what-file
107                         $pool['unconfirmed'] = '<strong><a href="{?URL?}/modules.php?module=admin&amp;what=list_unconfirmed&amp;mid=' . $pool['id'] . '">' . $pool['unconfirmed'] . '</a></strong>';
108                 } // END - if
109
110                 // Prepare data for the row template
111                 $content = array(
112                         'sw'          => $SW,
113                         'u_link'      => generateUserProfileLink($pool['sender']),
114                         'subject'     => $pool['subject'],
115                         'text'        => $pool['text'],
116                         'pay'         => getPaymentTitlePrice($pool['payment_id']),
117                         'cat'         => getCategory($pool['cat_id']),
118                         'sent'        => $pool['max_rec'],
119                         'ruserids'    => convertReceivers($pool['receivers']),
120                         'unconfirmed' => $pool['unconfirmed'],
121                         'type'        => translatePoolType($pool['data_type']),
122                         'target_send' => $pool['target_send'],
123                         'frametester' => generateFrametesterUrl($pool['url']),
124                         'url'         => $pool['url'],
125                         'timestamp'   => generateDateTime($pool['timestamp'], 0),
126                         'mid'         => $pool['id'],
127                 );
128
129                 // Load row template and switch colors
130                 $OUT .= loadTemplate('admin_email_archiv_row', true, $content);
131                 $SW = 3 - $SW;
132         } // END - while
133
134         // Remmber generated rows in array
135         $content['rows'] = $OUT;
136
137         // Load main template
138         loadTemplate('admin_email_archiv', false, $content);
139 } else {
140         // No mail orders fond
141         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));
142 }
143
144 // Free memory
145 SQL_FREERESULT($result);
146
147 // [EOF]
148 ?>