Это я исправил в представлении своем. Могу предположить, что нужно XML модели, или файле PHP модели?
<?php
class Plan_obuchenieModelObuchenies extends JModelList
{
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'ordering', 'a.ordering',
'state', 'a.state',
'created_by', 'a.created_by',
'modified_by', 'a.modified_by',
'nazvanie_programmi', 'a.nazvanie_programmi',
'data_nacahlo', 'a.data_nacahlo',
'data_okonchanija', 'a.data_okonchanija',
'stoimost', 'a.stoimost',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering Elements order
* @param string $direction Order direction
*
* @return void
*
* @throws Exception
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$list = $app->getUserState($this->context . '.list');
$ordering = isset($list['filter_order']) ? $list['filter_order'] : null;
$direction = isset($list['filter_order_Dir'])? $list['filter_order_Dir'] : null;
$list['limit'] = (int) JFactory::getConfig()->get('list_limit', 20);
$list['start'] = $app->input->getInt('start', 0);
$list['ordering'] = $ordering;
$list['direction'] = $direction;
$app->setUserState($this->context . '.list', $list);
$app->input->set('list', null);
// List state information.
parent::populateState($ordering, $direction);
$app = JFactory::getApplication();
$ordering = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $ordering);
$direction = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $ordering);
$this->setState('list.ordering', $ordering);
$this->setState('list.direction', $direction);
$start = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0, 'int');
$limit = $app->getUserStateFromRequest($this->context . '.limit', 'limit', 0, 'int');
if ($limit == 0)
{
$limit = $app->get('list_limit', 0);
}
$this->setState('list.limit', $limit);
$this->setState('list.start', $start);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*
* @since 1.6
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query
->select(
$this->getState(
'list.select', 'DISTINCT a.*'
)
);
$query->from('`#__plan_obuchenie_` AS a');
// Join over the users for the checked out user.
$query->select('uc.name AS uEditor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the created by field 'created_by'
$query->join('LEFT', '#__users AS created_by ON created_by.id = a.created_by');
// Join over the created by field 'modified_by'
$query->join('LEFT', '#__users AS modified_by ON modified_by.id = a.modified_by');
// Join over the foreign key 'nazvanie_programmi'
$query->select('`#__plan_obuchenie__2710829`.`nazvanie_programmi` AS obuchenies_fk_value_2710829');
$query->join('LEFT', '#__plan_obuchenie_ AS #__plan_obuchenie__2710829 ON #__plan_obuchenie__2710829.`id` = a.`nazvanie_programmi`');
if (!JFactory::getUser()->authorise('core.edit', 'com_plan_obuchenie'))
{
$query->where('a.state = 1');
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->Quote('%' . $db->escape($search, true). '%');
}
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'ordering');
$orderDirn = $this->state->get('list.direction', 'asc');
if ($orderCol && $orderDirn)
{
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
return $query;
}
/**
* Method to get an array of data items
*
* @return mixed An array of data on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
foreach ($items as $item)
{
if (isset($item->nazvanie_programmi) && $item->nazvanie_programmi != '')
{
if (is_object($item->nazvanie_programmi))
{
$item->nazvanie_programmi = \Joomla\Utilities\ArrayHelper::fromObject($item->nazvanie_programmi);
}
$values = (is_array($item->nazvanie_programmi))? $item->nazvanie_programmi : explode(',', $item->nazvanie_programmi);
$textValue = array();
foreach ($values as $value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('`#__plan_obuchenie__2710829`.`nazvanie_programmi`')
->from($db->quoteName('#__plan_obuchenie_', '#__plan_obuchenie__2710829'))
->where($db->quoteName('id'). ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results)
{
$textValue[] = $results->nazvanie_programmi;
}
}
$item->nazvanie_programmi = !empty($textValue)? implode(', ', $textValue) : $item->nazvanie_programmi;
}
}
return $items;
}
/**
* Overrides the default function to check Date fields format, identified by
* "_dateformat" suffix, and erases the field if it's not correct.
*
* @return void
*/
protected function loadFormData()
{
$app = JFactory::getApplication();
$filters = $app->getUserState($this->context . '.filter', array());
$error_dateformat = false;
foreach ($filters as $key => $value)
{
if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null)
{
$filters[$key] = '';
$error_dateformat = true;
}
}
if ($error_dateformat)
{
$app->enqueueMessage(JText::_("COM_PLAN_OBUCHENIE_SEARCH_FILTER_DATE_FORMAT"), "warning");
$app->setUserState($this->context . '.filter', $filters);
}
return parent::loadFormData();
}
/**
* Checks if a given date is valid and in a specified format (YYYY-MM-DD)
*
* @param string $date Date to be checked
*
* @return bool
*/
private function isValidDate($date)
{
$date = str_replace('/', '-', $date);
return (date_create($date))? JFactory::getDate($date)->format("Y-m-d") : null;
}
}