view.html.php
123 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | /** |
| 15 | * VikAppointments API logs view. |
| 16 | * |
| 17 | * @since 1.7 |
| 18 | */ |
| 19 | class VikAppointmentsViewapilogs extends JViewVAP |
| 20 | { |
| 21 | /** |
| 22 | * VikAppointments view display method. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | function display($tpl = null) |
| 27 | { |
| 28 | $app = JFactory::getApplication(); |
| 29 | $input = $app->input; |
| 30 | $dbo = JFactory::getDbo(); |
| 31 | |
| 32 | // set the toolbar |
| 33 | $this->addToolBar(); |
| 34 | |
| 35 | $filters = array(); |
| 36 | $filters['keysearch'] = $app->getUserStateFromRequest($this->getPoolName() . '.keysearch', 'keysearch', '', 'string'); |
| 37 | $filters['id_login'] = $input->getUint('id_login', 0); |
| 38 | |
| 39 | $this->filters = $filters; |
| 40 | |
| 41 | $this->ordering = $app->getUserStateFromRequest($this->getPoolName() . '.ordering', 'filter_order', 'l.createdon', 'string'); |
| 42 | $this->orderDir = $app->getUserStateFromRequest($this->getPoolName() . '.orderdir', 'filter_order_Dir', 'DESC', 'string'); |
| 43 | |
| 44 | $lim = $app->getUserStateFromRequest('com_vikappointments.limit', 'limit', $app->get('list_limit'), 'int'); |
| 45 | $lim0 = $this->getListLimitStart($filters); |
| 46 | $navbut = ""; |
| 47 | |
| 48 | $rows = array(); |
| 49 | |
| 50 | $q = $dbo->getQuery(true) |
| 51 | ->select('SQL_CALC_FOUND_ROWS l.*') |
| 52 | ->select($dbo->qn(array('u.application', 'u.username'))) |
| 53 | ->from($dbo->qn('#__vikappointments_api_login_logs', 'l')) |
| 54 | ->leftjoin($dbo->qn('#__vikappointments_api_login', 'u') . ' ON ' . $dbo->qn('l.id_login') . ' = ' . $dbo->qn('u.id')) |
| 55 | ->where(1) |
| 56 | ->order($dbo->qn($this->ordering) . ' ' . $this->orderDir); |
| 57 | |
| 58 | if ($filters['keysearch']) |
| 59 | { |
| 60 | $q->andWhere(array( |
| 61 | $dbo->qn('u.application') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"), |
| 62 | $dbo->qn('u.username') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"), |
| 63 | $dbo->qn('l.content') . ' LIKE ' . $dbo->q("%{$filters['keysearch']}%"), |
| 64 | ), 'OR'); |
| 65 | } |
| 66 | |
| 67 | if ($filters['id_login']) |
| 68 | { |
| 69 | $q->where($dbo->qn('l.id_login') . ' = ' . $filters['id_login']); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Add support for manipulating query through the plugins. |
| 74 | * |
| 75 | * @see /site/helpers/libraries/mvc/view.php @ JViewVAP::onBeforeListQuery() |
| 76 | * |
| 77 | * @since 1.7 |
| 78 | */ |
| 79 | $this->onBeforeListQuery($q); |
| 80 | |
| 81 | $dbo->setQuery($q, $lim0, $lim); |
| 82 | $dbo->execute(); |
| 83 | |
| 84 | // assert limit used for list query |
| 85 | $this->assertListQuery($lim0, $lim); |
| 86 | |
| 87 | if ($dbo->getNumRows()) |
| 88 | { |
| 89 | $rows = $dbo->loadAssocList(); |
| 90 | $dbo->setQuery('SELECT FOUND_ROWS();'); |
| 91 | jimport('joomla.html.pagination'); |
| 92 | $pageNav = new JPagination($dbo->loadResult(), $lim0, $lim); |
| 93 | $navbut = JLayoutHelper::render('blocks.pagination', ['pageNav' => $pageNav]); |
| 94 | } |
| 95 | |
| 96 | $this->rows = $rows; |
| 97 | $this->navbut = $navbut; |
| 98 | |
| 99 | // display the template (default.php) |
| 100 | parent::display($tpl); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Setting the toolbar. |
| 105 | * |
| 106 | * @return void |
| 107 | */ |
| 108 | private function addToolBar() |
| 109 | { |
| 110 | // add menu title and some buttons to the page |
| 111 | JToolbarHelper::title(JText::translate('VAPMAINTITLEVIEWAPILOGS'), 'vikappointments'); |
| 112 | |
| 113 | JToolBarHelper::back('JTOOLBAR_BACK', 'index.php?option=com_vikappointments&view=editconfigapp'); |
| 114 | |
| 115 | if (JFactory::getUser()->authorise('core.delete', 'com_vikappointments')) |
| 116 | { |
| 117 | JToolbarHelper::deleteList(VikAppointments::getConfirmSystemMessage(), 'apilog.delete'); |
| 118 | |
| 119 | JToolbarHelper::custom('apilog.truncate', 'trash', 'trash', JText::translate('VAPDELETEALL'), false); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 |