** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
$widget = (new CWidget())->setTitle(_('Actions'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem([_('Event source'), SPACE, new CComboBox('eventsource', $data['eventsource'], 'submit()', [EVENT_SOURCE_TRIGGERS => _('Triggers'), EVENT_SOURCE_DISCOVERY => _('Discovery'), EVENT_SOURCE_AUTO_REGISTRATION => _('Auto registration'), EVENT_SOURCE_INTERNAL => _x('Internal', 'event source')])])->addItem(new CSubmit('form', _('Create action')))));
// create form
$actionForm = (new CForm())->setName('actionForm');
// create table
$actionTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_items'))->onClick("checkAll('" . $actionForm->getName() . "', 'all_items', 'g_actionid');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Conditions'), _('Operations'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder'])]);
if ($this->data['actions']) {
    $actionConditionStringValues = actionConditionValueToString($this->data['actions'], $this->data['config']);
    $actionOperationDescriptions = getActionOperationDescriptions($this->data['actions']);
    foreach ($this->data['actions'] as $aIdx => $action) {
        $conditions = [];
        $operations = [];
        order_result($action['filter']['conditions'], 'conditiontype', ZBX_SORT_DOWN);
        foreach ($action['filter']['conditions'] as $cIdx => $condition) {
            $conditions[] = getConditionDescription($condition['conditiontype'], $condition['operator'], $actionConditionStringValues[$aIdx][$cIdx]);
            $conditions[] = BR();
        }
        sortOperations($data['eventsource'], $action['operations']);
        foreach ($action['operations'] as $oIdx => $operation) {
            $operations[] = $actionOperationDescriptions[$aIdx][$oIdx];
        }
        if ($action['status'] == ACTION_STATUS_DISABLED) {
            $status = (new CLink(_('Disabled'), 'actionconf.php?action=action.massenable&g_actionid[]=' . $action['actionid'] . url_param('eventsource')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(ZBX_STYLE_RED)->addSID();
        } else {
 * Operation tab
 */
$operationFormList = new CFormList('operationlist');
if ($this->data['eventsource'] == EVENT_SOURCE_TRIGGERS || $this->data['eventsource'] == EVENT_SOURCE_INTERNAL) {
    $operationFormList->addRow(_('Default operation step duration'), [(new CNumericBox('esc_period', $this->data['action']['esc_period'], 6))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH), ' (' . _('minimum 60 seconds') . ')']);
}
// create operation table
$operationsTable = (new CTable())->setAttribute('style', 'width: 100%;');
if ($this->data['eventsource'] == EVENT_SOURCE_TRIGGERS || $this->data['eventsource'] == EVENT_SOURCE_INTERNAL) {
    $operationsTable->setHeader([_('Steps'), _('Details'), _('Start in'), _('Duration (sec)'), _('Action')]);
    $delay = count_operations_delay($this->data['action']['operations'], $this->data['action']['esc_period']);
} else {
    $operationsTable->setHeader([_('Details'), _('Action')]);
}
if ($this->data['action']['operations']) {
    $actionOperationDescriptions = getActionOperationDescriptions([$this->data['action']]);
    $defaultMessage = ['subject' => $this->data['action']['def_shortdata'], 'message' => $this->data['action']['def_longdata']];
    $actionOperationHints = getActionOperationHints($this->data['action']['operations'], $defaultMessage);
    foreach ($this->data['action']['operations'] as $operationid => $operation) {
        if (!str_in_array($operation['operationtype'], $data['allowedOperations'])) {
            continue;
        }
        if (!isset($operation['opconditions'])) {
            $operation['opconditions'] = [];
        }
        if (!isset($operation['mediatypeid'])) {
            $operation['mediatypeid'] = 0;
        }
        $details = (new CSpan($actionOperationDescriptions[0][$operationid]))->setHint($actionOperationHints[$operationid]);
        if ($this->data['eventsource'] == EVENT_SOURCE_TRIGGERS || $this->data['eventsource'] == EVENT_SOURCE_INTERNAL) {
            $esc_steps_txt = null;