New wrapper functions introduced, TODOs.txt updated
[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  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.mxchange.org                  *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  * -------------------------------------------------------------------- *
37  * Mod-Copyright (c) 2004 by Robert Niedziela                           *
38  * www.megacomputing.de                                                 *
39  ************************************************************************/
40
41 // Some security stuff...
42 if ((!defined('__SECURITY')) || (!isAdmin())) {
43         die();
44 } // END - if
45
46 // Add description as navigation point
47 addYouAreHereLink('admin', __FILE__);
48
49 // Init SQL
50 $sql = "SELECT
51         `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
52 FROM
53         `{?_MYSQL_PREFIX?}_pool`
54 WHERE
55         `data_type`='SEND' OR `data_type`='DELETED'
56 ORDER BY
57         `timestamp` DESC";
58
59 // Check for maximum pages
60 $result_maximum = SQL_QUERY($sql, __FILE__, __LINE__);
61
62 // Set offset an current page to default values
63 if (!isGetRequestParameterSet('page'))   setGetRequestParameter('page'  , 1);
64 if (!isGetRequestParameterSet('offset')) setGetRequestParameter('offset', getMailsPage());
65
66 // Add limitation to SQL string
67 $sql .= ' LIMIT ' . (getRequestParameter('offset') * getRequestParameter('page') - getRequestParameter('offset')) . ', ' . getRequestParameter('offset');
68
69 // Run SQL query for normal mails
70 $result = SQL_QUERY($sql, __FILE__, __LINE__);
71
72 // Calculate pages
73 $numPages = round(SQL_NUMROWS($result_maximum) / getMailsPage() + 0.5);
74
75 // Free the result which we don't need
76 SQL_FREERESULT($result_maximum);
77
78 if (!SQL_HASZERONUMS($result)) {
79         // Mail orders are in pool so we can display them
80
81         // Add navigation table rows
82         $content['top_email_nav']    = addEmailNavigation($numPages, getMailsPage(), true , 3, true);
83         $content['bottom_email_nav'] = addEmailNavigation($numPages, getMailsPage(), false, 3, true);
84
85         // List all entries
86         $OUT = '';
87         while ($pool = SQL_FETCHARRAY($result)) {
88                 // Check sent mails and clicks
89                 $result_mails = SQL_QUERY_ESC("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
90                         array(bigintval($pool['id'])), __FILE__, __LINE__);
91
92                 // Load entries
93                 $pool = merge_array($pool, SQL_FETCHARRAY($result_mails));
94
95                 // Merge result
96                 SQL_FREERESULT($result_mails);
97
98                 // Unconfirmed mails
99                 $pool['unconfirmed'] = generateUnconfirmedAdminLink($pool['id'],  ($pool['max_rec'] - $pool['clicks']), 'mid');
100
101                 // Prepare data for the row template
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         } // END - while
110
111         // Remmber generated rows in array
112         $content['rows'] = $OUT;
113
114         // Load main template
115         loadTemplate('admin_email_archiv', false, $content);
116 } else {
117         // No mail orders fond
118         displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');
119 }
120
121 // Free memory
122 SQL_FREERESULT($result);
123
124 // [EOF]
125 ?>