Your IP : 216.73.216.170


Current Path : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_pay/models/
Upload File :
Current File : /var/www/iplanru/data/www/i-plan.ru/administrator/components/com_pay/models/payments.php

<?php

// No direct access
defined( '_JEXEC' ) or die;

/**
 * @author kirdinyuri
 */
class PayModelPayments extends JModelList
{

	/**
	 * Конструктор класса
	 * @param Array $config
	 */
	public function __construct( $config = array() )
	{
		if ( empty( $config['filter_fields'] ) ) {
			$config['filter_fields'] = array(
				'id', 'id',
				'method', 'method',
				'cs', 'cs',
				'date', 'date',
				'matid', 'matid',
				'fio', 'fio',
				'mail', 'mail',
				'adress', 'adress',
				'tel', 'tel',
				'mess', 'mess',
				'pr', 'pr'
			);
		}
		parent::__construct( $config );
	}

	/**
	 * @param String $ordering
	 * @param String $direction
	 */
	protected function populateState( $ordering = null, $direction = null )
	{
		if ( $layout = JFactory::getApplication()->input->get( 'layout' ) ) {
			$this->context .= '.' . $layout;
		}
		/*$search = $this->getUserStateFromRequest( $this->context . '.filter.search', 'filter_search' );
		$this->setState( 'filter.search', $search );
		$published = $this->getUserStateFromRequest( $this->context . '.filter.published', 'filter_published', '' );
		$this->setState( 'filter.published', $published );*/
		/*$authorId = $this->getUserStateFromRequest( $this->context . '.filter.author_id', 'filter_author_id' );
		$this->setState( 'filter.author_id', $authorId );*/
		
		$method = $this->getUserStateFromRequest($this->context . '.filter.method', 'filter_method');	
		$this->setState('filter.method', $method);
		$pr = $this->getUserStateFromRequest($this->context . '.filter.pr', 'filter_pr');	
		$this->setState('filter.pr', $pr);
		
		parent::populateState( 'id', 'desc' );
	}

	/**
	 * @param string $id
	 * @return string
	 */
	protected function getStoreId( $id = '' )
	{
		$id .= ':' . $this->getState( 'filter.search' );
		$id .= ':' . $this->getState( 'filter.published' );
		/*$id .= ':' . $this->getState( 'filter.author_id' );*/
		return parent::getStoreId( $id );
	}

	/**
	 * Составление запроса для получения списка записей
	 * @return JDatabaseQuery
	 */
	protected function getListQuery()
	{
		$query = $this->getDbo()->getQuery( true );
		$query->select('*');
		$query->from( '#__payment' );
		
		$pr = $this->getState('filter.pr'); 
		if ($pr<>'')
		{
			$query->where('pr = "'.$pr.'"');
		}
		/*$authorId = $this->getState( 'filter.author_id' );
		if ( is_numeric( $authorId ) ) {
			$query->where( 'u.id=' . $authorId );
		}*/
		/*$search = $this->getState( 'filter.search' );
		if ( !empty( $search ) ) {
			$search = $this->getDbo()->Quote( '%' . $this->getDbo()->escape( $search, true ) . '%' );
			$query->where( '(t1.title LIKE ' . $search . ' OR t1.alias LIKE ' . $search . ')' );
		}*/
		
		$method = $this->getState('filter.method');
		if (!empty($method))
		{
			if ($method=="null") $method='';
			$query->where('method = "'.$method.'"');
		}
		
		$orderCol = $this->state->get( 'list.ordering' );
		$orderDirn = $this->state->get( 'list.direction' );
		$query->order( $this->getDbo()->escape( $orderCol . ' ' . $orderDirn ) );
		return $query;
	}

	/**
	 * Авторы записей
	 * @return    JDatabaseQuery
	 */
	public function getAuthors()
	{
		$query = $this->getDbo()->getQuery( true );
		$query->select( 'u.id AS value, u.name AS text' );
		$query->from( '#__users AS u' );
		$query->join( 'INNER', '#__payment AS c ON c.created_by = u.id' );
		$query->group( 'u.id, u.name' );
		$query->order( 'u.name' );
		return $this->getDbo()->setQuery( $query )->loadObjectList();
	}
}