addColumn('no', 'no');
$this->addColumn('date', 'added', ['title' => 'Date Added', 'orderBy' => 'User.added']);
$this->addColumn('text', 'fullName', ['title' => 'Full Name', 'orderBy' => 'lastName']);
$mode = $this->getConfig('mode');
if (Module::MODE_SIMPLE == $mode) {
$this->addColumn('email', 'email', ['orderBy' => 'email']);
$this->addColumn('text', 'directPhone', ['title' => 'Phone', 'orderBy' => 'directPhone']);
} else if (Module::MODE_ASSOCIATION == $mode) {
$this->addColumn(
'text',
'companyName',
[
'title' => 'Company',
'orderBy' => 'companyName',
'defaultText' => '-',
]
);
} else {
throw new Qs_Exception('Unknown module mode.');
}
$this->addColumn('status', 'status', ['orderBy' => 'status', 'values' => $this->_getStatuses()]);
$this->_addOptionsColumn();
return $this;
}
protected function _addOptionsColumn()
{
$options = [];
$itemName = $this->getConfig('itemName');
if (Module::MODE_ASSOCIATION == $this->getConfig('mode')) {
$options['actions']['edit'] = [
'title' => 'Edit ' . $itemName,
'linkTitle' => 'Edit this ' . $itemName,
'separator' => '
',
];
if (($url = Qs_SiteMap::find(null, ['type' => 'ECommerce_Order_Admin_'], null, 'url'))) {
$options['actions']['viewPurchases'] = [
'title' => 'View/Edit Purchases',
'linkTitle' => 'View/Edit Purchases of this ' . $itemName,
'formattedLink' => $url . '?userId=%d',
'separator' => '
',
];
}
if (($url = Qs_SiteMap::find(null, ['type' => 'Event\\History\\Admin\\'], null, 'url'))) {
$options['actions']['eventHistory'] = [
'title' => 'View/Edit Event History',
'linkTitle' => 'View/Edit Event History of this ' . $itemName,
'formattedLink' => $url . '?userId=%d',
'separator' => '
',
];
}
if (($url = Qs_SiteMap::find(null, ['type' => 'Event\\Attendee\\Admin\\'], null, 'url'))) {
$options['actions']['selectEvent'] = [
'title' => 'Add to Event',
'linkTitle' => 'Add this ' . $itemName . ' to Event',
'formattedLink' => $url . '?action=selectEvent&userId=%d',
'separator' => '
',
];
}
$options['actions']['delete'] = [
'title' => 'Delete ' . $itemName,
'linkTitle' => 'Delete this ' . $itemName,
'separator' => '
',
];
} else {
$options['actions'] = [
'edit' => [],
'delete' => [],
];
}
if (Qs_Config::getByClass('Qs_ViewController_Log')->enabled
&& ($logBaseUrl = Qs_SiteMap::findFirst(null, ['type' => 'ViewControllerLog_Admin_'], null, 'url'))
) {
$options['actions']['viewLog'] = [
'formattedLink' => $logBaseUrl . '/user?roleId=%d',
'linkTitle' => "View Log of this " . $itemName,
];
}
$this->addColumn('options', 'options', $options);
return $this;
}
protected function _getStatuses()
{
return (new Qs_Db_Table('UserStatus'))->get4Select();
}
}