]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-transfer.php
A lot while() conditions rewritten to SQL_FETCHARRAY(), see bug #107, @TODO tags...
[mailer.git] / inc / modules / member / what-transfer.php
index 738ca29ba8fa0486ee7df1e45c708015f2d8d310..4e9d6e4d5ebb95a32f26bc927aff02d89d78c3b6 100644 (file)
@@ -238,9 +238,10 @@ case "new": // Start new transfer
                if (SQL_NUMROWS($result) > 0) {
                        // Load list
                        $OUT  = "<select name=\"to_uid\" size=\"1\" class=\"member_select\">
-  <option value=\"0\">".SELECT_NONE."</option>\n";
+       <option value=\"0\">{--SELECT_NONE--}</option>\n";
+                       // @TODO Try to rewrite his to $content = SQL_FETCHARRAY(), see some lines above for two different queries
                        while (list($uid, $nick) = SQL_FETCHROW($result)) {
-                               $OUT .= "<option value=\"".$uid."\"";
+                               $OUT .= "       <option value=\"".$uid."\"";
                                if ((REQUEST_ISSET_POST(('to_uid'))) && (REQUEST_POST('to_uid') == $uid)) $OUT .= " selected=\"selected\"";
                                $OUT .= ">";
                                if (($nick != $uid) && (!empty($nick))) {
@@ -300,6 +301,7 @@ case "list_out": // List only outgoing transactions
        {
        case "list_in":
                $sql = "SELECT trans_id, from_uid, points, reason, time_trans FROM `{!_MYSQL_PREFIX!}_user_transfers_in` WHERE userid=%s ORDER BY time_trans DESC LIMIT ".getConfig('transfer_max');
+               // @TODO Rewrite these constants
                $NOTHING = getMessage('TRANSFER_NO_INCOMING_TRANSFERS');
                define('__TRANSFER_SUM', getMessage('TRANSFER_TOTAL_INCOMING'));
                define('__TRANSFER_TITLE', getMessage('TRANSFER_LIST_INCOMING'));
@@ -307,6 +309,7 @@ case "list_out": // List only outgoing transactions
 
        case "list_out":
                $sql = "SELECT trans_id, to_uid, points, reason, time_trans FROM `{!_MYSQL_PREFIX!}_user_transfers_out` WHERE userid=%s ORDER BY time_trans DESC LIMIT ".getConfig('transfer_max');
+               // @TODO Rewrite these constants
                $NOTHING = getMessage('TRANSFER_NO_OUTGOING_TRANSFERS');
                define('__TRANSFER_SUM', getMessage('TRANSFER_TOTAL_OUTGOING'));
                define('__TRANSFER_TITLE', getMessage('TRANSFER_LIST_OUTGOING'));
@@ -318,25 +321,25 @@ case "list_out": // List only outgoing transactions
        $result = SQL_QUERY_ESC($sql, array($GLOBALS['userid']), __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0) {
                $OUT = ""; $SW = 2;
+               // @TODO This should be somehow rewritten to $content = SQL_FETCHARRAY(), see switch() block above for SQL queries
                while (list($tid, $uid, $points, $reason, $stamp) = SQL_FETCHROW($result)) {
-                       if ($type == "OUT") $points = "$points-";
-                       $OUT .= "<tr>
-  <td class=\"transfer_row1 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row1\">".$tid."</div>
-  </td>
-  <td class=\"transfer_row2 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row2\">".MAKE_DATETIME($stamp, "3")."</div>
-  </td>
-  <td class=\"transfer_row3 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row3\">".$uid."</div>
-  </td>
-  <td class=\"transfer_row4 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row4\">".$reason."</div>
-  </td>
-  <td class=\"transfer_row5 switch_sw".$SW." bottom2\">
-    <div class=\"transfer_row5\">".$points."</div>
-  </td>
-</tr>\n";
+                       // Rewrite points
+                       if ($type == "OUT") $points = $points."-";
+
+                       // Prepare content for template
+                       $content = array(
+                               'sw'     => $SW,
+                               'tid'    => $id,
+                               'stamp'  => MAKE_DATETIME($stamp, "3"),
+                               'uid'    => $uid,
+                               'reason' => $reason,
+                               'points' => TRANSLATE_COMMA($points)
+                       );
+
+                       // Load row template
+                       $OUT .= LOAD_TEMPLATE("member_transfer_row2", true, $content);
+
+                       // Add points and switch color
                        $total += $points;
                        $SW = 3 - $SW;
                }
@@ -353,6 +356,7 @@ case "list_out": // List only outgoing transactions
        }
 
        // ... and add them to a constant for the template
+       // @TODO Rewrite these constants
        define('__TRANSFER_ROWS', $OUT);
 
        // Remeber total amount
@@ -404,29 +408,26 @@ array($GLOBALS['userid'], getConfig('transfer_max')), __FILE__, __LINE__);
 
        $total = 0;
        if (SQL_NUMROWS($result) > 0) {
+               // Search for entries
+               $result = SQL_QUERY("SELECT party_uid, trans_id, points, reason, time_trans, trans_type FROM `{!_MYSQL_PREFIX!}_transfers_tmp` ORDER BY time_trans DESC",
+                       __FILE__, __LINE__);
+
                // Output rows
                $OUT = ""; $SW = 2;
-               $result = SQL_QUERY("SELECT party_uid, trans_id, points, reason, time_trans, trans_type FROM `{!_MYSQL_PREFIX!}_transfers_tmp` ORDER BY time_trans DESC", __FILE__, __LINE__);
-               while (list($uid, $idx, $points, $reason, $stamp, $type) = SQL_FETCHROW($result)) {
-                       if ($type == "OUT") $points = "-$points";
-                       $OUT .= "<tr>
-  <td class=\"transfer_row1 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row1\">".$idx."</div>
-  </td>
-  <td class=\"transfer_row2 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row2\">".MAKE_DATETIME($stamp, "3")."</div>
-  </td>
-  <td class=\"transfer_row3 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row3\">".$uid."</div>
-  </td>
-  <td class=\"transfer_row4 switch_sw".$SW." bottom2 right2\">
-    <div class=\"transfer_row4\">".$reason."</div>
-  </td>
-  <td class=\"transfer_row5 switch_sw".$SW." bottom2\">
-    <div class=\"transfer_row5\">".$points."</div>
-  </td>
-</tr>\n";
-                       $total += $points;
+               while ($content = SQL_FETCHARRAY($result)) {
+                       // Rewrite points
+                       if ($content['trans_type'] == "OUT") $content['points'] = "-".$content['points']."";
+
+                       // Prepare content for template
+                       $content['sw']     = $SW;
+                       $content['time']   = MAKE_DATETIME($content['time_trans'], "3");
+                       $content['points'] = TRANSLATE_COMMA($content['points']);
+
+                       // Load row template
+                       $OUT .= LOAD_TEMPLATE("member_transfer_row", true, $content);
+
+                       // Add points and switch color
+                       $total += $content['points'];
                        $SW = 3 - $SW;
                }
 
@@ -442,6 +443,7 @@ array($GLOBALS['userid'], getConfig('transfer_max')), __FILE__, __LINE__);
        }
 
        // ... and add them to a constant for the template
+       // @TODO Rewrite all these constants
        define('__TRANSFER_ROWS', $OUT);
 
        // Remeber total amount