diff --git a/src/com_tjnotifications/admin/access.xml b/src/com_tjnotifications/admin/access.xml new file mode 100644 index 00000000..d3ffdf84 --- /dev/null +++ b/src/com_tjnotifications/admin/access.xml @@ -0,0 +1,11 @@ + + +
+ + + + + + +
+
diff --git a/src/com_tjnotifications/admin/assets/css/tjnotifcations.css b/src/com_tjnotifications/admin/assets/css/tjnotifcations.css new file mode 100644 index 00000000..bbb6f4eb --- /dev/null +++ b/src/com_tjnotifications/admin/assets/css/tjnotifcations.css @@ -0,0 +1,3 @@ +.minwidth-150px{min-width:150px} +.minwidth-100px{min-width:100px} +.table-responsive{width:100%;margin-bottom:15px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;-ms-overflow-style:-ms-autohiding-scrollbar} diff --git a/src/com_tjnotifications/admin/config.xml b/src/com_tjnotifications/admin/config.xml new file mode 100644 index 00000000..c11dd164 --- /dev/null +++ b/src/com_tjnotifications/admin/config.xml @@ -0,0 +1,12 @@ + + +
+ + + + +
+
+ +
+
diff --git a/src/com_tjnotifications/admin/controllers/log.php b/src/com_tjnotifications/admin/controllers/log.php new file mode 100644 index 00000000..8e61b5e2 --- /dev/null +++ b/src/com_tjnotifications/admin/controllers/log.php @@ -0,0 +1,23 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\MVC\Controller\FormController; + +/** + * Log Controller + * + * @since 1.1.0 + */ +class TjnotificationsControllerLog extends FormController +{ +} diff --git a/src/com_tjnotifications/admin/controllers/logs.php b/src/com_tjnotifications/admin/controllers/logs.php new file mode 100644 index 00000000..1893314a --- /dev/null +++ b/src/com_tjnotifications/admin/controllers/logs.php @@ -0,0 +1,38 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\MVC\Controller\AdminController; + +/** + * Logs controller class. + * + * @since 1.1.0 + */ +class TjnotificationsControllerLogs extends AdminController +{ + /** + * Proxy for getModel. + * + * @param string $name The name of the model. + * @param string $prefix The prefix for the PHP class name. + * @param array $config Array of configuration parameters. + * + * @return JModelLegacy + * + * @since 1.1.0 + */ + public function getModel($name = 'log', $prefix = 'TjnotificationsModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/src/com_tjnotifications/admin/helpers/tjnotifications.php b/src/com_tjnotifications/admin/helpers/tjnotifications.php index d15d15bd..f2a034b2 100644 --- a/src/com_tjnotifications/admin/helpers/tjnotifications.php +++ b/src/com_tjnotifications/admin/helpers/tjnotifications.php @@ -17,7 +17,7 @@ * @subpackage com_tjnotifications * @since 2.2 */ -class TjnotificationsHelper +class TjnotificationsHelper extends JHelperContent { /** * Configure the Linkbar. @@ -63,5 +63,17 @@ public static function addSubmenu($view = '') } } } + + JHtmlSidebar::addEntry( + JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONS'), + 'index.php?option=com_tjnotifications&view=notifications', + $view == 'notifications' + ); + + JHtmlSidebar::addEntry( + JText::_('COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONLOGS'), + 'index.php?option=com_tjnotifications&view=logs', + $view == 'logs' + ); } } diff --git a/src/com_tjnotifications/admin/language/en-GB.com_tjnotifications.ini b/src/com_tjnotifications/admin/language/en-GB.com_tjnotifications.ini index 141f6b92..1f1c2b26 100644 --- a/src/com_tjnotifications/admin/language/en-GB.com_tjnotifications.ini +++ b/src/com_tjnotifications/admin/language/en-GB.com_tjnotifications.ini @@ -93,3 +93,54 @@ COM_TJNOTIFICATIONS_CORE_TEMPLATE_VALUE="No" COM_TJNOTIFICATIONS_TAGS_DESC="Enter the tag given on left in to the editor these tag names will be replaced by description given in notification template" COM_TJNOTIFICATIONS_REPLACEMENT_TAGS="Replacement Tag" COM_TJNOTIFICATIONS_REPLACEMENT_TAGS_DESC="Description" +; Since v1.1.0 +COM_TJNOTIFICATION="Notifications" +COM_TJNOTIFICATIONS_ALLOW_SAVE_OPTION="Enable logs?" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_SUBJECT="Subject" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_KEY="Key" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_TITLE="Title" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_PROVIDER="Provider" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_FROM="From" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_TO="To" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_CC="CC" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_BCC="BCC" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_DATE="Date" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_STATE="State" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_PARAMS="Params" +COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONS="Notifications" +COM_TJNOTIFICATIONS_TITLE_NOTIFICATIONLOGS="Notifications Logs" +COM_TJNOTIFICATIONS_LOGS="Logs" +COM_TJLMS_EXPORT_FILE_SUCCESS="Download complete" +COM_TJNOTIFICATIONS_VIEW_EMAIL_BODY="Email Body" +COM_TJNOTIFICATIONS_VIEW_EMAIL_POPUP_CLOSE="Close" +COM_TJNOTIFICATIONS_VIEW_PARAMS_POPUP="Show Params" +COM_TJNOTIFICATIONS_FIELD_PROVIDER_LABEL="Provider" +COM_TJNOTIFICATIONS_FIELD_PROVIDER_DESC="The provider that is defining the notifications" +COM_TJNOTIFICATIONS_PROVIDER_EMAIL="Email" +COM_TJNOTIFICATIONS_PROVIDER_SMS="SMS" +COM_TJNOTIFICATIONS_PROVIDER_PUSH="Push Message" +COM_TJNOTIFICATIONS_FIELD_KEY_LABEL="Key" +COM_TJNOTIFICATIONS_FIELD_KEY_DESC="The key that is defining the notifications" +COM_TJNOTIFICATIONS_FIELD_KEY_OPTION="-- Select Key --" +COM_TJNOTIFICATIONS_EXPORT_FILE_SUCCESS="Download Complete" +COM_TJNOTIFICATIONS_EXPORT_FILE_ERROR="Something went wrong." +COM_TJNOTIFICATIONS_EXPORT_FILE_NOTICE="Do not click anywhere or refresh the page until CSV download successfully." +COM_TJNOTIFICATIONS_FIELD_STATE_LABEL="State" +COM_TJNOTIFICATIONS_FIELD_STATE_OPTION="-- Select State --" +COM_TJNOTIFICATIONS_STATE_SENT="Sent" +COM_TJNOTIFICATIONS_STATE_FAILED="Failed" +COM_TJNOTIFICATIONS_LIST_LOGS="List Logs" +COM_TJNOTIFICATIONS_EMPTY_PARAMS="-" +COM_TJNOTIFICATIONS_APPLICATION_OPTION_DESC="Enable logs?" +COM_TJNOTIFICATIONS_PROVIDER_WEB="Web" +COM_TJNOTIFICATIONS_VIEW_NOTIFICATIONS_DEFAULT_FIELD_BODY="Body" +COM_TJNOTIFICATIONS_TITLE_VIEW_CONTENTS="View Content" +COM_TJNOTIFICATIONS_STATE_SENT="Sent" +COM_TJNOTIFICATIONS_STATE_FAILED="Failed" +COM_TJNOTIFICATIONS_FIELD_NOTIFICATION_BODY_LABEL="Notification Body" +COM_TJNOTIFICATIONS_LIST_LOGS_DESC="List all notifiaction logs" +; permissions +JACTION_VIEW="View" +JACTION_VIEW_COMPONENT_DESC="Allow user to view notifications logs" +JACTION_EXPORT="Export" +JACTION_EXPORT_COMPONENT_DESC="Allow user to export notifications logs data" diff --git a/src/com_tjnotifications/admin/models/forms/filter_logs.xml b/src/com_tjnotifications/admin/models/forms/filter_logs.xml new file mode 100644 index 00000000..558ecc03 --- /dev/null +++ b/src/com_tjnotifications/admin/models/forms/filter_logs.xml @@ -0,0 +1,23 @@ + +
+ + + + + + + + + + + + + + + + + + + + +
diff --git a/src/com_tjnotifications/admin/models/log.php b/src/com_tjnotifications/admin/models/log.php new file mode 100644 index 00000000..45c557c5 --- /dev/null +++ b/src/com_tjnotifications/admin/models/log.php @@ -0,0 +1,62 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +jimport('joomla.application.component.model'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; + +/** + * Log model. + * + * @since 1.1.0 + */ +class TjnotificationsModelLog extends AdminModel +{ + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return JForm|boolean A JForm object on success, false on failure + * + * @since 1.1.0 + */ + public function getForm($data = array(), $loadData = true) + { + // Get the form. + $form = $this->loadForm('com_tjnotifications.log', 'log', array('control' => 'jform', 'load_data' => $loadData)); + + if (empty($form)) + { + return false; + } + + return $form; + } + + /** + * Returns a Table object, always creating it. + * + * @param string $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + */ + public function getTable($type = 'Log', $prefix = 'TjnotificationsTable', $config = array()) + { + return Table::getInstance($type, $prefix, $config); + } +} diff --git a/src/com_tjnotifications/admin/models/logs.php b/src/com_tjnotifications/admin/models/logs.php new file mode 100644 index 00000000..e305ffa4 --- /dev/null +++ b/src/com_tjnotifications/admin/models/logs.php @@ -0,0 +1,153 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +jimport('joomla.application.component.model'); + +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\ListModel; + +/** + * notifications model. + * + * @since 1.1.0 + */ +class TjnotificationsModelLogs extends ListModel +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * + * @see JController + * @since 1.1.0 + */ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'id', 'tjl.id', + 'to', 'tjl.to', + 'key', 'tjl.key', + 'from', 'tjl.from', + 'cc', 'tjl.cc', + 'state', 'tjl.state', + 'subject', 'tjl.subject', + 'search' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + * @since 1.1.0 + */ + protected function populateState($ordering = 'tjl.id', $direction = 'desc') + { + $app = Factory::getApplication(); + + // Load the filter search + $search = $app->getUserStateFromRequest($this->context . 'filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + parent::populateState($ordering, $direction); + + // Get pagination request variables + $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); + $limitstart = Factory::getApplication()->input->post->get('limitstart'); + + // In case limit has been changed, adjust it + $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); + + $this->setState('list.limit', $limit); + $this->setState('list.start', $limitstart); + } + + /** + * Build an SQL query to load the list data. + * + * @return JDatabaseQuery + * + * @since 1.1.0 + */ + protected function getListQuery() + { + // Initialize variables. + $db = Factory::getDbo(); + $query = $db->getQuery(true); + + // Create the base select statement. + $query->select('*') + ->from($db->quoteName('#__tj_notification_logs', 'tjl')); + + $search = $this->getState('filter.search'); + + // Filter by client + $client = $this->getState('filter.client'); + + if ($client) + { + $query->where($db->quoteName('tjl.client') . ' = ' . $db->quote($client)); + } + + // Filter by provider + $provider = $this->getState('filter.provider'); + + if ($provider) + { + $query->where($db->quoteName('tjl.provider') . ' = ' . $db->quote($provider)); + } + + // Filter by key + $key = $this->getState('filter.key'); + + if ($key) + { + $query->where($db->quoteName('tjl.key') . ' = ' . $db->quote($key)); + } + + // Filter by client + $state = $this->getState('filter.state'); + + if (is_numeric($state)) + { + $query->where($db->quoteName('tjl.state') . ' = ' . $db->quote($state)); + } + + if (!empty($search)) + { + $like = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); + $query->where($db->quoteName('tjl.subject') . ' LIKE ' . $like . ' OR ' . $db->quoteName('tjl.from') . ' LIKE ' . $like . ' OR ' . $db->quoteName('tjl.to') . ' LIKE ' . $like); + } + + $orderCol = $this->getState('list.ordering'); + $orderDirn = $this->getState('list.direction'); + + if ($orderCol && $orderDirn) + { + $query->order($db->quoteName($orderCol) . ' ' . $db->escape($orderDirn)); + } + + return $query; + } +} diff --git a/src/com_tjnotifications/admin/sql/updates/mysql/1.1.0.sql b/src/com_tjnotifications/admin/sql/updates/mysql/1.1.0.sql new file mode 100644 index 00000000..1329e125 --- /dev/null +++ b/src/com_tjnotifications/admin/sql/updates/mysql/1.1.0.sql @@ -0,0 +1,25 @@ +-- +-- Notifications Logs Tables : Table structure for table `#__tj_notification_logs` +-- +CREATE TABLE IF NOT EXISTS `#__tj_notification_logs` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `key` varchar(100) NOT NULL, + `client` varchar(100) NOT NULL, + `provider` varchar(50) NOT NULL, + `subject` varchar(250) NOT NULL, + `title` varchar(100) NOT NULL, + `body` text NOT NULL, + `from` varchar(500) NOT NULL, + `to` text NOT NULL, + `cc` text NOT NULL, + `bcc` text NOT NULL, + `date` datetime NOT NULL, + `state` tinyint(2) NOT NULL, + `params` text NOT NULL, + `priority`int(11) NOT NULL, + `message` text NOT NULL, + `category` text NOT NULL, + PRIMARY KEY (`id`) +) + DEFAULT CHARSET=utf8 + AUTO_INCREMENT=0 ; diff --git a/src/com_tjnotifications/admin/tables/log.php b/src/com_tjnotifications/admin/tables/log.php new file mode 100644 index 00000000..0221bc86 --- /dev/null +++ b/src/com_tjnotifications/admin/tables/log.php @@ -0,0 +1,32 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Table\Table; + +/** + * table class for notification + * + * @since 1.1.0 + */ +class TjnotificationsTableLog extends Table +{ + /** + * Constructor + * + * @param JDatabase &$db A database connector object + */ + public function __construct(&$db) + { + parent::__construct('#__tj_notification_logs', 'id', $db); + } +} diff --git a/src/com_tjnotifications/admin/views/logs/index.html b/src/com_tjnotifications/admin/views/logs/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/body.php b/src/com_tjnotifications/admin/views/logs/tmpl/body.php new file mode 100644 index 00000000..7f2cb50b --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/body.php @@ -0,0 +1,38 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Table\Table; + +$jinput = Factory::getApplication()->input; +$logId = $jinput->get('id', 0, 'INT'); + +if ($logId) +{ + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjnotifications/tables'); + $logTable = Table::getInstance('Log', 'TjnotificationsTable'); + $logTable->load(array('id' => $logId)); +} +?> +
+ id) : ?> + +
+ body; ?> +
+ +
+ diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/default.php b/src/com_tjnotifications/admin/views/logs/tmpl/default.php new file mode 100644 index 00000000..4b0d8c27 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/default.php @@ -0,0 +1,169 @@ + +* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +*/ +// No direct access to this file +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Layout\LayoutHelper; +use Joomla\CMS\Router\Route; +use Joomla\CMS\Language\Text; + +HTMLHelper::_('behavior.modal', 'a.modal'); +HTMLHelper::_('formbehavior.chosen', 'select'); + +$listOrder = $this->escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); + +$doc = Factory::getDocument(); +$doc->addStyleSheet(JUri::root() . 'administrator/components/com_tjnotifications/assets/css/tjnotifcations.css'); +?> + +
+sidebar)) : ?> +
+ sidebar; ?> +
+
+ +
+ + $this, 'options' => array('filterButton' => 1,'filtersHidden' => 0))); + ?> +
+ + pagination->getLimitBox(); ?> +
+
+ + + + + + + + + + + + + + + + + + + + items)) : ?> + items as $i => $row) :?> + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ id); ?> + + subject, ENT_COMPAT, 'UTF-8'); ?> + + + + + + ', $row->to); ?> + + ', $row->cc); ?> + + ', $row->bcc); ?> + + date, ENT_COMPAT, 'UTF-8'); ?> + + state === 1) ? Text::_('COM_TJNOTIFICATIONS_STATE_SENT') : Text::_('COM_TJNOTIFICATIONS_STATE_FAILED'); + ?> + + key, ENT_COMPAT, 'UTF-8'); ?> + + provider, ENT_COMPAT, 'UTF-8'); ?> + + from, ENT_COMPAT, 'UTF-8'); ?> + + params)): ?> + + + + + + + + id, ENT_COMPAT, 'UTF-8'); ?> +
+
+ pagination->getListFooter(); ?> + + + + + +
+
+
diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/default.xml b/src/com_tjnotifications/admin/views/logs/tmpl/default.xml new file mode 100644 index 00000000..c2620b17 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/default.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/index.html b/src/com_tjnotifications/admin/views/logs/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/com_tjnotifications/admin/views/logs/tmpl/param.php b/src/com_tjnotifications/admin/views/logs/tmpl/param.php new file mode 100644 index 00000000..a616cb37 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/tmpl/param.php @@ -0,0 +1,36 @@ + +* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +*/ +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Table\Table; + +$jinput = Factory::getApplication()->input; +$logId = $jinput->get('id', 0, 'INT'); + +if ($logId) +{ + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjnotifications/tables'); + $logTable = Table::getInstance('Log', 'TjnotificationsTable'); + $logTable->load(array('id' => $logId)); +} +?> +
+ id) : ?> + +
+ params; ?> +
+ +
diff --git a/src/com_tjnotifications/admin/views/logs/view.csv.php b/src/com_tjnotifications/admin/views/logs/view.csv.php new file mode 100644 index 00000000..76bab208 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/view.csv.php @@ -0,0 +1,34 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die('Restricted access'); + +jimport('techjoomla.view.csv'); + +/** + * View class for a list of notifications logs. + * + * @since 1.1.0 + */ +class TjnotificationsViewLogs extends TjExportCsv +{ + /** + * Display the view + * + * @param string $tpl The name of the template file to parse; automatically searches through the template paths. + * + * @return mixed A string if successful, otherwise an Error object. + */ + public function display($tpl = null) + { + parent::display(); + } +} diff --git a/src/com_tjnotifications/admin/views/logs/view.html.php b/src/com_tjnotifications/admin/views/logs/view.html.php new file mode 100644 index 00000000..823aef55 --- /dev/null +++ b/src/com_tjnotifications/admin/views/logs/view.html.php @@ -0,0 +1,89 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +jimport('joomla.application.component.view'); +JLoader::register('TjnotificationsHelper', JPATH_ADMINISTRATOR . '/components/com_tjnotifications/helpers/tjnotifications.php'); + +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Toolbar\Toolbar; + +/** + * View class for a list of notifications logs. + * + * @since 1.1.0 + */ +class TjnotificationsViewLogs extends HtmlView +{ + /** + * Display the view + * + * @param string $tpl Template name + * + * @return void + * + * @throws Exception + */ + public function display($tpl = null) + { + $this->canDo = JHelperContent::getActions('com_tjnotifications'); + + $this->state = $this->get('State'); + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + + TjnotificationsHelper::addSubmenu('logs'); + + // Set the tool-bar and number of found items + $this->addToolBar(); + + $this->sidebar = JHtmlSidebar::render(); + + parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * + * @since 1.1.0 + */ + protected function addToolBar() + { + ToolbarHelper::title(Text::_('COM_TJNOTIFICATIONS_LOGS'), 'list'); + + if ($this->canDo->get('core.export')) + { + // Adding techjoomla library for csv Export + jimport('techjoomla.tjtoolbar.button.csvexport'); + + $bar = Toolbar::getInstance('toolbar'); + + $message = array(); + $message['success'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_SUCCESS"); + $message['error'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_ERROR"); + $message['inprogress'] = Text::_("COM_TJNOTIFICATIONS_EXPORT_FILE_NOTICE"); + + $bar->appendButton('CsvExport', $message); + } + + if ($this->canDo->get('core.delete')) + { + ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'logs.delete', 'JTOOLBAR_DELETE'); + } + } +} diff --git a/src/com_tjnotifications/admin/views/notification/tmpl/edit.php b/src/com_tjnotifications/admin/views/notification/tmpl/edit.php index e7b822f6..bf7421a9 100644 --- a/src/com_tjnotifications/admin/views/notification/tmpl/edit.php +++ b/src/com_tjnotifications/admin/views/notification/tmpl/edit.php @@ -4,7 +4,13 @@ defined('_JEXEC') or die; JHtml::_('formbehavior.chosen','select'); JHtml::_('behavior.formvalidator'); +use Joomla\CMS\Language\Text; + $today= gmdate('Y-m-d'); + +$options['relative'] = true; + +JHtml::_('script', 'com_tjnotifications/template.js', $options); ?> diff --git a/src/com_tjnotifications/admin/views/notification/view.html.php b/src/com_tjnotifications/admin/views/notification/view.html.php index dff5fa7e..8b008b68 100644 --- a/src/com_tjnotifications/admin/views/notification/view.html.php +++ b/src/com_tjnotifications/admin/views/notification/view.html.php @@ -83,6 +83,10 @@ protected function addToolBar() JToolBarHelper::apply('notification.editSave', 'JTOOLBAR_APPLY'); JToolBarHelper::save('notification.saveClose', 'JTOOLBAR_SAVE'); JToolBarHelper::custom('notification.saveNew', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + + // Add preview toolbar + JToolbarHelper::modal('templatePreview', 'icon-eye', 'COM_TJNOTIFICATIONS_TEMPLATE_PREVIEW'); + JToolBarHelper::cancel('notification.cancel', 'JTOOLBAR_CANCEL'); } diff --git a/src/com_tjnotifications/media/js/template.js b/src/com_tjnotifications/media/js/template.js new file mode 100644 index 00000000..ffb289a8 --- /dev/null +++ b/src/com_tjnotifications/media/js/template.js @@ -0,0 +1,47 @@ +/** + * @package TJNotifications + * @subpackage com_tjnotifications + * + * @author Techjoomla + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +var template = { + + previewTemplate: function () { + + jQuery(document).on('click', 'button[data-target="#templatePreview"]', function () { + + jQuery('#show-info').hide(); + + if (typeof tinyMCE != "undefined") + { + tinyMCE.execCommand('mceToggleEditor', false, 'jform_email_body'); + } + else if (typeof CodeMirror != "undefined") + { + var editor = document.querySelector('.CodeMirror').CodeMirror; + jQuery('#jform_email_body').html(editor.getValue()); + } + else + { + jQuery('#show-info').show(); + } + + jQuery('#previewTempl').empty(); + jQuery('