/** * Show the minimal form for the definition criteria * * @param $ligne datas used to display the definition **/ static function showMinimalDefinitionForm($ligne, $options = array()) { global $DB, $CFG_GLPI; $params['seeResult'] = 0; $params['seeItemtype'] = 0; $img_OK = $CFG_GLPI["root_doc"] . '/pics/ok.png'; $img_NOT = $CFG_GLPI["root_doc"] . '/pics/extjs/window/icon-error.gif'; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $item = new $ligne["itemtype"](); if ($params['seeItemtype']) { echo "<td class='center'>"; echo $item->getTypeName(0); echo "</td>"; echo "<td class='center'>"; if ($ligne['link'] == 0) { echo __('and'); } else { if ($ligne['link'] == 1) { echo __('or'); } } echo "</td>"; } echo "<td class='center'>"; $test = explode(";", $ligne["field"]); $itemField = $test[0]; $itemTable = $test[1]; $itemDataType = $test[2]; if ($itemField == 'count') { echo __('Number'); } else { $searchOption = $item->getSearchOptionByField('field', $itemField); if (empty($searchOption)) { $searchOption = $item->getSearchOptionByField('field', 'name', $itemTable); } echo $searchOption['name']; } echo "</td>"; if ($params['seeResult']) { echo "<td class='center'><img src="; if ($ligne['result'] == 'ok') { echo $img_OK; } else { if ($ligne['result'] == 'not_ok') { echo $img_NOT; } } echo " ></td>"; } // logical operator echo "<td class='center'>"; if ($ligne['action_type'] == 'contains') { echo __('contains'); } else { if ($ligne['action_type'] == 'notcontains') { echo __('does not contain'); } else { if ($ligne['action_type'] == 'lessthan') { echo __('Less than', 'typology'); } else { if ($ligne['action_type'] == 'morethan') { echo __('More than', 'typology'); } else { if ($ligne['action_type'] == 'regex_match') { echo __('regular expression matches'); } else { if ($ligne['action_type'] == 'regex_not_match') { echo __('regular expression does not match'); } else { if ($ligne['action_type'] == 'equals') { echo __('is'); } else { if ($ligne['action_type'] == 'notequals') { echo __('is not'); } else { if ($ligne['action_type'] == 'under') { echo __('under'); } else { if ($ligne['action_type'] == 'notunder') { echo __('not under'); } } } } } } } } } } echo "</td>"; // criteria value echo "<td class='center'>"; if ($ligne['action_type'] == 'contains' || $ligne['action_type'] == 'notcontains' || $ligne['action_type'] == 'regex_match' || $ligne['action_type'] == 'regex_not_match') { echo $ligne["value"]; } else { switch ($itemDataType) { case "bool": echo Dropdown::getYesNo($ligne["value"]); break; case "number": echo $ligne["value"]; if ($itemField == 'size') { echo "\""; } break; case "string": echo $ligne["value"]; break; case "text": echo $ligne["value"]; if ($ligne["itemtype"] == 'DeviceHardDrive') { echo " " . __('Mio'); } else { if ($itemField == 'frequence') { echo " " . __('MHz'); } else { if ($ligne["itemtype"] == 'DeviceMemory' && $itemField == 'specif_default') { echo " " . __('Mio'); } else { if ($ligne["itemtype"] == 'DeviceProcessor' && $itemField == 'specif_default') { echo " " . __('MHz'); } } } } break; // case "ip" : // echo $ligne["value"]; // break; // case "ip" : // echo $ligne["value"]; // break; default: switch ($itemTable) { case "glpi_users": echo getUserName($ligne["value"]); break; case "glpi_softwareversions": $query = "SELECT `glpi_softwares`.`name` as softname,\n `glpi_softwareversions`.`name` as vname,\n `glpi_softwareversions`.`id` as vid\n FROM `glpi_softwareversions`\n INNER JOIN `glpi_softwares` on (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_softwareversions`.`id`='" . $ligne["value"] . "'"; if ($result = $DB->query($query)) { while ($data = $DB->fetch_array($result)) { echo $data['softname'] . " - "; if ($data['vname'] == '') { echo "(" . $data['vid'] . ")"; } else { echo $data['vname']; } } } break; default: if ($item instanceof CommonDevice) { $item->getFromDB($ligne["value"]); echo $item->getName(); } else { echo Dropdown::getDropdownName($itemTable, $ligne["value"]); } break; } break; } } echo "</td>"; // computer value if ($params['seeResult']) { echo "<td class='center'>"; if ($ligne['realvalue'][0] > 1 && $ligne['realvalue'][1] > 1 || $ligne['realvalue'][0] == 1 && $ligne['realvalue'][1] == 2) { echo $ligne['realvalue'][0] . ' / ' . $ligne['realvalue'][1]; echo "<br>"; } else { if ($ligne['realvalue'][0] == 0 && $ligne['realvalue'][1] != 1) { echo __('Item not found'); } } if (isset($ligne['list_ok']) && $ligne['realvalue'][0] > 0 || $ligne['realvalue'][0] == 0 && $ligne['realvalue'][1] == 1) { $count = count($ligne['list_ok']); $i = 0; foreach ($ligne['list_ok'] as $key => $val) { $i++; if ($val == '') { $val = __('Item not found'); } if ($itemDataType != "bool") { echo $val; if ($itemField == 'size') { echo "\""; } else { if ($ligne["itemtype"] == 'DeviceHardDrive') { echo " " . __('Mio'); } else { if ($itemField == 'frequence') { echo " " . __('MHz'); } else { if ($ligne["itemtype"] == 'DeviceMemory' && $itemField == 'specif_default') { echo " " . __('Mio'); } else { if ($ligne["itemtype"] == 'DeviceProcessor' && $itemField == 'specif_default') { echo " " . __('MHz'); } } } } } } else { echo Dropdown::GetYesNo($val); } if ($i < $count) { echo "<br>"; } } } echo "</td>"; } }