| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaBaseView UNA Base Representation Classes
- * @{
- */
- class BxBaseReportsGrid extends BxTemplGrid
- {
- protected $_sParamsDivider;
-
- protected $_sFilter1Name;
- protected $_sFilter1Value;
- protected $_aFilter1Values;
- protected $sJsObject = 'oBxDolReportsManageTools';
-
- protected $_aReportSystemInfo;
-
- public function __construct($aInfo, $oTemplate = false)
- {
- parent::__construct($aInfo, $oTemplate);
-
- $this->_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);
- }
- }
- /** @} */
|