Current File : /home/pacjaorg/public_html/km/components/com_djclassifieds/views/item/tmpl/default_auctions.php
<?php
/**
 * @package DJ-Classifieds
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */

defined ('_JEXEC') or die('Restricted access');

JHtml::_('jquery.framework');

$app = JFactory::getApplication();
$user = JFactory::getUser();
$par = $this->par;
$item = $this->item;
$bid_active = $this->bid_active;
$min_bid = $this->min_bid;

$auction_cl = 'row_gd';
if($par->get('auctions_position','top')=='middle'){
	$auction_cl = 'row_content';	
}elseif($par->get('auctions_position','top')=='bottom'){
	$auction_cl = 'row_bottom';
}

?>

<div class="auction <?php echo $auction_cl;?>" id="auctions">
	<?php echo DJClassifiedsTheme::renderLayout('auctionform', array('bids' => $this->bids, 'item' => $this->item, 'show_form' => true, 'bid_active' => $bid_active, 'min_bid' => $min_bid, 'user' => JFactory::getUser(), 'par' => $par)); ?>
</div>

<?php if($bid_active){ ?>
	<script>
		jQuery(function($){
			startBid();
			var modal_shown = false;
			var bid_interval = setInterval(function(){
				var ajax_data = {
					'option': 'com_djclassifieds',
					'view': 'item',
					'task': 'loadBids',
					'item_id': '<?php echo $item->id; ?>',
					'user_id': '<?php echo $user->id; ?>'
				};
				jQuery.ajax({
					url: '<?php echo JRoute::_('index.php'); ?>',
					type: 'post',
					data: ajax_data
				}).done(function (response, textStatus, jqXHR){
					if(textStatus == 'success' && response){
						var $new_bids = $(response).filter('.auction_bids');
						$('#auctions .auction_bids').attr('data-date-exp', $new_bids.attr('data-date-exp'));
						$('#auctions .auction_bids').attr('data-date-now', $new_bids.attr('data-date-now'));
						if(!modal_shown && $new_bids.text().split(' ').join('').split('\n').join('').split('\r').join('') != $('#auctions .auction_bids').text().split(' ').join('').split('\n').join('').split('\r').join('')){
							$('#auctions .auction_bids').replaceWith($new_bids);
							loadPrice();
							$('#auctions .auction_bids .modal').on('show.bs.modal', function(){ // contact form modals
								modal_shown = true;
								var iframe = jQuery(this).attr('data-iframe');
								if(iframe){
									jQuery(this).find('.modal-body').html(iframe);
								}
							}).on('hidden.bs.modal', function(){
								modal_shown = false;
							});
						}

						var $new_bids_form = $(response).filter('.bids_form');
						if($new_bids_form.text().split(' ').join('').split('\n').join('').split('\r').join('') != $('#auctions .bids_form').text().split(' ').join('').split('\n').join('').split('\r').join('')){
							$('#auctions .bids_form').replaceWith($new_bids_form);
							loadPrice();
							if($new_bids_form.find('.bids_box').length){ // bids form fresh load
								startBid();
							}
							if($new_bids_form.find('.bids_close_info').length){ // auction closed
								clearInterval(bid_interval);
							}
						}
					}
				});
			}, 1000);
		});

		function loadPrice()
		{
			var ajax_data = {
				'option': 'com_djclassifieds',
				'view': 'item',
				'task': 'loadPrice',
				'item_id': '<?php echo $item->id; ?>'
			};
			jQuery.ajax({
				url: '<?php echo JRoute::_('index.php'); ?>',
				type: 'post',
				data: ajax_data
			}).done(function (response, textStatus, jqXHR){
				if(textStatus == 'success' && response){
					jQuery('.price_wrap').html(jQuery(response).filter('.price_wrap').html());
				}
			});
		}
		
		var bidTimeout;
		function startBid(){
			jQuery('#bid_submit').on('click', function(event){
				var bid_form = document.getElementById('djbids_form');
				var bid_box = document.getElementById('auctions');
				var bid_value = document.getElementById('djbid_value').value;

				if(bid_value > 0){
					bid_form.innerHTML = '<div class="djloader" style="text-align:center;"><img src="<?php echo JUri::root().DJClassifiedsTheme::getImgAssetPath('loading.gif'); ?>" /></div>';

					var ajax_data = {
						'option': 'com_djclassifieds',
						'view': 'item',
						'task': 'saveBid',
						'id': '<?php echo $item->id; ?>',
						'bid': bid_value
					};

					jQuery.ajax({
						url: '<?php echo JRoute::_('index.php'); ?>',
						type: 'post',
						data: ajax_data
					}).done(function (response, textStatus, jqXHR){
						if(textStatus == 'success' && response){
							bid_box.innerHTML = response;
							startBid();
							loadPrice();
							jQuery(document).trigger('djclassifieds.loaded', {context: 'item', client: 'site', ajax_data: ajax_data});
						}
					});
				}else{
					jQuery('#djbids_form').after('<div id="djbid_alert" class="djbid-msg"><?php echo DJClassifiedsTheme::sanitizeText(JText::_('COM_DJCLASSIFIEDS_PLEASE_ENTER_BID_VALUE')); ?></div>');
				}

				clearTimeout(bidTimeout);
				bidTimeout = setTimeout(function(){
					jQuery('#djbid_alert, #djbid_message').remove();
				}, 3000);
			});
		}
	</script>
<?php } ?>

<?php if($bid_active && $par->get('auction_timer','0') && $item->date_exp < '2038-01-01'){ ?>
	<?php echo DJClassifiedsTheme::renderLayout('auctiontimer', array('item' => $this->item, 'par' => $par)); ?>
<?php } ?>
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!