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 - 2012 by Mailer Developer Team *
20 * For more information visit: http://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__);
48 if (isFormSent('add')) {
49 // Check input variables
50 if (!isPostRequestElementSet('pay_name')) unsetPostRequestElement('add');
51 if ((round(postRequestElement('pay_rate')) == 0) || (!isPostRequestElementSet('pay_rate'))) unsetPostRequestElement('add');
53 setPostRequestElement('pay_min_count', bigintval(postRequestElement('pay_min_count')));
55 if ((postRequestElement('pay_min_count') == '0') || (!isPostRequestElementSet('pay_min_count'))) unsetPostRequestElement('add');
56 if (!isPostRequestElementSet('pay_currency')) unsetPostRequestElement('add');
58 } elseif ((isFormSent('edit')) || (isFormSent('delete')) || (isFormSent('do_edit')) || (isFormSent('do_delete'))) {
59 // Check if at least one entry was selected
60 if (!isPostRequestElementSet('id')) {
61 // Nothing selected for editing / deleting???
62 unsetPostRequestElement('edit');
63 unsetPostRequestElement('delete');
64 unsetPostRequestElement('do_edit');
65 unsetPostRequestElement('do_delete');
66 } elseif (isFormSent('do_edit')) {
67 // Change entries here...
68 foreach (postRequestElement('id') as $id => $sel) {
74 `{?_MYSQL_PREFIX?}_sponsor_paytypes`
84 postRequestElement('name', $id),
85 postRequestElement('rate', $id),
86 bigintval(postRequestElement('min', $id)),
87 postRequestElement('curr', $id),
89 ), __FILE__, __LINE__);
93 $message = '{--SPONSOR_PAY_ENTRIES_CHANGED--}';
94 } elseif (isFormSent('do_delete')) {
95 // Remove entries here...
96 foreach (postRequestElement('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 displayMessage($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(postRequestElement('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 postRequestElement('pay_name'),
121 convertCommaToDot(postRequestElement('pay_rate')),
122 bigintval(postRequestElement('pay_min_count')),
123 postRequestElement('pay_currency')
124 ), __FILE__, __LINE__);
126 // Payment type added!
127 $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ADDED=' . postRequestElement('pay_name') . '%}';
129 // Entry does already exists
130 $message = '{%message,ADMIN_SPONSOR_PAYTYPE_ALREADY=' . postRequestElement('pay_name') . '%}';
134 SQL_FREERESULT($result);
137 displayMessage($message);
138 } elseif ((isFormSent('edit')) || (isFormSent('delete'))) {
141 foreach (postRequestElement('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
182 `{?_MYSQL_PREFIX?}_sponsor_paytypes`
187 // Are there some payment types setup?
188 if (!SQL_HASZERONUMS($result)) {
189 // Prepare variables for listing
192 // List alle found payment types
193 while ($content = SQL_FETCHARRAY($result)) {
195 $OUT .= loadTemplate('admin_list_sponsor_pay_row', TRUE, $content);
198 // Load list template
199 $content['list_out'] = loadTemplate('admin_list_sponsor_pay', TRUE, $OUT);
201 // Noting setup so far!
202 $content['list_out'] = displayMessage('{--ADMIN_SPONSOR_NO_PAYTYPES--}', TRUE);
206 SQL_FREERESULT($result);
208 // Add new payment types here
209 $content['add_out'] = loadTemplate('admin_add_sponsor_paytype', TRUE);
211 // Load final template
212 loadTemplate('admin_sponsor_paytypes', FALSE, $content);