* @license PHP License * @package WB * @subpackage content */ /** * Load classes */ // WBClass::load('WBContent'); /** * Wombat Incident Ticket System * * @version 1.0.0 * @package WB * @subpackage content */ class WBITS extends WBStdClass { /** * Table name */ const TABLE_TICKET = 'ticket'; const PAGER_TYPE_ALL = 'pager_all'; const PAGER_TYPE_USER = 'pager_user'; const PAGER_TYPE_COMPANY = 'pager_company'; /** * table * @var WBDatasource_Table_ITS */ protected $table; /** * @var WBFormProcessor_Filter */ private $filter; /** * Constructor * */ public function __construct($parameter) { $parameter = array_merge(array( 'tmpl' => null, 'tmplDir' => null, 'req' => null, 'formConfigDir' => null ), $parameter); $this->filter = WBClass::create('WBFormProcessor_Filter'); $this->filter->setRequest($parameter['req']); $this->filter->setTemplate($parameter['tmpl'], $parameter['tmplDir']); $this->filter->setFormConfigDir($parameter['formConfigDir']); $this->table = WBClass::create('WBDatasource_Table_ITS'); $this->table->switchTranslation(false); } /** * Initlialize filter options * * Render and process filter form. * * @param array $searchfields * @return array template variables */ public function initFilter($searchfields = array()) { $searchfields = array_merge(array('title', 'blurb'), $searchfields); return $this->filter->buildClause($searchfields); } /** * Get ticket pager * * @return WBDatasource_Pager */ public function getPager($type = self::PAGER_TYPE_ALL) { $clause = $this->filter->getClause(); switch ($type) { case self::PAGER_TYPE_ALL: break; default: case self::PAGER_TYPE_USER: $clause[] = array( 'field' => 'customeruid', 'value' => WBUser_Auth::getCurrent()->getId() ); break; } $id = __CLASS__ . ':' . self::TABLE_TICKET; $options = array( 'limit' => 10, 'callback' => WBClass::create('WBITS_DatasourceCallback') ); return $this->table->getPager($id, self::TABLE_TICKET, null, $clause, $options); } /** * Load ticket by obscureid id * * @param string $obscureid * @return WBITS_Ticket */ public function loadByObscureId($obscureid = null) { $parameter = array( 'table' => $this->table ); $ticket = WBClass::create('WBITS_Ticket', $parameter); if (empty($obscureid)) { return $ticket; } return $ticket->loadByObscureId($obscureid); } }