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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009, 2010 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 addMenuDescription('admin', __FILE__);
48 if (isFormSent('add')) {
49 // Check input variables
50 if (!isPostRequestParameterSet('pay_name')) unsetPostRequestParameter('add');
51 if ((round(postRequestParameter('pay_rate')) == 0) || (!isPostRequestParameterSet('pay_rate'))) unsetPostRequestParameter('add');
53 setPostRequestParameter('pay_min_count', bigintval(postRequestParameter('pay_min_count')));
55 if ((postRequestParameter('pay_min_count') == '0') || (!isPostRequestParameterSet('pay_min_count'))) unsetPostRequestParameter('add');
56 if (!isPostRequestParameterSet('pay_currency')) unsetPostRequestParameter('add');
58 } elseif ((isFormSent('edit')) || (isFormSent('delete')) || (isFormSent('change')) || (isFormSent('remove'))) {
59 // Check if at least one entry was selected
60 if (!isPostRequestParameterSet('id')) {
61 // Nothing selected for editing / deleting???
62 unsetPostRequestParameter('edit');
63 unsetPostRequestParameter('delete');
64 unsetPostRequestParameter('change');
65 unsetPostRequestParameter('remove');
66 } elseif (isFormSent('change')) {
67 // Change entries here...
68 foreach (postRequestParameter('id') as $id => $sel) {
74 `{?_MYSQL_PREFIX?}_sponsor_paytypes`
84 postRequestParameter('name', $id),
85 postRequestParameter('rate', $id),
86 bigintval(postRequestParameter('min', $id)),
87 postRequestParameter('curr', $id),
89 ), __FILE__, __LINE__);
93 $message = '{--SPONSOR_PAY_ENTRIES_CHANGED--}';
94 } elseif (isFormSent('remove')) {
95 // Remove entries here...
96 foreach (postRequestParameter('id') as $id => $sel) {
98 SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
99 array(bigintval($id)), __FILE__, __LINE__);
103 $message = '{--SPONSOR_PAY_ENTRIES_REMOVED--}';
106 if (!empty($message)) {
108 loadTemplate('admin_settings_saved', false, $message);
112 if (isFormSent('add')) {
113 // Check if entry with same name does exists
114 $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `pay_name`='%s' LIMIT 1",
115 array(postRequestParameter('pay_name')), __FILE__, __LINE__);
116 if (SQL_HASZERONUMS($result)) {
117 // No entry found so add this line
118 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_paytypes` (`pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`) VALUES ('%s','%s','%s','%s')",
120 postRequestParameter('pay_name'),
121 convertCommaToDot(postRequestParameter('pay_rate')),
122 bigintval(postRequestParameter('pay_min_count')),
123 postRequestParameter('pay_currency')
124 ), __FILE__, __LINE__);
126 // Payment type added!
127 $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ADDED', postRequestParameter('pay_name'));
129 // Entry does already exists
130 $message = getMaskedMessage('ADMIN_SPONSOR_PAYTYPE_ALREADY', postRequestParameter('pay_name'));
134 SQL_FREERESULT($result);
137 loadTemplate('admin_settings_saved', false, $message);
138 } elseif ((isFormSent('edit')) || (isFormSent('delete'))) {
141 foreach (postRequestParameter('id') as $id => $sel) {
143 $result = SQL_QUERY_ESC("SELECT `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency` FROM `{?_MYSQL_PREFIX?}_sponsor_paytypes` WHERE `id`=%s LIMIT 1",
144 array(bigintval($id)), __FILE__, __LINE__);
145 if (SQL_NUMROWS($result) == 1) {
147 $content = SQL_FETCHARRAY($result);
149 if (isFormSent('edit')) {
151 $OUT .= loadTemplate('admin_list_sponsor_pay_edit_row', true, $content);
154 $OUT .= loadTemplate('admin_list_sponsor_pay_del_row', true, $content);
158 $OUT .= loadTemplate('admin_list_sponsor_pay_404', true, $id);
162 SQL_FREERESULT($result);
165 // Load main template depending on mode (edit/delete)
166 if (isFormSent('edit')) {
167 // Load main edit template
168 loadTemplate('admin_list_sponsor_pay_edit', false, $OUT);
170 // Load main delete template
171 loadTemplate('admin_list_sponsor_pay_del', false, $OUT);
174 // Load all payment types
175 $result = SQL_QUERY("SELECT
176 `id`, `pay_name`, `pay_rate`, `pay_min_count`, `pay_currency`
178 `{?_MYSQL_PREFIX?}_sponsor_paytypes`
183 // Do we have some paytypes setup?
184 if (!SQL_HASZERONUMS($result)) {
185 // Prepare variables for listing
188 // List alle found payment types
189 while ($content = SQL_FETCHARRAY($result)) {
191 $OUT .= loadTemplate('admin_list_sponsor_pay_row', true, $content);
194 // Load list template
195 $content['list_out'] = loadTemplate('admin_list_sponsor_pay', true, $OUT);
197 // Noting setup so far!
198 $content['list_out'] = loadTemplate('admin_settings_saved', true, '{--ADMIN_SPONSOR_NO_PAYTYPES--}');
202 SQL_FREERESULT($result);
204 // Add new payment types here
205 $content['add_out'] = loadTemplate('admin_add_sponsor_paytype', true);
207 // Load final template
208 loadTemplate('admin_sponsor_paytypes', false, $content);