Пример #1
0
 public function get_ad()
 {
     $query = $this->db_ > order_by('Name')->get('New_ad');
     $result = array();
     foreach ($query->result_array() as $row) {
         $result[$row['id']] = $row['Name'];
     }
     return $result;
 }
Пример #2
0
 protected function displayProfileLinks()
 {
     $out = "";
     $ar = order_by($this->app->getConfig("channels", "profile", "pages"), "topmenu_position");
     foreach ($ar as $rw) {
         if (!$rw["topmenu_position"]) {
             continue;
         }
         if ($rw["auth_required"] && !$this->app->getUser()) {
             continue;
         }
         if ($rw["auth_denied"] && $this->app->getUser()) {
             continue;
         }
         $out .= ($out ? "&nbsp;|&nbsp;" : "") . "<a href='" . $this->app->makeLink(array("CID" => "profile", "page" => $rw[id]), null, 1) . "'>" . $rw["topmenu"] . "</a>";
     }
     if ($this->app->getUser()) {
         $out = "<!--[Short_greeting]-->, " . $this->app->getUser("displayName") . "&nbsp;|&nbsp;" . $out;
     }
     return $out;
 }
Пример #3
0
function make_latest_data()
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    while ($db_app = DBfetch($db_applications)) {
        $db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock'));
        $app_rows = array();
        $item_cnt = 0;
        while ($db_item = DBfetch($db_items)) {
            $description = item_description($db_item);
            if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
                continue;
            }
            ++$item_cnt;
            if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
                continue;
            }
            if (isset($db_item['lastclock'])) {
                $lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']);
            } else {
                $lastclock = new CCol('-', 'center');
            }
            $lastvalue = format_lastvalue($db_item);
            if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) {
                if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) {
                    $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                } else {
                    $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']);
                }
                $change = nbsp($change);
            } else {
                $change = new CCol('-', 'center');
            }
            if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
                $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action');
            } else {
                $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action');
            }
            array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions)));
        }
        if ($item_cnt > 0) {
            if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
                $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            } else {
                $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
            }
            $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')'));
            $col->setColSpan(5);
            $table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col));
            $any_app_exist = true;
            foreach ($app_rows as $row) {
                $table->ShowRow($row);
            }
        }
    }
}
Пример #4
0
$form->SetMethod('get');
$form->AddItem(new CButton("form", S_CREATE_MAP));
show_table_header(S_CONFIGURATION_OF_NETWORK_MAPS, $form);
echo SBR;
if (isset($_REQUEST["form"])) {
    insert_map_form();
} else {
    $form = new CForm();
    $form->setName('frm_maps');
    $numrows = new CSpan(null, 'info');
    $numrows->setAttribute('name', 'numrows');
    $header = get_table_header(array(S_MAPS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
    show_table_header($header);
    $table = new CTableInfo(S_NO_MAPS_DEFINED);
    $table->SetHeader(array(new CCheckBox('all_maps', NULL, "checkAll('" . $form->getName() . "','all_maps','maps');"), make_sorting_link(S_NAME, 'sm.name'), make_sorting_link(S_WIDTH, 'sm.width'), make_sorting_link(S_HEIGHT, 'sm.height'), S_MAP));
    $result = DBselect('SELECT sm.sysmapid,sm.name,sm.width,sm.height ' . ' FROM sysmaps sm' . ' WHERE ' . DBin_node('sm.sysmapid') . order_by('sm.name,sm.width,sm.height', 'sm.sysmapid'));
    while ($row = DBfetch($result)) {
        if (!sysmap_accessible($row["sysmapid"], PERM_READ_WRITE)) {
            continue;
        }
        $table->AddRow(array(new CCheckBox('maps[' . $row['sysmapid'] . ']', NULL, NULL, $row['sysmapid']), new CLink($row["name"], "sysmaps.php?form=update" . "&sysmapid=" . $row["sysmapid"] . "#form", 'action'), $row["width"], $row["height"], new CLink(S_EDIT, "sysmap.php?sysmapid=" . $row["sysmapid"])));
    }
    //----- GO ------
    $goBox = new CComboBox('go');
    $goBox->addItem('delete', S_DELETE_SELECTED);
    // goButton name is necessary!!!
    $goButton = new CButton('goButton', S_GO . ' (0)');
    $goButton->setAttribute('id', 'goButton');
    zbx_add_post_js('chkbxRange.pageGoName = "maps";');
    $table->setFooter(new CCol(array($goBox, $goButton)));
    $form->addItem($table);
Пример #5
0
$table = new CTableInfo();
$table->SetHeader(array(is_show_subnodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_link(S_HOST, 'h.host') : NULL, array($link, SPACE, make_sorting_link(S_DESCRIPTION, 'i.description')), make_sorting_link(S_LAST_CHECK, 'i.lastclock'), S_LAST_VALUE, S_CHANGE, S_HISTORY));
//	$table->ShowStart();
$db_apps = array();
$db_appids = array();
$sql_where .= $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] : '';
$sql = 'SELECT DISTINCT h.host,h.hostid, a.* ' . ' FROM applications a, hosts h ' . $sql_from . ' WHERE a.hostid=h.hostid' . $sql_where . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status=' . HOST_STATUS_MONITORED . order_by('h.host,h.hostid', 'a.name,a.applicationid');
//SDI($sql);
$db_app_res = DBselect($sql);
while ($db_app = DBfetch($db_app_res)) {
    $db_app['item_cnt'] = 0;
    $db_apps[$db_app['applicationid']] = $db_app;
    $db_appids[$db_app['applicationid']] = $db_app['applicationid'];
}
$tab_rows = array();
$sql = 'SELECT DISTINCT i.*, ia.applicationid ' . ' FROM items i,items_applications ia' . ' WHERE ' . DBcondition('ia.applicationid', $db_appids) . ' AND i.itemid=ia.itemid AND i.lastvalue IS NOT NULL' . ' AND (i.status=' . ITEM_STATUS_ACTIVE . ' OR i.status=' . ITEM_STATUS_NOTSUPPORTED . ')' . order_by('i.description,i.itemid,i.lastclock');
//SDI($sql);
$db_items = DBselect($sql);
while ($db_item = DBfetch($db_items)) {
    $description = item_description($db_item);
    if (!empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
        continue;
    }
    $db_app =& $db_apps[$db_item['applicationid']];
    if (!isset($tab_rows[$db_app['applicationid']])) {
        $tab_rows[$db_app['applicationid']] = array();
    }
    $app_rows =& $tab_rows[$db_app['applicationid']];
    $db_app['item_cnt']++;
    if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
        continue;
Пример #6
0
 function get_data($type, $equipment_type = 0, $department = 0, $area = 0, $unit = 0, $status = -1, $hospitals = 0, $vendor_id = 0)
 {
     if ($type == "equipment_types") {
         $this->db->select("equipment_type_id,equipment_type")->from("equipment_type");
         $this->db->order_by("equipment_type");
     }
     if ($type == "vendor_types") {
         $this->db->select("vendor_type_id,vendor_type")->from("vendor_type");
         $this->db->order_by("vendor_type");
     } else {
         if ($type == "hospital") {
             $this->db->select("hospital_id,hospital")->from("hospital");
         } else {
             if ($type == "department") {
                 $this->db->select("department_id,hospital_id,department")->from("department")->order_by('department');
             } elseif ($type == "equipment_filter") {
                 if ($this->input->post('department')) {
                     $this->db->where('equipment.department_id', $this->input->post('department'));
                 }
                 if ($this->input->post('unit')) {
                     $this->db->where('equipment.unit_id', $this->input->post('unit'));
                 }
                 if ($this->input->post('area')) {
                     $this->db->where('equipment.area_id', $this->input->post('area'));
                 }
                 if ($this->input->post('equipment_status') != NULL) {
                     $this->db->where('equipment.equipment_status', $this->input->post('equipment_status'));
                 }
                 if ($this->input->post('equipment_type')) {
                     $this->db->where('equipment.equipment_type_id', $this->input->post('equipment_type'));
                 }
                 $this->db->select("equipment.equipment_type_id,equipment_type,equipment.department_id,department,equipment.area_id,area_name,equipment.unit_id,unit_name,equipment_status,equipment_id,make,model,serial_number,asset_number,procured_by,cost,supply_date,warranty_start_date,warranty_end_date,service_engineer,service_engineer_contact,department\n\t\t")->from("equipment")->join("equipment_type", "equipment.equipment_type_id=equipment_type.equipment_type_id")->join("department", "equipment.department_id=department.department_id")->join("unit", "equipment.unit_id=unit.unit_id", "left")->join("area", "equipment.area_id=area.area_id", "left")->order_by("equipment_type");
                 $query = $this->db->get();
                 return $query->result();
             } elseif ($type == "filter") {
                 if ($this->input->post('department')) {
                     $this->db->where('equipment.department_id', $this->input->post('department'));
                 }
                 if ($this->input->post('unit')) {
                     $this->db->where('equipment.unit_id', $this->input->post('unit'));
                 }
                 if ($this->input->post('area')) {
                     $this->db->where('equipment.area_id', $this->input->post('area'));
                 }
                 if ($this->input->post('equipment_status') != NULL) {
                     $this->db->where('equipment.equipment_status', $this->input->post('equipment_status'));
                 }
                 if ($this->input->post('equipment_type')) {
                     $this->db->where('equipment.equipment_type_id', $this->input->post('equipment_type'));
                 }
                 $this->db->select("equipment.equipment_type_id,equipment_type,equipment.department_id,department,equipment.area_id,area_name,equipment.unit_id,unit_name,equipment_status,equipment_id,make,model,serial_number,asset_number,procured_by,cost,supply_date,warranty_start_date,warranty_end_date,service_engineer,service_engineer_contact,department,equipment_status\n\t\t")->from("equipment")->join("equipment_type", "equipment.equipment_type_id=equipment_type.equipment_type_id")->join("department", "equipment.department_id=department.department_id")->join("unit", "equipment.unit_id=unit.unit_id", "left")->join("area", "equipment.area_id=area.area_id", "left")->order_by("equipment_type");
                 $query = $this->db->get();
                 return $query->result();
             } elseif ($type == "service_filter") {
                 if ($this->input->post('department')) {
                     $this->db->where('equipment.department_id', $this->input->post('department'));
                 }
                 if ($this->input->post('equipment_type')) {
                     $this->db->where('equipment.equipment_type_id', $this->input->post('equipment_type'));
                 }
                 if ($this->input->post('working_status') != NULL) {
                     $this->db->where('service_record.working_status', $this->input->post('working_status'));
                 }
                 $this->db->select("equipment.equipment_id,equipment.equipment_type_id,equipment.department_id,contact_person.contact_person_id,vendor.vendor_id,request_id,equipment_type,call_date,call_time,call_information_type,call_information,service_person_remarks,service_date,service_time,problem_status,working_status,vendor_name,contact_person_first_name,contact_person_last_name\n\t\t")->from("service_record")->join("equipment", "service_record.equipment_id=equipment.equipment_id")->join("vendor", "service_record.vendor_id=vendor.vendor_id", 'left')->join("contact_person", "service_record.contact_person_id=contact_person.contact_person_id", 'left')->join("equipment_type", "equipment.equipment_type_id=equipment_type.equipment_type_id")->group_by("equipment_id")->order_by("equipment_id");
                 $query = $this->db->get();
                 //echo $this->db->last_query();
                 return $query->result();
             } else {
                 if ($type == "area") {
                     if ($hospitals != 0) {
                         $hosp_id = array();
                         foreach ($hospitals as $hospital) {
                             $hosp_id[] = $hospital->hospital_id;
                         }
                         $this->db->where_in('hospital_id', $hosp_id);
                     }
                     $this->db->select("area_id,area_name,area.department_id,hospital_id")->from("area")->join('department', 'area.department_id=department.department_id', 'left');
                 } else {
                     if ($type == "unit") {
                         $this->db->select("unit_id,unit_name,department_id")->from("unit");
                     } else {
                         if ($type == "icd_chapters") {
                             $this->db->select("chapter_id,chapter_title")->from("icd_chapter")->order_by('chapter_title');
                         } else {
                             if ($type == "icd_blocks") {
                                 $this->db->select("*")->from("icd_block")->order_by('block_title');
                             } else {
                                 if ($type == "icd_codes") {
                                     $this->db->select("*")->from("icd_code")->order_by('code_title');
                                 } else {
                                     if ($type == "unit") {
                                         $this->db->select("unit_id,unit_name,department_id")->from("unit");
                                     } else {
                                         if ($type == "user") {
                                             $this->db->select("user.user_id,username,password,user.staff_id,first_name,last_name,designation,phone,department")->from("user")->join('staff', 'user.staff_id=staff.staff_id')->join('department', 'staff.department_id=department.department_id');
                                             if ($this->input->post('search')) {
                                                 $user = strtolower($this->input->post('user'));
                                                 $this->db->like('LOWER(username)', $user, 'after');
                                             }
                                             if ($this->input->post('select') || $this->input->post('update')) {
                                                 if ($this->input->post('select')) {
                                                     $user_id = $this->input->post('user_id');
                                                 } else {
                                                     if ($this->input->post('update')) {
                                                         $user_id = $this->input->post('user');
                                                     }
                                                 }
                                                 $this->db->select('function_id,add,edit,view')->where('user.user_id', $user_id)->join('user_function_link', 'user.user_id=user_function_link.user_id');
                                             }
                                         } else {
                                             if ($type == 'staff') {
                                                 if ($this->input->post('search')) {
                                                     $staff = strtolower($this->input->post('staff'));
                                                     $this->db->like('LOWER(first_name)', $staff, 'after');
                                                 }
                                                 if ($this->input->post('select')) {
                                                     $staff_id = $this->input->post('staff_id');
                                                     $this->db->where('staff_id', $staff_id);
                                                 }
                                                 $this->db->select("staff_id,first_name,last_name,gender,date_of_birth,staff.department_id,department,unit_id,area_id,staff_role_id,\n\t\t\tstaff_category_id,designation,email,phone,specialisation,research,research_area")->from("staff")->join('department', 'staff.department_id = department.department_id', 'left');
                                             } else {
                                                 if ($type == 'view_staff') {
                                                     if ($this->input->post('search')) {
                                                         $staff = strtolower($this->input->post('staff'));
                                                         $this->db->like('LOWER(first_name)', $staff, 'after');
                                                     }
                                                     if ($this->input->post('select')) {
                                                         $staff_id = $this->input->post('staff_id');
                                                         $this->db->where('staff_id', $staff_id);
                                                     }
                                                     $this->db->select("staff_id,first_name,last_name,gender,date_of_birth,staff.department_id,department,unit_id,area_id,staff_role_id,\n\t\t\tstaff_category_id,designation,email,phone,specialisation,research,research_area")->from("staff")->join('department', 'staff.department_id = department.department_id', 'left');
                                                 } else {
                                                     if ($type == "staff_category") {
                                                         if ($this->input->post('search')) {
                                                             $staff_category = strtolower($this->input->post('staff_category'));
                                                             $this->db->like('LOWER(staff_category)', $staff_category, 'after');
                                                         }
                                                         if ($this->input->post('staff_category_id')) {
                                                             $staff_category_id = $this->input->post('staff_category_id');
                                                             $this->db->where('staff_category_id', $staff_category_id);
                                                         }
                                                         $this->db->select("staff_category_id,staff_category")->from("staff_category");
                                                     } else {
                                                         if ($type == "staff_role") {
                                                             if ($this->input->post('search')) {
                                                                 $staff_role = strtolower($this->input->post('staff_role'));
                                                                 $this->db->like('LOWER(staff_role)', $staff_role, 'after');
                                                             }
                                                             if ($this->input->post('staff_role_id')) {
                                                                 $staff_role_id = $this->input->post('staff_role_id');
                                                                 $this->db->where('staff_role_id', $staff_role_id);
                                                             }
                                                             $this->db->select("staff_role_id,staff_role")->from("staff_role");
                                                         } else {
                                                             if ($type == "item_type") {
                                                                 $this->db->select("item_type_id,item_type")->from("item_type");
                                                             } else {
                                                                 if ($type == "drug_type") {
                                                                     $this->db->select("drug_type_id,drug_type,description")->from("drug_type");
                                                                 } else {
                                                                     if ($type == "drugs") {
                                                                         $this->db->select("item_id,item_name")->from("item")->order_by('item_name');
                                                                     } else {
                                                                         if ($type == "dosage") {
                                                                             if ($this->input->post('search')) {
                                                                                 $dosage_type = strtolower($this->input->post('dosage_name'));
                                                                                 $this->db->like('LOWER(dosage)', $dosage_type, 'after');
                                                                             }
                                                                             if ($this->input->post('select')) {
                                                                                 $dosage_id = $this->input->post('dosage_id');
                                                                                 $this->db->where('dosage_id', $dosage_id);
                                                                             }
                                                                             $this->db->select("dosage,dosage_id,dosage_unit")->from("dosage");
                                                                         } else {
                                                                             if ($type == "generics") {
                                                                                 if ($this->input->post('select')) {
                                                                                     $generic_id = $this->input->post('generic_item_id');
                                                                                     $this->db->where('generic_item_id', $generic_id);
                                                                                 }
                                                                                 if ($this->input->post('search')) {
                                                                                     $generic_type = strtolower($this->input->post('generic_name'));
                                                                                     $this->db->like('LOWER(generic_name)', $generic_type, 'after');
                                                                                 }
                                                                                 $this->db->select("generic_item_id,generic_name,drug_type,item_type,drug_type.drug_type_id,item_type.item_type_id")->from("generic_item")->join('drug_type', 'generic_item.drug_type_id=drug_type.drug_type_id', 'left')->join('item_type', 'generic_item.item_type_id=item_type.item_type_id', 'left')->order_by('generic_name');
                                                                             } else {
                                                                                 if ($type == "service_records") {
                                                                                     if ($this->input->post('select')) {
                                                                                         $request_id = $this->input->post('request_id');
                                                                                         $this->db->where('request_id', $request_id);
                                                                                     }
                                                                                     if ($this->input->post('search')) {
                                                                                         $service = strtolower($this->input->post('call_information_type'));
                                                                                         $this->db->like('LOWER(call_information_type)', $service, 'after');
                                                                                     }
                                                                                     $this->db->select("equipment_id,request_id,call_date,call_time,vendor_id,contact_person_id,call_information_type,call_information,service_person_remarks,contact_person_id,service_date,service_time,problem_status,working_status")->from("service_record");
                                                                                 } else {
                                                                                     if ($type == "equipment") {
                                                                                         if ($this->input->post('select')) {
                                                                                             $equipment_id = $this->input->post('equipment_id');
                                                                                             $this->db->where('equipment_id', $equipment_id);
                                                                                         }
                                                                                         if ($this->input->post('search')) {
                                                                                             $equipment = strtolower($this->input->post('equipment_type'));
                                                                                             $this->db->like('LOWER(equipment_type)', $equipment, 'after');
                                                                                         }
                                                                                         if ($equipment_type != 0) {
                                                                                             $this->db->where("equipment.equipment_type_id", $equipment_type);
                                                                                         }
                                                                                         if ($department != 0) {
                                                                                             $this->db->where("equipment.department_id", $department);
                                                                                         }
                                                                                         if ($area != 0) {
                                                                                             $this->db->where("equipment.area_id", $area);
                                                                                         }
                                                                                         if ($unit != 0) {
                                                                                             $this->db->where("equipment.unit_id", $unit);
                                                                                         }
                                                                                         if ($status != "-1") {
                                                                                             $this->db->where("equipment.equipment_status", $status);
                                                                                         }
                                                                                         $this->db->select("equipment_id,make,serial_number,asset_number,equipment_type,equipment_type.equipment_type_id,model,procured_by,cost,supplier,service_engineer,service_engineer_contact,vendor_name,supply_date,warranty_start_date,warranty_end_date,contact_person_first_name,contact_person_last_name, contact_person_contact,hospital,department,equipment_status,hospital.hospital_id,department.department_id")->from("equipment")->join('equipment_type', 'equipment.equipment_type_id=equipment_type.equipment_type_id', 'left')->join('hospital', 'equipment.hospital_id=hospital.hospital_id', 'left')->join('department', 'equipment.department_id=department.department_id', 'left')->join('vendor', 'vendor.vendor_id=equipment.vendor_id', 'left')->join('contact_person', 'contact_person.contact_person_id=equipment.contact_person_id', 'left')->order_by('equipment_type');
                                                                                     } else {
                                                                                         if ($type == "services") {
                                                                                             if ($this->input->post('select')) {
                                                                                                 $equipment_id = $this->input->post('equipment_id');
                                                                                                 $this->db->where('equipment_id', $equipment_id);
                                                                                             }
                                                                                             if ($this->input->post('search')) {
                                                                                                 $equipment = strtolower($this->input->post('equipment_type'));
                                                                                                 $this->db->like('LOWER(equipment_type)', $equipment, 'after');
                                                                                             }
                                                                                             $this->db->select("equipment_id,make,serial_number,asset_number,equipment_type,equipment.equipment_id,equipment.equipment_type_id,model,procured_by,cost,supplier,supply_date,warranty_period,service_engineer,service_engineer_contact,hospital,department,username,equipment_status,hospital.hospital_id,department.department_id,user.user_id")->from("equipment")->join('equipment_type', 'equipment.equipment_type_id=equipment_type.equipment_type_id', 'left')->join('hospital', 'equipment.hospital_id=hospital.hospital_id', 'left')->join('department', 'equipment.department_id=department.department_id', 'left')->join('user', 'equipment.user_id=user.user_id', 'left')->order_by('equipment_type');
                                                                                         } else {
                                                                                             if ($type == "vendor_type") {
                                                                                                 if ($this->input->post('select')) {
                                                                                                     $vendor_type_id = $this->input->post('vendor_type_id');
                                                                                                     $this->db->where('vendor_type_id', $vendor_type_id);
                                                                                                 }
                                                                                                 if ($this->input->post('search')) {
                                                                                                     $vendor_type = strtolower($this->input->post('vendor_type'));
                                                                                                     $this->db->like('LOWER(vendor_type)', $vendor_type, 'both');
                                                                                                 }
                                                                                                 $this->db->select("vendor_type_id,vendor_type")->from("vendor_type")->order_by("vendor_type");
                                                                                             } else {
                                                                                                 if ($type == "equipment_type") {
                                                                                                     if ($this->input->post('select')) {
                                                                                                         $equipment_type_id = $this->input->post('equipment_type_id');
                                                                                                         $this->db->where('equipment_type_id', $equipment_type_id);
                                                                                                     }
                                                                                                     if ($this->input->post('search')) {
                                                                                                         $equipment_type_id = strtolower($this->input->post('equipment_type'));
                                                                                                         $this->db->like('LOWER(equipment_type)', $equipment_type_id, 'after');
                                                                                                     }
                                                                                                     $this->db->select("equipment_type_id,equipment_type")->from("equipment_type")->order_by("equipment_type");
                                                                                                 } else {
                                                                                                     if ($type == "vendor") {
                                                                                                         if ($this->input->post('select')) {
                                                                                                             $vendor_id = $this->input->post('vendor_id');
                                                                                                             $this->db->where('vendor_id', $vendor_id);
                                                                                                         }
                                                                                                         if ($this->input->post('search')) {
                                                                                                             $vendor_name = strtolower($this->input->post('vendor_name_search'));
                                                                                                             $this->db->like('LOWER(vendor_name)', $vendor_name, 'after');
                                                                                                         }
                                                                                                         $this->db->select("*")->from("vendor")->order_by("vendor_id");
                                                                                                     } else {
                                                                                                         if ($type == "vendor-all") {
                                                                                                             $this->db->select("*")->from("vendor")->order_by("vendor_id");
                                                                                                         } else {
                                                                                                             if ($type == "vendor_type") {
                                                                                                                 $this->db->select("vendor_type_id,vendor_type")->from("vendor_type")->order_by("vendor_type");
                                                                                                             } else {
                                                                                                                 if ($type == "contact_person") {
                                                                                                                     if ($this->input->post('select')) {
                                                                                                                         $contact_person_id = $this->input->post('contact_person_id');
                                                                                                                         $this->db->where('contact_person_id', $contact_person_id);
                                                                                                                     }
                                                                                                                     if ($this->input->post('search')) {
                                                                                                                         $contact_person_name = strtolower($this->input->post('contact_person_name_search'));
                                                                                                                         $contact_person_name_splitted = explode(' ', $contact_person_name);
                                                                                                                         if (!isset($contact_person_name_splitted[1])) {
                                                                                                                             $contact_person_name_splitted[1] = ' ';
                                                                                                                         }
                                                                                                                         $this->db->like('LOWER(contact_person_first_name)', $contact_person_name_splitted[0], 'both');
                                                                                                                         $this->db->or_like('LOWER(contact_person_last_name)', $contact_person_name_splitted[0], 'both');
                                                                                                                         $this->db->or_like('LOWER(contact_person_first_name)', $contact_person_name_splitted[1], 'both');
                                                                                                                         $this->db->or_like('LOWER(contact_person_last_name)', $contact_person_name_splitted[1], 'both');
                                                                                                                     }
                                                                                                                     $this->db->select("*")->from("contact_person")->order_by("contact_person_first_name, contact_person_last_name");
                                                                                                                 } else {
                                                                                                                     if ($type == "vendor_specific_contact_person") {
                                                                                                                         $this->db->where('vendor_id', $vendor_id);
                                                                                                                         $this->db->select("*")->from("contact_person")->order_by("contact_person_first_name, contact_person_last_name");
                                                                                                                     } else {
                                                                                                                         if ($type == "unassigned_contact_person") {
                                                                                                                             $this->db->where('vendor_id', '0');
                                                                                                                             $this->db->select("*")->from("contact_person")->order_by("contact_person_first_name, contact_person_last_name");
                                                                                                                         } else {
                                                                                                                             if ($type == "drug_type") {
                                                                                                                                 if ($this->input->post('search')) {
                                                                                                                                     $drug_type = strtolower($this->input->post('drug_type'));
                                                                                                                                     $this->db->like('LOWER(drug_type)', $drug_type, 'after');
                                                                                                                                 }
                                                                                                                                 if ($this->input->post('select')) {
                                                                                                                                     $drug_id = $this->input->post('drug_type_id');
                                                                                                                                     $this->db->where('drug_type_id', $drug_id);
                                                                                                                                 }
                                                                                                                                 $this->db->select("drug_type_id,drug_type,description")->from("drug_type");
                                                                                                                             } else {
                                                                                                                                 if ($type == "test_method") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('test_method_id');
                                                                                                                                         $this->db->where('test_method_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('test_method') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('test_method'));
                                                                                                                                         $this->db->like('LOWER(test_method)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("test_method_id,test_method")->from("test_method")->order_by('test_method');
                                                                                                                                 } elseif ($type == "test_group") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('test_group_id');
                                                                                                                                         $this->db->where('group_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('group_name') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('group_name'));
                                                                                                                                         $this->db->like('LOWER(group_name)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     if ($department != 0 && count($department) > 0) {
                                                                                                                                         $deps = array();
                                                                                                                                         foreach ($department as $d) {
                                                                                                                                             $deps[] = $d->department_id;
                                                                                                                                         }
                                                                                                                                         $this->db->where_in('department_id', $deps);
                                                                                                                                     }
                                                                                                                                     $this->db->select("test_group.group_id,group_name,test_name,test_method")->from("test_group")->join('test_group_link', 'test_group.group_id = test_group_link.group_id')->join('test_master', 'test_group_link.test_master_id = test_master.test_master_id')->join('test_method', 'test_master.test_method_id=test_method.test_method_id')->join('test_area', 'test_master.test_area_id=test_area.test_area_id')->order_by('group_name');
                                                                                                                                 } elseif ($type == "test_status_type") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('test_status_type_id');
                                                                                                                                         $this->db->where('test_status_type_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('test_status_type') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('test_status_type'));
                                                                                                                                         $this->db->like('LOWER(test_status_type)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("test_status_type_id,test_status_type")->from("test_status_type")->order_by('test_status_type');
                                                                                                                                 } elseif ($type == "test_name") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('test_master_id');
                                                                                                                                         $this->db->where('test_master_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('test_name') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('test_name'));
                                                                                                                                         $this->db->like('LOWER(test_name)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     if ($department != 0 && count($department) > 0) {
                                                                                                                                         $deps = array();
                                                                                                                                         foreach ($department as $d) {
                                                                                                                                             $deps[] = $d->department_id;
                                                                                                                                         }
                                                                                                                                         $this->db->where_in('department_id', $deps);
                                                                                                                                     }
                                                                                                                                     $this->db->select("test_master_id,test_name,test_master.test_method_id,test_master.test_area_id,test_method")->from("test_master")->join('test_method', 'test_master.test_method_id=test_method.test_method_id')->join('test_area', 'test_master.test_area_id=test_area.test_area_id')->order_by('test_name');
                                                                                                                                 } elseif ($type == "test_area") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('test_area_id');
                                                                                                                                         $this->db->where('test_area_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('test_area') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('test_area'));
                                                                                                                                         $this->db->like('LOWER(test_area)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     if ($department != 0 && count($department) > 0) {
                                                                                                                                         $deps = array();
                                                                                                                                         foreach ($department as $d) {
                                                                                                                                             $deps[] = $d->department_id;
                                                                                                                                         }
                                                                                                                                         $this->db->where_in('department_id', $deps);
                                                                                                                                     }
                                                                                                                                     $this->db->select("test_area_id,test_area")->from("test_area")->order_by('test_area');
                                                                                                                                 } elseif ($type == "antibiotic") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('antibiotic_id');
                                                                                                                                         $this->db->where('antibiotic_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('antibiotic') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('antibiotic'));
                                                                                                                                         $this->db->like('LOWER(antibiotic)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("antibiotic_id,antibiotic")->from("antibiotic")->order_by('antibiotic');
                                                                                                                                 } elseif ($type == "micro_organism") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('micro_organism_id');
                                                                                                                                         $this->db->where('micro_organism_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('micro_organism') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('micro_organism'));
                                                                                                                                         $this->db->like('LOWER(micro_organism)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("micro_organism_id,micro_organism")->from("micro_organism")->order_by('micro_organism');
                                                                                                                                 } elseif ($type == "specimen_type") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('specimen_type_id');
                                                                                                                                         $this->db->where('specimen_type_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('specimen_type') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('specimen_type'));
                                                                                                                                         $this->db->like('LOWER(specimen_type)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("specimen_type_id,specimen_type")->from("specimen_type")->order_by('specimen_type');
                                                                                                                                 } elseif ($type == "sample_status") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $test_id = $this->input->post('sample_status_id');
                                                                                                                                         $this->db->where('sample_status_id', $test_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('sample_status') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('sample_status'));
                                                                                                                                         $this->db->like('LOWER(sample_status)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("sample_status_id,sample_status")->from("sample_status")->order_by('sample_status');
                                                                                                                                 } elseif ($type == "lab_unit") {
                                                                                                                                     if ($this->input->post('select')) {
                                                                                                                                         $lab_unit_id = $this->input->post('lab_unit_it');
                                                                                                                                         $this->db->where('lab_unit_id', $lab_unit_id);
                                                                                                                                     }
                                                                                                                                     if ($this->input->post('search') && $this->input->post('lab_unit') != "") {
                                                                                                                                         $search_method = strtolower($this->input->post('lab_unit'));
                                                                                                                                         $this->db->like('LOWER(lab_unit)', $search_method, 'after');
                                                                                                                                     }
                                                                                                                                     $this->db->select("lab_unit_id,lab_unit")->from("lab_unit")->order_by('lab_unit');
                                                                                                                                 } else {
                                                                                                                                     if ($type == "districts") {
                                                                                                                                         $this->db->select("district_id,district")->from("district");
                                                                                                                                     } else {
                                                                                                                                         if ($type == "states") {
                                                                                                                                             $this->db->select("state_id,state")->from("state");
                                                                                                                                         } else {
                                                                                                                                             if ($type == "countries") {
                                                                                                                                                 $this->db->select("*")->from("country")->from('country_name');
                                                                                                                                                 $this->db - order_by("country_name");
                                                                                                                                             } else {
                                                                                                                                                 if ($type == "area_types") {
                                                                                                                                                     $this->db->select("area_type_id,area_type")->from("area_types");
                                                                                                                                                 } else {
                                                                                                                                                     if ($type == "area_activity") {
                                                                                                                                                         $this->db->select("area_activity_id,activity_name")->from("area_activity");
                                                                                                                                                     } else {
                                                                                                                                                         if ($type == "vendor") {
                                                                                                                                                             $this->db->select("vendor_id,vendor_name")->from("vendor");
                                                                                                                                                         } else {
                                                                                                                                                             if ($type == "vendors") {
                                                                                                                                                                 $this->db->select("vendor_id,vendor_name")->from("vendor");
                                                                                                                                                             } else {
                                                                                                                                                                 if ($type == "contact_persons") {
                                                                                                                                                                     $this->db->select("contact_person_id,contact_person_first_name,contact_person_last_name")->from("contact_person");
                                                                                                                                                                 } else {
                                                                                                                                                                     if ($type == "vend") {
                                                                                                                                                                         $this->db->select("vendor_id,vendor_name")->from("vendor");
                                                                                                                                                                     } else {
                                                                                                                                                                         if ($type == "contact") {
                                                                                                                                                                             $this->db->select("contact_person_id,contact_person_first_name,contact_person_last_name")->from("contact_person");
                                                                                                                                                                         } else {
                                                                                                                                                                             if ($type == "facility_activity") {
                                                                                                                                                                                 $this->db->select("activity_id")->from("facility_activity");
                                                                                                                                                                             } else {
                                                                                                                                                                                 if ($type == "activity_done") {
                                                                                                                                                                                     $this->db->select("*")->from("activity_done");
                                                                                                                                                                                 } else {
                                                                                                                                                                                     if ($type == "facility_type") {
                                                                                                                                                                                         $this->db->select("facility_type_id,facility_type")->from("facility_type");
                                                                                                                                                                                     } else {
                                                                                                                                                                                         if ($type == "area") {
                                                                                                                                                                                             $this->db->select("area_id,area_name")->from("area");
                                                                                                                                                                                         } else {
                                                                                                                                                                                             if ($type == "vendor") {
                                                                                                                                                                                                 $this->db->select("vendor_id,vendor_name")->from("vendor");
                                                                                                                                                                                             } else {
                                                                                                                                                                                                 if ($type == "vendor_contracts") {
                                                                                                                                                                                                     $this->db->select("contract_id,status")->from("vendor_contracts");
                                                                                                                                                                                                 } else {
                                                                                                                                                                                                     if ($type == "village_town") {
                                                                                                                                                                                                         $this->db->select("village_town_id,village_town")->from("village_town");
                                                                                                                                                                                                     } else {
                                                                                                                                                                                                         if ($type == "procedure") {
                                                                                                                                                                                                             $this->db->select("procedure_id,procedure_name")->from("procedure");
                                                                                                                                                                                                         } else {
                                                                                                                                                                                                             if ($type == "sanitation_activity") {
                                                                                                                                                                                                                 $date = date("Y-m-d", strtotime($this->input->post('date')));
                                                                                                                                                                                                                 $day = date('w', strtotime($this->input->post('date')));
                                                                                                                                                                                                                 if (date("d", strtotime($date)) > '28') {
                                                                                                                                                                                                                     $week_start = date('Y-m-29', strtotime($date));
                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                     $week_start = date('Y-m-d', strtotime("{$date} - 6 days"));
                                                                                                                                                                                                                 }
                                                                                                                                                                                                                 $week_end = date('Y-m-d', strtotime($date . ' +  days'));
                                                                                                                                                                                                                 $fortnight_start_date = date("Y-m-1", strtotime($date));
                                                                                                                                                                                                                 if ($date - $fortnight_start_date > 15) {
                                                                                                                                                                                                                     $fortnight_end_date = date("Y-m-15", strtotime($date));
                                                                                                                                                                                                                 } else {
                                                                                                                                                                                                                     $fortnight_start_date = date("Y-m-15", strtotime($date));
                                                                                                                                                                                                                     $fortnight_end_date = date("Y-m-t", strtotime($date));
                                                                                                                                                                                                                 }
                                                                                                                                                                                                                 $this->db->select('activity_name,frequency,weightage,frequency_type,activity_id,day_done.*,week_done.*,fortnight_done.*,month_done.*')->from('facility_activity')->join('area_activity', 'facility_activity.area_activity_id=area_activity.area_activity_id')->join('area', 'facility_activity.facility_area_id=area.area_id')->join("(SELECT activity_id day_activity_done,date day_activity_date,time day_activity_time,score daily_score FROM activity_done JOIN facility_activity USING(activity_id) JOIN area_activity USING(area_activity_id) WHERE frequency_type='Daily' AND date='{$date}') day_done", 'facility_activity.activity_id=day_done.day_activity_done', 'left')->join("(SELECT activity_id week_activity_done,date week_activity_date,time week_activity_time,score weekly_score,comments FROM activity_done JOIN facility_activity USING(activity_id) JOIN area_activity USING(area_activity_id) WHERE frequency_type='Weekly' AND date='{$week_start}' ) week_done", 'facility_activity.activity_id=week_done.week_activity_done', 'left')->join("(SELECT activity_id fortnight_activity_done,date fortnight_activity_date,time fortnight_activity_time,score fortnightly_score FROM activity_done JOIN facility_activity USING(activity_id) JOIN area_activity USING(area_activity_id) WHERE frequency_type='Fortnightly' AND (date BETWEEN '{$fortnight_start_date}' AND '{$fortnight_end_date}')) fortnight_done", 'facility_activity.activity_id=fortnight_done.fortnight_activity_done', 'left')->join("(SELECT activity_id month_activity_done,date month_activity_date,time month_activity_time,score monthly_score,comments FROM activity_done JOIN facility_activity USING(activity_id) JOIN area_activity USING(area_activity_id) WHERE frequency_type='Monthly' AND MONTH(date)=MONTH('{$week_start}') AND YEAR(date)=YEAR('{$week_start}')) month_done", 'facility_activity.activity_id=month_done.month_activity_done', 'left')->where('area.area_id', $this->input->post('area'));
                                                                                                                                                                                                             }
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                 }
                                                                                                                                                                             }
                                                                                                                                                                         }
                                                                                                                                                                     }
                                                                                                                                                                 }
                                                                                                                                                             }
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                             }
                                                                                                                                         }
                                                                                                                                     }
                                                                                                                                 }
                                                                                                                             }
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $query = $this->db->get();
     return $query->result();
 }
Пример #7
0
function get_action_cmds_for_event($eventid)
{
    $hostids = array();
    $sql = 'SELECT DISTINCT i.hostid ' . ' FROM events e, functions f, items i ' . ' WHERE e.eventid=' . $eventid . ' AND e.objectid=' . EVENT_SOURCE_TRIGGERS . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid';
    if ($host = DBfetch(DBselect($sql, 1))) {
        $hostids[$host['hostid']] = $host['hostid'];
    }
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids);
    $table = new CTableInfo(S_NO_ACTIONS_FOUND);
    $table->SetHeader(array(is_show_subnodes() ? S_NODES : null, S_TIME, S_STATUS, S_COMMAND, S_ERROR));
    $sql = 'SELECT DISTINCT a.alertid,a.clock,a.sendto,a.esc_step,a.subject,a.message,a.status,a.retries,a.error ' . ' FROM events e,alerts a' . ' WHERE a.eventid=' . $eventid . ' AND a.alerttype=' . ALERT_TYPE_COMMAND . ' AND e.eventid = a.eventid' . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . order_by('a.clock,a.alertid,a.sendto,a.status,a.retries');
    $result = DBselect($sql);
    while ($row = DBfetch($result)) {
        $time = date("Y.M.d H:i:s", $row["clock"]);
        if ($row['esc_step'] > 0) {
            $time = array(bold(S_STEP . ': '), $row["esc_step"], br(), bold(S_TIME . ': '), br(), $time);
        }
        if ($row["status"] == ALERT_STATUS_SENT) {
            $status = new CSpan(S_EXECUTED, "green");
        } else {
            if ($row["status"] == ALERT_STATUS_NOT_SENT) {
                $status = new CSpan(S_IN_PROGRESS, "orange");
            } else {
                $status = new CSpan(S_NOT_SENT, "red");
            }
        }
        $message = array(bold(S_COMMAND . ':'));
        $msg = explode("\n", $row['message']);
        foreach ($msg as $m) {
            array_push($message, BR(), $m);
        }
        if (empty($row["error"])) {
            $error = new CSpan(SPACE, "off");
        } else {
            $error = new CSpan($row["error"], "on");
        }
        $table->addRow(array(get_node_name_by_elid($row['alertid']), new CCol($time, 'top'), new CCol($status, 'top'), new CCol($message, 'wraptext top'), new CCol($error, 'wraptext top')));
    }
    return $table;
}
Пример #8
0
    }
    $frmScr->addItemToBottomRow(new CButtonCancel());
    $frmScr->Show();
} else {
    validate_sort_and_sortorder('s.name', ZBX_SORT_UP);
    $form = new CForm();
    $form->setName('scripts');
    $form->setAttribute('id', 'scripts');
    $form->addVar('action', '1');
    $numrows = new CSpan(null, 'info');
    $numrows->setAttribute('name', 'numrows');
    $header = get_table_header(array(S_SCRIPTS, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
    show_table_header($header);
    $table = new CTableInfo(S_NO_SCRIPTS_DEFINED);
    $table->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $form->getName() . "','all_scripts','scripts');"), make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_COMMAND, 's.command'), S_USER_GROUP, S_HOST_GROUP, S_HOST_ACCESS));
    $sql = 'SELECT s.* ' . ' FROM scripts s ' . ' WHERE ' . DBin_node('s.scriptid') . order_by('s.name,s.command');
    $scripts = DBselect($sql);
    while ($script = DBfetch($scripts)) {
        $user_group_name = S_ALL_S;
        if ($script['usrgrpid'] > 0) {
            $user_group = get_group_by_usrgrpid($script['usrgrpid']);
            $user_group_name = $user_group['name'];
        }
        $host_group_name = S_ALL_S;
        if ($script['groupid'] > 0) {
            $group = get_hostgroup_by_groupid($script['groupid']);
            $host_group_name = $group['name'];
        }
        $table->addRow(array(new CCheckBox('scripts[' . $script['scriptid'] . ']', 'no', NULL, $script['scriptid']), new CLink($script['name'], 'scripts.php?form=1' . '&scriptid=' . $script['scriptid'] . '#form'), htmlspecialchars($script['command']), $user_group_name, $host_group_name, PERM_READ_WRITE == $script['host_access'] ? S_WRITE : S_READ));
        $row_count++;
    }
Пример #9
0
                continue;
            }
            $table->AddRow(array(new CLink($row["name"], "?config=0&form=update&screenid=" . $row["screenid"], 'action'), $row["hsize"] . " x " . $row["vsize"], new CLink(S_EDIT, "screenedit.php?screenid=" . $row["screenid"])));
            $row_count++;
        }
        $table->Show();
    }
} else {
    if (isset($_REQUEST["form"])) {
        insert_slideshow_form();
    } else {
        $row_count = 0;
        $numrows = new CSpan(null, 'info');
        $numrows->addOption('name', 'numrows');
        $header = get_table_header(array(S_SLIDESHOWS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
        show_table_header($header);
        $table = new CTableInfo(S_NO_SLIDESHOWS_DEFINED);
        $table->SetHeader(array(make_sorting_link(S_NAME, 's.name'), make_sorting_link(S_DELAY, 's.delay'), make_sorting_link(S_COUNT_OF_SLIDES, 'cnt')));
        $db_slides = DBselect('SELECT s.slideshowid, s.name, s.delay, count(*) as cnt ' . ' FROM slideshows s ' . ' left join slides sl on sl.slideshowid=s.slideshowid ' . ' WHERE ' . DBin_node('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay ' . order_by('s.name,s.delay,cnt', 's.slideshowid'));
        while ($slide_data = DBfetch($db_slides)) {
            if (!slideshow_accessible($slide_data['slideshowid'], PERM_READ_WRITE)) {
                continue;
            }
            $table->AddRow(array(new CLink($slide_data['name'], '?config=1&form=update&slideshowid=' . $slide_data['slideshowid'], 'action'), $slide_data['delay'], $slide_data['cnt']));
            $row_count++;
        }
        $table->Show();
    }
}
zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");');
include_once "include/page_footer.php";
Пример #10
0
 $db_appids = array();
 $sql_where = '';
 if ($_REQUEST['hostid'] > 0) {
     $sql_where = ' AND h.hostid=' . $_REQUEST['hostid'];
 }
 $sql = 'SELECT DISTINCT h.host,h.hostid,a.* ' . ' FROM applications a,hosts h ' . ' WHERE a.hostid=h.hostid ' . $sql_where . ' AND ' . DBcondition('h.hostid', $available_hosts) . order_by('a.applicationid,h.host,h.hostid', 'a.name');
 //SDI($sql);
 $db_app_res = DBselect($sql);
 while ($db_app = DBfetch($db_app_res)) {
     $db_app['scenarios_cnt'] = 0;
     $db_apps[$db_app['applicationid']] = $db_app;
     $db_appids[$db_app['applicationid']] = $db_app['applicationid'];
 }
 $db_httptests = array();
 $db_httptestids = array();
 $sql = 'SELECT wt.*,a.name as application, h.host,h.hostid ' . ' FROM httptest wt ' . ' LEFT JOIN applications a on wt.applicationid=a.applicationid ' . ' LEFT JOIN hosts h on h.hostid=a.hostid ' . ' WHERE ' . DBcondition('a.applicationid', $db_appids) . ($showdisabled == 0 ? ' AND wt.status <> 1' : '') . order_by('wt.name', 'h.host');
 //SDI($sql);
 $db_httptests_res = DBselect($sql);
 while ($httptest_data = DBfetch($db_httptests_res)) {
     $httptest_data['step_cout'] = null;
     $db_apps[$httptest_data['applicationid']]['scenarios_cnt']++;
     $db_httptests[$httptest_data['httptestid']] = $httptest_data;
     $db_httptestids[$httptest_data['httptestid']] = $httptest_data['httptestid'];
 }
 $sql = 'SELECT hs.httptestid, COUNT(hs.httpstepid) as cnt ' . ' FROM httpstep hs' . ' WHERE ' . DBcondition('hs.httptestid', $db_httptestids) . ' GROUP BY hs.httptestid';
 //SDI($sql);
 $httpstep_res = DBselect($sql);
 while ($step_cout = DBfetch($httpstep_res)) {
     $db_httptests[$step_cout['httptestid']]['step_cout'] = $step_cout['cnt'];
 }
 $tab_rows = array();
Пример #11
0
    }
} else {
    $table = new CTableInfo();
    if ($prof_type) {
        $table->setHeader(array(is_show_all_nodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, make_sorting_link(S_HOST, 'h.host'), $_REQUEST['groupid'] > 0 ? null : make_sorting_link(S_GROUP, 'g.name'), make_sorting_link(S_DEVICE_OS_SHORT, 'hpe.device_os_short'), make_sorting_link(S_DEVICE_HW_ARCH, 'hpe.device_hw_arch'), make_sorting_link(S_DEVICE_TYPE, 'hpe.device_type'), make_sorting_link(S_DEVICE_STATUS, 'hpe.device_status')));
        $sql_where = '';
        if ($_REQUEST['groupid'] > 0) {
            $sql_where = ' AND hg.groupid=' . $_REQUEST['groupid'];
        }
        $sql = 'SELECT DISTINCT g.name, h.hostid,h.host,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status' . ' FROM hosts h,hosts_profiles_ext hpe,hosts_groups hg,groups g ' . ' WHERE h.hostid=hpe.hostid ' . ' AND h.hostid=hg.hostid ' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $PAGE_HOSTS['hostids']) . $sql_where . order_by('h.host,h.hostid,g.name,hpe.device_os_short,hpe.device_hw_arch,hpe.device_type,hpe.device_status');
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $table->AddRow(array(get_node_name_by_elid($row['hostid']), new CLink($row["host"], "?hostid=" . $row["hostid"] . url_param("groupid") . '&prof_type=' . $prof_type, "action"), $_REQUEST["groupid"] > 0 ? null : $row["name"], $row["device_os_short"], $row["device_hw_arch"], $row["device_type"], $row["device_status"]));
        }
    } else {
        $table->setHeader(array(is_show_all_nodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, make_sorting_link(S_HOST, 'h.host'), make_sorting_link(S_NAME, 'p.name'), make_sorting_link(S_OS, 'p.os'), make_sorting_link(S_SERIALNO, 'p.serialno'), make_sorting_link(S_TAG, 'p.tag'), make_sorting_link(S_MACADDRESS, 'p.macaddress')));
        $sql_from = '';
        $sql_where = '';
        if ($_REQUEST['groupid'] > 0) {
            $sql_from = ', hosts_groups hg ';
            $sql_where = ' and h.hostid=hg.hostid AND hg.groupid=' . $_REQUEST['groupid'];
        }
        $sql = 'SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress' . ' FROM hosts h,hosts_profiles p ' . $sql_from . ' WHERE h.hostid=p.hostid' . ' and ' . DBcondition('h.hostid', $PAGE_HOSTS['hostids']) . $sql_where . order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress');
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $table->AddRow(array(get_node_name_by_elid($row['hostid']), new CLink($row["host"], '?hostid=' . $row['hostid'] . url_param('groupid') . '&prof_type=' . $prof_type, "action"), $row["name"], $row["os"], $row["serialno"], $row["tag"], $row["macaddress"]));
        }
    }
    $table->show();
}
include_once "include/page_footer.php";
Пример #12
0
 $form->setName('users');
 $numrows = new CSpan(null, 'info');
 $numrows->setAttribute('name', 'numrows');
 $header = get_table_header(array(S_USERS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
 show_table_header($header);
 $table = new CTableInfo(S_NO_USERS_DEFINED);
 $table->setHeader(array(new CCheckBox('all_users', NULL, "checkAll('" . $form->GetName() . "','all_users','group_userid');"), make_sorting_link(S_ALIAS, 'u.alias'), make_sorting_link(S_NAME, 'u.name'), make_sorting_link(S_SURNAME, 'u.surname'), make_sorting_link(S_USER_TYPE, 'u.type'), S_GROUPS, S_IS_ONLINE_Q, S_GUI_ACCESS, S_API_ACCESS, S_DEBUG_MODE, S_STATUS));
 $cond_from = '';
 $cond_where = '';
 if ($_REQUEST['filter_usrgrpid'] > 0) {
     $cond_from = ', users_groups ug, usrgrp ugrp ';
     $cond_where = ' AND ug.userid = u.userid ' . ' AND ug.usrgrpid=' . $_REQUEST['filter_usrgrpid'];
 }
 $users = array();
 $userids = array();
 $db_users = DBselect('SELECT DISTINCT u.userid,u.alias,u.name,u.surname,u.type,u.autologout ' . ' FROM users u ' . $cond_from . ' WHERE ' . DBin_node('u.userid') . $cond_where . order_by('u.alias,u.name,u.surname,u.type', 'u.userid'));
 while ($db_user = DBfetch($db_users)) {
     $users[$db_user['userid']] = $db_user;
     $userids[$db_user['userid']] = $db_user['userid'];
 }
 $users_sessions = array();
 $sql = 'SELECT s.userid, MAX(s.lastaccess) as lastaccess, s.status ' . ' FROM sessions s, users u' . ' WHERE ' . DBcondition('s.userid', $userids) . ' AND s.userid=u.userid ' . ' GROUP BY s.userid,s.status';
 //SDI($sql);
 $db_sessions = DBselect($sql);
 while ($db_ses = DBfetch($db_sessions)) {
     if (!isset($users_sessions[$db_ses['userid']])) {
         $users_sessions[$db_ses['userid']] = $db_ses;
     }
     if (isset($users_sessions[$db_ses['userid']]) && $users_sessions[$db_ses['userid']]['lastaccess'] < $db_ses['lastaccess']) {
         $users_sessions[$db_ses['userid']] = $db_ses;
     }
Пример #13
0
ksort($services);
$header = array(is_show_all_nodes() ? new CCol(S_NODE, 'center') : null, new CCol(make_sorting_link(S_DISCOVERED_DEVICE, 'ip'), 'center'), new CCol(S_MONITORED_HOST, 'center'), new CCol(array(S_UPTIME . '/', S_DOWNTIME), 'center'));
foreach ($services as $name => $foo) {
    $header[] = new CImg('vtext.php?text=' . $name);
}
$table = new CTableInfo();
$table->setHeader($header, 'vertical_header');
$sql_where = '';
if ($druleid > 0) {
    $sql_where = ' AND druleid=' . $druleid;
}
$sql = 'SELECT DISTINCT druleid,proxy_hostid,name ' . ' FROM drules ' . ' WHERE ' . DBin_node('druleid') . $sql_where . ' AND status=' . DRULE_STATUS_ACTIVE . ' ORDER BY name';
$db_drules = DBselect($sql);
while ($drule = DBfetch($db_drules)) {
    $discovery_info = array();
    $db_dhosts = DBselect('SELECT dh.dhostid,dh.druleid,dh.ip,dh.status,dh.lastup,dh.lastdown,h.host' . ' FROM dhosts dh' . ' LEFT JOIN hosts h ON h.ip=dh.ip and h.proxy_hostid=' . $drule['proxy_hostid'] . ' WHERE ' . DBin_node('dh.dhostid') . ' AND dh.druleid=' . $drule['druleid'] . order_by('dh.ip', 'dh.dhostid,dh.status'));
    while ($dhost = DBfetch($db_dhosts)) {
        $class = 'enabled';
        $time = 'lastup';
        if (DHOST_STATUS_DISABLED == $dhost['status']) {
            $class = 'disabled';
            $time = 'lastdown';
        }
        $discovery_info[$dhost['ip']] = array('class' => $class, 'host' => $dhost['host'], 'time' => $dhost[$time], 'druleid' => $dhost['druleid']);
        $db_dservices = DBselect('SELECT type,port,key_,status,lastup,lastdown FROM dservices ' . ' WHERE dhostid=' . $dhost['dhostid'] . ' order by status,type,port');
        while ($dservice = DBfetch($db_dservices)) {
            $class = 'active';
            $time = 'lastup';
            if (DSVC_STATUS_DISABLED == $dservice['status']) {
                $class = 'inactive';
                $time = 'lastdown';
Пример #14
0
$form = new CForm(null, 'get');
$form->addItem(new CButton("form", S_CREATE_SLIDESHOW));
$slide_wdgt = new CWidget();
$slide_wdgt->addPageHeader(S_CONFIGURATION_OF_SLIDESHOWS_BIG, $form);
if (isset($_REQUEST['form'])) {
    $slide_wdgt->addItem(insert_slideshow_form());
} else {
    $form = new CForm();
    $form->setName('shows');
    $numrows = new CDiv();
    $numrows->setAttribute('name', 'numrows');
    $slide_wdgt->addHeader(S_SLIDESHOWS_BIG);
    $slide_wdgt->addHeader($numrows);
    $table = new CTableInfo(S_NO_SLIDESHOWS_DEFINED);
    $table->setHeader(array(new CCheckBox('all_shows', NULL, "checkAll('" . $form->getName() . "','all_shows','shows');"), make_sorting_header(S_NAME, 's.name'), make_sorting_header(S_DELAY, 's.delay'), make_sorting_header(S_COUNT_OF_SLIDES, 'cnt')));
    $sql = 'SELECT s.slideshowid, s.name, s.delay, count(sl.slideshowid) as cnt ' . ' FROM slideshows s ' . ' LEFT JOIN slides sl ON sl.slideshowid=s.slideshowid ' . ' WHERE ' . DBin_node('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay ' . order_by('s.name,s.delay,cnt', 's.slideshowid');
    $db_slides = DBselect($sql);
    // gathering all data we got from database in array, so we can feed it to pagination function
    $slides_arr = array();
    while ($slide_data = DBfetch($db_slides)) {
        $slides_arr[] = $slide_data;
    }
    // getting paging element
    $paging = getPagingLine($slides_arr);
    foreach ($slides_arr as $slide_data) {
        if (!slideshow_accessible($slide_data['slideshowid'], PERM_READ_WRITE)) {
            continue;
        }
        $table->addRow(array(new CCheckBox('shows[' . $slide_data['slideshowid'] . ']', NULL, NULL, $slide_data['slideshowid']), new CLink($slide_data['name'], '?config=1&form=update&slideshowid=' . $slide_data['slideshowid'], 'action'), $slide_data['delay'], $slide_data['cnt']));
    }
    // adding paging to widget
Пример #15
0
 $numrows = new CSpan(null, 'info');
 $numrows->addOption('name', 'numrows');
 $header = get_table_header(array(S_GRAPHS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
 show_table_header($header, $r_form);
 /* TABLE */
 $form = new CForm();
 $form->setName('graphs');
 $form->addVar('hostid', $_REQUEST['hostid']);
 $table = new CTableInfo(S_NO_GRAPHS_DEFINED);
 $table->setHeader(array($_REQUEST['hostid'] != 0 ? NULL : S_HOSTS, array(new CCheckBox('all_graphs', NULL, "CheckAll('" . $form->GetName() . "','all_graphs');"), make_sorting_link(S_NAME, 'g.name')), make_sorting_link(S_WIDTH, 'g.width'), make_sorting_link(S_HEIGHT, 'g.height'), make_sorting_link(S_GRAPH_TYPE, 'g.graphtype')));
 $sql_from = '';
 $sql_where = '';
 if ($PAGE_HOSTS['selected'] > 0) {
     $sql_where .= ' AND i.hostid=' . $PAGE_HOSTS['selected'];
 }
 $sql = 'SELECT DISTINCT g.* ' . ' FROM graphs g, graphs_items gi,items i ' . $sql_from . ' WHERE ' . DBcondition('g.graphid', $available_graphs) . ' AND gi.graphid=g.graphid ' . ' AND i.itemid=gi.itemid ' . $sql_where . order_by('g.name,g.width,g.height,g.graphtype', 'g.graphid');
 $result = DBselect($sql);
 while ($row = DBfetch($result)) {
     if ($_REQUEST['hostid'] != 0) {
         $host_list = NULL;
     } else {
         $host_list = array();
         $db_hosts = get_hosts_by_graphid($row['graphid']);
         while ($db_host = DBfetch($db_hosts)) {
             array_push($host_list, $db_host['host']);
         }
         $host_list = implode(',', $host_list);
     }
     if ($row['templateid'] == 0) {
         $name = new CLink($row['name'], 'graphs.php?graphid=' . $row['graphid'] . '&form=update', 'action');
     } else {
Пример #16
0
    $securityLevelVisibility = array();
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, 'row_snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_authpassphrase');
    zbx_subarray_push($securityLevelVisibility, ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, 'row_snmpv3_privpassphrase');
    zbx_add_post_js("var securityLevelSwitcher = new CViewSwitcher('new_check_snmpv3_securitylevel', 'change', " . zbx_jsvalue($securityLevelVisibility, true) . ");");
} else {
    $numrows = new CDiv();
    $numrows->setAttribute('name', 'numrows');
    $dscry_wdgt->addHeader(S_DISCOVERY_BIG);
    $dscry_wdgt->addHeader($numrows);
    /* table */
    $form = new CForm();
    $form->setName('frmdrules');
    $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED);
    $tblDiscovery->setHeader(array(new CCheckBox('all_drules', null, "checkAll('" . $form->GetName() . "','all_drules','g_druleid');"), make_sorting_header(S_NAME, 'd.name'), make_sorting_header(S_IP_RANGE, 'd.iprange'), make_sorting_header(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS));
    $sql = 'SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid');
    $db_rules = DBselect($sql);
    // Discovery rules will be gathered here, so we can feed this array to pagination function
    $rules_arr = array();
    while ($rule_data = DBfetch($db_rules)) {
        $rules_arr[] = $rule_data;
    }
    // getting paging element
    $paging = getPagingLine($rules_arr);
    foreach ($rules_arr as $rule_data) {
        $checks = array();
        $sql = 'SELECT type FROM dchecks WHERE druleid=' . $rule_data['druleid'] . ' ORDER BY type, ports';
        $db_checks = DBselect($sql);
        while ($check_data = DBfetch($db_checks)) {
            if (!isset($checks[$check_data['type']])) {
                $checks[$check_data['type']] = discovery_check_type2str($check_data['type']);
Пример #17
0
 public static function get_users($type = 'user', $order = false)
 {
     if ($order) {
         $users = order_by($order)->get($type)->to_array();
     } else {
         $users = get($type)->to_array();
     }
     if (self::$include_superadmin) {
         $users[] = self::get_superadmin();
     }
     return $users;
 }
Пример #18
0
function print_benchmark_details($rev, $old_rev)
{
    global $DB, $td, $th, $benchmark_order;
    # fetch the current revisions data
    $test_data = $DB->query("\n\t\t\t\tSELECT\trevision, name, metric, result\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\trevision == {$rev}\n\t\t\t\t")->fetchAll(PDO::FETCH_ASSOC);
    print "<table class=info>";
    print "<tr>" . "<th>Benchmark</th>" . "<th>Metric</th>" . "<th>Result (+/- vs " . "<a href='details.php?rev={$old_rev}'>{$old_rev}</a>" . ")</th>";
    # fetch the previous revisions data, for comparison
    $old_test_data = $DB->query("\n\t\t\t\tSELECT\trevision, name, metric, result\n\t\t\t\tFROM\t\tbenchmarks\n\t\t\t\tWHERE\t\trevision == {$old_rev}\n\t\t\t\t")->fetchAll(PDO::FETCH_ASSOC);
    # process data
    foreach ($test_data as &$row) {
        $old_row = array_shift($old_test_data);
        $row["difference"] = add_percentage_difference("result", $row, $old_row);
    }
    unset($row);
    // release the reference to $row
    $test_data = order_by($test_data, $benchmark_order, "metric");
    # print
    foreach ($test_data as $row_set) {
        foreach ($row_set as $row) {
            unset($row["revision"]);
            # pick a color
            $color = "";
            if ($row["difference"] > 0) {
                $color = get_bad_color();
            } elseif ($row["difference"] < 0) {
                $color = get_good_color();
            }
            unset($row["difference"]);
            print "<tr>\n";
            foreach ($row as $key => $entry) {
                print "<td {$color}>{$entry}</td>";
            }
            print "</tr>\n";
        }
    }
    print "</table>";
}
Пример #19
0
 // ----
 $available_maintenances = get_accessible_maintenance_by_user(PERM_READ_WRITE);
 $maintenances = array();
 $maintenanceids = array();
 $sql_from = '';
 $sql_where = '';
 if ($_REQUEST['hostid'] > 0) {
     $sql_from = ', maintenances_hosts mh, maintenances_groups mg, hosts_groups hg ';
     $sql_where = ' AND hg.hostid=' . $_REQUEST['hostid'] . ' AND (' . '(mh.hostid=hg.hostid AND m.maintenanceid=mh.maintenanceid) ' . ' OR (mg.groupid=hg.groupid AND m.maintenanceid=mg.maintenanceid))';
 } else {
     if ($_REQUEST['groupid'] > 0) {
         $sql_from = ', maintenances_hosts mh, maintenances_groups mg, hosts_groups hg ';
         $sql_where = ' AND hg.groupid=' . $_REQUEST['groupid'] . ' AND (' . '(mg.groupid=hg.groupid AND m.maintenanceid=mg.maintenanceid) ' . ' OR (mh.hostid=hg.hostid AND m.maintenanceid=mh.maintenanceid))';
     }
 }
 $sql = 'SELECT m.* ' . ' FROM maintenances m ' . $sql_from . ' WHERE ' . DBin_node('m.maintenanceid') . ' AND ' . DBcondition('m.maintenanceid', $available_maintenances) . $sql_where . order_by('m.name');
 $db_maintenances = DBselect($sql);
 while ($maintenance = DBfetch($db_maintenances)) {
     $maintenances[$maintenance['maintenanceid']] = $maintenance;
     $maintenanceids[$maintenance['maintenanceid']] = $maintenance['maintenanceid'];
 }
 $form = new CForm(null, 'post');
 $form->setName('maintenances');
 $table = new CTableInfo();
 $table->setHeader(array(array(new CCheckBox('all_maintenances', NULL, "CheckAll('" . $form->GetName() . "','all_maintenances','group_maintenanceid');"), make_sorting_link(S_NAME, 'm.name')), S_TYPE, S_STATUS, S_DESCRIPTION));
 foreach ($maintenances as $maintenanceid => $maintenance) {
     if ($maintenance['active_till'] < time()) {
         $mnt_status = new CSpan(S_EXPIRED, 'red');
     } else {
         $mnt_status = new CSpan(S_ACTIVE, 'green');
     }
Пример #20
0
 foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
     $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name);
 }
 $header = get_table_header(S_HOSTS_BIG, array(S_GROUP . SPACE, $cmbGroups));
 $form->addItem($header);
 $table = new CTableInfo(S_NO_HOSTS_DEFINED);
 $table->setHeader(array(array(new CCheckBox("all_hosts", true, "CheckAll('" . $form->GetName() . "','all_hosts','hosts');"), make_sorting_link(S_NAME, 'h.host')), make_sorting_link(S_DNS, 'h.dns'), make_sorting_link(S_IP, 'h.ip'), make_sorting_link(S_PORT, 'h.port'), make_sorting_link(S_STATUS, 'h.status'), array(new CCheckBox("all_templates", true, "CheckAll('" . $form->GetName() . "','all_templates','templates');"), S_TEMPLATES), array(new CCheckBox("all_items", true, "CheckAll('" . $form->GetName() . "','all_items','items');"), S_ITEMS), array(new CCheckBox("all_triggers", true, "CheckAll('" . $form->GetName() . "','all_triggers','triggers');"), S_TRIGGERS), array(new CCheckBox("all_graphs", true, "CheckAll('" . $form->GetName() . "','all_graphs','graphs');"), S_GRAPHS)));
 $sql_from = '';
 $sql_where = '';
 if ($_REQUEST['groupid'] > 0) {
     $sql_from .= ' ,hosts_groups hg ';
     $sql_where .= ' AND hg.groupid=' . $_REQUEST['groupid'] . ' AND hg.hostid=h.hostid ';
 }
 $hosts = array();
 $hostids = array();
 $sql = 'SELECT DISTINCT h.* ' . ' FROM hosts h ' . $sql_from . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . $sql_where . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')' . order_by('h.host,h.dns,h.ip,h.port,h.status');
 $result = DBselect($sql);
 while ($host = DBfetch($result)) {
     $hosts[$host['hostid']] = $host;
     $hostids[$host['hostid']] = $host['hostid'];
 }
 // templates
 $sql = 'SELECT hostid,count(hosttemplateid) as cnt ' . ' FROM hosts_templates ' . ' WHERE ' . DBcondition('hostid', $hostids) . ' GROUP BY hostid';
 $result = DBselect($sql);
 while ($templates = DBfetch($result)) {
     $hosts[$templates['hostid']]['templates_cnt'] = $templates['cnt'];
 }
 // items
 $sql = 'SELECT hostid,count(itemid) as cnt ' . ' FROM items ' . ' WHERE ' . DBcondition('hostid', $hostids) . ' GROUP BY hostid';
 $result = DBselect($sql);
 while ($items = DBfetch($result)) {
Пример #21
0
$hosts = API::Host()->get($options);
// fetch scripts for the host JS menu
if ($_REQUEST['hostid'] == 0) {
    $hostScripts = API::Script()->getScriptsByHosts($options['hostids']);
}
// select hosts
$sql = 'SELECT DISTINCT h.name as hostname,h.hostid, a.* ' . ' FROM applications a, hosts h ' . $sql_from . ' WHERE a.hostid=h.hostid' . $sql_where . ' AND ' . dbConditionInt('h.hostid', $available_hosts) . order_by('h.name,h.hostid', 'a.name,a.applicationid');
$db_app_res = DBselect($sql);
while ($db_app = DBfetch($db_app_res)) {
    $db_app['item_cnt'] = 0;
    $db_apps[$db_app['applicationid']] = $db_app;
    $db_appids[$db_app['applicationid']] = $db_app['applicationid'];
}
$tab_rows = array();
// select items
$sql = 'SELECT DISTINCT i.*, ia.applicationid ' . ' FROM items i,items_applications ia' . ' WHERE ' . dbConditionInt('ia.applicationid', $db_appids) . ' AND i.itemid=ia.itemid' . ($_REQUEST['show_without_data'] ? '' : ' AND i.lastvalue IS NOT NULL') . ' AND (i.status=' . ITEM_STATUS_ACTIVE . ' OR i.status=' . ITEM_STATUS_NOTSUPPORTED . ')' . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . order_by('i.name,i.itemid,i.lastclock');
$db_items = DBselect($sql);
while ($db_item = DBfetch($db_items)) {
    $description = itemName($db_item);
    if (!empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) {
        continue;
    }
    if (strpos($db_item['units'], ',') !== false) {
        list($db_item['units'], $db_item['unitsLong']) = explode(',', $db_item['units']);
    } else {
        $db_item['unitsLong'] = '';
    }
    $db_app =& $db_apps[$db_item['applicationid']];
    if (!isset($tab_rows[$db_app['applicationid']])) {
        $tab_rows[$db_app['applicationid']] = array();
    }
Пример #22
0
$sql_cond .= $_REQUEST['action'] > -1 && $config == 0 ? ' AND a.action=' . $_REQUEST['action'] . ' ' : '';
$sql_cond .= $_REQUEST['resourcetype'] > -1 && $config == 0 ? ' AND a.resourcetype=' . $_REQUEST['resourcetype'] . ' ' : '';
$sql_cond .= $_REQUEST['filter_timesince'] ? ' AND a.clock>' . $_REQUEST['filter_timesince'] : ' AND a.clock>100';
$sql_cond .= $_REQUEST['filter_timetill'] ? ' AND a.clock<' . $_REQUEST['filter_timetill'] : '';
$frmForm = new CForm();
$frmForm->SetMethod('get');
$cmbConf = new CComboBox('config', $_REQUEST['config'], 'submit()');
$cmbConf->addItem(0, S_AUDIT_LOGS);
$cmbConf->addItem(1, S_AUDIT_ACTIONS);
$frmForm->addItem($cmbConf);
//	show_table_header(S_AUDIT_BIG, $frmForm);
$row_count = 0;
if (0 == $config) {
    $table = new CTableInfo();
    $table->setHeader(array(make_sorting_link(S_TIME, 'a.clock'), make_sorting_link(S_USER, 'u.alias'), S_IP, S_RESOURCE, S_ACTION, S_ID, S_DESCRIPTION, S_DETAILS));
    $sql = 'SELECT a.auditid,a.clock,u.alias,a.ip,a.resourcetype,a.action,a.resourceid,a.resourcename,a.details ' . ' FROM auditlog a, users u ' . ' WHERE u.userid=a.userid ' . $sql_cond . ' AND ' . DBin_node('u.userid', get_current_nodeid(null, PERM_READ_ONLY)) . order_by('a.clock,u.alias');
    $result = DBselect($sql, $_REQUEST['start'] + PAGE_SIZE);
    for ($i = 0; $row = DBfetch($result); $i++) {
        if ($i < $_REQUEST['start']) {
            continue;
        }
        switch ($row['action']) {
            case AUDIT_ACTION_ADD:
                $action = S_ADDED;
                break;
            case AUDIT_ACTION_UPDATE:
                $action = S_UPDATED;
                break;
            case AUDIT_ACTION_DELETE:
                $action = S_DELETED;
                break;
Пример #23
0
        set_users_jsmenu_array();
    }
} else {
    if ($_REQUEST['config'] == 1) {
        // USER GROUPS
        if (isset($_REQUEST['form'])) {
            insert_usergroups_form();
        } else {
            $numrows = new CSpan(null, 'info');
            $numrows->addOption('name', 'numrows');
            $header = get_table_header(array(S_USER_GROUPS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
            show_table_header($header);
            $form = new CForm();
            $table = new CTableInfo(S_NO_USER_GROUPS_DEFINED);
            $table->setHeader(array(S_USERS_STATUS, S_GUI_ACCESS, array(new CCheckBox('all_groups', NULL, "CheckAll('" . $form->GetName() . "','all_groups');"), make_sorting_link(S_NAME, 'ug.name')), S_MEMBERS));
            $result = DBselect('SELECT ug.usrgrpid, ug.name, ug.users_status, ug.gui_access ' . ' FROM usrgrp ug' . ' WHERE ' . DBin_node('ug.usrgrpid') . order_by('ug.name'));
            while ($row = DBfetch($result)) {
                $users = array();
                $users_id = array();
                $db_users = DBselect('SELECT DISTINCT u.alias,u.userid ' . ' FROM users u,users_groups ug ' . ' WHERE u.userid=ug.userid ' . ' AND ug.usrgrpid=' . $row['usrgrpid'] . ' ORDER BY u.alias');
                while ($db_user = DBfetch($db_users)) {
                    if (!empty($users)) {
                        $users[$db_user['userid']][] = ', ';
                    } else {
                        $users[$db_user['userid']] = array();
                    }
                    $users[$db_user['userid']][] = new Clink($db_user['alias'], 'users.php?form=update&config=0&userid=' . $db_user['userid'] . '#form');
                }
                $gui_access = user_auth_type2str($row['gui_access']);
                $users_status = $row['users_status'] == GROUP_STATUS_ENABLED ? S_ENABLED : S_DISABLED;
                if (granted2update_group($row['usrgrpid'])) {
Пример #24
0
 $sql = 'SELECT f.triggerid, i.* ' . ' FROM functions f, items i ' . ' WHERE ' . DBcondition('f.triggerid', $triggerids) . ' AND i.itemid=f.itemid';
 $result = DBselect($sql);
 while ($row = DBfetch($result)) {
     $item['itemid'] = $row['itemid'];
     $item['action'] = str_in_array($row['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues';
     $item['description'] = item_description($row);
     $triggers[$row['triggerid']]['items'][$row['itemid']] = $item;
 }
 $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : '';
 $sql_cond .= ' AND e.clock>' . $start;
 $sql_cond .= ' AND e.clock<' . $end;
 $table = new CTableInfo(S_NO_EVENTS_FOUND);
 $table->SetHeader(array(make_sorting_link(S_TIME, 'e.clock'), is_show_subnodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 ? S_HOST : null, S_DESCRIPTION, S_STATUS, S_SEVERITY, S_DURATION, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
 if (!empty($triggers)) {
     $col = 0;
     $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE ' . DBcondition('e.objectid', $triggerids) . ' AND (e.object+0)=' . EVENT_OBJECT_TRIGGER . $sql_cond . order_by('e.clock');
     //SDI($sql);
     $result = DBselect($sql);
     while ($row = DBfetch($result)) {
         $value = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value']));
         $row = array_merge($triggers[$row['triggerid']], $row);
         if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) {
             continue;
         }
         $duration = zbx_date2age($row['clock']);
         if ($next_event = get_next_event($row, $show_unknown)) {
             $duration = zbx_date2age($row['clock'], $next_event['clock']);
         }
         // Actions
         $actions = get_event_actions_status($row['eventid']);
         //--------
Пример #25
0
 * Display
 */
if (isset($_REQUEST['form'])) {
    $data = array('nodeid' => get_request('nodeid'), 'masterNode' => DBfetch(DBselect('SELECT n.name FROM nodes n WHERE n.masterid IS NULL AND n.nodetype=' . ZBX_NODE_MASTER)));
    if (get_request('nodeid') && !isset($_REQUEST['form_refresh'])) {
        $data['new_nodeid'] = $node['nodeid'];
        $data['name'] = $node['name'];
        $data['ip'] = $node['ip'];
        $data['port'] = $node['port'];
        $data['masterid'] = $node['masterid'];
        $data['nodetype'] = $node['nodetype'];
    } else {
        $data['new_nodeid'] = get_request('new_nodeid');
        $data['name'] = get_request('name', '');
        $data['ip'] = get_request('ip', '127.0.0.1');
        $data['port'] = get_request('port', 10051);
        $data['nodetype'] = get_request('nodetype', ZBX_NODE_CHILD);
        $data['masterid'] = get_request('masterid', get_current_nodeid(false));
    }
    $nodeView = new CView('administration.node.edit', $data);
} else {
    validate_sort_and_sortorder();
    $data = array();
    if (ZBX_DISTRIBUTED) {
        $data['nodes'] = DBselect('SELECT n.* FROM nodes n ' . order_by('n.nodeid,n.name,n.ip', 'n.masterid'));
    }
    $nodeView = new CView('administration.node.list', $data);
}
$nodeView->render();
$nodeView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
Пример #26
0
if (!isset($_REQUEST["form"])) {
    $form->AddItem(new CButton('form', S_CREATE_RULE));
}
show_table_header(S_CONFIGURATION_OF_DISCOVERY_BIG, $form);
echo SBR;
if (isset($_REQUEST["form"])) {
    /* form */
    insert_drule_form();
} else {
    show_table_header(S_DISCOVERY_BIG);
    /* table */
    $form = new CForm();
    $form->SetName('frmdrules');
    $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED);
    $tblDiscovery->SetHeader(array(array(new CCheckBox('all_drules', null, "CheckAll('" . $form->GetName() . "','all_drules');"), make_sorting_link(S_NAME, 'd.name')), make_sorting_link(S_IP_RANGE, 'd.iprange'), make_sorting_link(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS));
    $db_rules = DBselect('SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid'));
    while ($rule_data = DBfetch($db_rules)) {
        $cheks = array();
        $db_checks = DBselect("select * from dchecks where druleid=" . $rule_data["druleid"] . " order by type,druleid");
        while ($check_data = DBfetch($db_checks)) {
            $cheks[] = discovery_check_type2str($check_data['type']);
        }
        $status = new CCol(new CLink(discovery_status2str($rule_data["status"]), '?g_druleid%5B%5D=' . $rule_data['druleid'] . ($rule_data["status"] == DRULE_STATUS_ACTIVE ? '&group_disable=1' : '&group_enable=1'), discovery_status2style($rule_data["status"])));
        $description = array();
        if ($rule_data["proxy_hostid"]) {
            $proxy = get_host_by_hostid($rule_data["proxy_hostid"]);
            array_push($description, $proxy["host"], ":");
        }
        array_push($description, new CLink($rule_data['name'], "?form=update&druleid=" . $rule_data['druleid'], 'action'));
        $drule = new CCol(array(new CCheckBox('g_druleid[' . $rule_data["druleid"] . ']', null, null, $rule_data["druleid"]), SPACE, $description));
        $tblDiscovery->AddRow(array($drule, $rule_data['iprange'], $rule_data['delay'], implode(',', $cheks), $status));
Пример #27
0
            $db_img[$k]['bandwidth'] = 0;
            $db_img[$k]['hotlink'] = 0;
            $db_img[$k]['gallery'] = 0;
        }
    }
    // empty memory
    unset($hc);
    // what page are we on
    $page_number = isset($_GET['p']) ? cl($_GET['p']) - 1 : 0;
    // setup pagination address
    $pagination_address = $settings['SET_SITEURL'] . 'admin.php?p=%1$s&act=images' . $list_url . $orderby_url . $allTime_url . $ipSearch_url;
    // %1 page number
    // page pagination
    $pagination = pagination($page_number, $item_on_page, $DBCOUNT, $pagination_address);
    // order DB
    order_by($db_img, $orderBy, $order);
    $imageList = array_slice($db_img, $page_number * $item_on_page, $item_on_page);
    foreach ($imageList as $k => $image) {
        $bandwidthStyle = '';
        //($settings['SET_MAX_BANDWIDTH'] !=0 && ($settings['SET_MAX_BANDWIDTH']*1048576) < $image['bandwidth']?' style="background-color:red;color:#000"':'');
        $list_item .= '
				<tr class="' . ($odd = empty($odd) ? 'odd' : '') . '">
					<td>
						<a href="' . imageAddress(2, $image, "pm") . '" class="tip" title="' . _T("admin_ilp_thumb_page_link") . '"><img src="img/Image-Info.png" height="16" width="16" border="0" alt="' . _T("admin_ilp_thumb_page_link") . '" /></a>
						<a href="admin.php?act=edit&id=' . $image['id'] . '" class="tip" title="' . _T("admin_ilp_edit_alt") . '"><img src="img/Image-Edit.png" height="16" width="16" border="0" alt="' . _T("admin_ilp_edit_alt") . '" /></a>
						<a href="#" id="' . $image['deleteid'] . '" class="tip delete" title="' . _T("admin_ilp_report_alt_delete") . '" ret="' . sprintf(_T("admin_ilp_report_delete"), $image['id']) . '" ><img src="img/Image-Del.png" height="16" width="16" border="0" alt="' . _T("admin_ilp_report_alt_delete") . '" /></a>
						<a href="admin.php?act=ban&id=' . $image['id'] . '" class="tip" title="' . _T("admin_ilp_report_alt_ban") . '"><img src="img/User-Block.png" height="16" width="16" border="0" alt="' . _T("admin_ilp_report_alt_ban") . '" /></a>
						<a href="admin.php?act=images&ip=' . $image['ip'] . '" class="tip" title="' . sprintf(_T("admin_ilp_ipsearch_alt"), $image['ip']) . '"><img src="img/user-search.png" height="16" width="16" border="0" alt="' . sprintf(_T("admin_ilp_ipsearch_alt"), $image['ip']) . '" /></a>
					</td>
					<td>' . date('d M y', $image['added']) . '</td>
					<td><a href="' . imageAddress(1, $image) . '" target="_blank" title="' . $image['name'] . '" img_src="<img src=\'' . imageAddress(3, $image) . '\'/>" class="imglink img_tooltip lightbox">' . $image['alt'] . '</a></td>
Пример #28
0
 $cmbSource = new CComboBox('eventsource', $_REQUEST['eventsource'], 'submit()');
 $cmbSource->addItem(EVENT_SOURCE_TRIGGERS, S_TRIGGERS);
 $cmbSource->addItem(EVENT_SOURCE_DISCOVERY, S_DISCOVERY);
 $form->addItem(array(S_EVENT_SOURCE, SPACE, $cmbSource));
 $row_count = 0;
 $numrows = new CSpan(null, 'info');
 $numrows->setAttribute('name', 'numrows');
 $header = get_table_header(array(S_ACTIONS_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
 show_table_header($header, $form);
 unset($form, $cmbSource);
 /* table */
 $form = new CForm();
 $form->setName('actions');
 $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED);
 $tblActions->setHeader(array(new CCheckBox('all_items', null, "checkAll('" . $form->getName() . "','all_items','g_actionid');"), make_sorting_link(S_NAME, 'a.name'), S_CONDITIONS, S_OPERATIONS, make_sorting_link(S_STATUS, 'a.status')));
 $db_actions = DBselect('SELECT a.* ' . ' FROM actions a' . ' WHERE a.eventsource=' . $_REQUEST['eventsource'] . ' AND ' . DBin_node('actionid') . order_by('a.name,a.status', 'a.actionid'));
 while ($action_data = DBfetch($db_actions)) {
     if (!action_accessible($action_data['actionid'], PERM_READ_WRITE)) {
         continue;
     }
     $conditions = array();
     $db_conditions = DBselect('select * from conditions where actionid=' . $action_data['actionid'] . ' order by conditiontype,conditionid');
     while ($condition_data = DBfetch($db_conditions)) {
         array_push($conditions, array(get_condition_desc($condition_data['conditiontype'], $condition_data['operator'], $condition_data['value']), BR()));
     }
     unset($db_conditions, $condition_data);
     $operations = array();
     $db_operations = DBselect('select * from operations where actionid=' . $action_data['actionid'] . ' order by operationtype,operationid');
     while ($operation_data = DBfetch($db_operations)) {
         array_push($operations, array(get_operation_desc(SHORT_DESCRITION, $operation_data), BR()));
     }
Пример #29
0
}
$form = new CForm();
$form->SetMethod('get');
$form->AddItem(new CButton("form", S_CREATE_MEDIA_TYPE));
$row_count = 0;
$numrows = new CSpan(null, 'info');
$numrows->addOption('name', 'numrows');
$header = get_table_header(array(S_CONFIGURATION_OF_MEDIA_TYPES_BIG, new CSpan(SPACE . SPACE . '|' . SPACE . SPACE, 'divider'), S_FOUND . ': ', $numrows));
show_table_header($header, $form);
if (isset($_REQUEST["form"])) {
    echo SBR;
    insert_media_type_form();
} else {
    $table = new CTableInfo(S_NO_MEDIA_TYPES_DEFINED);
    $table->setHeader(array(make_sorting_link(S_TYPE, 'mt.type'), make_sorting_link(S_DESCRIPTION, 'mt.description'), S_DETAILS));
    $result = DBselect('SELECT mt.* ' . ' FROM media_type mt' . ' WHERE ' . DBin_node('mt.mediatypeid') . order_by('mt.type,mt.description'));
    while ($row = DBfetch($result)) {
        switch ($row['type']) {
            case MEDIA_TYPE_EMAIL:
                $details = S_SMTP_SERVER . ": '" . $row['smtp_server'] . "', " . S_SMTP_HELO . ": '" . $row['smtp_helo'] . "', " . S_SMTP_EMAIL . ": '" . $row['smtp_email'] . "'";
                break;
            case MEDIA_TYPE_EXEC:
                $details = S_SCRIPT_NAME . ": '" . $row['exec_path'] . "'";
                break;
            case MEDIA_TYPE_SMS:
                $details = S_GSM_MODEM . ": '" . $row['gsm_modem'] . "'";
                break;
            case MEDIA_TYPE_JABBER:
                $details = S_JABBER_IDENTIFIER . ": '" . $row['username'] . "'";
                break;
            default:
Пример #30
0
        $event_cond .= ' AND ((' . time() . '-e.clock)<' . $event_expire . ') ' . ' AND e.acknowledged=0 ';
        break;
    case EVENTS_OPTION_ONLYTRUE_NOTACK:
        $event_cond .= ' AND ((' . time() . '-e.clock)<' . $event_expire . ') ' . ' AND e.acknowledged=0 AND e.value=' . TRIGGER_VALUE_TRUE;
        break;
    case EVENTS_OPTION_NOFALSEFORB:
        $event_cond .= ' AND e.acknowledged=0 ' . ' AND ((e.value=' . TRIGGER_VALUE_TRUE . ') OR ((e.value=' . TRIGGER_VALUE_FALSE . ') AND t.type=' . TRIGGER_MULT_EVENT_DISABLED . '))';
        break;
    case EVENTS_OPTION_NOEVENT:
    default:
        $event_cond .= ' AND 1=2 ';
        break;
}
$triggers = array();
$triggerids = array();
$sql = 'SELECT DISTINCT t.triggerid,t.status,t.description, t.expression,t.priority, ' . ' t.lastchange,t.comments,t.url,t.value,h.host,h.hostid,t.type ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND f.triggerid=t.triggerid ' . ' AND i.itemid=f.itemid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND h.hostid=i.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . $cond . order_by('h.host,h.hostid,t.description,t.priority,t.lastchange');
$result = DBselect($sql);
while ($row = DBfetch($result)) {
    // Check for dependencies
    if (trigger_dependent($row['triggerid'])) {
        continue;
    }
    if ($show_triggers == TRIGGERS_OPTION_NOFALSEFORB) {
        $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=0 ' . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . $event_cond . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
        if (!($row = get_row_for_nofalseforb($row, $event_sql))) {
            continue;
        }
    }
    $triggers_num++;
    $row['events'] = array();
    $row['items'] = array();