Extension ext-earning introduced (unfinished), renamings:
[mailer.git] / inc / modules / member / what-earnings.php
index 4e651427a60eaf3fdf3737196d2d2df3e7c49a6f..3842cd7709a5bf7e8320c144ea74f8f581e82d67 100644 (file)
@@ -45,5 +45,67 @@ if (!defined('__SECURITY')) {
 // 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_ESC('SELECT
+       d.`earning_id`,
+       d.`earning_group`,
+       d.`earning_name`,
+       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?}_earning_data` AS d
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_user_earning` AS u
+ON
+       d.`earning_id`=u.`earning_id`
+WHERE
+       u.`earning_userid` IS NULL OR
+       u.`earning_userid`=%s
+ORDER BY
+       d.`earning_sorting` ASC',
+       array(
+               getMemberId()
+       ), __FILE__, __LINE__);
+
+// Do we have entries?
+if (SQL_NUMROWS($result) > 0) {
+       // Init output
+       $OUT = '';
+
+       // List all entries
+       while ($content = SQL_FETCHARRAY($result)) {
+               // Do we have user_earning data available?
+               if (is_null($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]
 ?>