in

Community Server

The platform that enables you to build rich, interactive communities

Football Pool Software suggestion... sufficient positive ballance required to make picks

Last post 10-19-2010 8:29 AM by Spooky. 20 replies.
Page 1 of 2 (21 items) 1 2 Next >
Sort Posts: Previous Next
  • 08-19-2009 7:07 AM

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Football Pool Software suggestion... sufficient positive ballance required to make picks

    It would be really nice to have a configuration setting that forces players to have sufficient positive account balance before they can submit picks for any given week. I've had issues in the past where players have made the picks and then never got around to paying for them. I handled it by invalidating their picks and disabling the accounts... but it always left a bad taste in the mouth of the other players who were expecting the pot to be a certain amount.

    Last year I made a few modifications in the code to prevent it from happening again, but my solution was a bit crude because it only verified that they had enough balance "at that moment" to make the picks. Since the balance is not adjusted until the game locks, a player "could" make several future weeks picks while only having enough positive balance for a single week. I will probably be doing my bailing wire/duct tape fix again this year... but would love to have a more elegant solution.

     -Spook

  • 08-19-2009 4:24 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    That may not be too hard. There are existing functions to check if a player has an entry in each pool. If you want to count every entry made (including ones for future weeks) the code would look like this:

    function GetAvailableFunds(username)
    
    	dim sql, rs
    	dim credits, fees
    
    	GetAvailableFunds = 0
    
    	'Get credits.
    	credits = 0
    	sql = "SELECT SUM(Amount) AS Total FROM Credits WHERE Username = '" & SqlEscape(username) & "'"
    	set rs = DbConn.Execute(sql)
    	if not rs.EOF then
    		credits = credits + rs.Fields("Total").Value
    	end if
    
    	'Get fees.
    	fees = 0
    
    	'Count each weekly entry.
    	dim week, numWeeks
    	numWeeks = GetWeekCount()
    	for week = 1 to numWeeks
    		if InWeeklyPool(username, week) then
    			fees = fees + WEEKLY_ENTRY_FEE
    		end if
    	next
    
    	'Add the side pool entry (if used).
    	if InSidePool(username) then
    		fees = fees + SIDE_ENTRY_FEE
    	end if
    
    	GetAvailableFunds  = credits - fees
    
    end function
    

    This ignores the playoffs pools, but you could include them as well. Then for any pool entry, check the available funds vs. the entry fee and decide if you want to allow it or not.

  • 08-26-2009 11:42 AM In reply to

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     Thanks Mike. I got this working just the way I wanted with your help.

     For anyone else wanting to do the same, here is exactly what I did:

     I added the following code to common.asp ... just stick it in anywhere between (but not inside) the other functions:

     P.S. I took out the if InSidePool portion because it was giving me an error and I didn't look into the error because it didn't apply to my pool


        '--------------------------------------------------------------------------
        ' Returns the amount of available funds for the user
        '--------------------------------------------------------------------------
        function GetAvailableFunds(username)

            dim sql, rs
            dim credits, fees

            GetAvailableFunds = 0

            'Get credits.
            credits = 0
            sql = "SELECT SUM(Amount) AS Total FROM Credits WHERE Username = '" & SqlEscape(username) & "'"
            set rs = DbConn.Execute(sql)
            if not rs.EOF then
                credits = credits + rs.Fields("Total").Value
            end if

            'Get fees.
            fees = 0

            'Count each weekly entry.
            dim week, numWeeks
            numWeeks = GetWeekCount()
            for week = 1 to numWeeks
                if InWeeklyPool(username, week) then
                    fees = fees + WEEKLY_ENTRY_FEE
                end if
            next

            GetAvailableFunds  = credits - fees

        end function

     

    Then insert this code into weeklyEntry.asp somewhere around line 189... Make it the last elseif before the else in the 'Process an update request block of code.


             elseif GetAvailableFunds(username) < WEEKLY_ENTRY_FEE then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")

     

    Filed under:
  • 08-26-2009 11:56 AM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     Very nice, that should take care of the deadbeats :)

    I suspect the error you were getting with InSidePool could be fixed by adding <!-- #include file="includes/side.asp" --> to the weeklyEntry.asp file (side.asp contains the InSidePool function).

  • 09-15-2009 11:44 AM In reply to

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     Hey Mike... I noticed a slight glitch in the way this is working.

     If the user does not have enough positive balance for another week he can not modify his current weeks picks, neither can the admin account for that matter, unless I add funds to his account and then take them away again post modification.

    Can you think of easy ways to address those issues?

    I'm thinking this change to weeklyEntry.asp will address the user's issue... but I'm not certain how best to address the Admin's inability to modify picks... but maybe that is not all that important.

     

        'Process an update request.
        elseif Request.Form("submit") = "Update" then

            'Prevent entries by the Admin.
            if username = ADMIN_USERNAME then
                call DisplayErrorMessage("Error: User '" & ADMIN_USERNAME & "' may not make picks.")

            'If the user is disabled, prevent the entry.
            elseif IsDisabled() then
                call DisplayErrorMessage("Error: Your account has been disabled, changes not accepted.<br />Please contact the Administrator.")

            'If all games have been locked, prevent any updates (except by the Admin).
            elseif not IsAdmin() and allLocked then
                call DisplayErrorMessage("Error: All games for this week have been locked, changes not<br />accepted.")
           
            'If the player does not have sufficient funds, do not allow the picks
            elseif GetAvailableFunds(username) < WEEKLY_ENTRY_FEE and NOT hasEntry then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")
            
            'Otherwise, process the request.

  • 09-15-2009 12:41 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    I think you need to adjust the available funds depending on whether the player has an entry for the current week or not. I'd add this near the top of the script:

       'Determine if the user has an entry for the given week (so we can display
      'the Delete button).
      dim hasEntry
      hasEntry = false
      if username <> "" and InWeeklyPool(username, week) then
        hasEntry = true
      end if

      'Get the user's available funds.
      dim availFunds
      availFunds = GetAvailableFunds(username, week)
      if hasEntry then
        availFunds = availFunds + WEEKLY_ENTRY_FEE
      end if 

    That basically gives them back credit for the current week since they've already paid for it.

    Then you can adjust your if statement:

      elseif not IsAdmin() and availFunds < 0 then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")

    the "not IsAdmin()" part will let the admin update it no matter what.

  • 09-15-2009 1:24 PM In reply to

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    Looks like I have that working with just a couple changes:

    mikehall:


      'Get the user's available funds.
      dim availFunds
      availFunds = GetAvailableFunds(username)
      if hasEntry then
        availFunds = availFunds + WEEKLY_ENTRY_FEE
      end if 

    That basically gives them back credit for the current week since they've already paid for it.

    Then you can adjust your if statement:

      elseif not IsAdmin() and availFunds < WEEKLY_ENTRY_FEE then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")

    the "not IsAdmin()" part will let the admin update it no matter what.

     

     GetAvailableFunds only takes the single input (gave me an error initially)

     WEEKLY_ENTRY_FEE instead of 0 for the requirement (0 allowed players to pick 1 extra week)

  • 09-15-2009 2:05 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     My bad, you're right on both points.

  • 09-15-2009 7:13 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     ok so has this section been settled? Somehow to where the funds have to be available in order to make picks? but what about the adjustments to picks?

     

    I've added the first section to common.asp and to weeklyEntry line 189(or close to it.). but i never changed anything after that post. So is there still a problem with the editing picks even though thats been added?

  • 09-15-2009 7:28 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     Go with Spook's last post above, that should work for the initial entry and any later editing:

      'Get the user's available funds.
      dim availFunds
      availFunds = GetAvailableFunds(username)
      if hasEntry then
        availFunds = availFunds + WEEKLY_ENTRY_FEE
      end if 

    ...

      elseif not IsAdmin() and availFunds < WEEKLY_ENTRY_FEE then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")

     

  • 09-16-2009 7:04 AM In reply to

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     To summarize all changes for making this mod work:

    [snip]

    see the newer summary on the next page of this thread..

  • 09-16-2009 7:14 AM In reply to

    • Spooky
    • Top 10 Contributor
    • Joined on 08-19-2009
    • Denver CO
    • Posts 64

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    [snip]

    see the newer summary on the next page of this thread..
  • 09-16-2009 10:06 AM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    ok so this code in the previous posts at the top isnt the right one to add to the bottom of weeklyEntry.asp?

    Spooky:


             elseif GetAvailableFunds(username) < WEEKLY_ENTRY_FEE then
                call DisplayErrorMessage("Error: Your account does not have sufficient funds to make <br />these picks, Changes Not Accepted.")

     

     

     

    I followed the directions you just gave in the last 2 posts you made. im updating now to test it out. thx for your help.

  • 10-01-2009 7:36 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

     ok i just redone the code for verifing funds but for some reason it is still letting people pick without payments..

  • 11-29-2009 8:59 PM In reply to

    Re: Football Pool Software suggestion... sufficient positive ballance required to make picks

    Same here.  I've inserted the scripts exactly as posted, but no luck.  People still can select lineups while "in the hole".  I started this pool a couple of weeks ago, would starting on week 10 have any effect on this?

    Maybe Mike will consider implementing this feature in the future for people like myself who can't figure out why this won't work.


Page 1 of 2 (21 items) 1 2 Next >
Powered by Community Server (Non-Commercial Edition), by Telligent Systems