From d12f40822989c7cf6d90c49a0b4214deb7bc026d Mon Sep 17 00:00:00 2001 From: RomanL Date: Fri, 19 Mar 2021 11:56:18 +0300 Subject: [PATCH] #3252 - core --- inc/classes/BxDolAuditGrid.php | 62 +++- inc/classes/BxDolAuditQuery.php | 87 ++++++ inc/classes/BxDolReport.php | 19 +- inc/classes/BxDolReportQuery.php | 18 +- inc/js/classes/BxDolAuditManageTools.js | 15 +- inc/js/classes/BxDolReportsManageTools.js | 37 +++ inc/js/classes/BxDolVote.js | 1 - inc/js/functions.js | 16 + install/sql/system.sql | 54 +++- template/css/manage_tools.css | 32 ++ template/css/report.css | 30 ++ template/report_by_list_with_comments.html | 22 ++ template/scripts/BxBaseAuditGrid.php | 122 +++++--- template/scripts/BxBaseAuditServices.php | 1 + template/scripts/BxBaseCmts.php | 2 +- template/scripts/BxBaseDashboardServices.php | 118 ++++++++ template/scripts/BxBaseFormView.php | 8 + .../BxBaseMenuDashboardContentManage.php | 68 +++++ .../BxBaseMenuDashboardReportsManage.php | 68 +++++ template/scripts/BxBaseReport.php | 42 +++ template/scripts/BxBaseReportsGrid.php | 276 ++++++++++++++++++ 21 files changed, 1047 insertions(+), 51 deletions(-) create mode 100644 inc/classes/BxDolAuditQuery.php create mode 100644 inc/js/classes/BxDolReportsManageTools.js create mode 100644 template/css/manage_tools.css create mode 100644 template/report_by_list_with_comments.html create mode 100644 template/scripts/BxBaseDashboardServices.php create mode 100644 template/scripts/BxBaseMenuDashboardContentManage.php create mode 100644 template/scripts/BxBaseMenuDashboardReportsManage.php create mode 100644 template/scripts/BxBaseReportsGrid.php diff --git a/inc/classes/BxDolAuditGrid.php b/inc/classes/BxDolAuditGrid.php index c589e1b499..919a4f1ade 100644 --- a/inc/classes/BxDolAuditGrid.php +++ b/inc/classes/BxDolAuditGrid.php @@ -17,6 +17,20 @@ class BxDolAuditGrid extends BxTemplGrid protected $_sFilter1Value; protected $_aFilter1Values; + protected $_sFilterProfileName; + protected $_sFilterProfileValue; + protected $_aFilterProfileValues; + + protected $_sFilterActionName; + protected $_sFilterActionValue; + protected $_aFilterActionValues; + + protected $_sFilterFromDateName; + protected $_sFilterFromDateValue; + + protected $_sFilterToDateName; + protected $_sFilterToDateValue; + public function __construct ($aOptions, $oTemplate = false) { $this->_sFilter1Name = 'module'; @@ -33,6 +47,39 @@ public function __construct ($aOptions, $oTemplate = false) $this->_aQueryAppend[$this->_sFilter1Name] = $this->_sFilter1Value; } + $this->_sFilterProfileName = 'profile'; + + $aProfiles = BxDolAuditQuery::getInstance()->getData(array('type' => 'profile_list')); + $this->_aFilterProfileValues[''] = _t('_sys_audit_filter_profile_select'); + foreach($aProfiles as $iProfile){ + $oProfile = BxDolProfile::getInstance($iProfile); + $this->_aFilterProfileValues[$iProfile] = $oProfile->getDisplayName(); + } + + $sFilterProfile = bx_get($this->_sFilterProfileName); + if(!empty($sFilterProfile)) { + $this->_sFilterProfileValue = bx_process_input($sFilterProfile); + $this->_aQueryAppend[$this->_sFilterProfileName] = $this->_sFilterProfileValue; + } + + $this->_sFilterActionName = 'action'; + + $aActions = BxDolAuditQuery::getInstance()->getData(array('type' => 'action_list')); + $this->_aFilterActionValues[''] = _t('_sys_audit_filter_action_select'); + foreach($aActions as $sAction){ + $this->_aFilterActionValues[$sAction] = _t($sAction); + } + + $sFilterAction = bx_get($this->_sFilterActionName); + if(!empty($sFilterAction)) { + $this->_sFilterActionValue = bx_process_input($sFilterAction); + $this->_aQueryAppend[$this->_sFilterActionName] = $this->_sFilterActionValue; + } + + $this->_sFilterFromDateName = 'from_date'; + $this->_sFilterToDateName = 'to_date'; + + parent::__construct ($aOptions, $oTemplate); $this->_sParamsDivider = '#-#'; @@ -44,10 +91,23 @@ public function __construct ($aOptions, $oTemplate = false) protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) { if(strpos($sFilter, $this->_sParamsDivider) !== false) - list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter); + list($this->_sFilter1Value, $this->_sFilterProfileValue, $this->_sFilterActionValue, $this->_sFilterFromDateValue, $this->_sFilterToDateValue, $sFilter) = explode($this->_sParamsDivider, $sFilter); if($this->_sFilter1Value != '') $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `content_module` = ?", $this->_sFilter1Value); + + if($this->_sFilterProfileValue != '') + $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `profile_id` = ?", $this->_sFilterProfileValue); + + if($this->_sFilterActionValue != '') + $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `action_lang_key` = ?", $this->_sFilterActionValue); + + if($this->_sFilterFromDateValue != '') + $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `added` > ?", strtotime($this->_sFilterFromDateValue)); + + if($this->_sFilterToDateValue != '') + $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `added` <= ?", strtotime($this->_sFilterToDateValue)); + if(bx_get('content_id') && is_numeric(bx_get('content_id'))) $this->_aOptions['source'] .= $this->oDb->prepareAsString(" AND `content_id` = ?", (int)bx_get('content_id')); if(bx_get('actor_id') && is_numeric(bx_get('actor_id'))) diff --git a/inc/classes/BxDolAuditQuery.php b/inc/classes/BxDolAuditQuery.php new file mode 100644 index 0000000000..d2499db3aa --- /dev/null +++ b/inc/classes/BxDolAuditQuery.php @@ -0,0 +1,87 @@ +_sTable = 'sys_audit'; + } + /** + * Prevent cloning the instance + */ + public function __clone() + { + if (isset($GLOBALS['bxDolClasses'][get_class($this)])) + trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR); + } + + /** + * Get singleton instance of the class + */ + public static function getInstance() + { + $sClass = __CLASS__; + if(!isset($GLOBALS['bxDolClasses'][__CLASS__])) + $GLOBALS['bxDolClasses'][__CLASS__] = new $sClass(); + + return $GLOBALS['bxDolClasses'][__CLASS__]; + } + + public function getData($aParams = array(), &$aItems = false) + { + $aMethod = array('name' => 'getAll', 'params' => array(0 => 'query')); + + $sSelectClause = "`sc`.*"; + $sJoinClause = $sWhereClause = $sGroupClause = $sLimitClause = ""; + $sOrderClause = "`sc`.`added` ASC"; + + if(isset($aParams['count_only']) && $aParams['count_only'] === true) { + $aMethod['name'] = 'getOne'; + $sSelectClause = "COUNT(`sc`.`id`)"; + } + + switch($aParams['type']) { + case 'profile_list': + $aMethod['name'] = 'getColumn'; + $sSelectClause = " DISTINCT `sc`.`profile_id`"; + + break; + + case 'action_list': + $aMethod['name'] = 'getColumn'; + $sSelectClause = " DISTINCT `sc`.`action_lang_key`"; + + break; + } + + if(!empty($sGroupClause)) + $sGroupClause = "GROUP BY " . $sGroupClause; + + if(!empty($sOrderClause)) + $sOrderClause = "ORDER BY " . $sOrderClause; + + $aMethod['params'][0] = "SELECT " . $sSelectClause . " + FROM `" . $this->_sTable . "` AS `sc`" . $sJoinClause . " + WHERE 1" . $sWhereClause . " " . $sGroupClause . " " . $sOrderClause. " " . $sLimitClause; + $oRv = call_user_func_array(array($this, $aMethod['name']), $aMethod['params']); + if ($aItems === false) + return $oRv; + $aItems = $oRv; + } +} + +/** @} */ diff --git a/inc/classes/BxDolReport.php b/inc/classes/BxDolReport.php index 2572b32fc7..d80dbab2ff 100644 --- a/inc/classes/BxDolReport.php +++ b/inc/classes/BxDolReport.php @@ -13,6 +13,9 @@ define('BX_DOL_REPORT_USAGE_INLINE', 'inline'); define('BX_DOL_REPORT_USAGE_DEFAULT', BX_DOL_REPORT_USAGE_BLOCK); +define('BX_DOL_REPORT_STASUS_NEW', 0); +define('BX_DOL_REPORT_STASUS_IN_PROCESS', 1); +define('BX_DOL_REPORT_STASUS_PROCESSED', 2); /** * Report any content * @@ -195,7 +198,7 @@ public function getStatCounter() $aReport = $this->_oQuery->getReport($this->getId()); return $aReport['count']; } - + /** * Actions functions */ @@ -243,6 +246,20 @@ public function isAllowedReportView($isPerformAction = false) return $this->checkAction('report_view', $isPerformAction); } + + public function changeStatusReport($iStatus, $iAuthorId, $sCmtText) + { + $iId = $this->getId(); + $aReport = $this->_oQuery->getDataById($iId); + if(!empty($this->_sObjectCmts) && ($oCmts = BxDolCmts::getObjectInstance($this->_sObjectCmts, $aReport['object_id']))) { + $oCmts->add(array( + 'cmt_author_id' => $iAuthorId, + 'cmt_parent_id' => 0, + 'cmt_text' => $sCmtText + )); + } + $this->_oQuery->changeStatusReport($iId, $iStatus, $iAuthorId); + } public function msgErrAllowedReportView() { diff --git a/inc/classes/BxDolReportQuery.php b/inc/classes/BxDolReportQuery.php index 3be9bd12c4..e39e335e06 100644 --- a/inc/classes/BxDolReportQuery.php +++ b/inc/classes/BxDolReportQuery.php @@ -28,6 +28,12 @@ public function getSqlParts($sMainTable, $sMainField) $aResult['fields'] = ", `{$this->_sTable}`.`count` as `report_count` "; return $aResult; } + + public function getDataById($iId) + { + $sQuery = $this->prepare("SELECT * FROM `{$this->_sTableTrack}` WHERE `id` = ?", $iId); + return $this->getRow($sQuery); + } public function getPerformedBy($iObjectId, $iStart = 0, $iPerPage = 0) { @@ -35,7 +41,7 @@ public function getPerformedBy($iObjectId, $iStart = 0, $iPerPage = 0) if(!empty($iPerPage)) $sLimitClause = $this->prepareAsString(" LIMIT ?, ?", $iStart, $iPerPage); - $sQuery = $this->prepare("SELECT `author_id`, `type`, `text` FROM `{$this->_sTableTrack}` WHERE `object_id`=? ORDER BY `date` DESC" . $sLimitClause, $iObjectId); + $sQuery = $this->prepare("SELECT `author_id`, `type`, `text`, `id`, `date` FROM `{$this->_sTableTrack}` WHERE `object_id`=? ORDER BY `date` DESC" . $sLimitClause, $iObjectId); return $this->getAll($sQuery); } @@ -95,6 +101,16 @@ protected function _deleteTrack($iObjectId, $iAuthorId) return false; } + + public function changeStatusReport($iId, $iStatus, $iProfileId) + { + if ($iStatus != BX_DOL_REPORT_STASUS_IN_PROCESS) + $sQuery = $this->prepare("UPDATE `{$this->_sTableTrack}` SET `status` = ? WHERE `id` = ?", $iStatus, $iId); + else + $sQuery = $this->prepare("UPDATE `{$this->_sTableTrack}` SET `status` = ?, `checked_by` = ? WHERE `id` = ?", $iStatus, $iProfileId, $iId); + $this->query($sQuery); + } + } /** @} */ diff --git a/inc/js/classes/BxDolAuditManageTools.js b/inc/js/classes/BxDolAuditManageTools.js index f80acfc922..d95ff827f8 100644 --- a/inc/js/classes/BxDolAuditManageTools.js +++ b/inc/js/classes/BxDolAuditManageTools.js @@ -22,9 +22,22 @@ function BxDolAuditManageTools(oOptions) { BxDolAuditManageTools.prototype.onChangeFilter = function (oFilter) { var $this = this; + var oFilter1 = $('#bx-grid-module-' + this._sObjNameGrid); var sValueFilter1 = oFilter1.length > 0 ? oFilter1.val() : ''; + var oFilterProfile = $('#bx-grid-profile-' + this._sObjNameGrid); + var sValueFilterProfile = oFilterProfile.length > 0 ? oFilterProfile.val() : ''; + + var oFilterAction = $('#bx-grid-action-' + this._sObjNameGrid); + var sValueFilterAction = oFilterAction.length > 0 ? oFilterAction.val() : ''; + + var oFilteFromDate = $('#bx-grid-from_date-' + this._sObjNameGrid); + var sValueFilterFromDate = oFilteFromDate.length > 0 ? oFilteFromDate.val() : ''; + + var oFilteToDate = $('#bx-grid-to_date-' + this._sObjNameGrid); + var sValueFilterToDate = oFilteToDate.length > 0 ? oFilteToDate.val() : ''; + var oSearch = $('#bx-grid-search-' + this._sObjNameGrid); var sValueSearch = oSearch.length > 0 ? oSearch.val() : ''; if (sValueSearch == _t('_sys_grid_search')) @@ -32,7 +45,7 @@ BxDolAuditManageTools.prototype.onChangeFilter = function (oFilter) { clearTimeout($this._iSearchTimeoutId); $this._iSearchTimeoutId = setTimeout(function () { - glGrids[$this._sObjNameGrid].setFilter(sValueFilter1 + $this._sParamsDivider + sValueSearch, true); + glGrids[$this._sObjNameGrid].setFilter(sValueFilter1 + $this._sParamsDivider + sValueFilterProfile + $this._sParamsDivider + sValueFilterAction + $this._sParamsDivider + sValueFilterFromDate + $this._sParamsDivider + sValueFilterToDate + $this._sParamsDivider + sValueSearch, true); }, 500); }; /** @} */ diff --git a/inc/js/classes/BxDolReportsManageTools.js b/inc/js/classes/BxDolReportsManageTools.js new file mode 100644 index 0000000000..e0a32bbfd5 --- /dev/null +++ b/inc/js/classes/BxDolReportsManageTools.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) UNA, Inc - https://una.io + * MIT License - https://opensource.org/licenses/MIT + * + * @defgroup UnaCore UNA Core + * @{ + */ + +function BxDolReportsManageTools(oOptions) { + this._iSearchTimeoutId = false; + this._sObjNameGrid = oOptions.sObjNameGrid; + this._sObjName = oOptions.sObjName == undefined ? 'oBxDolReportsManageTools' : oOptions.sObjName; + + this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect; + this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed; + this._sParamsDivider = oOptions.sParamsDivider == undefined ? '#-#' : oOptions.sParamsDivider; + + this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds; + this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams; + +} + +BxDolReportsManageTools.prototype.onChangeFilter = function (oFilter) { + var $this = this; + var oFilter1 = $('#bx-grid-filter1-' + this._sObjNameGrid); + var sValueFilter1 = oFilter1.length > 0 ? oFilter1.val() : ''; + var oSearch = $('#bx-grid-search-' + this._sObjNameGrid); + var sValueSearch = oSearch.length > 0 ? oSearch.val() : ''; + if (sValueSearch == _t('_sys_grid_search')) + sValueSearch = ''; + + clearTimeout($this._iSearchTimeoutId); + $this._iSearchTimeoutId = setTimeout(function () { + glGrids[$this._sObjNameGrid].setFilter(sValueFilter1 + $this._sParamsDivider + sValueSearch, true); + }, 500); +}; +/** @} */ diff --git a/inc/js/classes/BxDolVote.js b/inc/js/classes/BxDolVote.js index c34a671e12..4a5b39208c 100644 --- a/inc/js/classes/BxDolVote.js +++ b/inc/js/classes/BxDolVote.js @@ -70,7 +70,6 @@ BxDolVote.prototype.onVote = function(oLink, oData, onComplete) return; var oCounter = this._getCounter(oLink); - console.log(oCounter); if(oCounter && oCounter.length > 0) { oCounter.html(oData.countf); diff --git a/inc/js/functions.js b/inc/js/functions.js index 0e1342a660..5ea3176d73 100644 --- a/inc/js/functions.js +++ b/inc/js/functions.js @@ -735,6 +735,22 @@ function bx_get_notes(oSource, sModule, iContentId, oOptions, oVars) { $(window).dolPopupAjax(oOptions); } +function bx_get_report_comments(oSource, sModule, iContentId, oOptions, oVars) { + var oOptions = oOptions || {}; + var oVars = oVars || {}; + + var oOptions = $.extend({}, $.fn.dolPopupDefaultOptions, { + id: sModule + '_report_comment_' + iContentId, + url: bx_append_url_params('modules/?r=' + sModule + '/report_comment/', $.extend({ content_id: iContentId }, oVars)), + closeOnOuterClick: false, + removeOnClose: true, + onBeforeShow: function (oPopup) { + $(oPopup).find('.bx-popup-close-wrapper').removeClass('bx-def-media-desktop-hide bx-def-media-tablet-hide'); + } + }, oOptions); + + $(window).dolPopupAjax(oOptions); +} function validateLoginForm(eForm) { return true; diff --git a/install/sql/system.sql b/install/sql/system.sql index 6544570b3f..43933a5bc8 100644 --- a/install/sql/system.sql +++ b/install/sql/system.sql @@ -4061,6 +4061,8 @@ INSERT INTO `sys_objects_menu` (`object`, `title`, `set_name`, `module`, `templa ('sys_set_badges', '_sys_menu_title_set_badges', '', 'system', 6, 0, 1, 'BxTemplMenuSetBadges', ''), ('sys_social_sharing', '_sys_menu_title_social_sharing', 'sys_social_sharing', 'system', 23, 0, 1, 'BxTemplMenuSocialSharing', ''), ('sys_create_post', '_sys_menu_title_create_post', 'sys_add_content_links', 'system', 15, 0, 1, 'BxTemplMenuCreatePost', ''), +('sys_dashboard_content', '_sys_menu_title_dashboard_content_manage', 'sys_dashboard_content_manage', 'system', 15, 0, 1, 'BxTemplMenuDashboardContentManage', ''), +('sys_dashboard_reports', '_sys_menu_title_dashboard_reports_manage', 'sys_dashboard_reports_manage', 'system', 15, 0, 1, 'BxTemplMenuDashboardReportsManage', ''), ('sys_add_relation', '_sys_menu_title_add_relation', '', 'system', 6, 0, 1, 'BxTemplMenuAddRelation', ''), ('sys_vote_reactions_do', '_sys_menu_title_vote_reactions_do', '', 'system', 3, 0, 1, 'BxTemplVoteReactionsMenuDo', ''), ('sys_wiki', '_sys_menu_title_wiki', 'sys_wiki', 'system', 6, 0, 1, 'BxTemplMenuWiki', ''), @@ -4086,6 +4088,8 @@ INSERT INTO `sys_menu_sets` (`set_name`, `module`, `title`, `deletable`) VALUES ('sys_toolbar_member', 'system', '_sys_menu_set_title_toolbar_member', 0), ('sys_account_notifications', 'system', '_sys_menu_set_title_account_notifications', 0), ('sys_add_content_links', 'system', '_sys_menu_set_title_add_content', 0), +('sys_dashboard_content_manage', 'system', '_sys_menu_set_title_dashboard_content_manage', 0), +('sys_dashboard_reports_manage', 'system', '_sys_menu_set_title_dashboard_reports_manage', 0), ('sys_add_profile_links', 'system', '_sys_menu_set_title_add_profile', 0), ('sys_account_dashboard', 'system', '_sys_menu_set_title_account_dashboard', 0), ('sys_account_dashboard_manage_tools', 'system', '_sys_menu_set_title_account_dashboard_manage_tools', 0), @@ -4193,7 +4197,10 @@ INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `tit ('sys_account_dashboard', 'system', 'dashboard', '_sys_menu_item_title_system_account_dashboard', '_sys_menu_item_title_account_dashboard', 'page.php?i=dashboard', '', '', 'tachometer-alt', '', '', 2147483646, 1, 1, 1), ('sys_account_dashboard', 'system', 'dashboard-subscriptions', '_sys_menu_item_title_system_subscriptions', '_sys_menu_item_title_subscriptions', 'subscriptions.php', '', '', 'credit-card col-blue3', '', '', 2147483646, 1, 1, 2), ('sys_account_dashboard', 'system', 'dashboard-orders', '_sys_menu_item_title_system_orders', '_sys_menu_item_title_orders', 'orders.php', '', '', 'cart-arrow-down col-green3', '', '', 2147483646, 1, 1, 3), -('sys_account_dashboard', 'system', 'dashboard-invoices', '_sys_menu_item_title_system_invoices', '_sys_menu_item_title_invoices', 'invoices.php', '', '', 'file-invoice col-green3', '', '', 2147483646, 1, 1, 4); +('sys_account_dashboard', 'system', 'dashboard-invoices', '_sys_menu_item_title_system_invoices', '_sys_menu_item_title_invoices', 'invoices.php', '', '', 'file-invoice col-green3', '', '', 2147483646, 1, 1, 4), +('sys_account_dashboard', 'system', 'dashboard-content', '_sys_menu_item_title_system_account_dashboard_content', '_sys_menu_item_title_account_dashboard_content', 'page.php?i=dashboard-content', '', '', 'copy', '', '', 2147483646, 1, 1, 5), +('sys_account_dashboard', 'system', 'dashboard-reports', '_sys_menu_item_title_system_account_dashboard_reports', '_sys_menu_item_title_account_dashboard_reports', 'page.php?i=dashboard-reports', '', '', 'exclamation-circle', '', '', 2147483646, 1, 1, 6), +('sys_account_dashboard', 'system', 'dashboard-audit', '_sys_menu_item_title_system_account_dashboard_audit', '_sys_menu_item_title_account_dashboard_audit', 'page.php?i=dashboard-audit', '', '', 'history', '', '', 2147483646, 1, 1, 7); -- comment manage menu INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES @@ -4316,9 +4323,11 @@ INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `fie ('sys_studio_labels', 'Sql', 'SELECT * FROM `sys_labels` WHERE 1 ', 'sys_labels', 'id', 'order', '', '', 1000, NULL, 'start', '', 'value', '', 'like', 'value', '', 'BxTemplStudioFormsLabels', ''), ('sys_studio_categories', 'Sql', 'SELECT * FROM `sys_categories` WHERE 1 ', 'sys_categories', 'id', 'added', 'status', '', 20, NULL, 'start', '', 'value', '', 'like', '', '', 'BxTemplStudioFormsCategories', ''), -('sys_audit_administration', 'Sql', 'SELECT * FROM `sys_audit` WHERE 1 ', 'sys_audit', 'id', 'added', '', '', 20, NULL, 'start', '', 'value', '', 'like', '', '', 'BxTemplAuditGrid', ''), +('sys_audit_administration', 'Sql', 'SELECT * FROM `sys_audit` WHERE 1 ', 'sys_audit', 'id', 'added', '', '', 20, NULL, 'start', '', 'value', '', 'like', 'content_module,profile_id,content_id,context_profile_id,added', 'action_lang_key', 'BxTemplAuditGrid', ''), -('sys_badges_administration', 'Sql', 'SELECT * FROM `sys_badges` WHERE 1 ', 'sys_badges', 'id', 'added', '', '', 20, NULL, 'start', '', 'text', '', 'like', '', '', 'BxTemplStudioBadgesGrid', ''); +('sys_badges_administration', 'Sql', 'SELECT * FROM `sys_badges` WHERE 1 ', 'sys_badges', 'id', 'added', '', '', 20, NULL, 'start', '', 'text', '', 'like', '', '', 'BxTemplStudioBadgesGrid', ''), + +('sys_reports_administration', 'Sql', 'WHERE 1 ', '', 'id', 'date', '', '', 20, NULL, 'start', '', 'text,type', '', 'like', '', '', 'BxTemplReportsGrid', ''); CREATE TABLE IF NOT EXISTS `sys_grid_fields` ( `object` varchar(64) NOT NULL, @@ -4457,18 +4466,31 @@ INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable ('sys_studio_categories', 'actions', '', '20%', 0, 0, '', 7), ('sys_audit_administration', 'added', '_adm_form_txt_audit_added', '15%', 1, 25, '', 1), -('sys_audit_administration', 'profile', '_adm_form_txt_audit_profile', '15%', 1, 25, '', 2), -('sys_audit_administration', 'content', '_adm_form_txt_audit_content', '25%', 1, 25, '', 3), -('sys_audit_administration', 'module', '_adm_form_txt_audit_module', '15%', 1, 25, '', 4), -('sys_audit_administration', 'context', '_adm_pgt_txt_audit_context', '15%', 1, 25, '', 5), -('sys_audit_administration', 'action', '_adm_pgt_txt_audit_action', '15%', 1, 25, '', 6), +('sys_audit_administration', 'profile_id', '_adm_form_txt_audit_profile', '15%', 1, 25, '', 2), +('sys_audit_administration', 'content_id', '_adm_form_txt_audit_content', '20%', 1, 25, '', 3), +('sys_audit_administration', 'author_id', '_adm_form_txt_audit_author_content', '10%', 1, 25, '', 4), +('sys_audit_administration', 'content_module', '_adm_form_txt_audit_module', '10%', 1, 25, '', 5), +('sys_audit_administration', 'context_id', '_adm_pgt_txt_audit_context', '15%', 1, 25, '', 6), +('sys_audit_administration', 'action_lang_key', '_adm_pgt_txt_audit_action', '15%', 1, 25, '', 7), ('sys_badges_administration', 'checkbox', '_sys_select', '2%', 0, 0, '', 1), ('sys_badges_administration', 'view', '_adm_form_txt_badges_view', '15%', 1, 0, '', 2), ('sys_badges_administration', 'module', '_adm_form_txt_badges_module', '15%', 1, 25, '', 3), ('sys_badges_administration', 'text', '_adm_pgt_txt_badges_text', '28%', 1, 35, '', 4), ('sys_badges_administration', 'icon', '_adm_pgt_txt_badges_icon', '20%', 1, 0, '', 5), -('sys_badges_administration', 'actions', '', '20%', 0, 0, '', 6); +('sys_badges_administration', 'actions', '', '20%', 0, 0, '', 6), + +('sys_reports_administration', 'object', '_adm_form_txt_reports_object', '10%', 1, 25, '', 1), +('sys_reports_administration', 'author', '_adm_form_txt_reports_author', '10%', 1, 25, '', 2), +('sys_reports_administration', 'type', '_adm_form_txt_reports_type', '10%', 1, 25, '', 3), +('sys_reports_administration', 'text', '_adm_form_txt_reports_text', '10%', 1, 25, '', 4), +('sys_reports_administration', 'date', '_adm_form_txt_reports_date', '10%', 1, 25, '', 5), +('sys_reports_administration', 'status', '_adm_form_txt_reports_status', '10%', 1, 25, '', 6), +('sys_reports_administration', 'checked_by', '_adm_form_txt_reports_checked_by', '10%', 1, 25, '', 7), +('sys_reports_administration', 'notes', '_adm_form_txt_reports_notes', '10%', 1, 25, '', 8), +('sys_reports_administration', 'comments', '_adm_form_txt_reports_comments', '10%', 1, 25, '', 8), +('sys_reports_administration', 'actions', '', '10%', 0, '', '', 9); + CREATE TABLE IF NOT EXISTS `sys_grid_actions` ( @@ -4553,6 +4575,11 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `conf ('sys_badges_administration', 'single', 'delete_icon', '', '', 1, 3), ('sys_badges_administration', 'independent', 'add', '_adm_form_btn_badges_add', '', 0, 1); +INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `confirm`, `order`, `icon_only`) VALUES +('sys_reports_administration', 'single', 'check_in', '_adm_form_btn_reports_check_in', 'check-square', 0, 1, 1), +('sys_reports_administration', 'single', 'check_out', '_adm_form_btn_reports_check_out', 'square', 0, 2, 1); + + INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon_only`, `confirm`, `order`) VALUES ('sys_studio_roles', 'independent', 'add', '_adm_rl_btn_role_add', '', 0, 0, 1), ('sys_studio_roles', 'single', 'edit', '_adm_rl_btn_role_edit', 'pencil-alt', 1, 0, 1), @@ -4891,6 +4918,9 @@ INSERT INTO `sys_objects_page` (`object`, `uri`, `title_system`, `title`, `modul ('sys_updates', 'updates', '_sys_page_title_sys_updates', '_sys_page_title_updates', 'system', 1, 5, 'sys_homepage_submenu', 2147483647, 1, 'page.php?i=updates', '', '', '', 0, 1, 0, 'BxTemplPageHome', '', 0), ('sys_trends', 'trends', '_sys_page_title_sys_trends', '_sys_page_title_trends', 'system', 1, 5, 'sys_homepage_submenu', 2147483647, 1, 'page.php?i=trends', '', '', '', 0, 1, 0, 'BxTemplPageHome', '', 0), ('sys_dashboard', 'dashboard', '_sys_page_title_system_dashboard', '_sys_page_title_dashboard', 'system', 1, 12, '', 2147483646, 1, 'page.php?i=dashboard', '', '', '', 0, 1, 0, 'BxTemplPageDashboard', '', 0), +('sys_dashboard_content', 'dashboard-content', '_sys_page_title_system_dashboard_content', '_sys_page_title_dashboard_content', 'system', 1, 12, '', 2147483646, 1, 'page.php?i=dashboard-content', '', '', '', 0, 1, 0, 'BxTemplPageDashboard', '', 0), +('sys_dashboard_reports', 'dashboard-reports', '_sys_page_title_system_dashboard_reports', '_sys_page_title_dashboard_reports', 'system', 1, 12, '', 2147483646, 1, 'page.php?i=dashboard-reports', '', '', '', 0, 1, 0, 'BxTemplPageDashboard', '', 0), +('sys_dashboard_audit', 'dashboard-audit', '_sys_page_title_system_dashboard_audit', '_sys_page_title_dashboard_audit', 'system', 1, 12, '', 2147483646, 1, 'page.php?i=dashboard-audit', '', '', '', 0, 1, 0, 'BxTemplPageDashboard', '', 0), ('sys_create_account', 'create-account', '_sys_page_title_system_create_account', '_sys_page_title_create_account', 'system', 1, 5, '', 2147483647, 1, 'page.php?i=create-account', '', '', '', 0, 1, 0, '', '', 0), ('sys_login', 'login', '_sys_page_title_system_login', '_sys_page_title_login', 'system', 1, 5, '', 2147483647, 1, 'page.php?i=login', '', '', '', 0, 1, 0, '', '', 0), ('sys_login_step2', 'login-step2', '_sys_page_title_system_login_step2', '_sys_page_title_login_step2', 'system', 1, 5, '', 2147483647, 1, 'page.php?i=login-step2', '', '', '', 0, 1, 0, '', '', 0), @@ -5062,6 +5092,12 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, ` ('sys_dashboard', 1, 'system', '', '_sys_page_block_title_manage_tools', 11, 0, 0, 192, 'menu', 'sys_account_dashboard_manage_tools', 0, 1, 1, 3), +('sys_dashboard_content', 1, 'system', '', '_sys_page_block_title_dashboard_content', 11, 0, 0, 192, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"manage_content";s:6:"params";a:0:{}s:5:"class";s:21:"TemplServiceDashboard";}', 0, 1, 1, 1), + +('sys_dashboard_audit', 1, 'system', '', '_sys_page_block_title_dashboard_audit', 11, 0, 0, 192, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:12:"manage_audit";s:6:"params";a:0:{}s:5:"class";s:21:"TemplServiceDashboard";}', 0, 1, 1, 1), + +('sys_dashboard_reports', 1, 'system', '', '_sys_page_block_title_dashboard_reports', 11, 0, 0, 192, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:14:"manage_reports";s:6:"params";a:0:{}s:5:"class";s:21:"TemplServiceDashboard";}', 0, 1, 1, 1), + ('sys_dashboard', 3, 'system', '', '_sys_page_block_title_chart_growth', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:16:"get_chart_growth";s:6:"params";a:0:{}s:5:"class";s:18:"TemplChartServices";}', 0, 1, 1, 0), ('sys_dashboard', 2, 'system', '', '_sys_page_block_title_membership_stats', 11, 0, 0, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:24:"profile_membership_stats";s:6:"params";a:0:{}s:5:"class";s:20:"TemplServiceProfiles";}', 0, 1, 1, 2), diff --git a/template/css/manage_tools.css b/template/css/manage_tools.css new file mode 100644 index 0000000000..bad80e7256 --- /dev/null +++ b/template/css/manage_tools.css @@ -0,0 +1,32 @@ +/*--- General ---*/ +div.bx-grid-header div.bx-form-element-wrapper { + position: relative; + float: left; + width: 165px; +} +div.bx-grid-header .bx-form-element-wrapper.bx-grid-controls-filter-datepicker{ + width: auto; +} +div.bx-grid-header .bx-form-element-wrapper.bx-grid-controls-filter-label{ + width: auto; +} +div.bx-grid-header .bx-form-element-wrapper.bx-grid-controls-filter-label .bx-form-input-wrapper{ + height:2.5rem; + line-height:2.4rem; +} + +/*--- Administration tools ---*/ +div.bx-grid-header div.bx-form-element-wrapper { + margin-right: 0.5rem; +} +div.bx-grid-header div.bx-form-element-wrapper:last-child { + margin-right: 0; +} +Div.bx-grid-header div#bx-form-element-search, +div.bx-grid-header-controls-filter > .bx-form-element-wrapper { + margin-top: 0px !important; +} + +div.bx-grid-header .bx-form-element-wrapper.bx-grid-controls-filter-button{ + margin-top:0.25rem !important; +} \ No newline at end of file diff --git a/template/css/report.css b/template/css/report.css index aa6ae2bec8..1d94b638dc 100644 --- a/template/css/report.css +++ b/template/css/report.css @@ -29,6 +29,36 @@ div.bx-report-bi-info { div.bx-report-bi-info p { margin: 0px; } +/*--- Reported By List with comments---*/ +div.bx-report-by-list-comments div.bx-report-bi-info-list { + display:flex; + justify-content:space-between; +} +div.bx-report-by-list-comments .bx-report-bii-comments{ + position:relative; + padding-left:1rem; +} +div.bx-report-by-list-comments div.bx-report-bi-date { + width:15%; +} +div.bx-report-by-list-comments div.bx-report-bii-type { + width:20%; +} +div.bx-report-by-list-comments div.bx-report-bii-author { + width:35%; +} +div.bx-report-by-list-comments div.bx-report-bii-comments { + width:20%; +} +div.bx-report-by-list-comments .bx-report-comments{ + display:none; +} +div.bx-report-by-list-comments .bx-report-by-item{ + border-bottom: 1px solid #d0d0d0; +} +div.bx-report-by-list-comments .bx-report-by-item:last-child { + border-bottom: none; +} /*--- Report Element Styles ---*/ div.bx-report div.bx-report-element-holder, diff --git a/template/report_by_list_with_comments.html b/template/report_by_list_with_comments.html new file mode 100644 index 0000000000..2d1bd9b4a9 --- /dev/null +++ b/template/report_by_list_with_comments.html @@ -0,0 +1,22 @@ +
+
+ +
+
+
__date__
+
__type__
+ + +
+
+ +

__text__

+
+
+
+ __comments__ +
+
+
+
+
\ No newline at end of file diff --git a/template/scripts/BxBaseAuditGrid.php b/template/scripts/BxBaseAuditGrid.php index 7337cd1a82..06d9bfcea1 100644 --- a/template/scripts/BxBaseAuditGrid.php +++ b/template/scripts/BxBaseAuditGrid.php @@ -42,41 +42,26 @@ protected function _getCellAction ($mixedValue, $sKey, $aField, $aRow) return parent::_getCellDefault(_t($aRow['action_lang_key'], $aRow['action_lang_key_params']), $sKey, $aField, $aRow); } - protected function _getCellContent ($mixedValue, $sKey, $aField, $aRow) + protected function _getCellContentId ($mixedValue, $sKey, $aField, $aRow) { $mixedValue = ''; - if ($aRow['content_id'] > 0 && $aRow['content_info_object'] != ''){ - $oContentInfo = BxDolContentInfo::getObjectInstance($aRow['content_info_object']); - if ($oContentInfo){ - $sTitle = bx_process_output($oContentInfo->getContentTitle($aRow['content_id'])); - if ($sTitle != ''){ - $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( - 'href' => $oContentInfo->getContentLink($aRow['content_id']), - 'title' => $sTitle, - 'content' => $sTitle, - 'class' => 'bx-def-font-grayed' - )); - } + if ($aRow['content_id'] > 0){ + $iAuthorProfileId = BxDolRequest::serviceExists($aRow['content_module'], 'get_author') ? BxDolService::call($aRow['content_module'], 'get_author', array($aRow['content_id'])) : ''; + $oProfile = BxDolProfile::getInstance($iAuthorProfileId); + if ($oProfile){ + $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName()); } - } - if ($mixedValue == ''){ - $mixedValue = bx_process_output($aRow['content_title']); + } return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); } - protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow) + protected function _getCellContextProfileId ($mixedValue, $sKey, $aField, $aRow) { if ($aRow['context_profile_id'] > 0){ $oProfile = BxDolProfile::getInstance($aRow['context_profile_id']); if ($oProfile){ - $sProfile = $oProfile->getDisplayName(); - $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( - 'href' => $oProfile->getUrl(), - 'title' => $sProfile, - 'content' => $sProfile, - 'class' => 'bx-def-font-grayed' - )); + $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName()); } else{ $mixedValue = $aRow['context_profile_title']; @@ -88,7 +73,7 @@ protected function _getCellContext ($mixedValue, $sKey, $aField, $aRow) return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); } - protected function _getCellModule ($mixedValue, $sKey, $aField, $aRow) + protected function _getCellContentModule ($mixedValue, $sKey, $aField, $aRow) { $oModule = bxDolModule::getInstance($aRow['content_module']); if($oModule && $oModule instanceof iBxDolContentInfoService){ @@ -101,18 +86,29 @@ protected function _getCellModule ($mixedValue, $sKey, $aField, $aRow) } - protected function _getCellProfile ($mixedValue, $sKey, $aField, $aRow) + protected function _getCellProfileId ($mixedValue, $sKey, $aField, $aRow) { if ($aRow['profile_id'] > 0){ $oProfile = BxDolProfile::getInstance($aRow['profile_id']); if ($oProfile){ - $sProfile = $oProfile->getDisplayName(); - $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( - 'href' => $oProfile->getUrl(), - 'title' => $sProfile, - 'content' => $sProfile, - 'class' => 'bx-def-font-grayed' - )); + $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName()); + } + else{ + $mixedValue = $aRow['profile_title']; + } + } + else{ + $mixedValue = ''; + } + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellAuthorId ($mixedValue, $sKey, $aField, $aRow) + { + if ($aRow['profile_id'] > 0){ + $oProfile = BxDolProfile::getInstance($aRow['profile_id']); + if ($oProfile){ + $mixedValue = BxDolTemplate::getInstance()->parseLink($oProfile->getUrl(), $oProfile->getDisplayName()); } else{ $mixedValue = $aRow['profile_title']; @@ -127,8 +123,13 @@ protected function _getCellProfile ($mixedValue, $sKey, $aField, $aRow) function _getFilterControls() { parent::_getFilterControls(); - - return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values); + return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . + $this->_getFilterSelectOne($this->_sFilterProfileName, $this->_sFilterProfileValue, $this->_aFilterProfileValues) . + $this->_getFilterSelectOne($this->_sFilterActionName, $this->_sFilterActionValue, $this->_aFilterActionValues) . + $this->_getFilterDatePicker($this->_sFilterFromDateName, $this->_sFilterFromDateValue) . + $this->_getFilterLabel('-') . + $this->_getFilterDatePicker($this->_sFilterToDateName, $this->_sFilterToDateValue) . + $this->_getFilterButton(); } protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues) @@ -144,7 +145,7 @@ protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValu 'name' => $sFilterName, 'attrs' => array( 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject, - 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)' + // 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)' ), 'value' => $sFilterValue, 'values' => $aFilterValues @@ -153,6 +154,55 @@ protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValu $oForm = new BxTemplFormView(array()); return $oForm->genRow($aInputModules); } + + protected function _getFilterLabel($sFilterValue) + { + $aInputModules = array( + 'type' => 'value', + 'value' => $sFilterValue, + 'tr_attrs' => array('class' => 'bx-grid-controls-filter-label'), + ); + + $oForm = new BxTemplFormView(array()); + return $oForm->genRow($aInputModules, true); + } + + protected function _getFilterDatePicker($sFilterName, $sFilterValue) + { + if(empty($sFilterName)) + return ''; + + $aInputModules = array( + 'type' => 'datepicker', + 'name' => $sFilterName, + 'attrs' => array( + 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject, + ), + 'tr_attrs' => array('class' => 'bx-grid-controls-filter-datepicker'), + 'value' => $sFilterValue, + ); + + $oForm = new BxTemplFormView(array()); + return $oForm->genRow($aInputModules, true); + } + + protected function _getFilterButton() + { + $aInputModules = array( + 'type' => 'button', + 'name' => 'button', + 'attrs' => array( + 'id' => 'bx-grid-button-' . $this->_sObject, + 'onClick' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)', + ), + 'tr_attrs' => array('class' => 'bx-grid-controls-filter-button'), + 'value' => _t('_Search'), + ); + + $oForm = new BxTemplFormView(array()); + return $oForm->genRow($aInputModules, true); + } + } /** @} */ diff --git a/template/scripts/BxBaseAuditServices.php b/template/scripts/BxBaseAuditServices.php index fd44fa5739..12c6b17bdc 100644 --- a/template/scripts/BxBaseAuditServices.php +++ b/template/scripts/BxBaseAuditServices.php @@ -25,6 +25,7 @@ public function serviceManageTools() $oTemplate = BxDolTemplate::getInstance(); $oTemplate->addJs(array('BxDolAuditManageTools.js', 'BxDolGrid.js')); + $oTemplate->addCss(array('manage_tools.css')); $oTemplate->addJsTranslation(array('_sys_grid_search')); return array( 'content' => $oGrid->getCode() diff --git a/template/scripts/BxBaseCmts.php b/template/scripts/BxBaseCmts.php index 59067e0375..98d442db59 100644 --- a/template/scripts/BxBaseCmts.php +++ b/template/scripts/BxBaseCmts.php @@ -40,7 +40,7 @@ function __construct( $sSystem, $iId, $iInit = true, $oTemplate = false) $this->_sTmplNameItemContent = 'comment_content.html'; $this->_sJsObjClass = 'BxDolCmts'; - $this->_sJsObjName = 'oCmts' . bx_gen_method_name($sSystem, array('_' , '-')) . $iId; + $this->_sJsObjName = 'oCmts' . bx_gen_method_name($sSystem, array('_' , '-')) . '_' .str_replace('-', 'n', $iId); $this->_sStylePrefix = isset($this->_aSystem['root_style_prefix']) ? $this->_aSystem['root_style_prefix'] : 'cmt'; $sHtmlId = str_replace(array('_' , ' '), array('-', '-'), $sSystem) . '-' . $iId; diff --git a/template/scripts/BxBaseDashboardServices.php b/template/scripts/BxBaseDashboardServices.php new file mode 100644 index 0000000000..43c903debb --- /dev/null +++ b/template/scripts/BxBaseDashboardServices.php @@ -0,0 +1,118 @@ +getModulesBy(array('type' => 'modules', 'active' => 1)); + $aModulesList = array(); + foreach($aModules as $iKey => $aModule){ + $oModule = BxDolModule::getInstance($aModule['name']); + if ($oModule instanceof iBxDolContentInfoService){ + $CNF = $oModule->_oConfig->CNF; + if (isset($CNF['OBJECT_REPORTS'])){ + $aModule['selected'] = false; + $aModulesList[$aModule['uri']] = $aModule; + } + else{ + unset($aModules[$iKey]); + } + } + else{ + unset($aModules[$iKey]); + } + } + $aModules = array_values($aModules); + $sSelected = bx_get('module'); + + if ($sSelected == ''){ + $aModulesList[$aModules[0]['uri']]['selected'] = true; + $sSelected = $aModules[0]['uri']; + } + else{ + $aModulesList[$sSelected]['selected'] = true; + } + + $oMenu->setMenuData($aModulesList); + + $oGrid = BxDolGrid::getObjectInstance('sys_reports_administration'); + $oGrid->setModule($aModulesList[$sSelected]['name']); + + if(!$oGrid) + return ''; + + $oTemplate = BxDolTemplate::getInstance(); + $oTemplate->addJs(array('BxDolReportsManageTools.js', 'BxDolGrid.js')); + $oTemplate->addCss(array('manage_tools.css')); + $oTemplate->addJsTranslation(array('_sys_grid_search')); + + return array( + 'content' => $oGrid->getCode(), + 'menu' => $oMenu + ); + } + + public function serviceManageAudit() + { + return bx_srv('system', 'manage_tools', array(), 'TemplAuditServices'); + } + + public function serviceManageContent() + { + $oMenu = BxDolMenu::getObjectInstance('sys_dashboard_content'); + if(!$oMenu) + return ''; + + $BxDolModuleQuery = BxDolModuleQuery::getInstance(); + $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1)); + $aModulesList = array(); + foreach($aModules as $iKey => $aModule){ + $oModule = BxDolModule::getInstance($aModule['name']); + if ($oModule instanceof iBxDolContentInfoService && BxDolRequest::serviceExists($aModule['name'], 'manage_tools')){ + $aModule['selected'] = false; + $aModulesList[$aModule['uri']] = $aModule; + } + else{ + unset($aModules[$iKey]); + } + } + $aModules = array_values($aModules); + $sSelected = bx_get('module'); + + if ($sSelected == ''){ + $aModulesList[$aModules[0]['uri']]['selected'] = true; + $sSelected = $aModules[0]['uri']; + } + else{ + $aModulesList[$sSelected]['selected'] = true; + } + + $oMenu->setMenuData($aModulesList); + + $aGrid = BxDolService::call($aModulesList[$sSelected]['name'], 'manage_tools', array('administration')); + + return array( + 'content' => $aGrid['content'], + 'menu' => $oMenu + ); + } + +} + +/** @} */ diff --git a/template/scripts/BxBaseFormView.php b/template/scripts/BxBaseFormView.php index a75d260ff9..de961fe1d6 100644 --- a/template/scripts/BxBaseFormView.php +++ b/template/scripts/BxBaseFormView.php @@ -980,6 +980,14 @@ function genInput(&$aInput) switch ($aInput['type']) { + case 'datepicker': + if (!isset($aInput['attrs'])) + $aInput['attrs'] = array(); + $aInput['attrs']['autosuggestion'] = 'off'; + + $sInput = $this->genInputStandard($aInput); + break; + // standard inputs (and non-standard, interpreted as standard) case 'text': case 'datepicker': diff --git a/template/scripts/BxBaseMenuDashboardContentManage.php b/template/scripts/BxBaseMenuDashboardContentManage.php new file mode 100644 index 0000000000..ec4b871e67 --- /dev/null +++ b/template/scripts/BxBaseMenuDashboardContentManage.php @@ -0,0 +1,68 @@ +_aObject['menu_id'] = 'sys-dashboard-content-manage-menu'; + + $this->_bShowDivider = false; + } + + public function setMenuData ($aModulesList) + { + $this->_aModulesList = $aModulesList; + } + + protected function getMenuItemsRaw () + { + $aResult = array(); + $aUrl = bx_get_base_url_inline(); + + foreach($this->_aModulesList as $aModule){ + $aResult[$aModule['name']] = array( + 'name' => $aModule['name'], + 'title' => $aModule['title'], + 'link' => bx_append_url_params($aUrl[0], array_merge($aUrl[1], array('module' => $aModule['uri']))), + 'active' => true, + 'selected' => $aModule['selected']//todo selected + ); + } + if(!empty($aResult) && is_array($aResult)){ + $aResult['more-auto'] = array( + 'module' => 'system', + 'id' => 'more-auto', + 'name' => 'more-auto', + 'active' => true, + 'title' => '_sys_menu_item_title_va_more_auto', + 'href' => 'javascript:void(0)', + 'icon' => 'ellipsis-v', + ); + } + return $aResult; + } + + protected function _isSelected ($a) + { + if (isset($a['selected'])) + return $a['selected']; + return false; + } +} + +/** @} */ diff --git a/template/scripts/BxBaseMenuDashboardReportsManage.php b/template/scripts/BxBaseMenuDashboardReportsManage.php new file mode 100644 index 0000000000..ad7904e1f4 --- /dev/null +++ b/template/scripts/BxBaseMenuDashboardReportsManage.php @@ -0,0 +1,68 @@ +_aObject['menu_id'] = 'sys-dashboard-reports-manage-menu'; + + $this->_bShowDivider = false; + } + + public function setMenuData ($aModulesList) + { + $this->_aModulesList = $aModulesList; + } + + protected function getMenuItemsRaw () + { + $aResult = array(); + $aUrl = bx_get_base_url_inline(); + + foreach($this->_aModulesList as $aModule){ + $aResult[$aModule['name']] = array( + 'name' => $aModule['name'], + 'title' => $aModule['title'], + 'link' => bx_append_url_params($aUrl[0], array_merge($aUrl[1], array('module' => $aModule['uri']))), + 'active' => true, + 'selected' => $aModule['selected']//todo selected + ); + } + if(!empty($aResult) && is_array($aResult)){ + $aResult['more-auto'] = array( + 'module' => 'system', + 'id' => 'more-auto', + 'name' => 'more-auto', + 'active' => true, + 'title' => '_sys_menu_item_title_va_more_auto', + 'href' => 'javascript:void(0)', + 'icon' => 'ellipsis-v', + ); + } + return $aResult; + } + + protected function _isSelected ($a) + { + if (isset($a['selected'])) + return $a['selected']; + return false; + } +} + +/** @} */ diff --git a/template/scripts/BxBaseReport.php b/template/scripts/BxBaseReport.php index 346d675635..c8e59abb77 100644 --- a/template/scripts/BxBaseReport.php +++ b/template/scripts/BxBaseReport.php @@ -158,6 +158,48 @@ public function getElement($aParams = array()) 'script' => $this->getJsScript($bDynamicMode) )); } + + public function getReportedByWithComments($sObjectNotes) + { + $aTmplReports = array(); + $aTypes = BxDolForm::getDataItems('sys_report_types'); + + $aReports = $this->_oQuery->getPerformedBy($this->getId()); + foreach($aReports as $aReport) { + list($sUserName, $sUserUrl, $sUserIcon, $sUserUnit) = $this->_getAuthorInfo($aReport['author_id']); + + $sText = bx_process_output($aReport['text'], BX_DATA_TEXT_MULTILINE); + + $oCmtsNotes = BxDolCmts::getObjectInstance($sObjectNotes, -$aReport['id'], true, $this->_oTemplate); + $aCmtsNotes = $oCmtsNotes->getCommentsBlock(array(), array('in_designbox' => false)); + $iCmtsNotesCount = $oCmtsNotes->getCommentsCount(); + + $aTmplReports[] = array( + 'style_prefix' => $this->_sStylePrefix, + 'user_name' => $sUserName, + 'id' => $aReport['id'], + 'user_url' => $sUserUrl, + 'type' => $aTypes[$aReport['type']], + 'comments_count' => _t('_report_comments_count', $iCmtsNotesCount), + 'comments' => $aCmtsNotes['content'], + 'date' => bx_time_js($aReport['date']), + 'bx_if:show_text' => array( + 'condition' => strlen($sText) > 0, + 'content' => array( + 'text' => $sText + ) + ) + ); + } + + if(empty($aTmplReports)) + $aTmplReports = MsgBox(_t('_Empty')); + + return $this->_oTemplate->parseHtmlByName('report_by_list_with_comments.html', array( + 'style_prefix' => $this->_sStylePrefix, + 'bx_repeat:list' => $aTmplReports + )); + } protected function _getDoReport($aParams = array()) { diff --git a/template/scripts/BxBaseReportsGrid.php b/template/scripts/BxBaseReportsGrid.php new file mode 100644 index 0000000000..fbb555ce98 --- /dev/null +++ b/template/scripts/BxBaseReportsGrid.php @@ -0,0 +1,276 @@ +_sParamsDivider = '#-#'; + + $this->_sDefaultSortingOrder = 'DESC'; + + $this->_sFilter1Name = 'filter1'; + $this->_aFilter1Values = array( + '' => _t('_report_status_all'), + 0 => _t('_report_status_new'), + 1 => _t('_report_status_check_in'), + 2 => _t('_report_status_check_out'), + ); + + $sFilter2 = bx_get($this->_sFilter1Name); + if(!empty($sFilter2)) { + $this->_sFilter1Value = bx_process_input($sFilter2); + $this->_aQueryAppend[$this->_sFilter1Name] = $this->_sFilter1Value; + } + + + if (bx_get('module_name')){ + $this->setModule(bx_get('module_name')); + } + } + + public function getCode($isDisplayHeader = true) + { + return $this->getJsCode() . parent::getCode($isDisplayHeader); + } + + public function setModule($sModuleName) + { + $oModule = BxDolModule::getInstance($sModuleName); + $CNF = $oModule->_oConfig->CNF; + $oReport = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], -1, false); + $this->_aReportSystemInfo = $oReport->getSystemInfo(); + $this->_aQueryAppend['module_name'] = $sModuleName; + } + + public function getJsCode() + { + $aParams = array( + 'sObjName' => $this->sJsObject, + 'aHtmlIds' => array(), + 'oRequestParams' => array(), + 'sObjNameGrid' => 'sys_reports_administration' + ); + return BxDolTemplate::getInstance()->_wrapInTagJsCode("var " . $this->sJsObject . " = new BxDolReportsManageTools(" . json_encode($aParams) . ");"); + } + + + + public function performActionCheckIn() + { + $this->_performActionStatus(BX_DOL_REPORT_STASUS_IN_PROCESS, '_report_comment_check_in'); + } + + public function performActionCheckOut() + { + $this->_performActionStatus(BX_DOL_REPORT_STASUS_PROCESSED, '_report_comment_check_out'); + } + + private function _performActionStatus($iStatus, $sCmtsText) + { + $aIds = bx_get('ids'); + + $oModule = BxDolModule::getInstance($this->_aReportSystemInfo['module_name']); + $CNF = $oModule->_oConfig->CNF; + + $iAffected = 0; + $aIdsAffected = array (); + foreach($aIds as $iId) { + $oReport = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $iId, true); + $oReport->changeStatusReport($iStatus, bx_get_logged_profile_id(), _t($sCmtsText)); + $aIdsAffected[] = $iId; + $iAffected++; + } + + echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => $mixedResult)); + } + + + protected function _getCellDate($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow); + } + + protected function _getCellNotes($mixedValue, $sKey, $aField, $aRow) + { + $mixedValue = ''; + + $oModule = BxDolModule::getInstance($this->_aReportSystemInfo['module_name']); + $CNF = $oModule->_oConfig->CNF; + if (isset($CNF) && isset($CNF['OBJECT_NOTES'])){ + $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_NOTES'], $aRow['object_id']); + $mixedValue = BxDolTemplate::getInstance()->parseLink('javascript:', $oCmts->getCommentsCount(), array("onclick" => "bx_get_notes(this, '" . $oModule->_aModule['uri'] . "', '" . $aRow['object_id'] . "')")); + } + + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellComments($mixedValue, $sKey, $aField, $aRow) + { + $mixedValue = ''; + + $oModule = BxDolModule::getInstance($this->_aReportSystemInfo['module_name']); + $CNF = $oModule->_oConfig->CNF; + if (isset($CNF) && isset($CNF['OBJECT_NOTES'])){ + $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_NOTES'], -$aRow['id']); + $mixedValue = BxDolTemplate::getInstance()->parseLink('javascript:', $oCmts->getCommentsCount(), array("onclick" => "bx_get_notes(this, '" . $oModule->_aModule['uri'] . "', '" . -$aRow['id'] . "')")); + } + + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellObject ($mixedValue, $sKey, $aField, $aRow) + { + $mixedValue = ''; + $sTitle = bx_srv($this->_aReportSystemInfo['module_name'], 'get_title', array(0 => $aRow['object_id'])); + if ($sTitle != ''){ + $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( + 'href' => bx_srv($this->_aReportSystemInfo['module_name'], 'get_link', array(0 => $aRow['object_id'])), + 'title' => $sTitle, + 'content' => $sTitle + )); + } + + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellAuthor ($mixedValue, $sKey, $aField, $aRow) + { + if ($aRow['author_id'] > 0){ + $oProfile = BxDolProfile::getInstance($aRow['author_id']); + if ($oProfile){ + $sProfile = $oProfile->getDisplayName(); + $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( + 'href' => $oProfile->getUrl(), + 'title' => $sProfile, + 'content' => $sProfile + )); + } + else{ + $mixedValue = $aRow['profile_title']; + } + } + else{ + $mixedValue = ''; + } + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellCheckedBy ($mixedValue, $sKey, $aField, $aRow) + { + if ($aRow['checked_by'] > 0){ + $oProfile = BxDolProfile::getInstance($aRow['checked_by']); + if ($oProfile){ + $sProfile = $oProfile->getDisplayName(); + $mixedValue = $this->_oTemplate->parseHtmlByName('account_link.html', array( + 'href' => $oProfile->getUrl(), + 'title' => $sProfile, + 'content' => $sProfile + )); + } + else{ + $mixedValue = $aRow['profile_title']; + } + } + else{ + $mixedValue = ''; + } + return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow); + } + + protected function _getCellStatus ($mixedValue, $sKey, $aField, $aRow) + { + return parent::_getCellDefault(_t('_sys_txt_report_status_' . $mixedValue), $sKey, $aField, $aRow); + } + + protected function _getActionCheckIn($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) + { + if($aRow["status"] == BX_DOL_REPORT_STASUS_IN_PROCESS) + return ''; + return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow); + } + + protected function _getActionCheckOut($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array()) + { + if($aRow["status"] != BX_DOL_REPORT_STASUS_IN_PROCESS) + return ''; + return parent::_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow); + } + + protected function _getFilterControls() + { + return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getSearchInput(); + } + + protected function _getFilterSelectOne($sFilterName, $sFilterValue, $aFilterValues) + { + if(empty($sFilterName) || empty($aFilterValues)) + return ''; + + foreach($aFilterValues as $sKey => $sValue) + $aFilterValues[$sKey] = _t($sValue); + + $aInputModules = array( + 'type' => 'select', + 'name' => $sFilterName, + 'attrs' => array( + 'id' => 'bx-grid-' . $sFilterName . '-' . $this->_sObject, + 'onChange' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)' + ), + 'value' => $sFilterValue, + 'values' => array_merge(array('' => 'All'), $aFilterValues) + ); + + $oForm = new BxTemplFormView(array()); + return $oForm->genRow($aInputModules); + } + + protected function _getSearchInput() + { + $aInputSearch = array( + 'type' => 'text', + 'name' => 'search', + 'attrs' => array( + 'id' => 'bx-grid-search-' . $this->_sObject, + 'onKeyup' => 'javascript:$(this).off(\'keyup focusout\'); ' . $this->sJsObject . '.onChangeFilter(this)', + 'onBlur' => 'javascript:' . $this->sJsObject . '.onChangeFilter(this)', + ) + ); + + $oForm = new BxTemplFormView(array()); + return $oForm->genRow($aInputSearch); + } + + protected function _getDataSql ($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage) + { + $this->_aOptions['source'] = "SELECT * FROM `" . $this->_aReportSystemInfo['table_track'] . "` " . $this->_aOptions['source']; + + if(strpos($sFilter, $this->_sParamsDivider) !== false) + list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter); + + if(isset($this->_sFilter1Value) && $this->_sFilter1Value !== ''){ + $this->_aOptions['source'] .= " AND `status` = " . $this->_sFilter1Value; + } + + return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage); + } +} + +/** @} */