2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/09/2003 *
4 * =============== Last change: 04/21/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-stats.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Statistics over send mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Statistik ueber gesendete Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
42 } elseif (!isMember()) {
43 redirectToIndexMemberOnlyModule();
46 // Add description as navigation point
47 addMenuDescription('member', __FILE__);
50 $main_content = array();
52 // Load waiting/pending orders
53 $result = SQL_QUERY_ESC("SELECT id, cat_id, payment_id, subject, url, timestamp, target_send, data_type, zip
54 FROM `{?_MYSQL_PREFIX?}_pool`
55 WHERE sender=%s AND data_type != 'SEND'
56 ORDER BY timestamp DESC",
57 array(getUserId()), __FILE__, __LINE__);
59 // Are there mails left in pool?
60 if (SQL_NUMROWS($result) > 0) {
63 while ($data = SQL_FETCHARRAY($result)) {
64 // Is the ZIP code set? If not, set dashes
65 if (empty($data['zip'])) $data['zip'] = '---';
67 // Prepare content for output
68 // @TODO Rewrite in template subj->subject,stamp->timestamp,recs->target_send
72 'cat' => getCategory($data['cat_id']),
73 'pay' => getPaymentTitlePrice($data['payment_id']),
74 'subj' => $data['subject'],
75 'url' => generateDerefererUrl($data['url']),
76 'stamp' => generateDateTime($data['timestamp'], '2'),
77 'recs' => $data['target_send'],
78 'type' => translatePoolType($data['data_type']),
83 $OUT .= loadTemplate('member_pool_row', true, $content);
90 $main_content['pool'] = loadTemplate('member_pool_table', true, $OUT);
93 $main_content['pool'] = loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_MAILS_IN_POOL'));
97 SQL_FREERESULT($result);
100 $result = SQL_QUERY_ESC("SELECT
101 `id`, `cat_id`, `payment_id`, `subject`, `url`, `timestamp_ordered`, `max_rec`, `timestamp_send`, `clicks`
103 `{?_MYSQL_PREFIX?}_user_stats`
107 `timestamp_ordered` DESC",
108 array(getUserId()), __FILE__, __LINE__);
110 if (SQL_NUMROWS($result) > 0) {
111 // Mail orders are in pool so we can display them
113 while ($content = SQL_FETCHARRAY($result)) {
114 // Prepare data for the template
115 // @TODO Rewrite in template: stamp->timestamp_ordered,recs->max_rec,clix->clicks,perc->percents
118 'cat' => getCategory($content['cat_id']),
119 'pay' => getPaymentTitlePrice($content['payment_id']),
120 'url' => generateDerefererUrl($content['url']),
121 'stamp' => generateDateTime($content['timestamp_ordered'], '2'),
122 'recs' => $content['max_rec'],
123 'sent' => generateDateTime($content['timestamp_send'], '2'),
124 'clix' => $content['clicks'],
125 'perc' => ($content['clicks'] / $content['max_rec'] * 100)."%",
128 // Load row template and switch colors
129 $OUT .= loadTemplate('member_stats_row', true, $content);
133 // Load main template
134 $main_content['stats'] = loadTemplate('member_stats_table', true, $OUT);
136 // No mail orders fond
137 $main_content['stats'] = loadTemplate('admin_settings_saved', true, getMessage('MEMBER_NO_MAILS_IN_STATS'));
141 SQL_FREERESULT($result);
143 // Load main template
144 loadTemplate('member_stats_pool', false, $main_content);