/**
  * Process screen with particular screen objects.
  *
  * @return CTable
  */
 public function show()
 {
     if (empty($this->screen)) {
         return new CTableInfo(_('No screens defined.'));
     }
     $skipedFields = array();
     $screenitems = array();
     $emptyScreenColumns = array();
     // calculate table columns and rows
     foreach ($this->screen['screenitems'] as $screenitem) {
         $screenitems[] = $screenitem;
         for ($i = 0; $i < $screenitem['rowspan'] || $i == 0; $i++) {
             for ($j = 0; $j < $screenitem['colspan'] || $j == 0; $j++) {
                 if ($i != 0 || $j != 0) {
                     if (!isset($skipedFields[$screenitem['y'] + $i])) {
                         $skipedFields[$screenitem['y'] + $i] = array();
                     }
                     $skipedFields[$screenitem['y'] + $i][$screenitem['x'] + $j] = 1;
                 }
             }
         }
     }
     // create screen table
     $screenTable = new CTable();
     $screenTable->setAttribute('class', in_array($this->mode, array(SCREEN_MODE_PREVIEW, SCREEN_MODE_SLIDESHOW)) ? 'screen_view' : 'screen_edit');
     $screenTable->setAttribute('id', 'iframe');
     // action top row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $newColumns = array(new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         for ($i = 0, $size = $this->screen['hsize'] + 1; $i < $size; $i++) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_col=' . $i . '";');
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow($newColumns);
     }
     for ($r = 0; $r < $this->screen['vsize']; $r++) {
         $newColumns = array();
         $emptyScreenRow = true;
         // action left cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
             $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&add_row=' . $r . '";');
             array_push($newColumns, new CCol($icon));
         }
         for ($c = 0; $c < $this->screen['hsize']; $c++) {
             if (isset($skipedFields[$r][$c])) {
                 continue;
             }
             // screen item
             $isEditForm = false;
             $screenitem = array();
             foreach ($screenitems as $tmprow) {
                 if ($tmprow['x'] == $c && $tmprow['y'] == $r) {
                     $screenitem = $tmprow;
                     break;
                 }
             }
             if (empty($screenitem)) {
                 $screenitem = array('screenitemid' => 0, 'resourcetype' => 0, 'resourceid' => 0, 'width' => 0, 'height' => 0, 'colspan' => 1, 'rowspan' => 1, 'elements' => 0, 'valign' => VALIGN_DEFAULT, 'halign' => HALIGN_DEFAULT, 'style' => 0, 'url' => '', 'dynamic' => 0, 'sort_triggers' => SCREEN_SORT_TRIGGERS_DATE_DESC);
             }
             if (!empty($screenitem['screenitemid'])) {
                 $emptyScreenRow = false;
                 $emptyScreenColumns[$c] = 1;
             }
             // action
             if ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] != 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
             } elseif ($this->mode == SCREEN_MODE_EDIT && $screenitem['screenitemid'] == 0) {
                 $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
             } else {
                 $action = null;
             }
             // edit form cell
             if ($this->mode == SCREEN_MODE_EDIT && (isset($_REQUEST['form']) && $_REQUEST['form'] == 'update') && (isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r || isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitem['screenitemid']) == 0)) {
                 $screenView = new CView('configuration.screen.constructor.edit', array('screen' => $this->screen));
                 $item = $screenView->render();
                 $isEditForm = true;
             } elseif (!empty($screenitem['screenitemid']) && isset($screenitem['resourcetype'])) {
                 $screenBase = CScreenBuilder::getScreen(array('isFlickerfree' => $this->isFlickerfree, 'pageFile' => $this->pageFile, 'mode' => $this->mode, 'timestamp' => $this->timestamp, 'hostid' => $this->hostid, 'profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'timeline' => $this->timeline, 'resourcetype' => $screenitem['resourcetype'], 'screenitem' => $screenitem));
                 if (!empty($screenBase)) {
                     if ($this->mode == SCREEN_MODE_EDIT && !empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitem['screenitemid'];
                     } elseif ($this->mode == SCREEN_MODE_EDIT && empty($screenitem['screenitemid'])) {
                         $screenBase->action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r;
                     }
                     $item = $screenBase->get();
                 } else {
                     $item = null;
                 }
             } else {
                 $item = array(SPACE);
                 if ($this->mode == SCREEN_MODE_EDIT) {
                     array_push($item, BR(), new CLink(_('Change'), $action, 'empty_change_link'));
                 }
             }
             // align
             $halign = 'def';
             if ($screenitem['halign'] == HALIGN_CENTER) {
                 $halign = 'cntr';
             }
             if ($screenitem['halign'] == HALIGN_LEFT) {
                 $halign = 'left';
             }
             if ($screenitem['halign'] == HALIGN_RIGHT) {
                 $halign = 'right';
             }
             $valign = 'def';
             if ($screenitem['valign'] == VALIGN_MIDDLE) {
                 $valign = 'mdl';
             }
             if ($screenitem['valign'] == VALIGN_TOP) {
                 $valign = 'top';
             }
             if ($screenitem['valign'] == VALIGN_BOTTOM) {
                 $valign = 'bttm';
             }
             if ($this->mode == SCREEN_MODE_EDIT && !$isEditForm) {
                 $item = new CDiv($item, 'draggable');
                 $item->setAttribute('id', 'position_' . $r . '_' . $c);
                 $item->setAttribute('data-xcoord', $c);
                 $item->setAttribute('data-ycoord', $r);
             }
             // colspan/rowspan
             $newColumn = new CCol($item, $halign . '_' . $valign . ' screenitem');
             if (!empty($screenitem['colspan'])) {
                 $newColumn->setColSpan($screenitem['colspan']);
             }
             if (!empty($screenitem['rowspan'])) {
                 $newColumn->setRowSpan($screenitem['rowspan']);
             }
             array_push($newColumns, $newColumn);
         }
         // action right cell
         if ($this->mode == SCREEN_MODE_EDIT) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if ($emptyScreenRow) {
                 $removeRowLink = 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '";';
             } else {
                 $removeRowLink = 'javascript: if (Confirm("' . _('This screen-row is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_row=' . $r . '"; }';
             }
             $icon->addAction('onclick', $removeRowLink);
             array_push($newColumns, new CCol($icon));
         }
         $screenTable->addRow(new CRow($newColumns));
     }
     // action bottom row
     if ($this->mode == SCREEN_MODE_EDIT) {
         $icon = new CImg('images/general/plus.png', null, null, null, 'pointer');
         $icon->addAction('onclick', 'javascript: location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&add_row=' . $this->screen['vsize'] . '";');
         $newColumns = array(new CCol($icon));
         for ($i = 0; $i < $this->screen['hsize']; $i++) {
             $icon = new CImg('images/general/minus.png', null, null, null, 'pointer');
             if (isset($emptyScreenColumns[$i])) {
                 $removeColumnLink = 'javascript: if (Confirm("' . _('This screen-column is not empty. Delete it?') . '")) {' . ' location.href = "screenedit.php?screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '"; }';
             } else {
                 $removeColumnLink = 'javascript: location.href = "screenedit.php?config=1&screenid=' . $this->screen['screenid'] . '&rmv_col=' . $i . '";';
             }
             $icon->addAction('onclick', $removeColumnLink);
             array_push($newColumns, new CCol($icon));
         }
         array_push($newColumns, new CCol(new CImg('images/general/zero.png', 'zero', 1, 1)));
         $screenTable->addRow($newColumns);
     }
     return $screenTable;
 }
Пример #2
0
function bar_report_form3()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
    $config = get_request('config', 1);
    $title = get_request('title', S_REPORT . ' 3');
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $sorttype = get_request('sorttype', 0);
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date('YmdHis', time() - 86400));
    $report_timetill = get_request('report_timetill', date('YmdHis'));
    $captions = get_request('captions', array());
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    //	$reportForm->setMethod('post');
    if (isset($_REQUEST['report_show']) && !empty($items)) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date('YmdHis', $report_timesince));
    $reportForm->addVar('report_timetill', date('YmdHis', $report_timetill));
    //	$reportForm->addVar('items',$items); 				//params are set later!!
    //	$reportForm->addVar('periods',$periods);
    $reportForm->addRow(S_TITLE, new CTextBox('title', $title, 40));
    $reportForm->addRow(S_X . SPACE . S_LABEL, new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(S_Y . SPACE . S_LABEL, new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(S_LEGEND, new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    // GROUPS
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => 1, 'output' => 'extend');
    $db_groups = CHostGroup::get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(S_GROUPS, $group_tb->Get(S_SELECTED_GROUPS, S_OTHER . SPACE . S_GROUPS));
    // ----------
    // HOSTS
    //	validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid');
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, S_ALL_S);
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(S_GROUP, SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'host'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = CHost::get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'host');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['host']);
    }
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'host'), 'hostids' => $hostids);
    $db_hosts2 = CHost::get($options);
    order_result($db_hosts2, 'host');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['host']);
        }
    }
    $reportForm->addRow(S_HOSTS, $host_tb->Get(S_SELECTED_HOSTS, array(S_OTHER . SPACE . S_HOSTS . SPACE . '|' . SPACE . S_GROUP . SPACE, $cmbGroups)));
    // ----------
    //*/
    // PERIOD
    $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab = new CTable(null, 'calendar');
    $reporttimetab->setAttribute('width', '10%');
    $reporttimetab->setCellPadding(0);
    $reporttimetab->setCellSpacing(0);
    $reporttimetab->addRow(array(S_FROM, new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab->addRow(array(S_TILL, new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
    zbx_add_post_js('addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
    $reportForm->addRow(S_PERIOD, $reporttimetab);
    //-----------
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY);
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY);
    $reportForm->addRow(S_SCALE, $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, S_HOURLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, S_YEARLY);
    $reportForm->addRow(S_AVERAGE_BY, $avgcmb);
    // ITEMS
    $itemid = 0;
    $description = '';
    if (count($items) && $items[0]['itemid'] > 0) {
        $itemid = $items[0]['itemid'];
        $description = get_item_by_itemid($itemid);
        $description = item_description($description);
    }
    $reportForm->addVar('items[0][itemid]', $itemid);
    $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes');
    $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items[0][itemid]&dstfld2=items[0][description]&" . "srctbl=items&srcfld1=itemid&srcfld2=description&monitored_hosts=1');", 'T');
    $reportForm->addRow(S_ITEM, array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, S_PALETTE . ' #1');
    $paletteCmb->addItem(1, S_PALETTE . ' #2');
    $paletteCmb->addItem(2, S_PALETTE . ' #3');
    $paletteCmb->addItem(3, S_PALETTE . ' #4');
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, S_MIDDLE);
    $paletteTypeCmb->addItem(1, S_DARKEN);
    $paletteTypeCmb->addItem(2, S_BRIGHTEN);
    $reportForm->addRow(S_PALETTE, array($paletteCmb, $paletteTypeCmb));
    //--------------
    $reportForm->addItemToBottomRow(new CButton('report_show', S_SHOW));
    $reset = new CButton('reset', S_RESET);
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
Пример #3
0
 $config = get_request('config', 1);
 $caption = get_request('caption', '');
 $color = get_request('color', '009900');
 $report_timesince = get_request('report_timesince', time() - 86400);
 $report_timetill = get_request('report_timetill', time());
 $frmPd->addVar('config', $config);
 $frmPd->addVar('report_timesince', $report_timesince);
 $frmPd->addVar('report_timetill', $report_timetill);
 if (isset($_REQUEST['period_id'])) {
     $frmPd->addVar('period_id', $_REQUEST['period_id']);
 }
 $frmPd->addRow(array(new CVisibilityBox('caption_visible', !zbx_empty($caption), 'caption', S_DEFAULT), S_CAPTION), new CTextBox('caption', $caption, 10));
 //		$frmPd->addRow(S_CAPTION, new CTextBox('caption',$caption,10));
 //*
 $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
 $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
 $reporttimetab = new CTable(null, 'calendar');
 $reporttimetab->setAttribute('width', '10%');
 $reporttimetab->setCellPadding(0);
 $reporttimetab->setCellSpacing(0);
 $reporttimetab->addRow(array(S_FROM, new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon));
 zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");');
 $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
 $reporttimetab->addRow(array(S_TILL, new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon));
 zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
 $frmPd->addRow(S_PERIOD, $reporttimetab);
 //*/
 if ($config != 1) {
     $frmPd->addRow(S_COLOR, new CColor('color', $color));
 } else {
     $frmPd->addVar('color', $color);
Пример #4
0
function get_timeperiod_form()
{
    $tblPeriod = new CTableInfo();
    /* init new_timeperiod variable */
    $new_timeperiod = get_request('new_timeperiod', array());
    if (is_array($new_timeperiod) && isset($new_timeperiod['id'])) {
        $tblPeriod->addItem(new Cvar('new_timeperiod[id]', $new_timeperiod['id']));
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['date'])) {
        $new_timeperiod['date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // START TIME
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / 3600);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * 3600) / 60);
    }
    //--
    // PERIOD
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / 86400);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * 86400) / 3600);
    }
    //--
    // DAYSOFWEEK
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    //--
    // MONTHS
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    //--
    $bit_dayofweek = zbx_str_revert($dayofweek);
    $bit_month = zbx_str_revert($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, S_ONE_TIME_ONLY);
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, S_DAILY);
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, S_WEEKLY);
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, S_MONTHLY);
    $tblPeriod->addRow(array(S_PERIOD_TYPE, $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new Cvar('new_timeperiod[date]', $new_timeperiod['date']));
        $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(S_EVERY_DAY_S, new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } else {
        if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
            $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
            $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
            $tblPeriod->addItem(new Cvar('new_timeperiod[date]', $new_timeperiod['date']));
            $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
            $tblPeriod->addRow(array(S_EVERY_WEEK_S, new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
            $tabDays = new CTable();
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), S_MONDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), S_TUESDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), S_WEDNESDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), S_THURSDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), S_FRIDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), S_SATURDAY));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), S_SUNDAY));
            $tblPeriod->addRow(array(S_DAY_OF_WEEK, $tabDays));
        } else {
            if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
                $tblPeriod->addItem(new Cvar('new_timeperiod[date]', $new_timeperiod['date']));
                $tabMonths = new CTable();
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), S_JANUARY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), S_JULY));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), S_FEBRUARY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), S_AUGUST));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), S_MARCH, SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), S_SEPTEMBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), S_APRIL, SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), S_OCTOBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), S_MAY, SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), S_NOVEMBER));
                $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), S_JUNE, SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), S_DECEMBER));
                $tblPeriod->addRow(array(S_MONTH, $tabMonths));
                $radioDaily = new CTag('input');
                $radioDaily->addOption('type', 'radio');
                $radioDaily->addOption('name', 'new_timeperiod[month_date_type]');
                $radioDaily->addOption('value', '0');
                $radioDaily->addOption('onclick', 'submit()');
                $radioDaily2 = new CTag('input');
                $radioDaily2->addOption('type', 'radio');
                $radioDaily2->addOption('name', 'new_timeperiod[month_date_type]');
                $radioDaily2->addOption('value', '1');
                $radioDaily2->addOption('onclick', 'submit()');
                if ($new_timeperiod['month_date_type']) {
                    $radioDaily2->addOption('checked', 'checked');
                } else {
                    $radioDaily->addOption('checked', 'checked');
                }
                $tblPeriod->addRow(array(S_DATE, array($radioDaily, S_DAY, SPACE, SPACE, $radioDaily2, S_DAY_OF_WEEK)));
                if ($new_timeperiod['month_date_type'] > 0) {
                    $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
                    $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
                    $cmbCount->addItem(1, S_FIRST);
                    $cmbCount->addItem(2, S_SECOND);
                    $cmbCount->addItem(3, S_THIRD);
                    $cmbCount->addItem(4, S_FOURTH);
                    $cmbCount->addItem(5, S_LAST);
                    $td = new CCol($cmbCount);
                    $td->setColSpan(2);
                    $tabDays = new CTable();
                    $tabDays->addRow($td);
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), S_MONDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), S_TUESDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), S_WEDNESDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), S_THURSDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), S_FRIDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), S_SATURDAY));
                    $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), S_SUNDAY));
                    $tblPeriod->addRow(array(S_DAY_OF_WEEK, $tabDays));
                } else {
                    $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
                    $tblPeriod->addRow(array(S_DAY_OF_MONTH, new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
                }
            } else {
                $tblPeriod->addItem(new Cvar('new_timeperiod[every]', $new_timeperiod['every']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
                $tblPeriod->addItem(new Cvar('new_timeperiod[month]', bindec($bit_month)));
                $tblPeriod->addItem(new Cvar('new_timeperiod[day]', $new_timeperiod['day']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[hour]', $new_timeperiod['hour']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[minute]', $new_timeperiod['minute']));
                $tblPeriod->addItem(new Cvar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
                /***********************************************************/
                $tblPeriod->addItem(new Cvar('new_timeperiod[date]', $new_timeperiod['date']));
                $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
                $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['new_timeperiod_date'].clndr.clndrshow(pos.top,pos.left);");
                $filtertimetab = new CTable(null, 'calendar');
                $filtertimetab->addOption('width', '10%');
                $filtertimetab->SetCellPadding(0);
                $filtertimetab->SetCellSpacing(0);
                $filtertimetab->addRow(array(new CNumericBox('new_timeperiod_day', $new_timeperiod['date'] > 0 ? date('d', $new_timeperiod['date']) : '', 2), '/', new CNumericBox('new_timeperiod_month', $new_timeperiod['date'] > 0 ? date('m', $new_timeperiod['date']) : '', 2), '/', new CNumericBox('new_timeperiod_year', $new_timeperiod['date'] > 0 ? date('Y', $new_timeperiod['date']) : '', 4), SPACE, new CNumericBox('new_timeperiod_hour', $new_timeperiod['date'] > 0 ? date('H', $new_timeperiod['date']) : '', 2), ':', new CNumericBox('new_timeperiod_minute', $new_timeperiod['date'] > 0 ? date('i', $new_timeperiod['date']) : '', 2), $clndr_icon));
                zbx_add_post_js('create_calendar(null,' . '["new_timeperiod_day","new_timeperiod_month","new_timeperiod_year","new_timeperiod_hour","new_timeperiod_minute"],' . '"new_timeperiod_date",' . '"new_timeperiod[date]");');
                $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['mntc_active_till'].clndr.clndrshow(pos.top,pos.left);");
                $tblPeriod->addRow(array(S_DATE, $filtertimetab));
                zbx_add_post_js('if("undefined" != typeof(CLNDR["new_timeperiod_date"]))' . ' addListener($("hat_new_timeperiod_icon"),' . '"click",' . 'CLNDR["new_timeperiod_date"].clndr.clndrhide.bindAsEventListener(CLNDR["new_timeperiod_date"].clndr));');
                //-------
            }
        }
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tabTime = new CTable(null, 'calendar');
        $tabTime->addRow(array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)));
        $tblPeriod->addRow(array(S_AT . SPACE . '(' . S_HOUR . ':' . S_MINUTE . ')', $tabTime));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours']);
    for ($i = 0; $i < 25; $i++) {
        $perHours->addItem($i, $i . SPACE);
    }
    $tblPeriod->addRow(array(S_MAINTENANCE_PERIOD_LENGTH, array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), S_DAYS . SPACE . SPACE, $perHours, SPACE . S_HOURS)));
    //			$tabPeriod = new CTable();
    //			$tabPeriod->addRow(S_DAYS)
    //			$tblPeriod->addRow(array(S_AT.SPACE.'('.S_HOUR.':'.S_MINUTE.')', $tabTime));
    $td = new CCol(array(new CButton('add_timeperiod', S_SAVE), SPACE, new CButton('cancel_new_timeperiod', S_CANCEL)));
    $td->addOption('colspan', '3');
    $td->addOption('style', 'text-align: right;');
    $tblPeriod->SetFooter($td);
    return $tblPeriod;
}
Пример #5
0
    $cmbResource->addItem(AUDIT_RESOURCE_IT_SERVICE, S_IT_SERVICE);
    $cmbResource->addItem(AUDIT_RESOURCE_MAP, S_MAP);
    $cmbResource->addItem(AUDIT_RESOURCE_SCREEN, S_SCREEN);
    $cmbResource->addItem(AUDIT_RESOURCE_NODE, S_NODE);
    $cmbResource->addItem(AUDIT_RESOURCE_SCENARIO, S_SCENARIO);
    $cmbResource->addItem(AUDIT_RESOURCE_DISCOVERY_RULE, S_DISCOVERY_RULE);
    $cmbResource->addItem(AUDIT_RESOURCE_SLIDESHOW, S_SLIDESHOW);
    $cmbResource->addItem(AUDIT_RESOURCE_SCRIPT, S_SCRIPT);
    $cmbResource->addItem(AUDIT_RESOURCE_PROXY, S_PROXY);
    $cmbResource->addItem(AUDIT_RESOURCE_MAINTENANCE, S_MAINTENANCE);
    $cmbResource->addItem(AUDIT_RESOURCE_REGEXP, S_REGULAR_EXPRESSION);
    $filterForm->addRow(S_RESOURCE, $cmbResource);
}
//*
$clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
$clndr_icon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top+=10; pos.left+=16; CLNDR['audit_since'].clndr.clndrshow(pos.top,pos.left);");
$clndr_icon->setAttribute('style', 'vertical-align: middle;');
$nav_clndr = array(new CNumericBox('nav_day', $_REQUEST['nav_time'] > 0 ? date('d', $_REQUEST['nav_time']) : '', 2), new CNumericBox('nav_month', $_REQUEST['nav_time'] > 0 ? date('m', $_REQUEST['nav_time']) : '', 2), new CNumericBox('nav_year', $_REQUEST['nav_time'] > 0 ? date('Y', $_REQUEST['nav_time']) : '', 4), new CNumericBox('nav_hour', $_REQUEST['nav_time'] > 0 ? date('H', $_REQUEST['nav_time']) : '', 2), ':', new CNumericBox('nav_minute', $_REQUEST['nav_time'] > 0 ? date('i', $_REQUEST['nav_time']) : '', 2), $clndr_icon);
$filterForm->addRow(S_ACTIONS_BEFORE, $nav_clndr);
zbx_add_post_js('create_calendar(null,' . '["nav_day","nav_month","nav_year","nav_hour","nav_minute"],' . '"audit_since");');
zbx_add_post_js('addListener($("filter_icon"),' . '"click",CLNDR[\'audit_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'audit_since\'].clndr));');
//*/
$reset = new CButton('filter_rst', S_RESET);
$reset->setType('button');
$reset->setAction('javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();');
$filterForm->addItemToBottomRow(new CButton("filter_set", S_FILTER));
$filterForm->addItemToBottomRow($reset);
$audit_wdgt->addFlicker($filterForm, get_profile('web.audit.filter.state', 1));
//-------
$nav = get_thin_table_header($navigation);
$audit_wdgt->addItem(array($nav, $table, $nav));
Пример #6
0
//*/
$navForm->addItem(array($prev_page, SPACE, $next_page));
$navigation = $navForm;
//------------
/************************* FILTER **************************/
/***********************************************************/
$filterForm = new CFormTable();
//,'events.php?filter_set=1','POST',null,'sform');
$filterForm->setAttribute('name', 'zbx_filter');
$filterForm->setAttribute('id', 'zbx_filter');
//	$filterForm->setMethod('get');
$filterForm->addVar('nav_time', $_REQUEST['nav_time']);
$script = new CScript("javascript: if(CLNDR['nav_time'].clndr.setSDateFromOuterObj()){" . "\$('nav_time').value = parseInt(CLNDR['nav_time'].clndr.sdt.getTime()/1000); }");
$filterForm->addAction('onsubmit', $script);
$clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
$clndr_icon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top+=14; pos.left-=174; CLNDR['nav_time'].clndr.clndrshow(pos.top,pos.left);");
$clndr_icon->setAttribute('style', 'vertical-align: middle;');
$nav_clndr = array(new CNumericBox('nav_day', $_REQUEST['nav_time'] > 0 ? date('d', $_REQUEST['nav_time']) : '', 2), new CNumericBox('nav_month', $_REQUEST['nav_time'] > 0 ? date('m', $_REQUEST['nav_time']) : '', 2), new CNumericBox('nav_year', $_REQUEST['nav_time'] > 0 ? date('Y', $_REQUEST['nav_time']) : '', 4), SPACE, new CNumericBox('nav_hour', $_REQUEST['nav_time'] > 0 ? date('H', $_REQUEST['nav_time']) : '', 2), ':', new CNumericBox('nav_minute', $_REQUEST['nav_time'] > 0 ? date('i', $_REQUEST['nav_time']) : '', 2), $clndr_icon);
zbx_add_post_js('create_calendar(null,["nav_day","nav_month","nav_year","nav_hour","nav_minute"],"nav_time");');
$filterForm->addRow(S_EVENTS_BEFORE, $nav_clndr);
if (EVENT_SOURCE_TRIGGERS == $source) {
    $filterForm->addVar('triggerid', $_REQUEST['triggerid']);
    if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) {
        $trigger = expand_trigger_description($_REQUEST['triggerid']);
    } else {
        $trigger = "";
    }
    $row = new CRow(array(new CCol(S_TRIGGER, 'form_row_l'), new CCol(array(new CTextBox("trigger", $trigger, 96, 'yes'), new CButton("btn1", S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $filterForm->GetName() . "&dstfld1=triggerid&dstfld2=trigger" . "&srctbl=triggers&srcfld1=triggerid&srcfld2=description&real_hosts=1');", 'T')), 'form_row_r')));
    $filterForm->addRow($row);
    $filterForm->addVar('show_unknown', $show_unknown);
    $unkcbx = new CCheckBox('show_unk', $show_unknown, null, '1');
Пример #7
0
     $mname = get_request('mname', '');
     $maintenance_type = get_request('maintenance_type', 0);
     $active_since = zbxDateToTime(get_request('active_since', date('YmdHis')));
     $active_till = zbxDateToTime(get_request('active_till', date('YmdHis', time() + 86400)));
     $description = get_request('description', '');
 }
 $tblMntc = new CTable(null, 'formElementTable');
 $tblMntc->addRow(array(S_NAME, new CTextBox('mname', $mname, 50)));
 $cmbType = new CComboBox('maintenance_type', $maintenance_type);
 $cmbType->addItem(MAINTENANCE_TYPE_NORMAL, S_WITH_DATA_COLLECTION);
 $cmbType->addItem(MAINTENANCE_TYPE_NODATA, S_NO_DATA_COLLECTION);
 $tblMntc->addRow(array(S_MAINTENANCE_TYPE, $cmbType));
 $tblMntc->addItem(new Cvar('active_since', date('YmdHis', $active_since)));
 $tblMntc->addItem(new Cvar('active_till', date('YmdHis', $active_till)));
 $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
 $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; CLNDR["mntc_active_since"].clndr.clndrshow(pos.top,pos.left);');
 zbx_add_post_js('create_calendar(null, ["mntc_since_day","mntc_since_month","mntc_since_year",' . '"mntc_since_hour","mntc_since_minute"],"mntc_active_since","active_since");');
 $tblMntc->addRow(array(S_ACTIVE_SINCE, array(new CNumericBox('mntc_since_day', $active_since > 0 ? date('d', $active_since) : '', 2), '/', new CNumericBox('mntc_since_month', $active_since > 0 ? date('m', $active_since) : '', 2), '/', new CNumericBox('mntc_since_year', $active_since > 0 ? date('Y', $active_since) : '', 4), SPACE, new CNumericBox('mntc_since_hour', $active_since > 0 ? date('H', $active_since) : '', 2), ':', new CNumericBox('mntc_since_minute', $active_since > 0 ? date('i', $active_since) : '', 2), $clndr_icon)));
 $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); ' . 'pos.top+=10; pos.left+=16; CLNDR["mntc_active_till"].clndr.clndrshow(pos.top,pos.left);');
 zbx_add_post_js('create_calendar(null,["mntc_till_day","mntc_till_month","mntc_till_year",' . '"mntc_till_hour","mntc_till_minute"],"mntc_active_till","active_till");');
 $tblMntc->addRow(array(S_ACTIVE_TILL, array(new CNumericBox('mntc_till_day', $active_till > 0 ? date('d', $active_till) : '', 2), '/', new CNumericBox('mntc_till_month', $active_till > 0 ? date('m', $active_till) : '', 2), '/', new CNumericBox('mntc_till_year', $active_till > 0 ? date('Y', $active_till) : '', 4), SPACE, new CNumericBox('mntc_till_hour', $active_till > 0 ? date('H', $active_till) : '', 2), ':', new CNumericBox('mntc_till_minute', $active_till > 0 ? date('i', $active_till) : '', 2), $clndr_icon)));
 $tblMntc->addRow(array(S_DESCRIPTION, new CTextArea('description', $description, 66, 5)));
 $footer = array(new CButton('save', S_SAVE));
 if (isset($_REQUEST['maintenanceid'])) {
     $footer[] = new CButton('clone', S_CLONE);
     $footer[] = new CButtonDelete(S_DELETE_MAINTENANCE_PERIOD_Q, url_param('form') . url_param('maintenanceid'));
 }
 $footer[] = new CButtonCancel();
 $left_tab->addRow(new CFormElement(S_MAINTENANCE, $tblMntc, $footer));
 // }}} MAINTENANCE FORM
 // MAINTENANCE PERIODS {{{
    $row->setAttribute('id', 'times_' . $i);
    $servicesTimeTable->addRow($row);
    $i++;
}
$servicesTimeFormList->addRow(_('Service times'), new CDiv($servicesTimeTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
// create service time table
$serviceTimeTable = new CTable(null, 'formElementTable');
if ($this->data['new_service_time']['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME) {
    $downtimeSince = date('YmdHis');
    $downtimeTill = date('YmdHis', time() + 86400);
    $downtimeSince = zbxDateToTime($downtimeSince);
    $downtimeTill = zbxDateToTime($downtimeTill);
    // create calendar table
    $timeCalendarTable = new CTable();
    $calendarIcon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $calendarIcon->addAction('onclick', "javascript: var pos = getPosition(this); pos.top -= 203; pos.left += 16; CLNDR['downtime_since'].clndr.clndrshow(pos.top, pos.left); CLNDR['downtime_till'].clndr.clndrhide();");
    // downtime since
    if (isset($_REQUEST['new_service_time']['from'])) {
        $year = get_request('downtime_since_year');
        $month = get_request('downtime_since_month');
        $day = get_request('downtime_since_day');
        $hours = get_request('downtime_since_hour');
        $minutes = get_request('downtime_since_minute');
    } elseif ($downtimeSince > 0) {
        $year = date('Y', $downtimeSince);
        $month = date('m', $downtimeSince);
        $day = date('d', $downtimeSince);
        $hours = date('H', $downtimeSince);
        $minutes = date('i', $downtimeSince);
    } else {
        $year = '';
function bar_report_form3()
{
    $config = get_request('config', 1);
    $title = get_request('title', _('Report 3'));
    $xlabel = get_request('xlabel', '');
    $ylabel = get_request('ylabel', '');
    $scaletype = get_request('scaletype', TIMEPERIOD_TYPE_WEEKLY);
    $avgperiod = get_request('avgperiod', TIMEPERIOD_TYPE_DAILY);
    $report_timesince = get_request('report_timesince', date('YmdHis', time() - SEC_PER_DAY));
    $report_timetill = get_request('report_timetill', date('YmdHis'));
    $items = get_request('items', array());
    $hostids = get_request('hostids', array());
    $hostids = zbx_toHash($hostids);
    $showlegend = get_request('showlegend', 0);
    $palette = get_request('palette', 0);
    $palettetype = get_request('palettetype', 0);
    $reportForm = new CFormTable(null, null, 'get');
    //,'events.php?report_set=1','POST',null,'sform');
    $reportForm->setAttribute('name', 'zbx_report');
    $reportForm->setAttribute('id', 'zbx_report');
    //	$reportForm->setMethod('post');
    if (isset($_REQUEST['report_show']) && !empty($items)) {
        $reportForm->addVar('report_show', 'show');
    }
    $reportForm->addVar('config', $config);
    $reportForm->addVar('report_timesince', date('YmdHis', $report_timesince));
    $reportForm->addVar('report_timetill', date('YmdHis', $report_timetill));
    //	$reportForm->addVar('items',$items); 				//params are set later!!
    //	$reportForm->addVar('periods',$periods);
    $reportForm->addRow(_('Title'), new CTextBox('title', $title, 40));
    $reportForm->addRow(_('X label'), new CTextBox('xlabel', $xlabel, 40));
    $reportForm->addRow(_('Y label'), new CTextBox('ylabel', $ylabel, 40));
    $reportForm->addRow(_('Legend'), new CCheckBox('showlegend', $showlegend, null, 1));
    $reportForm->addVar('sortorder', 0);
    // GROUPS
    $groupids = get_request('groupids', array());
    $group_tb = new CTweenBox($reportForm, 'groupids', $groupids, 10);
    $options = array('real_hosts' => 1, 'output' => 'extend');
    $db_groups = API::HostGroup()->get($options);
    order_result($db_groups, 'name');
    foreach ($db_groups as $gnum => $group) {
        $groupids[$group['groupid']] = $group['groupid'];
        $group_tb->addItem($group['groupid'], $group['name']);
    }
    $reportForm->addRow(_('Groups'), $group_tb->Get(_('Selected groups'), _('Other groups')));
    // ----------
    // HOSTS
    //	validate_group(PERM_READ_ONLY,array('real_hosts'),'web.last.conf.groupid');
    $groupid = get_request('groupid', 0);
    $cmbGroups = new CComboBox('groupid', $groupid, 'submit()');
    $cmbGroups->addItem(0, _('All'));
    foreach ($db_groups as $gnum => $group) {
        $cmbGroups->addItem($group['groupid'], $group['name']);
    }
    $td_groups = new CCol(array(_('Group'), SPACE, $cmbGroups));
    $td_groups->setAttribute('style', 'text-align: right;');
    $host_tb = new CTweenBox($reportForm, 'hostids', $hostids, 10);
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'));
    if ($groupid > 0) {
        $options['groupids'] = $groupid;
    }
    $db_hosts = API::Host()->get($options);
    $db_hosts = zbx_toHash($db_hosts, 'hostid');
    order_result($db_hosts, 'name');
    foreach ($db_hosts as $hnum => $host) {
        $host_tb->addItem($host['hostid'], $host['name']);
    }
    $options = array('real_hosts' => 1, 'output' => array('hostid', 'name'), 'hostids' => $hostids);
    $db_hosts2 = API::Host()->get($options);
    order_result($db_hosts2, 'name');
    foreach ($db_hosts2 as $hnum => $host) {
        if (!isset($db_hosts[$host['hostid']])) {
            $host_tb->addItem($host['hostid'], $host['name']);
        }
    }
    $reportForm->addRow(_('Hosts'), $host_tb->Get(_('Selected hosts'), array(_('Other hosts | Group') . SPACE, $cmbGroups)));
    // ----------
    //*/
    // PERIOD
    $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_since'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab = new CTable(null, 'calendar');
    $reporttimetab->setAttribute('width', '10%');
    $reporttimetab->setCellPadding(0);
    $reporttimetab->setCellSpacing(0);
    $reporttimetab->addRow(array(_('From'), new CNumericBox('report_since_day', $report_timesince > 0 ? date('d', $report_timesince) : '', 2), '/', new CNumericBox('report_since_month', $report_timesince > 0 ? date('m', $report_timesince) : '', 2), '/', new CNumericBox('report_since_year', $report_timesince > 0 ? date('Y', $report_timesince) : '', 4), SPACE, new CNumericBox('report_since_hour', $report_timesince > 0 ? date('H', $report_timesince) : '', 2), ':', new CNumericBox('report_since_minute', $report_timesince > 0 ? date('i', $report_timesince) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_since_day","report_since_month","report_since_year","report_since_hour","report_since_minute"],' . '"avail_report_since",' . '"report_timesince");');
    $clndr_icon->addAction('onclick', 'javascript: ' . 'var pos = getPosition(this); ' . 'pos.top+=10; ' . 'pos.left+=16; ' . "CLNDR['avail_report_till'].clndr.clndrshow(pos.top,pos.left);");
    $reporttimetab->addRow(array(_('Till'), new CNumericBox('report_till_day', $report_timetill > 0 ? date('d', $report_timetill) : '', 2), '/', new CNumericBox('report_till_month', $report_timetill > 0 ? date('m', $report_timetill) : '', 2), '/', new CNumericBox('report_till_year', $report_timetill > 0 ? date('Y', $report_timetill) : '', 4), SPACE, new CNumericBox('report_till_hour', $report_timetill > 0 ? date('H', $report_timetill) : '', 2), ':', new CNumericBox('report_till_minute', $report_timetill > 0 ? date('i', $report_timetill) : '', 2), $clndr_icon));
    zbx_add_post_js('create_calendar(null,' . '["report_till_day","report_till_month","report_till_year","report_till_hour","report_till_minute"],' . '"avail_report_till",' . '"report_timetill");');
    zbx_add_post_js('addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_since\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_since\'].clndr));' . 'addListener($("filter_icon"),' . '"click",' . 'CLNDR[\'avail_report_till\'].clndr.clndrhide.bindAsEventListener(CLNDR[\'avail_report_till\'].clndr));');
    $reportForm->addRow(_('Period'), $reporttimetab);
    $scale = new CComboBox('scaletype', $scaletype);
    $scale->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $scale->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $scale->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $scale->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $scale->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Scale'), $scale);
    $avgcmb = new CComboBox('avgperiod', $avgperiod);
    $avgcmb->addItem(TIMEPERIOD_TYPE_HOURLY, _('Hourly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $avgcmb->addItem(TIMEPERIOD_TYPE_YEARLY, _('Yearly'));
    $reportForm->addRow(_('Average by'), $avgcmb);
    // items
    $itemid = 0;
    $description = '';
    if (count($items) && $items[0]['itemid'] > 0) {
        $itemid = $items[0]['itemid'];
        $description = get_item_by_itemid($itemid);
        $description = itemName($description);
    }
    $itemidVar = new CVar('items[0][itemid]', $itemid, 'items_0_itemid');
    $reportForm->addItem($itemidVar);
    $txtCondVal = new CTextBox('items[0][description]', $description, 50, 'yes');
    $txtCondVal->setAttribute('id', 'items_0_description');
    $btnSelect = new CButton('btn1', _('Select'), "return PopUp('popup.php?dstfrm=" . $reportForm->GetName() . "&dstfld1=items_0_itemid&dstfld2=items_0_description&" . "srctbl=items&srcfld1=itemid&srcfld2=name&monitored_hosts=1');", 'T');
    $reportForm->addRow(_('Item'), array($txtCondVal, $btnSelect));
    $paletteCmb = new CComboBox('palette', $palette);
    $paletteCmb->addItem(0, _s('Palette #%1$s', 1));
    $paletteCmb->addItem(1, _s('Palette #%1$s', 2));
    $paletteCmb->addItem(2, _s('Palette #%1$s', 3));
    $paletteCmb->addItem(3, _s('Palette #%1$s', 4));
    $paletteTypeCmb = new CComboBox('palettetype', $palettetype);
    $paletteTypeCmb->addItem(0, _('Middle'));
    $paletteTypeCmb->addItem(1, _('Darken'));
    $paletteTypeCmb->addItem(2, _('Brighten'));
    $reportForm->addRow(_('Palette'), array($paletteCmb, $paletteTypeCmb));
    $reportForm->addItemToBottomRow(new CSubmit('report_show', _('Show')));
    $reset = new CButton('reset', _('Reset'));
    $reset->setType('reset');
    $reportForm->addItemToBottomRow($reset);
    return $reportForm;
}
Пример #10
0
function get_timeperiod_form()
{
    $tblPeriod = new CTableInfo();
    // init new_timeperiod variable
    $new_timeperiod = get_request('new_timeperiod', array());
    $new = is_array($new_timeperiod);
    if (is_array($new_timeperiod)) {
        if (isset($new_timeperiod['id'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[id]', $new_timeperiod['id']));
        }
        if (isset($new_timeperiod['timeperiodid'])) {
            $tblPeriod->addItem(new CVar('new_timeperiod[timeperiodid]', $new_timeperiod['timeperiodid']));
        }
    }
    if (!is_array($new_timeperiod)) {
        $new_timeperiod = array();
        $new_timeperiod['timeperiod_type'] = TIMEPERIOD_TYPE_ONETIME;
    }
    if (!isset($new_timeperiod['every'])) {
        $new_timeperiod['every'] = 1;
    }
    if (!isset($new_timeperiod['day'])) {
        $new_timeperiod['day'] = 1;
    }
    if (!isset($new_timeperiod['hour'])) {
        $new_timeperiod['hour'] = 12;
    }
    if (!isset($new_timeperiod['minute'])) {
        $new_timeperiod['minute'] = 0;
    }
    if (!isset($new_timeperiod['start_date'])) {
        $new_timeperiod['start_date'] = 0;
    }
    if (!isset($new_timeperiod['period_days'])) {
        $new_timeperiod['period_days'] = 0;
    }
    if (!isset($new_timeperiod['period_hours'])) {
        $new_timeperiod['period_hours'] = 1;
    }
    if (!isset($new_timeperiod['period_minutes'])) {
        $new_timeperiod['period_minutes'] = 0;
    }
    if (!isset($new_timeperiod['month_date_type'])) {
        $new_timeperiod['month_date_type'] = !(bool) $new_timeperiod['day'];
    }
    // start time
    if (isset($new_timeperiod['start_time'])) {
        $new_timeperiod['hour'] = floor($new_timeperiod['start_time'] / SEC_PER_HOUR);
        $new_timeperiod['minute'] = floor(($new_timeperiod['start_time'] - $new_timeperiod['hour'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // period
    if (isset($new_timeperiod['period'])) {
        $new_timeperiod['period_days'] = floor($new_timeperiod['period'] / SEC_PER_DAY);
        $new_timeperiod['period_hours'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY) / SEC_PER_HOUR);
        $new_timeperiod['period_minutes'] = floor(($new_timeperiod['period'] - $new_timeperiod['period_days'] * SEC_PER_DAY - $new_timeperiod['period_hours'] * SEC_PER_HOUR) / SEC_PER_MIN);
    }
    // daysofweek
    $dayofweek = '';
    $dayofweek .= !isset($new_timeperiod['dayofweek_mo']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_tu']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_we']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_th']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_fr']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_sa']) ? '0' : '1';
    $dayofweek .= !isset($new_timeperiod['dayofweek_su']) ? '0' : '1';
    if (isset($new_timeperiod['dayofweek'])) {
        $dayofweek = zbx_num2bitstr($new_timeperiod['dayofweek'], true);
    }
    $new_timeperiod['dayofweek_mo'] = $dayofweek[0];
    $new_timeperiod['dayofweek_tu'] = $dayofweek[1];
    $new_timeperiod['dayofweek_we'] = $dayofweek[2];
    $new_timeperiod['dayofweek_th'] = $dayofweek[3];
    $new_timeperiod['dayofweek_fr'] = $dayofweek[4];
    $new_timeperiod['dayofweek_sa'] = $dayofweek[5];
    $new_timeperiod['dayofweek_su'] = $dayofweek[6];
    // months
    $month = '';
    $month .= !isset($new_timeperiod['month_jan']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_feb']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_mar']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_apr']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_may']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jun']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_jul']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_aug']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_sep']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_oct']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_nov']) ? '0' : '1';
    $month .= !isset($new_timeperiod['month_dec']) ? '0' : '1';
    if (isset($new_timeperiod['month'])) {
        $month = zbx_num2bitstr($new_timeperiod['month'], true);
    }
    $new_timeperiod['month_jan'] = $month[0];
    $new_timeperiod['month_feb'] = $month[1];
    $new_timeperiod['month_mar'] = $month[2];
    $new_timeperiod['month_apr'] = $month[3];
    $new_timeperiod['month_may'] = $month[4];
    $new_timeperiod['month_jun'] = $month[5];
    $new_timeperiod['month_jul'] = $month[6];
    $new_timeperiod['month_aug'] = $month[7];
    $new_timeperiod['month_sep'] = $month[8];
    $new_timeperiod['month_oct'] = $month[9];
    $new_timeperiod['month_nov'] = $month[10];
    $new_timeperiod['month_dec'] = $month[11];
    $bit_dayofweek = zbx_str_revert($dayofweek);
    $bit_month = zbx_str_revert($month);
    $cmbType = new CComboBox('new_timeperiod[timeperiod_type]', $new_timeperiod['timeperiod_type'], 'submit()');
    $cmbType->addItem(TIMEPERIOD_TYPE_ONETIME, _('One time only'));
    $cmbType->addItem(TIMEPERIOD_TYPE_DAILY, _('Daily'));
    $cmbType->addItem(TIMEPERIOD_TYPE_WEEKLY, _('Weekly'));
    $cmbType->addItem(TIMEPERIOD_TYPE_MONTHLY, _('Monthly'));
    $tblPeriod->addRow(array(_('Period type'), $cmbType));
    if ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_DAILY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every day(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 3)));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_WEEKLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month)));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addRow(array(_('Every week(s)'), new CNumericBox('new_timeperiod[every]', $new_timeperiod['every'], 2)));
        $tabDays = new CTable();
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
        $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
        $tblPeriod->addRow(array(_('Day of week'), $tabDays));
    } elseif ($new_timeperiod['timeperiod_type'] == TIMEPERIOD_TYPE_MONTHLY) {
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tabMonths = new CTable();
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jan]', $month[0], null, 1), _('January'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_jul]', $month[6], null, 1), _('July')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_feb]', $month[1], null, 1), _('February'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_aug]', $month[7], null, 1), _('August')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_mar]', $month[2], null, 1), _('March'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_sep]', $month[8], null, 1), _('September')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_apr]', $month[3], null, 1), _('April'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_oct]', $month[9], null, 1), _('October')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_may]', $month[4], null, 1), _('May'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_nov]', $month[10], null, 1), _('November')));
        $tabMonths->addRow(array(new CCheckBox('new_timeperiod[month_jun]', $month[5], null, 1), _('June'), SPACE, SPACE, new CCheckBox('new_timeperiod[month_dec]', $month[11], null, 1), _('December')));
        $tblPeriod->addRow(array(_('Month'), $tabMonths));
        $radioDaily = new CTag('input');
        $radioDaily->setAttribute('type', 'radio');
        $radioDaily->setAttribute('name', 'new_timeperiod[month_date_type]');
        $radioDaily->setAttribute('value', '0');
        $radioDaily->setAttribute('onclick', 'submit()');
        $radioDaily2 = new CTag('input');
        $radioDaily2->setAttribute('type', 'radio');
        $radioDaily2->setAttribute('name', 'new_timeperiod[month_date_type]');
        $radioDaily2->setAttribute('value', '1');
        $radioDaily2->setAttribute('onclick', 'submit()');
        if ($new_timeperiod['month_date_type']) {
            $radioDaily2->setAttribute('checked', 'checked');
        } else {
            $radioDaily->setAttribute('checked', 'checked');
        }
        $tblPeriod->addRow(array(_('Date'), array($radioDaily, _('Day'), SPACE, SPACE, $radioDaily2, _('Day of week'))));
        if ($new_timeperiod['month_date_type'] > 0) {
            $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day']));
            $cmbCount = new CComboBox('new_timeperiod[every]', $new_timeperiod['every']);
            $cmbCount->addItem(1, _('First'));
            $cmbCount->addItem(2, _('Second'));
            $cmbCount->addItem(3, _('Third'));
            $cmbCount->addItem(4, _('Fourth'));
            $cmbCount->addItem(5, _('Last'));
            $td = new CCol($cmbCount);
            $td->setColSpan(2);
            $tabDays = new CTable();
            $tabDays->addRow($td);
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_mo]', $dayofweek[0], null, 1), _('Monday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_tu]', $dayofweek[1], null, 1), _('Tuesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_we]', $dayofweek[2], null, 1), _('Wednesday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_th]', $dayofweek[3], null, 1), _('Thursday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_fr]', $dayofweek[4], null, 1), _('Friday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_sa]', $dayofweek[5], null, 1), _('Saturday')));
            $tabDays->addRow(array(new CCheckBox('new_timeperiod[dayofweek_su]', $dayofweek[6], null, 1), _('Sunday')));
            $tblPeriod->addRow(array(_('Day of week'), $tabDays));
        } else {
            $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
            $tblPeriod->addRow(array(_('Day of month'), new CNumericBox('new_timeperiod[day]', $new_timeperiod['day'], 2)));
        }
    } else {
        $tblPeriod->addItem(new CVar('new_timeperiod[every]', $new_timeperiod['every'], 'new_timeperiod_every_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[month]', bindec($bit_month), 'new_timeperiod_month_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[day]', $new_timeperiod['day'], 'new_timeperiod_day_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[hour]', $new_timeperiod['hour'], 'new_timeperiod_hour_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[minute]', $new_timeperiod['minute'], 'new_timeperiod_minute_tmp'));
        $tblPeriod->addItem(new CVar('new_timeperiod[start_date]', $new_timeperiod['start_date']));
        $tblPeriod->addItem(new CVar('new_timeperiod[month_date_type]', $new_timeperiod['month_date_type']));
        $tblPeriod->addItem(new CVar('new_timeperiod[dayofweek]', bindec($bit_dayofweek)));
        $clndr_icon = new CImg('images/general/bar/cal.gif', 'calendar', 16, 12, 'pointer');
        $clndr_icon->addAction('onclick', 'javascript: var pos = getPosition(this); pos.top += 10; pos.left += 16; CLNDR["new_timeperiod_date"].clndr.clndrshow(pos.top, pos.left);');
        $filtertimetab = new CTable(null, 'calendar');
        $filtertimetab->setAttribute('width', '10%');
        $filtertimetab->setCellPadding(0);
        $filtertimetab->setCellSpacing(0);
        $startDate = zbxDateToTime($new_timeperiod['start_date']);
        if (isset($_REQUEST['add_timeperiod'])) {
            $newTimePeriodYear = get_request('new_timeperiod_year');
            $newTimePeriodMonth = get_request('new_timeperiod_month');
            $newTimePeriodDay = get_request('new_timeperiod_day');
            $newTimePeriodHours = get_request('new_timeperiod_hour');
            $newTimePeriodMinutes = get_request('new_timeperiod_minute');
        } elseif ($startDate > 0) {
            $newTimePeriodYear = date('Y', $startDate);
            $newTimePeriodMonth = date('m', $startDate);
            $newTimePeriodDay = date('d', $startDate);
            $newTimePeriodHours = date('H', $startDate);
            $newTimePeriodMinutes = date('i', $startDate);
        } else {
            $newTimePeriodYear = '';
            $newTimePeriodMonth = '';
            $newTimePeriodDay = '';
            $newTimePeriodHours = '';
            $newTimePeriodMinutes = '';
        }
        $filtertimetab->addRow(array(new CNumericBox('new_timeperiod_day', $newTimePeriodDay, 2), '/', new CNumericBox('new_timeperiod_month', $newTimePeriodMonth, 2), '/', new CNumericBox('new_timeperiod_year', $newTimePeriodYear, 4), SPACE, new CNumericBox('new_timeperiod_hour', $newTimePeriodHours, 2), ':', new CNumericBox('new_timeperiod_minute', $newTimePeriodMinutes, 2), $clndr_icon));
        zbx_add_post_js('create_calendar(null, ["new_timeperiod_day", "new_timeperiod_month", "new_timeperiod_year", "new_timeperiod_hour", "new_timeperiod_minute"], "new_timeperiod_date", "new_timeperiod_start_date");');
        $tblPeriod->addRow(array(_('Date'), $filtertimetab));
    }
    if ($new_timeperiod['timeperiod_type'] != TIMEPERIOD_TYPE_ONETIME) {
        $tabTime = new CTable(null, 'calendar');
        $tabTime->addRow(array(new CNumericBox('new_timeperiod[hour]', $new_timeperiod['hour'], 2), ':', new CNumericBox('new_timeperiod[minute]', $new_timeperiod['minute'], 2)));
        $tblPeriod->addRow(array(_('At (hour:minute)'), $tabTime));
    }
    $perHours = new CComboBox('new_timeperiod[period_hours]', $new_timeperiod['period_hours']);
    for ($i = 0; $i < 24; $i++) {
        $perHours->addItem($i, $i);
    }
    $perMinutes = new CComboBox('new_timeperiod[period_minutes]', $new_timeperiod['period_minutes']);
    for ($i = 0; $i < 60; $i++) {
        $perMinutes->addItem($i, $i);
    }
    $tblPeriod->addRow(array(_('Maintenance period length'), array(new CNumericBox('new_timeperiod[period_days]', $new_timeperiod['period_days'], 3), _('Days') . SPACE . SPACE, $perHours, SPACE . _('Hours'), $perMinutes, SPACE . _('Minutes'))));
    $td = new CCol(array(new CSubmit('add_timeperiod', $new ? _('Save') : _('Add')), SPACE, new CSubmit('cancel_new_timeperiod', _('Cancel'))));
    $td->setAttribute('colspan', '3');
    $td->setAttribute('style', 'text-align: right;');
    $tblPeriod->setFooter($td);
    return $tblPeriod;
}