2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/19/2003 *
4 * =================== Last change: 12/12/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-payments.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Payments (points) for confirmed mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Verguetungen fuer bestätigte Mails *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 if (((!isPostRequestParameterSet('t_wait')) || (!isPostRequestParameterSet('payment'))) && (isGetRequestParameterSet('do')) && (getRequestParameter('do') == 'add')) {
47 unsetPostRequestParameter('ok');
51 switch (getRequestParameter('do')) {
53 addSql("INSERT INTO `{?_MYSQL_PREFIX?}_payments` (`time`, `payment`, `mail_title`, `price`) VALUES ('".postRequestParameter('t_wait')."','".postRequestParameter('payment')."','".postRequestParameter('title')."','".postRequestParameter('price')."')");
54 if (countSumTotalData(postRequestParameter('t_wait'), 'payments', 'id', 'time', true) == 1) {
55 // Re-init the array here
61 foreach (postRequestParameter('time') as $id => $value) {
62 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");
67 foreach (postRequestParameter('id') as $id => $value) {
68 addSql("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=" . bigintval($id) . " LIMIT 1");
74 if (countSqls() > 0) {
76 runFilterChain('run_sqls');
77 $content = '<span class="notice">{--SETTINGS_SAVED--}</span>';
79 // Nothing has changed!
80 $content = '<span class="notice">{--SETTINGS_NOT_SAVED--}</span>';
84 displayMessage($content);
85 } elseif ((isFormSent('delete')) && (ifPostContainsSelections())) {
86 // Delete entries here
88 foreach (postRequestParameter('sel') as $id => $value) {
89 $result = SQL_QUERY_ESC("SELECT `id`, `time`, `mail_title` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
90 array(bigintval($id)), __FILE__, __LINE__);
91 $content = SQL_FETCHARRAY($result);
94 SQL_FREERESULT($result);
96 // Load row template and switch colors
97 $OUT .= loadTemplate('admin_delete_payments_row', true, $content);
100 // Load main template
101 loadTemplate('admin_delete_payments', false, $OUT);
102 } elseif ((isFormSent('edit')) && (ifPostContainsSelections())) {
105 foreach (postRequestParameter('sel') as $id => $value) {
106 $result = SQL_QUERY_ESC("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
107 array(bigintval($id)), __FILE__, __LINE__);
108 $content = SQL_FETCHARRAY($result);
111 SQL_FREERESULT($result);
113 // Load row template and switch colors
114 $OUT .= loadTemplate('admin_edit_payments_row', true, $content);
117 // Load main template
118 loadTemplate('admin_edit_payments', false, $OUT);
121 $result = SQL_QUERY("SELECT `id`, `time`, `payment`, `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` ORDER BY `time` ASC", __FILE__, __LINE__);
122 if (!SQL_HASZERONUMS($result)) {
123 // Make referal levels editable and deletable
126 // List already existing categories for editing
127 while ($content = SQL_FETCHARRAY($result)) {
128 // Load row template and switch colors
129 $OUT .= loadTemplate('admin_list_payments_row', true, $content);
133 SQL_FREERESULT($result);
135 // Load main template
136 loadTemplate('admin_list_payments', false, $OUT);
139 // Form for adding new referal levels
140 loadTemplate('admin_add_payment');