]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-config_payouts.php
Fixes for constant and old lost code removed
[mailer.git] / inc / modules / admin / what-config_payouts.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 04/11/2004 *
4  * ================                             Last change: 08/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-config_payouts.php                          *
8  * -------------------------------------------------------------------- *
9  * Short description : Configure payout types                           *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Auszahlungensarten editieren                     *
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  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!isAdmin())) {
41         die();
42 }
43
44 // Add description as navigation point
45 addMenuDescription('admin', __FILE__);
46
47 if (isPostRequestElementSet('rate')) setRequestPostElement('rate', convertCommaToDot(postRequestElement('rate')));
48
49 if ((isPostRequestElementSet('add')) && (isPostRequestElementSet('title')) && (postRequestElement('rate') > 0)) {
50         // Add new payout type
51         $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE type='%s' LIMIT 1",
52         array(postRequestElement('title')), __FILE__, __LINE__);
53         if (SQL_NUMROWS($result) == 0) {
54                 // Add now
55                 SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_payout_types`
56 (type, rate, min_points, from_account, from_pass, engine_url, engine_ret_ok, engine_ret_failed, pass_enc, allow_url)
57 VALUES ('%s', %d, %d,'%s','%s','%s','%s','%s','%s','%s')",
58                 array(
59                         postRequestElement('title'),
60                         bigintval(postRequestElement('rate')),
61                         bigintval(postRequestElement('min_points')),
62                         postRequestElement('yacc'),
63                         postRequestElement('ypass'),
64                         postRequestElement('yurl'),
65                         postRequestElement('yrdone'),
66                         postRequestElement('yrfailed'),
67                         postRequestElement('ytrans'),
68                         postRequestElement('allow_url'),
69                 ), __FILE__, __LINE__);
70
71                 // Get message
72                 $message = getMessage('ADMIN_PAYOUT_TYPE_ADDED');
73         } else {
74                 // Free memory
75                 SQL_FREERESULT($result);
76
77                 // Does already exist
78                 $message = "<div class=\"admin_failed\">{--ADMIN_PAYOUT_TYPE_ALREADY--}</div>";
79         }
80 }
81
82 // Payout requests by your members
83 $result_mem = SQL_QUERY("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_payouts` WHERE `status`='NEW' ORDER BY payout_timestamp DESC", __FILE__, __LINE__);
84
85 $display = true;
86 if ((isPostRequestElementSet('edit')) && (countPostSelection() > 0)) {
87         // Edit payout types
88         if ((isGetRequestElementSet('ok')) && (getRequestElement('ok') == 'ok')) {
89                 // Init SQLs
90                 initSqls();
91
92                 // Edit entries
93                 foreach (postRequestElement('sel') as $id => $sel) {
94                         // Secure ID
95                         $id = bigintval($id);
96
97                         // Edit only if something is entered
98                         if ((isPostRequestElementSet('title', $id)) && (postRequestElement('rate', $id) > 0)) {
99                                 // Update entry
100                                 addSql(SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_payout_types` SET
101 type='%s',
102 rate=%s,
103 min_points=%s,
104 allow_url='%s'
105 WHERE `id`='".$id."' LIMIT 1",
106                                 array(
107                                         postRequestElement('title', $id),
108                                         convertCommaToDot(postRequestElement('rate', $id)),
109                                         convertCommaToDot(postRequestElement('min_points' , $id)),
110                                         postRequestElement('allow', $id),
111                                 ),__FILE__, __LINE__, false));
112                         }
113                 }
114
115                 // Run all SQLs
116                 runFilterChain('run_sqls');
117
118                 // Get message
119                 $message = getMessage('ADMIN_PAYOUT_ENTRIES_CHANGED');
120         } else {
121                 $display = false; //Suppress any other outputs
122                 $OUT = ''; $SW = 2;
123                 foreach (postRequestElement('sel') as $id => $sel) {
124                         // Load data
125                         $result = SQL_QUERY_ESC("SELECT type, rate, min_points, allow_url FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
126                         array(bigintval($id)), __FILE__, __LINE__);
127                         list($title, $rate, $min_points, $allow) = SQL_FETCHROW($result);
128                         SQL_FREERESULT($result);
129
130                         // Prepare data for the row template
131                         $content = array(
132                                 'sw'    => $SW,
133                                 'id'    => $id,
134                                 'title' => $title,
135                                 'rate'  => translateComma($rate),
136                                 'min_points'  => translateComma($min_points),
137                                 'allow' => addSelectionBox('yn', $allow, "allow[".$id."]"),
138                         );
139
140                         // Load row template and switch color
141                         $OUT .= loadTemplate('admin_config_payouts_edit_row', true, $content);
142                         $SW = 3 - $SW;
143                 }
144
145                 // Load main template
146                 loadTemplate('admin_config_payouts_edit', false, $OUT);
147         }
148 } elseif ((isPostRequestElementSet('del')) && (countPostSelection() > 0)) {
149         // Delete payout types
150         if ((isGetRequestElementSet('ok')) && (getRequestElement('ok') == 'ok')) {
151                 // Init SQLs
152                 initSqls();
153
154                 // Delete entries
155                 foreach (postRequestElement('sel') as $id => $sel) {
156                         addSql(SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
157                         array(bigintval($id)), __FILE__, __LINE__, false));
158                 } // END - foreach
159
160                 // Run all SQLs
161                 runFilterChain('run_sqls');
162
163                 // Get message
164                 $message = getMessage('ADMIN_PAYOUT_ENTRIES_DELETED');
165         } else {
166                 $display = false; //Suppress any other outputs
167                 $OUT = ''; $SW = 2;
168                 foreach (postRequestElement('sel') as $id => $sel) {
169                         // Secure ID number
170                         $id = bigintval($id);
171
172                         // Load data
173                         $result = SQL_QUERY_ESC("SELECT type, rate, min_points FROM `{?_MYSQL_PREFIX?}_payout_types` WHERE `id`=%s LIMIT 1",
174                         array($id), __FILE__, __LINE__);
175                         list($title, $rate, $min_points) = SQL_FETCHROW($result);
176                         SQL_FREERESULT($result);
177
178                         // Prepare data for the row template
179                         $content = array(
180                                 'sw'    => $SW,
181                                 'id'    => $id,
182                                 'title' => $title,
183                                 'rate'  => translateComma($rate),
184                                 'min_points'  => translateComma($min_points),
185                         );
186
187                         // Load row template and switch color
188                         $OUT .= loadTemplate('admin_config_payouts_del_row', true, $content);
189                         $SW = 3 - $SW;
190                 }
191
192                 // Load main template
193                 loadTemplate('admin_config_payouts_del', false, $OUT);
194         }
195 }
196
197 if (!empty($message)) {
198         // Output message
199         loadTemplate('admin_settings_saved', false, $message);
200 } // END - if
201
202 // Payout types
203 $result_type = SQL_QUERY("SELECT
204         `id`, `type`, `rate`, `min_points`, `from_account`
205 FROM
206         `{?_MYSQL_PREFIX?}_payout_types`
207 ORDER BY
208         `type` ASC", __FILE__, __LINE__);
209
210 if ((SQL_NUMROWS($result_type) > 0) && ($display)) {
211         // List all payout types
212         $OUT = ''; $SW = 2;
213         while ($content = SQL_FETCHARRAY($result_type)) {
214                 // Prepare data for the row template
215                 $content = array(
216                         'sw'           => $SW,
217                         'id'           => $content['id'],
218                         'from_account' => $content['from_account'],
219                         'type'         => $content['type'],
220                         'rate'         => translateComma($content['rate']),
221                         'min_points'   => translateComma($content['min_points']),
222                 );
223
224                 // Load row template and switch color
225                 $OUT .= loadTemplate('admin_config_payouts_row', true, $content);
226                 $SW = 3 - $SW;
227         }
228
229         // Free memory
230         SQL_FREERESULT($result_type);
231
232         // Load main template
233         loadTemplate('admin_config_payouts', false, $OUT);
234 }
235
236 // Does your members request payouts?
237 if ((SQL_NUMROWS($result_mem) > 0) && ($display)) {
238         // Members has requested payouts
239         loadTemplate('admin_settings_saved', false, "<a href=\"{?URL?}/modules.php?module=admin&amp;what=list_payouts\">{--ADMIN_PAYOUT_LIST_REQUESTS--}</a></P>");
240 } elseif ($display) {
241         // No member requests so far
242         loadTemplate('admin_settings_saved', false, getMessage('ADMIN_PAYOUT_NO_MEMBER_REQUESTS'));
243 }
244
245 // Free result
246 SQL_FREERESULT($result_mem);
247
248 // Add new paypout type
249 if ($display === true) loadTemplate('admin_payout_add_new');
250
251 // [EOF]
252 ?>