function getDatasForTemplate($event, $options = array()) { global $CFG_GLPI; if ($event == 'AlertNotValidatedTypology') { $this->datas['##typology.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']); $this->datas['##lang.typology.entity##'] = __('Entity'); $this->datas['##typology.action##'] = __('Elements not match with the typology', 'typology'); $this->datas['##lang.typology.name##'] = PluginTypologyTypology::getTypeName(1); $this->datas['##lang.typology.itemtype##'] = __('Type'); $this->datas['##lang.typology.items_id##'] = __('Name'); $this->datas['##lang.typology.error##'] = __('Error'); $this->datas['##lang.typology.url##'] = __('Link to the typology', 'typology'); $this->datas['##lang.typology.itemurl##'] = __('Link to the element', 'typology'); $this->datas['##lang.typology.itemuser##'] = __('User'); $this->datas['##lang.typology.itemlocation##'] = __('Location'); foreach ($options['items'] as $id => $item) { $tmp = array(); $tmp['##typology.name##'] = $item['name']; $itemtype = new $item['itemtype'](); $itemtype->getFromDB($item["items_id"]); $tmp['##typology.itemtype##'] = $itemtype->getTypeName(); $tmp['##typology.items_id##'] = $itemtype->getName(); $tmp['##typology.error##'] = PluginTypologyTypology_Item::displayErrors($item['error'], false); $tmp['##typology.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_typology_" . $item['plugin_typology_typologies_id']); $tmp['##typology.itemurl##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=" . Toolbox::strtolower($item['itemtype']) . "_" . $item["items_id"]); $tmp['##typology.itemuser##'] = getUserName($itemtype->fields["users_id"]); $tmp['##typology.itemlocation##'] = Dropdown::getDropdownName("glpi_locations", $itemtype->fields['locations_id']); $this->datas['typologyitems'][] = $tmp; } } }
$resultComputer = $DB->query($queryComputer); $computeOK = 0; $computeNOTOK = 0; while ($dataComputer = $DB->fetch_array($resultComputer)) { $link = Toolbox::getItemTypeFormURL("Computer"); $computerName = "<a href='" . $link . "?id=" . $dataComputer["items_id"] . "' target='_blank'>" . Dropdown::getDropdownName("glpi_computers", $dataComputer["items_id"]) . "</a>"; $computer = new Computer(); $computer->getFromDB($dataComputer["items_id"]); $userName = getUserName($computer->fields["users_id"]); if ($dataComputer["is_validated"] > 0) { $critTypOK = __('Yes'); $computeOK++; } else { $critTypOK = "<font color='red'>" . __('No') . " " . __('for the criteria', 'typology') . " "; $i = 0; $critTypOK .= PluginTypologyTypology_Item::displayErrors($dataComputer["error"]); $critTypOK .= "</font>"; $computeNOTOK++; } $row_num++; $num = 1; echo Search::showNewLine($output_type); echo Search::showItem($output_type, '', $num, $row_num); echo Search::showItem($output_type, $computerName, $num, $row_num); echo Search::showItem($output_type, $userName, $num, $row_num); echo Search::showItem($output_type, $critTypOK, $num, $row_num); echo Search::showEndLine($output_type); } $row_num++; $num = 1; $message = "<b><font color='green'>" . __('Responding', 'typology') . " " . $computeOK . " / " . $dataService["COUNT"] . "</font>" . ", " . "<font color='red'>" . __('Not responding', 'typology') . " " . $computeNOTOK . " / " . $dataService["COUNT"] . "</font></b>";
function plugin_typology_giveItem($type, $ID, $data, $num) { $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; switch ($type) { case 'Computer': switch ($table . '.' . $field) { case "glpi_plugin_typology_typologies_items.is_validated": if (empty($data["ITEM_{$num}"])) { $out = ''; } else { $validated = explode("\$\$", $data["ITEM_{$num}"]); $out = Dropdown::getYesNo($validated[0]); } return $out; break; case "glpi_plugin_typology_typologies_items.error": // if (empty($data["ITEM_$num"])) { // $out = __('No error','typology'); // } else { $list = explode("\$\$", $data["ITEM_{$num}"]); $out = PluginTypologyTypology_Item::displayErrors($list[0]); // } return $out; break; } break; } return ""; }