1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22$widget = (new CWidget())->setTitle($data['title']); 23 24// append host summary to widget header 25if ($data['hostid'] != 0) { 26 switch ($data['elements_field']) { 27 case 'group_itemid': 28 $host_table_element = 'items'; 29 break; 30 case 'g_triggerid': 31 $host_table_element = 'triggers'; 32 break; 33 case 'group_graphid': 34 $host_table_element = 'graphs'; 35 break; 36 default: 37 $host_table_element = ''; 38 } 39 40 $widget->addItem(get_header_host_table($host_table_element, $data['hostid'])); 41} 42 43// create form 44$form = (new CForm()) 45 ->setName('elements_form') 46 ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) 47 ->addVar('action', $data['action']) 48 ->addVar($data['elements_field'], $data['elements']) 49 ->addVar('hostid', $data['hostid']); 50 51// create form list 52$form_list = new CFormList('elements_form_list'); 53 54// append copy types to form list 55$form_list->addRow(new CLabel(_('Target type'), 'copy_type'), 56 (new CRadioButtonList('copy_type', (int) $data['copy_type'])) 57 ->addValue(_('Host groups'), COPY_TYPE_TO_HOST_GROUP) 58 ->addValue(_('Hosts'), COPY_TYPE_TO_HOST) 59 ->addValue(_('Templates'), COPY_TYPE_TO_TEMPLATE) 60 ->setModern(true) 61); 62 63// append multiselect wrapper to form list 64$form_list->addRow((new CLabel(_('Target'), 'copy_targetids_ms'))->setAsteriskMark(), 65 (new CDiv())->setId('copy_targets') 66); 67 68// append tabs to form 69$tab_view = (new CTabView())->addTab('elements_tab', '', $form_list); 70 71// append buttons to form 72$tab_view->setFooter(makeFormFooter( 73 new CSubmit('copy', _('Copy')), 74 [new CButtonCancel(url_param('groupid').url_param('hostid'))] 75)); 76 77$form->addItem($tab_view); 78$widget->addItem($form); 79 80require_once dirname(__FILE__).'/js/configuration.copy.elements.js.php'; 81 82return $widget; 83