+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL Start: 07/31/2011 *
+ * =================== Last change: 07/31/2011 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : what-earnings.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Extra earnings for the user *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Zusatzverdienst fuer die Mitglieder *
+ * -------------------------------------------------------------------- *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ die();
+} elseif (!isMember()) {
+ redirectToIndexMemberOnlyModule();
+}
+
+// Add description as navigation point
+addYouAreHereLink('member', __FILE__);
+
+// Is the form sent?
+if (isFormSent()) {
+ // Then handle the extra earning request
+ doMemberEarning(
+ postRequestElement('earning_id'),
+ postRequestElement('earning_daily_amount'),
+ postRequestElement('earning_active')
+ );
+} // END - if
+
+// Check for all earnings
+$result = SQL_QUERY('SELECT
+ d.`earning_id`,
+ d.`earning_group`,
+ d.`earning_name`
+FROM
+ `{?_MYSQL_PREFIX?}_earning_data` AS d
+ORDER BY
+ d.`earning_sorting` ASC', __FILE__, __LINE__);
+
+// Do we have entries?
+if (SQL_NUMROWS($result) > 0) {
+ // Init output
+ $OUT = '';
+
+ // List all entries
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Load user_earning data
+ $result2 = SQL_QUERY_ESC('SELECT
+ u.`earning_active`,
+ UNIX_TIMESTAMP(u.`earning_added`) AS `earning_added`,
+ UNIX_TIMESTAMP(u.`earning_cancelled`) AS `earning_cancelled`,
+ u.`earning_daily_amount`,
+ u.`earning_points`
+FROM
+ `{?_MYSQL_PREFIX?}_user_earning` AS u
+WHERE
+ u.`earning_id`=%s AND
+ u.`earning_userid`=%s
+LIMIT 1',
+ array(
+ bigintval($content['earning_id']),
+ getMemberId()
+ ), __FILE__, __LINE__);
+
+ // Do we have an entry?
+ if (SQL_NUMROWS($result2) == 1) {
+ // Load it
+ $content = merge_array($content, SQL_FETCHARRAY($result2));
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result2);
+
+ // Do we have user_earning data available?
+ if (!isset($content['earning_active'])) {
+ // Load row template "open subscription"
+ $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_form_row', true, $content);
+ } else {
+ // Load row template "already subscribed"
+ $OUT .= loadTemplate('member_earning_' . strtolower($content['earning_group']) . '_row', true, $content);
+ }
+ } // END - while
+
+ // Load main template
+ loadTemplate('member_earning', false, $OUT);
+} else {
+ // Display message
+ displayMessage('{--MEMBER_EARNINGS_404--}');
+}
+
+// Free result
+SQL_FREERESULT($result);
+
+// [EOF]
+?>