BxTasksGridTimeAdministration.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. * @defgroup Tasks Tasks
  6. * @ingroup UnaModules
  7. *
  8. * @{
  9. */
  10. require_once('BxTasksGridTime.php');
  11. class BxTasksGridTimeAdministration extends BxTasksGridTime
  12. {
  13. public function __construct ($aOptions, $oTemplate = false)
  14. {
  15. parent::__construct ($aOptions, $oTemplate);
  16. if($this->_isAdministration())
  17. $this->_initFilter(1, $this->_oModule->getAssignees());
  18. $this->_initFilter(2, $this->_oModule->getContexts());
  19. }
  20. protected function _getCellContextModule($mixedValue, $sKey, $aField, $aRow)
  21. {
  22. return parent::_getCellDefault($this->_oModule->getModuleTitle($mixedValue), $sKey, $aField, $aRow);
  23. }
  24. protected function _getCellContextId($mixedValue, $sKey, $aField, $aRow)
  25. {
  26. if(($oContext = BxDolProfile::getInstance($mixedValue)) !== false)
  27. $mixedValue = $oContext->getDisplayName();
  28. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  29. }
  30. protected function _getFilterControls()
  31. {
  32. $this->_getFcDefault();
  33. $sContent = $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values, '_bx_tasks_grid_filter_item_title_tm_select_one_author_id');
  34. $sContent .= $this->_getFilterSelectOne($this->_sFilter2Name, $this->_sFilter2Value, $this->_aFilter2Values, '_bx_tasks_grid_filter_item_title_tm_select_one_context_module');
  35. $sContent .= $this->_getFcDateSearch();
  36. return $sContent;
  37. }
  38. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  39. {
  40. $this->_parseFilterValue($sFilter);
  41. if(!empty($this->_sFilter1Value))
  42. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND ' . $this->_getSqlField('author_id') . '=?', $this->_sFilter1Value);
  43. if(!empty($this->_sFilter2Value))
  44. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND `tp`.`type`=?', $this->_sFilter2Value);
  45. if(!empty($this->_sFilter3Value))
  46. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND ' . $this->_getSqlField('value_date') . '>=?', strtotime($this->_sFilter3Value));
  47. if(!empty($this->_sFilter4Value))
  48. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND ' . $this->_getSqlField('value_date') . '<=?', strtotime($this->_sFilter4Value));
  49. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  50. }
  51. }
  52. /** @} */