Jump to content

Bids - Cancellation at the end of 24 hours


CEO North Air

Recommended Posts

  • Administrators

Hey guys, the date for bids is stored simply as a date so it is tough to comapre a 24 hour period but you can comapre if it is the next day or not. If you put this code at the start of your schedule_results.tpl file it will to see how old any filed bids are. Having the time comparison set at 86400 (1 day in seconds) will erase any bid that was filed two days ago.

ie - any bid made on 2-20-2010 will be erased on 2-22-2010, so you could have an active bid for 47 hours..

You can change that number to 0, but that may not be desireable either. An example using 0 -

any bid made on 2-20-2010 would be erased on 2-21-2010. so a bid could only last 1 second, if it were to be filed right before midnight on 2-20-2010 it would be erased the next time the script ran on 2-21-2010.

<?php
       $bids = SchedulesData::getAllBids();
       $today = date("Y-m-d");
       if(isset($bids))
       {
           foreach($bids as $bid)
           {
              $date1 = $bid->dateadded;
              $date2 = strtotime($today);
              $dateArr  = explode("-",$date1);
              $date1Int = mktime(0,0,0,$dateArr[1],$dateArr[2],$dateArr[0]) ;
              $diff = ($date1Int-$date2);
                  if ($diff < -86400)
                      {SchedulesData::removeBid($bid->bidid);}
           }
       }
?>

This code would be better placed in the index function of the Schedules.php file but you would have to replace it every time you updated.....

good luck! - ;)

  • Like 1
Link to comment
Share on other sites

  • Administrators

Simplify this up there for ya:

$bids = SchedulesData::getAllBids();
if(isset($bids))
{
foreach($bids as $bid)
{
	$bid_time = strtotime($bid->dateadded);
	$diff = abs(time() - $bid_time);	
	if ($diff > 60*60*24*2) /* two days, in seconds */
	{
		SchedulesData::removeBid($bid->bidid);
	}
}
}

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...