Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury
Author Message
sak
Worker
Worker


Joined: Jul 06, 2005
Posts: 172

PostPosted: Wed Nov 16, 2005 11:23 pm Reply with quote

Hey guys. I have a small issue with the Donat-o-Meter in NukeTreasury 1.1. It's listing ALL donations and ignores my parameters for how many to list. I'm not a great coder myself at this point, and couldn't identify the problem in the code. I fooled around with it and still couldn't beat it into submission.

It is INTENT on listing every single donation with no end in sight Razz

my site is at Only registered users can see links on this board! Get registered or login! if you want to see what I'm talking about. We're running nuke 7.6 patched and a number of mods (NSN groups mainly).

I appreciate the help!
 
View user's profile Send private message Visit poster's website
sak
PostPosted: Wed Nov 23, 2005 12:31 pm Reply with quote

no one? Sad
 
blith
Client


Joined: Jul 18, 2003
Posts: 977

PostPosted: Wed Nov 23, 2005 12:40 pm Reply with quote

and you have set the number of donations to list as what?
 
View user's profile Send private message Visit poster's website
sak
PostPosted: Tue Nov 29, 2005 11:14 pm Reply with quote

I've tried virtually every number (even negatives). Nothing makes a difference, it's like it completely ignores that field. I've tried adjusting the swingday as well, but nothing works. The swingday just cuts out any donations before that day of the month. I want my swingday to stay as 1.

grr too many donations listed!
 
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9455
Location: Arizona

PostPosted: Wed Nov 30, 2005 1:31 pm Reply with quote

sak wrote:
grr too many donations listed!


Gee, I wish I had that problem! ROTFL

If I get some time later tonight, I'll take a look at the script code on my site. Unfortunately, must work to eat.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
sak
PostPosted: Wed Nov 30, 2005 11:13 pm Reply with quote

Here's the code from the original block-Donat_o_Meter.php file that comes with NukeTreasury v1.1

Code:
<?php

/************************************************************************/
/* NukeTreasury - Financial management for PHP-Nuke                      */
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash                       */
/*                       thrash@fragnastika.com                         */
/*                       thrashn8r@hotmail.com                          */
/*                                                                      */
/* 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.       */
/*                                                                      */
/* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307  */
/* USA                                                                  */
/* Upgraded and cleaned up by Telli http://codezwiz.com                 */
/************************************************************************/

if (eregi("block-Donat_o_Meter.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

include("modules/Donations/config.inc.php");

   $swingd = $tr_config[swing_day];
   if(!($swingd > 0 AND $swingd < 32))
      $swingd = 6;
   
   $dmshowdate = $tr_config[dm_show_date];
   $dmshowamt = $tr_config[dm_show_amt];
   $DM_TITLE = $tr_config[dm_title];
   
   if(!$DM_TITLE)
      $DM_TITLE = "Help keep us going!";
      
   if(is_numeric($tr_config[dm_num_don]) && $tr_config[dm_num_don] > 0 )
      $dmlen = $tr_config[dm_num_don];
   else if (is_numeric($dmlen) && $dmlen ==0)
      $dmlen = -1;
   else
      $dmlen = 10;
      
   // Check the current day against the swing day to execute the proper query
   if( date('d') >= $swingd )
   {
      $query_Recordset1 = ' SELECT business, COUNT( mc_gross ) AS count, SUM( mc_gross ) AS gross, SUM( mc_gross - mc_fee ) AS net, DATE_FORMAT( NOW( ) , \'%M\' ) AS mon, '
         . ' DATE_FORMAT( SUBDATE( DATE_FORMAT( ADDDATE( NOW( ) , INTERVAL 1 MONTH ) , \'%Y-%c-1\' ) , INTERVAL 1 DAY ) , \' %b %e\' ) AS due_by, '
         . ' DATE_FORMAT( NOW( ) , \'%b\' ) AS mon_short'
         . ' FROM transactions'
         . ' WHERE ( transactions.payment_date >= DATE_FORMAT( NOW( ) , \'%Y-%m-' . $swingd . '\' ) ) '
         . ' GROUP BY business';
   
      $query_Recordset3 = 'SELECT custom AS name, option_selection1 as showname, ';
      $query_Recordset3 .= 'DATE_FORMAT( payment_date, \'%b-%e\' ) AS date, ';
      $query_Recordset3 .= 'CONCAT(\'$\',SUM(mc_gross)) AS amt ';
      $query_Recordset3 .= ' FROM transactions'
         . ' WHERE ( transactions.payment_date >= DATE_FORMAT( NOW( ) , \'%Y-%m-' . $swingd . '\' ) ) '
         . ' GROUP BY txn_id ORDER BY payment_date DESC';
   } else
   {
      $query_Recordset1 = ' SELECT business, COUNT( mc_gross ) AS count, SUM( mc_gross ) AS gross, SUM( mc_gross - mc_fee ) AS net, DATE_FORMAT( SUBDATE( NOW( ) , INTERVAL ' . $swingd . ' '
         . ' DAY ) , \'%M\' ) AS mon, \'Now!\' AS due_by, DATE_FORMAT( SUBDATE( NOW( ) , INTERVAL ' . $swingd . ' '
         . ' DAY ) , \'%b\' ) AS mon_short'
         . ' FROM transactions'
         . ' WHERE ( transactions.payment_date < DATE_FORMAT( NOW( ) , \'%Y-%m-' . $swingd . '\' ) ) AND transactions.payment_date > DATE_FORMAT( SUBDATE( NOW( ) , INTERVAL ' . $swingd . ' '
         . ' DAY ) , \'%Y-%m-' . $swingd . '\' )'
         . ' GROUP BY business ';
   
      $query_Recordset3 = 'SELECT custom AS name, option_selection1 as showname, ';
      $query_Recordset3 .= 'DATE_FORMAT( payment_date, \'%b-%e\' ) AS date, ';
      $query_Recordset3 .= 'CONCAT(\'$\',SUM(mc_gross)) AS amt ';
      $query_Recordset3 .= ' FROM transactions'
         . ' WHERE ( transactions.payment_date < DATE_FORMAT( NOW( ) , \'%Y-%m-' . $swingd . '\' ) ) AND transactions.payment_date > DATE_FORMAT( SUBDATE( NOW( ) , INTERVAL ' . $swingd . ' '
         . ' DAY ) , \'%Y-%m-' . $swingd . '\' ) '
         . ' GROUP BY txn_id ORDER BY payment_date DESC';
   }
   
   // Get the donation totals
   $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
   $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   //If there are not records, then get "null" data
   if( !$row_Recordset1 )
   {
      $query_Recordset1 = ' SELECT \'\' AS business, \'0\' AS count, \'0\' AS gross, \'0\' AS net, DATE_FORMAT( NOW( ) , \'%M\' ) AS mon, DATE_FORMAT( SUBDATE( DATE_FORMAT( ADDDATE( NOW( ) , INTERVAL 1 '
         . ' MONTH ) , \'%Y-%c-1\' ) , INTERVAL 1 '
         . ' DAY ) , \' %b %e\' ) AS due_by, DATE_FORMAT( NOW( ) , \'%b\' ) AS mon_short'; 
      $Recordset1 = mysql_query($query_Recordset1, $ipnppd) or die(mysql_error());
      $row_Recordset1 = mysql_fetch_assoc($Recordset1);
   }
   
   // Get the goal
   $query_Recordset2 = $sql = 'SELECT * FROM config WHERE name=\'goal\' AND subtype=\'' . $row_Recordset1['mon_short'] . '\'';
   $Recordset2= mysql_query($query_Recordset2, $ipnppd) or die(mysql_error());
   $row_Recordset2 = mysql_fetch_assoc($Recordset2);
   
   // Set our remaining template vars
   $DM_MON = $row_Recordset1[mon];
   $DM_GOAL = sprintf('$%.02f', $row_Recordset2['value']);
   $DM_DUE = $row_Recordset1['due_by'];
   $DM_NUM = $row_Recordset1['count'];
   $DM_GROSS = sprintf('$%.02f',$row_Recordset1['gross']);
   $DM_NET = sprintf('$%.02f',$row_Recordset1['net']);
   $DM_LEFT = sprintf('$%.02f', $row_Recordset2['value'] - $row_Recordset1['net']);
   $DM_BUTTON = $tr_config[dm_button];
   $DM_BUTT_DIMS = '';
   if( is_numeric($tr_config[dm_img_width]) )
   $DM_BUTT_DIMS .= "width=\"$tr_config[dm_img_width]\" ";
   if( is_numeric($tr_config[dm_img_height]) )
   $DM_BUTT_DIMS .= "height=\"$tr_config[dm_img_height]\" ";


      // Load the template
   $tmpl_file = "modules/Donations/Donatometer.html";
   $thefile = implode("", file($tmpl_file));
   $thefile = addslashes($thefile);
   $thefile = "\$r_file=\"".$thefile."\";";
   eval($thefile);
   $content = $r_file;

   // Do we want to display the donators?
   if(is_numeric($dmlen) && $dmlen >= 0 )
   {
      // Get the list of donators
      $Recordset3= mysql_query($query_Recordset3, $ipnppd) or die(mysql_error());
   
         $content .= "<br><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">"
               . "<tr><td align=\"center\" colspan=\"2\"><u>Donations</u></td></tr>"
                  . "<tr><td>"
                     . "<div align=\"right\"><a href=\"javascript:openwindow5()\">&copy;</a></div></td></tr>";

      // List all the donators
      $l = 0;
      while ( ($row_Recordset3 = mysql_fetch_assoc($Recordset3)) && ($i != $tr_config[dm_num_don]) )
      {
         // Refunded transactions will show up with $0 amount
         if( $row_Recordset3['amt'] > "$0" )
         {
            // Observe the user's wish regarding revealing their name
            if( strcmp($row_Recordset3['showname'],"Yes") == 0)
               $name = $row_Recordset3['name'];
            else
               $name = "Anonymous";
            
            if( !$dmshowamt && !$dmshowdate )
               $dmalign = "center";
            else
               $dmalign = "left";
            $content .= "<tr><td width=\"100%\" align=\"$dmalign\" colspan=\"2\">";
            $content .=  $name;
            if( $dmshowamt )
               $content .= " $row_Recordset3[amt]";
            if( $dmshowdate )
               $content .= " $row_Recordset3[date]";
            $content .= "</td></tr>";
                         
         }
         $l++;

      } 
      $content .= "</table>";
}
   
?>


Now, I've manually set $dmlen to see if the if/then/else at the top were fudged. This doesn't seem to be the problem. I suspect it's something toward the bottom...perhaps the while ( ($row_Recordset3 = mysql_fetch_assoc($Recordset3)) && ($i != $tr_config[dm_num_don]) ) or something like that. I don't know enough about php to see the problem.
 
montego
PostPosted: Thu Dec 01, 2005 7:21 am Reply with quote

sak, I found the issue and you were correct in your assumption that is the while statement.

Change:
Code:


      while ( ($row_Recordset3 = mysql_fetch_assoc($Recordset3)) && ($i != $tr_config[dm_num_don]) )


to

Code:


      while ( ($row_Recordset3 = mysql_fetch_assoc($Recordset3)) && ($l <= $tr_config[dm_num_don]) )


Let me know if this works. I don't have enough donations to test this with! ROTFL

Regards,
montego
 
sak
PostPosted: Thu Dec 01, 2005 6:53 pm Reply with quote

Thanks man! It appears to work! It lists one extra donation, but that isn't a problem. It actually RESPONDS to what I input now, so I'm not listing 1000 donations. This is a very good thing.

Cheers
 
montego
PostPosted: Thu Dec 01, 2005 8:10 pm Reply with quote

If you don't want that last one, simply remove the "=" sign in the while statement for the test of the $l variable.

I.e.,:

Code:


$l < $tr_config[dm_num_don]


Regards,
montego
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Nuke Treasury

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©