Lot Auction Relistings

Details of modifications which users can incorporate within Enuuk Auction Platform free of charge
Post Reply
RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Lot Auction Relistings

Post by RWAP » Tue May 08, 2012 11:26 am

Currently no items are relisted where there has been a purchaser.

This is fine for most auction types, but in the case of a Lot Auction, this makes no sense, if there are still items remaining to be sold.

I would therefore propose the following minor change:

In class\LotAuction.php, find:

Code: Select all

/// COMMON METHODS TO EXTEND /// 
Add above this:

Code: Select all

    /**
    *   Prepare the offer values for a relist
    *
    *   Change dates, reset price, and delete all bids
    *   @param  MyPDO   $DB   database instance
    */
    public function relist(MyPDO $DB)
    {
        if($this->quantity==0){
            return false; //Can't relist a Lot auction where all items have been sold
        }
        if ($this->relisting<=0) return false;  // No relisting options

        //Reset values
        $this->relisting = $this->relisting - 1;
        $deltaTime = strtotime($this->endDate) - strtotime($this->startDate);
        $this->startDate = date('Y-m-d H:i:s');
        $this->endDate = date('Y-m-d H:i:s', time()+$deltaTime);
        $this->active = 1;
        $result = $this->saveToDB($DB);
        return $result;
    }

Then, you need to amend the class\Cron.php
Find:

Code: Select all

    static public function relistOffers(MyPDO $DB, Core_Context $context)
    {
        $now = date("Y-m-d H:i:s"); //Used to get corrected time based on timezone settings
        $offers = Offer::getListFromDB($DB, 'where offers.active = 0
                                        and offers.draft = 0
                                        and offers.endDate <= "'.$now.'"
                                        and offers.winner is null
                                        and relisting > 0');
        
        // Relist and save to DB (asap)
        // Note: this part is done ASAP to avoid other users re-relisting in paralel
        $offersObj = array();
        foreach($offers as $v){
            $o = Offer::getInstanceFromDB($DB, $v['id']);
            $o->relist($DB); //Deletes bid history, and reset prices and dates
            $offersObj[] = $o;
        }
Change this to:

Code: Select all

    static public function relistOffers(MyPDO $DB, Core_Context $context)
    {
        $now = date("Y-m-d H:i:s"); //Used to get corrected time based on timezone settings
        $offers = Offer::getListFromDB($DB, 'where offers.active = 0
                                        and offers.draft = 0
                                        and offers.endDate <= "'.$now.'"
                                        and (offers.winner is null || offers.type="'.Offer::LOT.'")
                                        and relisting > 0');

        // Relist and save to DB (asap)
        // Note: this part is done ASAP to avoid other users re-relisting in paralel
        $offersObj = array();
        foreach($offers as $v){
            $o = Offer::getInstanceFromDB($DB, $v['id']);
            $relist=true;
            if ($o instanceof LotAuction){
                if ($o->quantity==0){
                	unset ($offers[$k]);
                    $relist=false;
               	}
            }
            if ($relist){
	            $o->relist($DB); //Deletes bid history, and reset prices and dates
    	        $offersObj[] = $o;
            }
        }

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Lot Auction Relistings

Post by RWAP » Tue May 15, 2012 1:59 pm

I am obviously missing something here - as although the Lot Auction is now relisted, I still get an email telling me that it finished with winners.....

RWAP
Site Admin
Posts: 748
Joined: Fri Jan 08, 2010 2:23 am
Location: Stoke-on-Trent
Contact:

Re: Lot Auction Relistings

Post by RWAP » Fri May 25, 2012 11:39 am

Ah - it is always something simple isn't it...

I just needed to change:

class\OfferMail\LotAuction.php

Find:

Code: Select all

            case Offer::EVENT_CLOSE: 
                if($subject->winner){
                    //send a summary
Change this to:

Code: Select all

            case Offer::EVENT_CLOSE: 
                if($subject->winner && ($subject->relisting==0 || $subject->quantity==0)){
                    //send a summary if auction is not going to be relisted..

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest