Naming convention applied, encodeEntities() added
[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  * 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  * Mod-Copyright (c) 2004 by Robert Niedziela                           *
40  * www.megacomputing.de                                                 *
41  ************************************************************************/
42
43 // Some security stuff...
44 if ((!defined('__SECURITY')) || (!isAdmin())) {
45         die();
46 } // END - if
47
48 // Add description as navigation point
49 addMenuDescription('admin', __FILE__);
50
51 // Check for maximum pages
52 $result_maximum = SQL_QUERY("SELECT
53         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
54 FROM
55         `{?_MYSQL_PREFIX?}_pool`
56 WHERE
57         `data_type`='SEND' OR `data_type`='DELETED'
58 ORDER BY
59         `timestamp` DESC", __FILE__, __LINE__);
60
61 // Set offset an current page to default values
62 if (!isGetRequestParameterSet('page'))   setGetRequestParameter('page'  , 1);
63 if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', getConfig('mails_page'));
64
65 // Add limitation to SQL string
66 $sql .= ' LIMIT ' . (getRequestParameter('offset') * getRequestParameter('page') - getRequestParameter('offset')) . ', ' . getRequestParameter('offset');
67
68 // Run SQL query for normal mails
69 $result = SQL_QUERY($sql, __FILE__, __LINE__);
70
71 // Calculate pages
72 $numPages = round(SQL_NUMROWS($result_maximum) / getConfig('mails_page') + 0.5);
73
74 // Free the result which we don't need
75 SQL_FREERESULT($result_maximum);
76
77 if (SQL_NUMROWS($result) > 0) {
78         // Mail orders are in pool so we can display them
79
80         // Add navigation table rows
81         $content['top_email_nav']    = addEmailNavigation($numPages, getConfig('mails_page'), true , 3, true);
82         $content['bottom_email_nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
83
84         // List all entries
85         $OUT = ''; $SW = 2;
86         while ($pool = SQL_FETCHARRAY($result)) {
87                 // Check sent mails and clicks
88                 $result_mails = SQL_QUERY_ESC("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
89                         array(bigintval($pool['id'])), __FILE__, __LINE__);
90
91                 // Load entries
92                 $pool = merge_array($pool, SQL_FETCHARRAY($result_mails));
93
94                 // Merge result
95                 SQL_FREERESULT($result_mails);
96
97                 // Unconfirmed mails
98                 $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'],  ($pool['max_rec'] - $pool['clicks']), 'mid');
99
100                 // Prepare data for the row template
101                 $content['sw'] = $SW;
102                 $content['timestamp'] = generateDateTime($pool['timestamp'], 0);
103
104                 // Merge pool data with content
105                 $content = merge_array($content, $pool);
106
107                 // Load row template and switch colors
108                 $OUT .= loadTemplate('admin_email_archiv_row', true, $content);
109                 $SW = 3 - $SW;
110         } // END - while
111
112         // Remmber generated rows in array
113         $content['rows'] = $OUT;
114
115         // Load main template
116         loadTemplate('admin_email_archiv', false, $content);
117 } else {
118         // No mail orders fond
119         loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MAILS_IN_POOL--}');
120 }
121
122 // Free memory
123 SQL_FREERESULT($result);
124
125 // [EOF]
126 ?>