Extension ext-earning introduced (unfinished), renamings:
[mailer.git] / inc / modules / admin / what-list_sponsor.php
index 32ad71a..cbcae48 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * 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 *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -43,69 +41,77 @@ if ((!defined('__SECURITY')) || (!isAdmin())) {
 } // END - if
 
 // Add description as navigation point
 } // END - if
 
 // Add description as navigation point
-addMenuDescription('admin', __FILE__);
+addYouAreHereLink('admin', __FILE__);
 
 
-if (isGetRequestParameterSet('id')) {
+if (isGetRequestElementSet('id')) {
        // Show detailed informations to a sponsor
        $result = SQL_QUERY_ESC("SELECT
        // Show detailed informations to a sponsor
        $result = SQL_QUERY_ESC("SELECT
-       `company`, `position`, `gender`, `surname`, `family`, `street_nr1`, `street_nr2`, `zip`, `city`, `country`,
-       `phone`, `fax`, `cell`, `email`, `url`, `tax_ident`,
-       `status`, `sponsor_created`, `last_online`, `last_change`, `receive_warnings`,
-       `points_amount`, `points_used`, `remote_addr`, `warning_interval`, `refid`, `ref_count`
+       `company`,`position`,`gender`,`surname`,`family`,`street_nr1`,`street_nr2`,`zip`,`city`,`country`,
+       `phone`,`fax`,`cell`,`email`,`url`,`tax_ident`,
+       `status`,
+       UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
+       UNIX_TIMESTAMP(`last_online`) AS `last_online`,
+       UNIX_TIMESTAMP(`last_change`) AS `last_change`,
+       `receive_warnings`,
+       `points_amount`,`points_used`,`remote_addr`,`warning_interval`,`refid`,`ref_count`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
        `id`=%s LIMIT 1",
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
        `id`=%s LIMIT 1",
-       array(bigintval(getRequestParameter('id'))), __FILE__, __LINE__);
+       array(bigintval(getRequestElement('id'))), __FILE__, __LINE__);
 
        if (SQL_NUMROWS($result) == 1) {
                // Load sponsor details
                $content = SQL_FETCHARRAY($result);
 
        if (SQL_NUMROWS($result) == 1) {
                // Load sponsor details
                $content = SQL_FETCHARRAY($result);
-               SQL_FREERESULT($result);
 
                // Check if an entry is empty
                foreach ($content as $k => $v) {
 
                // Check if an entry is empty
                foreach ($content as $k => $v) {
-                       if (empty($v)) $content[$k] = '---';
+                       if ((empty($v)) && ($v != 0)) $content[$k] = '---';
                } // END - foreach
 
                // Prepare all data for the template
                //  Sponsor's id
                } // END - foreach
 
                // Prepare all data for the template
                //  Sponsor's id
-               $content['id']          = getRequestParameter('id');
+               $content['id']              = getRequestElement('id');
                //  Contact data
                //  Contact data
-               $content['email_link']  = generateEmailLink($content['email'], 'sponsor_data');
-               //  Timestamps
+               $content['email_link']      = generateEmailLink($content['email'], 'sponsor_data');
+               //  Epoche times
                $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
                $content['last_online']     = generateDateTime($content['last_online'], 2);
                $content['last_change']     = generateDateTime($content['last_change'], 2);
                //  Orders total
                $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
                $content['last_online']     = generateDateTime($content['last_online'], 2);
                $content['last_change']     = generateDateTime($content['last_change'], 2);
                //  Orders total
-               $content['orders']      = countSumTotalData(bigintval(getRequestParameter('id')), 'sponsor_orders', 'id', 'sponsorid', true);
+               $content['orders']          = countSumTotalData(bigintval(getRequestElement('id')), 'sponsor_orders', 'id', 'sponsor_id', true);
 
                // Load template
                loadTemplate('admin_list_sponsor_details', false, $content);
        } else {
                // Sponsor not found
 
                // Load template
                loadTemplate('admin_list_sponsor_details', false, $content);
        } else {
                // Sponsor not found
-               loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('id'))));
+               displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('id')) . '%}');
        }
        }
-} elseif (isGetRequestParameterSet('rid')) {
+
+       // Free result
+       SQL_FREERESULT($result);
+} elseif (isGetRequestElementSet('refid')) {
        // Search for sponsor
        // Search for sponsor
-       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`='%s' LIMIT 1",
-               array(bigintval(getRequestParameter('rid'))), __FILE__, __LINE__);
+       $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `id`=%s LIMIT 1",
+               array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Free memory
                SQL_FREERESULT($result);
 
                // Sponsor found so let's list all his referals
                $result = SQL_QUERY_ESC("SELECT
        if (SQL_NUMROWS($result) == 1) {
                // Free memory
                SQL_FREERESULT($result);
 
                // Sponsor found so let's list all his referals
                $result = SQL_QUERY_ESC("SELECT
-       `id`, `gender`, `surname`, `family`, `email`, `status`,
-       `sponsor_created`, `last_online`, `points_amount`, `points_used`,
-       `remote_addr`, `ref_count`
+       `id`,`gender`,`surname`,`family`,`email`,`status`,
+       UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
+       UNIX_TIMESTAMP(`last_online`) AS `last_online`,
+       `points_amount`,`points_used`,
+       `remote_addr`,`ref_count`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
        `refid`='%s'
 ORDER BY
        `id` ASC",
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 WHERE
        `refid`='%s'
 ORDER BY
        `id` ASC",
-               array(bigintval(getRequestParameter('rid'))), __FILE__, __LINE__);
+               array(bigintval(getRequestElement('refid'))), __FILE__, __LINE__);
 
                if (!SQL_HASZERONUMS($result)) {
                        // List refs now
 
                if (!SQL_HASZERONUMS($result)) {
                        // List refs now
@@ -113,39 +119,34 @@ ORDER BY
                        SQL_FREERESULT($result);
                } else {
                        // No refs made so far
                        SQL_FREERESULT($result);
                } else {
                        // No refs made so far
-                       loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&amp;what=list_sponsor&amp;id=' . bigintval(getRequestParameter('rid')) . '%}">' . bigintval(getRequestParameter('rid')) . '</a>'));
+                       displayMessage(getMaskedMessage('ADMIN_SPONSOR_REFS_404', '<a href="{%url=modules.php?module=admin&amp;what=list_sponsor&amp;id=' . bigintval(getRequestElement('refid')) . '%}">' . bigintval(getRequestElement('refid')) . '</a>'));
                }
        } else {
                // Sponsor not found
                }
        } else {
                // Sponsor not found
-               loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_SPONSOR_404', bigintval(getRequestParameter('rid'))));
+               displayMessage('{%message,ADMIN_SPONSOR_404=' . bigintval(getRequestElement('refid')) . '%}');
        }
 } else {
        // List all sponsors
        $result_main = SQL_QUERY("SELECT
        }
 } else {
        // List all sponsors
        $result_main = SQL_QUERY("SELECT
-       `id`, `gender`, `surname`, `family`, `email`, `status`,
-       `sponsor_created`, `last_online`, `points_amount`, `points_used`, `remote_addr`
+       `id`,`gender`,`surname`,`family`,`email`,`status`,
+       UNIX_TIMESTAMP(`sponsor_created`) AS `sponsor_created`,
+       UNIX_TIMESTAMP(`last_online`) AS `last_online`,
+       `points_amount`,`points_used`,
+       (`points_amount` + `points_used`) AS `points`,
+       `remote_addr`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 ORDER BY
        `id` ASC", __FILE__, __LINE__);
 
        if (!SQL_HASZERONUMS($result_main)) {
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_data`
 ORDER BY
        `id` ASC", __FILE__, __LINE__);
 
        if (!SQL_HASZERONUMS($result_main)) {
-               // At least one sponsor found!
+               // At least one sponsor found
                $OUT = '';
                while ($content = SQL_FETCHARRAY($result_main)) {
                        // Transfer data to array
                $OUT = '';
                while ($content = SQL_FETCHARRAY($result_main)) {
                        // Transfer data to array
-                       $content = array(
-                               'id'              => $content['id'],
-                               'gender'          => $content['gender'],
-                               'surname'         => $content['surname'],
-                               'family'          => $content['family'],
-                               'email'           => generateEmailLink($content['email'], 'sponsor_data'),
-                               'status'          => $content['status'],
-                               'sponsor_created' => generateDateTime($content['sponsor_created'], 2),
-                               'last_online'     => generateDateTime($content['last_online'], 2),
-                               'points'          => ($content['points_amount'] - $content['points_used']),
-                               'remote_addr'     => $content['remote_addr'],
-                       );
+                       $content['email']           = generateEmailLink($content['email'], 'sponsor_data');
+                       $content['sponsor_created'] = generateDateTime($content['sponsor_created'], 2);
+                       $content['last_online']     = generateDateTime($content['last_online'], 2);
 
                        // Load row template
                        $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
 
                        // Load row template
                        $OUT .= loadTemplate('admin_list_sponsor_row', true, $content);
@@ -158,7 +159,7 @@ ORDER BY
                loadTemplate('admin_list_sponsor', false, $OUT);
        } else {
                // No sponsors registered so far
                loadTemplate('admin_list_sponsor', false, $OUT);
        } else {
                // No sponsors registered so far
-               loadTemplate('admin_settings_saved', false, '{--ADMIN_SPONSOR_NONE_REGISTERED--}');
+               displayMessage('{--ADMIN_SPONSOR_NONE_REGISTERED--}');
        }
 }
 
        }
 }