Beispiel #1
0
    static function renderAuctionTiming(&$auction, $forceCountdown=false) {

        $cfg = BidsHelperTools::getConfig();

/*        $startDate = BidsHelperDateTime::getTimeStamp($auction->end_date);
        if( $startDate > time() ) {
            $auction->countdown = JText::_('COM_BIDS_NOT_YET_STARTED');
            return;
        }*/

        $auction->countdown = 0;

        $expiredate = BidsHelperDateTime::getTimeStamp($auction->end_date);

        if($auction->close_offer) {
            $auction->countdown = JText::_('COM_BIDS_CLOSED');
        } else if ($cfg->bid_opt_enable_countdown || $forceCountdown) {

            $diff = $expiredate - time();
            if ($diff > 0) {
                $s = sprintf('%02d', $diff % 60);
                $diff = intval($diff / 60);
                $m = sprintf('%02d', $diff % 60);
                $diff = intval($diff / 60);
                $h = sprintf('%02d', $diff % 24);
                $diff = intval($diff / 24);

                $auction->countdown = ( $diff > 0 ? ( $diff . ' ' . JText::_('COM_BIDS_DAYS') . ', ') : '' ) . $h . ':' . $m . ':' . $s;
            } else {
                $auction->countdown = JText::_('COM_BIDS_EXPIRED');
            }
        }

        $auction->expired = $auction->close_offer ? false : (boolean) ($expiredate <= time() );
    }
Beispiel #2
0
 static function calendar($isodate, $name)
 {
     $cfg = BidsHelperTools::getConfig();
     $result = JHTML::_('calendar', $isodate, $name, $name, BidsHelperDateTime::dateFormatConversion($cfg->date_format));
     if ($isodate) {
         //ISODATES and JHtml::_('calendar') doesn't take kindly all formats
         $result = str_replace(' value="' . htmlspecialchars($isodate, ENT_COMPAT, 'UTF-8') . '"', ' value="' . htmlspecialchars(JHtml::date($isodate, $cfg->date_format, false), ENT_COMPAT, 'UTF-8') . '"', $result);
     }
     return $result;
 }
Beispiel #3
0
 static function editEndDate(&$auction, $isAdmin = false)
 {
     $cfg = BidsHelperTools::getConfig();
     $dateFormat = BidsHelperDateTime::dateFormatConvert2JHTML(false);
     $fType = CustomFieldsFactory::getFieldType('date');
     $calendarFormat = $fType->dateFormatConversion($dateFormat);
     $dateFormat = BidsHelperDateTime::dateFormatConvert2JHTML(false);
     if (!$cfg->bid_opt_enable_date) {
         if ($auction->id && $auction->published) {
             $html = JHTML::date(JFactory::getDate($auction->end_date)->toUnix(), $dateFormat);
         } else {
             $tooltipMsg = array();
             if (intval($cfg->bid_opt_default_period) > 0) {
                 $tooltipMsg[] = JText::_('COM_BIDS_AUTO_END_DATE_TOOLTIP_1') . ' ' . $cfg->bid_opt_default_period . ' ' . JText::_('COM_BIDS_DAYS');
             }
             if ($cfg->bid_opt_allow_proxy && intval($cfg->bid_opt_proxy_default_period) > 0) {
                 $tooltipMsg[] = JText::_('COM_BIDS_AUTO_END_DATE_TOOLTIP_2') . ' ' . $cfg->bid_opt_proxy_default_period . ' ' . JText::_('COM_BIDS_DAYS');
             }
             if (($cfg->bid_opt_global_enable_bin || $cfg->bid_opt_enable_bin_only) && intval($cfg->bid_opt_bin_default_period) > 0) {
                 $tooltipMsg[] = JText::_('COM_BIDS_AUTO_END_DATE_TOOLTIP_3') . ' ' . $cfg->bid_opt_bin_default_period . ' ' . JText::_('COM_BIDS_DAYS');
             }
             if ($cfg->bid_opt_global_enable_reserve_price && intval($cfg->bid_opt_reserve_price_default_period) > 0) {
                 $tooltipMsg[] = JText::_('COM_BIDS_AUTO_END_DATE_TOOLTIP_4') . ' ' . $cfg->bid_opt_reserve_price_default_period . ' ' . JText::_('COM_BIDS_DAYS');
             }
             $html = count($tooltipMsg) ? JHtml::tooltip(implode('<br />', $tooltipMsg)) : '-';
         }
     } else {
         if ($auction->published && !$isAdmin) {
             $html = JHTML::date(JFactory::getDate($auction->end_date)->toUnix(), $dateFormat);
         } else {
             $attribs = array('class' => 'inputbox required validate-start-date');
             $date = $auction->end_date ? $auction->end_date : '';
             $d = $date ? $date : '';
             if (preg_match('/^[0-9][0-9]:[0-9][0-9]$/', $date)) {
                 //if it's only end hour
                 $d = "";
             }
             $html = JHTML::calendar($d, 'end_date', 'end_date', $calendarFormat, $attribs);
             if ($d) {
                 $html = str_replace(' value="' . htmlspecialchars($d, ENT_COMPAT, 'UTF-8') . '"', ' value="' . htmlspecialchars(JHtml::date($d, $cfg->bid_opt_date_format, false), ENT_COMPAT, 'UTF-8') . '"', $html);
             }
             if ($cfg->bid_opt_enable_hour) {
                 $endHours = $auction->end_date ? JHTML::date($auction->end_date, 'H') : '00';
                 $endMinutes = $auction->end_date ? JHTML::date($auction->end_date, 'i') : '00';
                 $html .= '&nbsp;<input name="end_hour" size="1" value="' . $endHours . '" maxlength="2" class="inputbox required" onblur="bidCheckHours(this)" /> :
                     <input name="end_minutes" size="1" value="' . $endMinutes . '" maxlength="2" class="inputbox required" onblur="bidCheckMinutes(this)" />';
             }
             $html .= '&nbsp;' . JHtml::image(JUri::root() . 'components/com_bids/images/requiredfield.gif', 'Required');
         }
     }
     return $html;
 }
Beispiel #4
0
    function saveBidAjax() {
        if (!$this->checkTCAgreed()) {
            echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_PLEASE_AGREE_TC')."\"}";
            exit;
        }

        $app = JFactory::getApplication();
        $my = JFactory::getUser();
        $cfg=BidsHelperTools::getConfig();

        $task = strtolower($this->getTask());

        $auction_id = JRequest::getInt('id', -1);
        $proxy = JRequest::getInt('proxy', 0);

        $amount = JRequest::getVar('amount', 0);
        if (substr($amount,0,1)=='.') {
            $amount = (float) '0'.$amount; //american style prices like .95 instead of 0.95
        }

        $quantity_param = JRequest::getInt('quantity', 1);
        $auctionmodel = $this->getModel('auction');
        if ( !$auctionmodel->load($auction_id) ) {
            echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_DOES_NOT_EXIST')."\"}";
            exit;
        }

        $auction = $auctionmodel->get('auction');

        $redirect_link = JHtml::_('auctiondetails.auctionDetailsURL', $auction, false);

        if ($auction->userid == $my->id) {
            echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_ERR_NO_SELF_BIDDING')."\"}";
            exit;
        }
        if ($auction->close_offer || $auction->close_by_admin || (BidsHelperDateTime::getTimeStamp($auction->end_date) <= time()) ) {
            echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_AUCTION_IS_CLOSED')."\"}";
            exit;
        }
        if ( $auction->published != 1 || BidsHelperDateTime::getTimeStamp($auction->start_date) > time() ) {
            echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_DOES_NOT_EXIST')."\"}";
            exit;
        }
        if ( 'bin'==$task  ) {

            if($auction->BIN_price <=0) {
                echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_NO_BIN')."\"}";
                exit;
            } else {
                $amount = max($amount, $auction->BIN_price);
            }

        }
        if(AUCTION_TYPE_BIN_ONLY==$auction->auction_type) {

            if('bin'!=$task) {
                echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_ERR_BIN_ONLY')."\"}";
                exit;
            }

            if($cfg->bid_opt_quantity_enabled && $auction->quantity<$quantity_param) {
                echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_ERR_QUANTITY_LEFT')."\"}";
                exit;
            }
        }
        //HERE ENDS ALL SECURITY CHECKS

        //TODO:i think bids greater than BIN price should not be considered BIN
        if
        (
            AUCTION_TYPE_PRIVATE!=$auction->auction_type
            && ( 'bin'==$task
                || (!$proxy && $auction->BIN_price>0 && $amount>=$auction->BIN_price)
            )
        )
        { // BIN bids

            //for BIN, take amount from field BIN_price
            $newBid = $auctionmodel->bid($my->id,$amount,0,$quantity_param);

            if ( $auction->automatic || $auction->params['auto_accept_bin'] ) {
                $auctionmodel->close($newBid);
            }

            //$this->setRedirect($redirect_link);
            //return;
            echo "{\"success\":\"1\",\"bid\":\"{$newBid->bid_price}\"}";
            exit;
        }

        $acceptedPrice = $auctionmodel->getMinAcceptedPrice();
        if( $amount < $acceptedPrice ) {

            switch($auction->auction_type) {
                case AUCTION_TYPE_PUBLIC:
                    //$app->enqueueMessage(JText::_('COM_BIDS_ERR_PRICE_MAXBID'));//on public auctions I can't bid lower than min accepted price
                    echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_ERR_PRICE_MAXBID')."\"}";
                    exit;
                    break;
                case AUCTION_TYPE_PRIVATE:
                    //$app->enqueueMessage(JText::_('COM_BIDS_ERR_PRICE_MYBID'));//on private auctions I can't bid lower second time
                    echo "{\"success\":\"0\",\"message\":\"".JText::_('COM_BIDS_ERR_PRICE_MYBID')."\"}";
                    exit;
                    break;
            }
            //$this->setRedirect($redirect_link);
            return;
        }

        //reserve price message
        if ($cfg->bid_opt_global_enable_reserve_price && $auction->reserve_price > 0 && $auction->params['show_reserve']) {
            $app->enqueueMessage( JText::_( $amount<$auction->reserve_price ? 'COM_BIDS_RESERVE_NOT_MET' : 'COM_BIDS_RESERVE_MET') );
        }

        if(AUCTION_TYPE_PUBLIC==$auction->auction_type && $cfg->bid_opt_allow_proxy) {

            if($proxy) {
                $auctionmodel->proxyBid($my->id, $amount);//bidding ends here
                $this->setRedirect($redirect_link);
                return;
            } else {
                $auctionmodel->deleteProxy($my->id);
            }
        }

        $newBid = $auctionmodel->bid($my->id,$amount,0,$quantity_param);

        echo "{\"success\":\"1\",\"bid\":\"{$newBid->bid_price}\"}";
        exit;

        //$app->enqueueMessage(JText::_('COM_BIDS_SUCCES'));

        //$this->setRedirect( $redirect_link );
    }
Beispiel #5
0
    function cron()
    {
        /* cron script Pass and authentication*/
        $cfg=BidsHelperTools::getConfig();
        $config =JFactory::getConfig();
        $pass=JRequest::getVar('pass');
        $debug= JRequest::getVar('debug',0);

        $date=new JDate();
        $nowMysql=$date->toMySQL(false);

        $database = JFactory::getDbo();

        JTheFactoryHelper::modelIncludePath('payments');
        JTheFactoryHelper::tableIncludePath('payments');

        $log= JTable::getInstance('bidcronlog');
        $log->priority='log';
        $log->event='cron';
        $log->logtime=$nowMysql;
        $logtext="";

        if ($cfg->bid_opt_cron_password!==$pass) {
            //Bad Password, log and exit;
            $log->log=JText::_("COM_BIDS_BAD_PASSWORD_USED")." > $pass";
            $log->store();
            die(JText::_("COM_BIDS_ACCESS_DENIED"));
        }
    	@set_time_limit(0);
    	@ignore_user_abort(true);



        // reminder for due to expire suggestions
        $database->setQuery(" SELECT s.auction_id,a.userid
                                FROM #__bid_suggestions AS s
                                LEFT JOIN #__bid_auctions AS a
                                    ON s.auction_id = a.id
                                WHERE
                                    s.status=2
                                    AND UTC_TIMESTAMP() > DATE_ADD( s.modified, INTERVAL 24 HOUR)
                                    AND a.published=1
                                    AND a.close_offer=0
                                    AND a.close_by_admin=0
                                    AND UTC_TIMESTAMP() < a.end_date
                                GROUP BY s.auction_id");
        $curs = $database->loadObjectList();
        
        if(count($curs)>0) {
            $auction =  JTable::getInstance('auction');
            $userIds = array();
        
            foreach($curs as $k=>$val) {
                $userIds[] = $val->userid;
            }
            $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ( '.implode(',',$userIds).' )');
            $mails = $database->loadObjectList();
            $auction->SendMails($mails,'suggest_reminder'); //Notyfy Sellers abour pending suggestions
        }
        
        // reject expired suggestions
        $database->setQuery(" SELECT a.id AS suggestionId,a.auction_id,b.userid
                                FROM #__bid_suggestions AS a
                                LEFT JOIN #__bid_auctions AS b
                                    ON a.auction_id = b.id
        			WHERE
                                    UTC_TIMESTAMP() > DATE_ADD( a.modified, INTERVAL 48 HOUR)
                                    AND a.status=2");
        $curs = $database->loadObjectList();
        
        if(count($curs)>0) {
            $auction =  JTable::getInstance('auction');
            $userIds = array();
            $suggestionIds = array();
        
            foreach($curs as $k=>$val) {
                $suggestionIds[] = $val->suggestionId;
                $userIds[] = $val->userid;
            }
        
            $database->setQuery('UPDATE #__bid_suggestions SET status=0 WHERE id IN ('.implode(',',$suggestionIds).')');
            $database->query();// reject the suggestions
        
            $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ( '.implode(',',$userIds).' )');
            $mails = $database->loadObjectList();
            $auction->SendMails($mails,'suggest_rejected'); //Notyfy Bidders abour rejected suggestion
        }
        
        //CLOSE auctions
        $query = "SELECT
                        a.*,
                        a.id as auctionId,
                        GROUP_CONCAT(b.userid) AS bidderIds,
                        GROUP_CONCAT(w.userid) AS watcherIds
                    FROM #__bid_auctions AS a
                    LEFT JOIN #__bids AS b
                        ON a.id=b.auction_id
                    LEFT JOIN #__bid_watchlist AS w
                        ON a.id=w.auction_id
                    WHERE
                        UTC_TIMESTAMP() >= a.end_date
                        AND a.close_offer = 0
                        AND a.published = 1
                        AND a.close_by_admin=0
                    GROUP BY a.id";
        $database->setQuery($query);
        $rows = $database->loadObjectList('auctionId');


        $extendedAuctions = array();
        if($cfg->bid_opt_auto_extent && $cfg->bid_opt_auto_extent_nobids) {
            //these auctions have no bids and will be extended
            foreach($rows as $id=>$r) {
                if(!$r->bidderIds) {
                    $extendedAuctions[] = $id;
                }
            }
        }

        if(count($rows)>0) {
            $auction =  JTable::getInstance('auction');

            //exclude auctions that are going to be extended
            $closeAuctions = array_diff(array_keys($rows),$extendedAuctions);
            if(count($closeAuctions)) {
                $database->setQuery('UPDATE
                                        #__bid_auctions
                                     SET
                                        close_offer=1,
                                        closed_date=UTC_TIMESTAMP()
                                     WHERE
                                        id IN ('.implode(',',  $closeAuctions).')');
                $database->query();
            }
        
            foreach ($rows as $r) {
                //Notify bidders
                $auction->bind($r);
        
                //extend auctions with no bids
                if($cfg->bid_opt_auto_extent && $cfg->bid_opt_auto_extent_nobids>0 && !$r->bidderIds) {
                    $extendedPeriodSeconds = $cfg->bid_opt_auto_extent_nobids * BidsHelperDateTime::translateAutoextendPeriod($cfg->bid_opt_auto_extent_nobids_type);
                    $endTime = BidsHelperDateTime::getTimeStamp($auction->end_date);
                    $newEndTime = $endTime + $extendedPeriodSeconds;

                    $auction->end_date = gmdate('Y-m-d H:i:s',$newEndTime);
                    $auction->store();

                    continue;
                }
        
                jimport('joomla.application.component.model');
                JModelLegacy::addIncludePath(JPATH_COMPONENT_SITE.DS.'models');
                $auctionmodel = JModelLegacy::getInstance('auction','bidsModel');
                $auctionmodel->load($r->auctionId);
        
                $seller = JTable::getInstance('user');
                $seller->load($r->userid);
        
                if($r->automatic) {
        
                    $a = $auctionmodel->get('auction');
                    $highestBid = $a->highestBid;
        
                    $nrHighestBids = 1;
                    if( AUCTION_TYPE_PRIVATE == $a->auction_type ) {
                        if($highestBid) {
                            $query = 'SELECT COUNT(1) AS nrHighestBids
                                        FROM #__bids
                                        WHERE
                                            auction_id='.$r->auctionId.'
                                            AND bid_price='.$highestBid->bid_price;
                            $database->setQuery($query);
                            $nrHighestBids = $database->loadResult();
                        }
                        else {
                            $nrHighestBids = 0;
                        }
                    }
        
                    if($highestBid) {
                        if ($nrHighestBids>1) {
                            //mark auction as NOT automatic and alert owner that 2 or more bids are the same
                            $database->setQuery('UPDATE #__bid_auctions SET automatic=0 WHERE id='.$a->id);
                            $database->query();
        
                            $auctionmodel->SendMails(array($seller),'bid_choose_winner');
                        } else {
                            if ($cfg->bid_opt_global_enable_reserve_price && $a->reserve_price>0 && $a->reserve_price>=$highestBid->bid_price) {
                                //reserve price not met!
                                $auctionmodel->SendMails(array($seller),'bid_reserve_not_met');//reserve price not met
                            } else {
                                $bid = JTable::getInstance('bid');
                                $bid->bind($highestBid);
                                $auctionmodel->close($bid);
                            }
                        }
                    } else {
                        $auctionmodel->SendMails(array($seller),'bid_offer_no_winner_to_owner');
                    }
        
                } else {
                    // Notify owner to choose winner OR that his auction has no winner
                    $auctionmodel->SendMails(array($seller), $r->bidderIds ? 'bid_choose_winner' : 'bid_offer_no_winner_to_owner');
                }
        
                if($r->bidderIds) {
                    $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ('.$r->bidderIds.')');
                    $mails = $database->loadObjectList();
                    $auctionmodel->SendMails($mails,'bid_closed'); //Notyfy Bidders abour closed Auction
        
                    $database->setQuery('DELETE FROM #__bid_watchlist WHERE auction_id='.$r->id.' AND userid IN ('.$r->bidderIds.')');
                    $database->query();//delete bidders from watchlist, to avoid double notification
                }
                //Notify  Watchlist, Clean Watchlist
                if($r->watcherIds) {
                    $database->setQuery('SELECT u.* FROM #__users AS u WHERE u.id IN ('.$r->watcherIds.')');
                    $mails = $database->loadObjectList();
                    $auctionmodel->SendMails($mails,'bid_watchlist_closed'); //Notify Watchlist
        
                    $database->setQuery('DELETE FROM #__bid_watchlist WHERE auction_id='.$r->id);
                    $database->query();
                }
            }
        }
        
        // END EXPIRED AUCTION
    
    
        //Daily Jobs (things that should run once a day )
        $daily= JRequest::getVar('daily','');
        if ($daily){
            //Notify upcoming expirations
        	$query = "SELECT a.* from #__bid_auctions AS a
        		 	  WHERE UTC_TIMESTAMP() >= DATE_ADD(end_date,INTERVAL -1 DAY) AND a.close_offer != 1 AND published = 1 AND a.close_by_admin!=1";
        	$database->setQuery($query);
        	$rows = $database->loadObjectList();
    
        	$auction =  JTable::getInstance('auction');
  	        
            $logtext.=sprintf("Soon to expire: %d auctions\r\n",count($rows));
    
            foreach ($rows as $row){
                    $auction->load($row->id);
                    $usr=JFactory::getUser($row->userid);
                    $auction->SendMails(array($usr),'bid_your_will_expire'); // Notify Owner that his auction will soon expire
    
                    $query = "SELECT u.* FROM #__users u
                            left join #__bid_watchlist w on u.id = w.userid
                            where w.auction_id = ".$row->id;
    
                    $database->setQuery($query);
                    $watchlist_mails = $database->loadObjectList();
                    $auction->SendMails($watchlist_mails,'bid_watchlist_will_expire'); //Notify Users in watchlist that an auction will expire
            }
    
        	//Close all auctions without a parent user (deleted users?)s
        	$query = "UPDATE
                        #__bid_auctions AS a
                        LEFT JOIN #__users AS b
                            ON a.userid=b.id
                        SET
                            close_by_admin=1,
                            closed_date=UTC_TIMESTAMP()
                        WHERE b.id IS NULL";
        	$database->setQuery($query);
        	$database->query();
            //delete Very old auctions (past Archived time)
        	$interval =  intval($bidCfg->bid_opt_archive);
            $d_opt = ( $bidCfg->bid_opt_archive_type!='') ? $bidCfg->bid_opt_archive_type : 'month';
            $d_opt_sql = strtoupper($d_opt);
        	if ($interval>0){
            	$query = "SELECT id
                                FROM #__bid_auctions
                                WHERE UTC_TIMESTAMP() > DATE_ADD( closed_date, INTERVAL $interval
                                {$d_opt_sql} )
                                AND (close_offer =1
                                or  close_by_admin=1)";
                $database->setQuery($query);
                $idx = $database->loadResultArray(); //select auctions that have to be purged
    
    
                $row =  JTable::getInstance('auction');
                if (count($idx)) {
                    foreach ($idx as $id){
                        $row->delete($id);
                    }
                }
        	}

            $model= JModelLegacy::getInstance('Currency','JTheFactoryModel');
            $currtable= JTable::getInstance('CurrencyTable','JTheFactory');
    
            $currencies=$model->getCurrencyList();
            $default_currency=$model->getDefault();
            $results=array();
            foreach($currencies as $currency){
                if ($currency->name==$default_currency){
                    $currtable->load($currency->id);
                    $currtable->convert=1;
                    $currtable->store();
                    $results[]=$currency->name." ---> ".$default_currency." = 1";
                    continue;
                }
                $conversion=$model->getGoogleCurrency($currency->name,$default_currency);
                if ($conversion===false){
                    $results[]=JText::_("COM_BIDS_ERROR_CONVERTING")." {$currency->name} --> $default_currency";
                    continue;
                }
                $currtable->load($currency->id);
                $currtable->convert=$conversion;
                $currtable->store();
                $results[]=$currency->name." ---> ".$default_currency." = $conversion ";
            }
            $logtext.=implode("\r\n",$results);
            $logtext.="\r\n";
            //some cleanup
        	
        }
        $log->log=$logtext;
        $log->store();
        if ($debug) return;
        ob_clean();
        exit();
        

    }
Beispiel #6
0
    function display($tmpl) {

        jimport('joomla.html.parameter');

        $cfg = BidsHelperTools::getConfig();

        $model = $this->getModel('auctions');
        $items = $model->get('auctions');

        $lists=array();

		$gallery = BidsHelperGallery::getGalleryPlugin();

        $i=0;
        foreach($items as $k=>&$item) {

            $item->rownr = ++$i;
            $item->params = new JParameter($item->params);

            $gallery->clearImages();
            $gallery->addImageList(explode(',',$item->pictures));
            $item->thumbnail = $gallery->getThumbImage();

            $item->start_date_text = JHTML::_('auctiondetails.startDateHtml', $item);

            $item->description = JFilterOutput::cleanText($item->description);
            $item->shortdescription = JFilterOutput::cleanText($item->shortdescription);

            $item->tagIds = $item->tagIds ? explode(',', $item->tagIds) : array();
            $item->tagNames = $item->tagNames ? explode(',', $item->tagNames) : array();

            $item->links = JHTML::_('auctiondetails.createLinks',$item);
            if (!isset($item->favorite))
                $item->favorite = false;
            $item->del_from_watchlist = (bool) $item->favorite;
            $item->add_from_watchlist = !$item->del_from_watchlist;

            if ($cfg->bid_opt_multiple_shipping) {
                $p = JTable::getInstance('bidshipzone');
                $item->shipping_zones = $p->getPriceList($item->id);
            }

            BidsHelperAuction::renderAuctionTiming($item);
            $item->countdownHtml = JHTML::_('auctiondetails.countdownHtml',$item);

            if ( BidsHelperDateTime::getTimeStamp($item->end_date) <= time() ) {
                $item->expired = true;
            } else {
                $item->expired = false;
            }

            $item->start_date_text = JHTML::_('auctiondetails.startDateHtml', $item);
            $item->end_date_text = JHTML::_('auctiondetails.endDateHtml', $item);

            BidsHelperAuction::setAuctionStatus($item);

            if ($item->params->get('max_price', '1') == 0 || $item->auction_type == AUCTION_TYPE_PRIVATE) {
                $item->highest_bid = null;
            }

            $lists['bidderPaypalButton'][$item->id] = isset($item->wonBids) ? JHTML::_('auctiondetails.bidderPaypalButton',$item) : null;
        }

        $this->assign('positions', array());

        $filter_type = $model->getState('filters.filter_type');
        $filter_bidtype = $model->getState('filters.filter_bidtype');
        $filter_archive = $model->getState('filters.filter_archive');
        $filter_order = $model->getState('filters.filter_order');
        $filter_order_Dir = $model->getState('filters.filter_order_Dir');
        $pagination = $model->get('pagination');

        $lists['archive'] = JHTML::_('listauctions.selectMyFilter', $model->getState('filters.filter_archive'));
        $lists['filter_bidtype'] = JHTML::_('listauctions.selectBidType', $model->getState('filters.filter_bidtype') );
        $lists['orders'] = JHTML::_('listauctions.selectOrder',$filter_order);
        $lists['filter_order_asc'] = JHTML::_('listauctions.selectOrderDir', $filter_order_Dir);
        $lists['filter_cats'] = JHTML::_('listAuctions.selectCategory', $model->getState('filters.cat'));
        $lists['inputKeyword'] = JHTML::_('listAuctions.inputKeyword', $model->getState('filters.keyword'));
        $filters = $model->getFilters();
        $lists['inputsHiddenFilters'] = JHTML::_('listAuctions.inputsHiddenFilters', $filters );
        $lists['htmlLabelFilters'] = JHTML::_('listAuctions.htmlLabelFilters', $filters, false );
        $lists['resetFilters'] = JHTML::_('listAuctions.linkResetFilters', $model->getState('behavior'));

        $this->assign('lists', $lists);

        $uri = JFactory::getURI();
        $this->assign("action", JRoute::_(JFilterOutput::ampReplace($uri->toString())));
        $this->assign("auction_rows", $items);

        $this->assign("filter_type", $filter_type);
        $this->assign("filter_bidtype", $filter_bidtype);
        $this->assign("filter_order_Dir", $filter_order_Dir);
        $this->assign("reverseorder_Dir", $filter_order_Dir=='ASC' ? 'ASC' : 'DESC' );
        $this->assign("filter_order", $filter_order);
        $this->assign("filter_archive", $filter_archive);
        $this->assign("pagination", $pagination);

        JHTML::script( JURI::root().'components/com_bids/js/jquery/jquery.js' );
        JHTML::script( JURI::root().'components/com_bids/js/jquery/jquery.noconflict.js' );

        JHTML::script( JURI::root().'components/com_bids/js/ratings.js' );
        JHTML::script( JURI::root().'components/com_bids/js/startup.js' );

        JHTML::_('behavior.modal');
        JHTML::_('behavior.tooltip');

        BidsHelperHtml::loadCountdownJS();

        parent::display($tmpl);
    }
Beispiel #7
0
    function autoExtend() {

        $cfg = BidsHelperTools::getConfig();

        $endTime = BidsHelperDateTime::getTimeStamp($this->auction->end_date);
        $remainingTime = $endTime - time();

        $endingRange = $cfg->bid_opt_auto_extent_limit * BidsHelperDateTime::translateAutoextendPeriod($cfg->bid_opt_auto_extent_limit_type);

        if ( (0 < $remainingTime) && ($remainingTime < $endingRange) ) {

            $extendOffset = $cfg->bid_opt_auto_extent_offset * BidsHelperDateTime::translateAutoextendPeriod($cfg->bid_opt_auto_extent_offset_type);
            $this->auction->end_date = $endTime + $extendOffset;
            $this->auction->end_date = gmdate('Y-m-d H:i:s', $this->auction->end_date);
            $this->auction->extended_counter += 1;

            $this->store(true);
        }
    }