Current File : /home/pacjaorg/public_html/km/administrator/components/com_djclassifieds/models/payments.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');

class DjClassifiedsModelPayments extends JModelList
{
	public function __construct($config = array())
	{
		if (empty($config['filter_fields'])) {
			$config['filter_fields'] = array(
				'i_name', 'i.name',
				'pp_name', 'pp.name',
				'id', 'p.id',				
				'method', 'p.method',
				'date', 'p.date',				
				'status', 'p.status',
				'type', 'p.type',
				'subtype', 'p.type_details',
				'u.name', 'p.ip_address'
			);
		}

		parent::__construct($config);
	}
	
	protected function populateState($ordering = null, $direction = null)
	{
		// List state information.
		parent::populateState('p.id', 'desc');

		$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
		$this->setState('filter.search', $search);

		$status = $this->getUserStateFromRequest($this->context.'.filter.status', 'filter_status', '');
		$this->setState('filter.status', $status);
		
		$type = $this->getUserStateFromRequest($this->context.'.filter.type', 'filter_type', '');
		$this->setState('filter.type', $type);
			
		$subtype = $this->getUserStateFromRequest($this->context.'.filter.subtype', 'filter_subtype', '');
		$this->setState('filter.subtype', $subtype);

		$order = $this->getUserStateFromRequest($this->context.'.filter.order', 'filter_order');
		if($order){
			$this->setState('list.ordering', $order);
		}
		$order_dir = $this->getUserStateFromRequest($this->context.'.filter.order_Dir', 'filter_order_Dir');
		if($order_dir){
			$this->setState('list.direction', $order_dir);
		}
	}

	protected function getStoreId($id = '')
	{
		// Compile the store id.
		$id	.= ':'.$this->getState('filter.search');
		$id	.= ':'.$this->getState('filter.status');
		$id	.= ':'.$this->getState('filter.type');
		$id	.= ':'.$this->getState('filter.subtype');
		
		return parent::getStoreId($id);
	}
	
	public function _buildWhere()
	{		
		$app = JFactory::getApplication();
		$where= '';
		
		$status = $this->getState('filter.status');
		if ($status) {
			$where .= " AND p.status = '".$status."' ";
		}
		
		$type = $this->getState('filter.type');
		if (is_numeric($type)) {
			$where .= ' AND p.type = ' . (int) $type;
		}

		$subtype = $this->getState('filter.subtype');
		if ($type == '0' && $subtype) {
			$where .= ' AND p.type_details LIKE "%'.$subtype.'%"';
		}

		$search = $this->getState('filter.search');		
		if (!empty($search)) {
			$db = JFactory::getDBO();
			$search_id = $db->Quote($db->escape($search, true));
			$search = $db->Quote('%'.$db->escape($search, true).'%');
			$where .= " AND (i.name LIKE ".$search." OR pp.name LIKE ".$search." OR u.name LIKE ".$search." OR u.email LIKE ".$search." OR p.id=".$search_id." OR p.item_id=".$search_id.")";
		}
		
		return $where;
	}

	protected function getListQuery()
	{
		$orderCol	= $this->state->get('list.ordering');
		$orderDirn	= $this->state->get('list.direction');

		$query = "SELECT p.*, i.name as i_name, pp.name as pp_name, plan.name as plan_name, u.name as u_name, o.u_order_id, o.u_order_name, o.u_order_email, i_order_name, i_order_id, offers.item_id as offer_item_id, offers.name as offer_item_name "
		."FROM #__djcf_payments p "
		."LEFT JOIN #__djcf_items i ON i.id=p.item_id "
		."LEFT JOIN #__djcf_points pp ON pp.id=p.item_id "
		."LEFT JOIN #__djcf_plans plan ON plan.id=p.item_id "
		."LEFT JOIN (SELECT o.item_id, o.id, i.user_id as u_order_id, i.name as i_order_name, o.item_id as i_order_id, u.name as u_order_name, u.email as u_order_email
					FROM #__djcf_orders o, #__djcf_items i, #__users u WHERE o.item_id=i.id AND i.user_id=u.id ) o ON o.id=p.item_id "
		."LEFT JOIN (SELECT o.id, o.item_id, i.name FROM #__djcf_offers o INNER JOIN #__djcf_items i ON o.item_id=i.id) offers ON offers.id=p.item_id "
		."LEFT JOIN #__users u ON u.id=p.user_id "
		."WHERE 1 ".$this->_buildWhere()." "
		."ORDER BY ".$orderCol." ".$orderDirn;

		return $query;
	}
}
?>
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

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