2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/10/2005 *
4 * =================== Last change: 05/19/2008 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_sponsor_pay.php *
8 * -------------------------------------------------------------------- *
9 * Short description : List/edit/delete all payments and add new *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Auflisten/Aendern/Loeschen aller Buchungspakete *
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 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
50 if (isFormSent('add')) {
51 // Check input variables
52 if (!isPostRequestParameterSet('pay_name')) unsetPostRequestParameter('add');
53 if ((round(postRequestParameter('pay_rate')) == 0) || (!isPostRequestParameterSet('pay_rate'))) unsetPostRequestParameter('add');
55 setPostRequestParameter('pay_min_count', bigintval(postRequestParameter('pay_min_count')));
57 if ((postRequestParameter('pay_min_count') == '0') || (!isPostRequestParameterSet('pay_min_count'))) unsetPostRequestParameter('add');
58 if (!isPostRequestParameterSet('pay_currency')) unsetPostRequestParameter('add');
60 } elseif ((isFormSent('edit')) || (isFormSent('del')) || (isFormSent('change')) || (isFormSent('remove'))) {
61 // Check if at least one entry was selected
62 if (!isPostRequestParameterSet('id')) {
63 // Nothing selected for editing / deleting???
64 unsetPostRequestParameter('edit');
65 unsetPostRequestParameter('del');
66 unsetPostRequestParameter('change');
67 unsetPostRequestParameter('remove');
68 } elseif (isFormSent('change')) {
69 // Change entries here...
70 foreach (postRequestParameter('id') as $id => $sel) {
76 `{?_MYSQL_PREFIX?}_sponsor_paytypes`
86 postRequestParameter('name', $id),
87 postRequestParameter('rate', $id),
88 bigintval(postRequestParameter('min', $id)),
89 postRequestParameter('curr', $id),
91 ), __FILE__, __LINE__);
95 $message = getMessage('SPONSOR_PAY_ENTRIES_CHANGED');
96 } elseif (isFormSent('remove')) {
97 // Remove entries here...
98 foreach (postRequestParameter('id') as $id => $sel) {
100 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`='%s' LIMIT 1",
101 array(bigintval($id)), __FILE__, __LINE__);
105 $message = getMessage('SPONSOR_PAY_ENTRIES_REMOVED');
108 if (!empty($message)) {
110 loadTemplate('admin_settings_saved', false, $message);
114 if (isFormSent('add')) {
115 // Check if entry with same name does exists
116 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1",
117 array(postRequestParameter('pay_name')), __FILE__, __LINE__);
118 if (SQL_HASZERONUMS($result)) {
119 // No entry found so add this line
120 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')",
122 postRequestParameter('pay_name'),
123 convertCommaToDot(postRequestParameter('pay_rate')),
124 bigintval(postRequestParameter('pay_min_count')),
125 postRequestParameter('pay_currency')
126 ), __FILE__, __LINE__);
128 // Payment type added!
129 $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ADDED', postRequestParameter('pay_name'));
132 SQL_FREERESULT($result);
134 // Entry does already exists
135 $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY', postRequestParameter('pay_name'));
139 loadTemplate('admin_settings_saved', false, $message);
140 } elseif ((isFormSent('edit')) || (isFormSent('del'))) {
143 foreach (postRequestParameter('id') as $id => $sel) {
145 $result = SQL_QUERY_ESC("SELECT `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`='%s' LIMIT 1",
146 array(bigintval($id)), __FILE__, __LINE__);
147 if (SQL_NUMROWS($result) == 1) {
149 list($name, $rate, $min, $curr) = SQL_FETCHROW($result);
150 SQL_FREERESULT($result);
152 // Transfer data to array
154 'id' => bigintval($id),
155 'sw' => bigintval($SW),
156 'name' => htmlspecialchars($name),
157 'rate' => translateComma($rate),
158 'min' => bigintval($min),
159 'curr' => htmlspecialchars($curr)
162 if (isFormSent('edit')) {
164 $OUT .= loadTemplate('admin_list_sponsor_pay_edit_row', true, $content);
167 $OUT .= loadTemplate('admin_list_sponsor_pay_del_row', true, $content);
171 $OUT .= loadTemplate('admin_list_sponsor_pay_404', true, $id);
178 // Load main template depending on mode (edit/delete)
179 if (isFormSent('edit')) {
180 // Load main edit template
181 loadTemplate('admin_list_sponsor_pay_edit', false, $OUT);
183 // Load main delete template
184 loadTemplate('admin_list_sponsor_pay_del', false, $OUT);
187 // Load all payment types
188 $result = SQL_QUERY("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` ORDER BY `pay_name` ASC",
191 // Do we have some paytypes setup?
192 if (SQL_NUMROWS($result) > 0) {
193 // Prepare variables for listing
196 // List alle found payment types
197 while ($content = SQL_FETCHARRAY($result)) {
198 // Remember data in array
201 'id' => $content['id'],
202 'name' => $content['pay_name'],
203 'rate' => translateComma($content['pay_rate']),
204 'min' => $content['pay_min_count'],
205 'currency' => $content['pay_currency']
209 $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
216 SQL_FREERESULT($result);
218 // Load list template
219 $content['list_out'] = loadTemplate('admin_list_sponsor_pay', true, $OUT);
221 // Noting setup so far!
222 $content['list_out'] = loadTemplate('admin_settings_saved', true, getMessage('ADMIN_SPONSOR_NO_PAYTYPES'));
225 // Add new payment types here
226 $content['add_out'] = loadTemplate('admin_add_sponsor_paytype', true);
228 // Load final template
229 loadTemplate('admin_sponsor_paytypes', false, $content);