$item['yaxisside'] = 0;
    }
    insert_js('loadItem(' . $n . ', ' . CJs::encodeJson($item['gitemid']) . ', ' . $this->data['graphid'] . ', ' . $item['itemid'] . ', ' . CJs::encodeJson($name) . ', ' . $item['type'] . ', ' . $item['calc_fnc'] . ', ' . $item['drawtype'] . ', ' . $item['yaxisside'] . ', \'' . $item['color'] . '\', ' . $item['flags'] . ');', true);
}
$graphFormList->addRow(_('Items'), new CDiv($itemsTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// append tabs to form
$graphTab = new CTabView();
if (!$this->data['form_refresh']) {
    $graphTab->setSelected(0);
}
$graphTab->addTab('graphTab', empty($this->data['parent_discoveryid']) ? _('Graph') : _('Graph prototype'), $graphFormList);
/*
 * Preview tab
 */
$chartImage = new CImg('chart3.php?period=3600');
$chartImage->preload();
$graphPreviewTable = new CTable(null, 'center maxwidth');
$graphPreviewTable->addRow(new CDiv($chartImage, null, 'previewChar'));
$graphTab->addTab('previewTab', _('Preview'), $graphPreviewTable);
$graphForm->addItem($graphTab);
// append buttons to form
if (!empty($this->data['graphid'])) {
    $updateButton = new CSubmit('update', _('Update'));
    $deleteButton = new CButtonDelete($this->data['parent_discoveryid'] ? _('Delete graph prototype?') : _('Delete graph?'), url_params(array('graphid', 'parent_discoveryid', 'hostid')));
    if (!empty($this->data['templateid'])) {
        $updateButton->setEnabled(false);
        $deleteButton->setEnabled(false);
    }
    $graphForm->addItem(makeFormFooter($updateButton, array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel(url_param('parent_discoveryid')))));
} else {
    $graphForm->addItem(makeFormFooter(new CSubmit('add', _('Add')), new CButtonCancel(url_param('parent_discoveryid'))));
 /**
  * Returns output for simple graph preview.
  *
  * @return CTag
  */
 protected function getPreviewOutput()
 {
     $itemPrototype = $this->getItemPrototype();
     $queryParams = array('items' => array($itemPrototype), 'period' => 3600, 'legend' => 1, 'width' => $this->screenitem['width'], 'height' => $this->screenitem['height'], 'name' => $itemPrototype['hosts'][0]['name'] . NAME_DELIMITER . $itemPrototype['name']);
     $src = 'chart3.php?' . http_build_query($queryParams);
     $img = new CImg($src);
     $img->preload();
     return new CSpan($img);
 }
Exemplo n.º 3
0
 /**
  * Returns output for preview of graph prototype.
  *
  * @return CTag
  */
 protected function getPreviewOutput()
 {
     $graphPrototype = $this->getGraphPrototype();
     switch ($graphPrototype['graphtype']) {
         case GRAPH_TYPE_NORMAL:
         case GRAPH_TYPE_STACKED:
             $url = 'chart3.php';
             break;
         case GRAPH_TYPE_EXPLODED:
         case GRAPH_TYPE_3D_EXPLODED:
         case GRAPH_TYPE_3D:
         case GRAPH_TYPE_PIE:
             $url = 'chart7.php';
             break;
         case GRAPH_TYPE_BAR:
         case GRAPH_TYPE_COLUMN:
         case GRAPH_TYPE_BAR_STACKED:
         case GRAPH_TYPE_COLUMN_STACKED:
             $url = 'chart_bar.php';
             break;
         default:
             show_error_message(_('Graph prototype not found.'));
             exit;
     }
     $graphPrototypeItems = API::GraphItem()->get(array('output' => array('gitemid', 'itemid', 'sortorder', 'flags', 'type', 'calc_fnc', 'drawtype', 'yaxisside', 'color'), 'graphids' => array($graphPrototype['graphid'])));
     $queryParams = array('items' => $graphPrototypeItems, 'graphtype' => $graphPrototype['graphtype'], 'period' => 3600, 'legend' => $graphPrototype['show_legend'], 'graph3d' => $graphPrototype['show_3d'], 'width' => $this->screenitem['width'], 'height' => $this->screenitem['height'], 'name' => $graphPrototype['name']);
     $url .= '?' . http_build_query($queryParams);
     $img = new CImg($url);
     $img->preload();
     return new CSpan($img);
 }