A lot CSS classes rewritten, please update all your themes.
[mailer.git] / inc / modules / admin / what-payments.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/19/2003 *
4  * ===================                          Last change: 12/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-payments.php                                *
8  * -------------------------------------------------------------------- *
9  * Short description : Payments (points) for confirmed mails            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Verguetungen fuer best&auml;tigte Mails              *
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
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 if (((!isPostRequestParameterSet('t_wait')) || (!isPostRequestParameterSet('payment'))) && (isGetRequestParameterSet('do')) && (getRequestParameter('do') == 'add')) {
49         unsetPostRequestParameter('ok');
50 } // END - if
51
52 if (isFormSent()) {
53         switch (getRequestParameter('do')) {
54                 case 'add':
55                         addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
56                         if (countSumTotalData(postRequestParameter('t_wait'), 'payments', 'id', 'time', true) == 1) {
57                                 // Re-init the array here
58                                 initSqls();
59                         } // END - if
60                         break;
61
62                 case 'edit':
63                         foreach (postRequestParameter('time') as $id => $value) {
64                                 addSql("UPDATE `{?_MYSQL_PREFIX?}_payments` SET `time`='" . $value . "', `payment`='".postRequestParameter('payment', $id)."', price='".postRequestParameter('price', $id)."', mail_title='".postRequestParameter('mail_title', $id)."' WHERE `id`='".$id."' LIMIT 1");
65                         } // END - foreach
66                         break;
67
68                 case 'del':
69                         foreach (postRequestParameter('id') as $id => $value) {
70                                 addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
71                         } // END - foreach
72                         break;
73         } // END - switch
74
75         // Save settings
76         if (countSqls() > 0) {
77                 // Run all queries
78                 runFilterChain('run_sqls');
79                 $content = '<span class="notice">{--SETTINGS_SAVED--}</span>';
80         } else {
81                 // Nothing has changed!
82                 $content = '<span class="notice">{--SETTINGS_NOT_SAVED--}</span>';
83         }
84
85         // Output template
86         loadTemplate('admin_settings_saved', false, $content);
87 } elseif ((isFormSent('del')) && (ifPostContainsSelections())) {
88         // Delete entries here
89         $OUT = '';
90         foreach (postRequestParameter('sel') as $id => $value) {
91                 $result = SQL_QUERY_ESC("SELECT `id`, `time`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
92                         array(bigintval($id)), __FILE__, __LINE__);
93                 $content = SQL_FETCHARRAY($result);
94
95                 // Free result
96                 SQL_FREERESULT($result);
97
98                 // Load row template and switch colors
99                 $OUT .= loadTemplate('admin_del_payments_row', true, $content);
100         } // END - foreach
101
102         // Load main template
103         loadTemplate('admin_del_payments', false, $OUT);
104 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
105         // Edit entries
106         $OUT = '';
107         foreach (postRequestParameter('sel') as $id => $value) {
108                 $result = SQL_QUERY_ESC("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
109                         array(bigintval($id)), __FILE__, __LINE__);
110                 $content = SQL_FETCHARRAY($result);
111
112                 // Free result
113                 SQL_FREERESULT($result);
114
115                 // Load row template and switch colors
116                 $OUT .= loadTemplate('form_submit_payments_row', true, $content);
117         } // END - foreach
118
119         // Load main template
120         loadTemplate('form_submit_payments', false, $OUT);
121 } else {
122         // Referal levels
123         $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
124         if (!SQL_HASZERONUMS($result)) {
125                 // Make referal levels editable and deletable
126                 $OUT = '';
127
128                 // List already existing categories for editing
129                 while ($content = SQL_FETCHARRAY($result)) {
130                         // Load row template and switch colors
131                         $OUT .= loadTemplate('admin_list_payments_row', true, $content);
132                 } // END - switch
133
134                 // Free memory
135                 SQL_FREERESULT($result);
136
137                 // Load main template
138                 loadTemplate('admin_list_payments', false, $OUT);
139         } // END - if
140
141         // Form for adding new referal levels
142         loadTemplate('admin_add_payment');
143 }
144
145 // [EOF]
146 ?>