"copied"
[mailer.git] / 0.2.1-FINAL / inc / modules / member / what-stats.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 11/09/2003 *
4  * ===============                              Last change: 04/21/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-stats.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Statistics over send mails                       *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Statistik ueber gesendete Mails                  *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
18  * This program is free software; you can redistribute it and/or modify *
19  * it under the terms of the GNU General Public License as published by *
20  * the Free Software Foundation; either version 2 of the License, or    *
21  * (at your option) any later version.                                  *
22  *                                                                      *
23  * This program is distributed in the hope that it will be useful,      *
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
26  * GNU General Public License for more details.                         *
27  *                                                                      *
28  * You should have received a copy of the GNU General Public License    *
29  * along with this program; if not, write to the Free Software          *
30  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } elseif (!IS_MEMBER()) {
39         LOAD_URL("modules.php?module=index");
40 }
41
42 // Add description as navigation point
43 ADD_DESCR("member", __FILE__);
44
45 // Init output
46 $main_content = array();
47
48 // Load waiting/pending orders
49 $result = SQL_QUERY_ESC("SELECT id, cat_id, payment_id, subject, url, timestamp, target_send, data_type, zip
50 FROM "._MYSQL_PREFIX."_pool
51 WHERE sender=%s AND data_type != 'SEND'
52 ORDER BY timestamp DESC",
53         array($GLOBALS['userid']), __FILE__, __LINE__);
54
55 // Are there mails left in pool?
56 if (SQL_NUMROWS($result) > 0) {
57         // Load all orders
58         $OUT = ""; $SW = 2;
59         while ($data = SQL_FETCHARRAY($result)) {
60                 // Is the ZIP code set? If not, set dashes
61                 if (empty($data['zip'])) $data['zip'] =  "---";
62
63                 // Prepare content for output
64                 $content = array(
65                         'sw'    => $SW,
66                         'id'    => $data['id'],
67                         'cat'   => GET_CATEGORY($data['cat_id']),
68                         'pay'   => GET_PAYMENT($data['payment_id']),
69                         'subj'  => COMPILE_CODE($data['subject']),
70                         'url'   => DEREFERER($data['url']),
71                         'stamp' => MAKE_DATETIME($data['timestamp'], "2"),
72                         'recs'  => $data['target_send'],
73                         'type'  => TRANSLATE_POOL_TYPE($data['data_type']),
74                         'zip'   => $data['zip']
75                 );
76
77                 // Load template
78                 $OUT .= LOAD_TEMPLATE("member_pool_row", true, $content);
79
80                 // Switch color
81                 $SW = 3 - $SW;
82         } // END - if
83
84         // Load main template
85         $main_content['pool'] = LOAD_TEMPLATE("member_pool_table", true, $OUT);
86 } else {
87         // No mails in pool!
88         $main_content['pool'] = LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_MAILS_IN_POOL);
89 }
90
91 // Free result
92 SQL_FREERESULT($result);
93
94 // Load sent orders
95 //                               0     1         2         3      4            5            6            7           8
96 $result = SQL_QUERY_ESC("SELECT id, cat_id, payment_id, subject, url, timestamp_ordered, max_rec, timestamp_send, clicks
97 FROM "._MYSQL_PREFIX."_user_stats
98 WHERE userid=%s
99 ORDER BY timestamp_ordered DESC",
100         array($GLOBALS['userid']), __FILE__, __LINE__);
101
102 if (SQL_NUMROWS($result) > 0) {
103         // Mail orders are in pool so we can display them
104         $SW = 2; $OUT = "";
105         while ($data = SQL_FETCHROW($result)) {
106                 // Prepare data for the template
107                 $content = array(
108                         'sw'    => $SW,
109                         'cat'   => GET_CATEGORY($data[1]),
110                         'pay'   => GET_PAYMENT($data[2]),
111                         'subj'  => COMPILE_CODE($data[3]),
112                         'url'   => DEREFERER($data[4]),
113                         'stamp' => MAKE_DATETIME($data[5], "2"),
114                         'recs'  => $data[6],
115                         'sent'  => MAKE_DATETIME($data[7], "2"),
116                         'clix'  => $data[8],
117                         'perc'  => COMPILE_CODE($data[8] / $data[6] * 100)."%",
118                 );
119
120                 // Load row template and switch colors
121                 $OUT .= LOAD_TEMPLATE("member_stats_row", true, $content);
122                 $SW = 3 - $SW;
123         }
124
125         // Load main template
126         $main_content['stats'] = LOAD_TEMPLATE("member_stats_table", true, $OUT);
127 } else {
128         // No mail orders fond
129         $main_content['stats'] = LOAD_TEMPLATE("admin_settings_saved", true, MEMBER_NO_MAILS_IN_STATS);
130 }
131
132 // Free result
133 SQL_FREERESULT($result);
134
135 // Load main template
136 LOAD_TEMPLATE("member_stats_pool", false, $main_content);
137
138 //
139 ?>