function plugin_projet_giveItem($type, $ID, $data, $num) { global $CFG_GLPI, $DB; $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; } switch ($type) { case 'PluginProjetProjet': switch ($table . '.' . $field) { case "glpi_plugin_projet_projets_projets.plugin_projet_projets_id_1": $out = " "; $split = explode("\$\$\$\$", $data["ITEM_" . $num]); $split2 = explode("\$\$\$\$", $data["ITEM_" . $num . "_2"]); $displayed = array(); for ($k = 0; $k < count($split); $k++) { //$linkid = $split2[$k]; $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split2[$k]; if ($linkid > 0 && $linkid != $data['id'] && !isset($displayed[$linkid])) { $text = $linkid . " - " . Dropdown::getDropdownName('glpi_plugin_projet_projets', $linkid); if (count($displayed)) { $out .= "<br>"; } $displayed[$linkid] = $linkid; $out .= $text; } } return $out; break; case "glpi_plugin_projet_projets.name": $out = ""; if (!empty($data["ITEM_" . $num . "_2"])) { $link = Toolbox::getItemTypeFormURL('PluginProjetProjet'); if ($output_type == Search::HTML_OUTPUT) { $out = "<a href=\"" . $link . "?id=" . $data["ITEM_" . $num . "_2"] . "\">"; } $out .= $data["ITEM_{$num}"]; if ($output_type == Search::HTML_OUTPUT) { if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["ITEM_" . $num . "_2"] . ")"; } $out .= "</a>"; } if (plugin_projet_haveRight("task", "r") && $output_type == Search::HTML_OUTPUT) { $query_tasks = "SELECT COUNT(`id`) AS nb_tasks\n FROM `glpi_plugin_projet_tasks`\n WHERE `plugin_projet_projets_id` = '" . $data['id'] . "' "; $query_tasks .= "AND `is_deleted` = '0'"; $result_tasks = $DB->query($query_tasks); $nb_tasks = $DB->result($result_tasks, 0, "nb_tasks"); //select finished tasks $query_states = "SELECT COUNT(`id`) AS nb_tasks\n FROM `glpi_plugin_projet_tasks`\n WHERE `plugin_projet_projets_id` = '" . $data['id'] . "' "; $query_states .= "AND `is_deleted` = '0'"; $finished = " `for_dependency` = '1' "; $states = getAllDatasFromTable("glpi_plugin_projet_taskstates", $finished); $tab = array(); if (!empty($states)) { foreach ($states as $state) { $tab[] = $state['id']; } } if (!empty($tab)) { $query_states .= "AND `plugin_projet_taskstates_id` IN (" . implode(',', $tab) . ")"; } $result_states = $DB->query($query_states); $is_finished = $DB->result($result_states, 0, "nb_tasks"); $out .= " (<a href=\"" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/task.php?plugin_projet_projets_id=" . $data["id"] . "\">"; if ($nb_tasks - $is_finished > 0) { $out .= "<span class='red'>"; $out .= $nb_tasks - $is_finished . "</span></a>)"; } else { $out .= "<span class='green'>"; $out .= $nb_tasks . "</span></a>)"; } } } return $out; break; case "glpi_plugin_projet_projets.date_end": if (!empty($data["ITEM_{$num}"])) { if ($data["ITEM_{$num}"] <= date('Y-m-d') && !empty($data["ITEM_{$num}"])) { $out = "<span class='red'>" . Html::convdate($data["ITEM_{$num}"]) . "</span>"; } else { $out = "<span class='green'>" . Html::convdate($data["ITEM_{$num}"]) . "</span>"; } } else { $out = "--"; } return $out; break; case "glpi_plugin_projet_projets.advance": $out = PluginProjetProjet::displayProgressBar('100', $data["ITEM_{$num}"]); return $out; break; case "glpi_plugin_projet_projets_items.items_id": $restrict = "`plugin_projet_projets_id` = '" . $data['id'] . "' \n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_projet_projets_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { if (!class_exists($device["itemtype"])) { continue; } $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - "; if ($device["itemtype"] == 'User') { if ($output_type == Search::HTML_OUTPUT) { $link = Toolbox::getItemTypeFormURL('User'); $out .= "<a href=\"" . $link . "?id=" . $device["items_id"] . "\">"; } $out .= getUserName($device["items_id"]); if ($output_type == Search::HTML_OUTPUT) { $out .= "</a>"; } } else { $out .= $item->getLink(); } $out .= "<br>"; } } else { $out = ' '; } return $out; break; } return ""; break; case 'PluginProjetTask': switch ($table . '.' . $field) { case "glpi_plugin_projet_tasks_tasks.plugin_projet_tasks_id_1": $out = " "; $split = explode("\$\$\$\$", $data["ITEM_" . $num]); $split2 = explode("\$\$\$\$", $data["ITEM_" . $num . "_2"]); $displayed = array(); for ($k = 0; $k < count($split); $k++) { //$linkid = $split2[$k]; $linkid = $split[$k] == $data['id'] ? $split2[$k] : $split2[$k]; if ($linkid > 0 && $linkid != $data['id'] && !isset($displayed[$linkid])) { $text = $linkid . " - " . Dropdown::getDropdownName('glpi_plugin_projet_tasks', $linkid); if (count($displayed)) { $out .= "<br>"; } $displayed[$linkid] = $linkid; $out .= $text; } } return $out; break; case "glpi_plugin_projet_tasks.advance": $out = PluginProjetProjet::displayProgressBar('100', $data["ITEM_{$num}"]); return $out; break; case "glpi_plugin_projet_tasks.priority": $out = Ticket::getPriorityName($data["ITEM_{$num}"]); return $out; break; case 'glpi_plugin_projet_tasks.depends': $out = ""; if ($data["ITEM_{$num}"] == 1) { $out .= "<span class='red'>"; } $out .= Dropdown::getYesNo($data["ITEM_{$num}"]); if ($data["ITEM_{$num}"] == 1) { $out .= "</span>"; } return $out; break; case "glpi_plugin_projet_tasks.plugin_projet_projets_id": $out = Dropdown::getdropdownname("glpi_plugin_projet_projets", $data["ITEM_{$num}"]); $out .= " (" . $data["ITEM_{$num}"] . ")"; return $out; break; case "glpi_plugin_projet_tasks_items.items_id": $restrict = "`plugin_projet_tasks_id` = '" . $data['id'] . "' \n ORDER BY `itemtype`, `items_id`"; $items = getAllDatasFromTable("glpi_plugin_projet_tasks_items", $restrict); $out = ''; if (!empty($items)) { foreach ($items as $device) { $item = new $device["itemtype"](); $item->getFromDB($device["items_id"]); $out .= $item->getTypeName() . " - " . $item->getLink() . "<br>"; } } return $out; break; case "glpi_contacts.name": if (!empty($data["ITEM_{$num}"])) { $link = Toolbox::getItemTypeFormURL('Contact'); $out = "<a href=\"" . $link . "?id=" . $data["ITEM_{$num}"] . "\">"; $temp = $data["contacts_name"]; $firstname = $data["contacts_firstname"]; if (strlen($firstname) > 0) { if ($CFG_GLPI["names_format"] == FIRSTNAME_BEFORE) { $temp = $firstname . " " . $temp; } else { $temp .= " " . $firstname; } } $out .= $temp; if ($_SESSION["glpiis_ids_visible"] || empty($data["ITEM_{$num}"])) { $out .= " (" . $data["ITEM_{$num}"] . ")"; } $out .= "</a>"; } else { $out = ""; } return $out; break; case "glpi_plugin_projet_taskplannings.id": if (!empty($data["ITEM_{$num}"])) { $plan = new PluginProjetTaskPlanning(); $plan->getFromDB($data["ITEM_{$num}"]); $out = Html::convDateTime($plan->fields["begin"]) . "<br> -> " . Html::convDateTime($plan->fields["end"]); } else { $out = __('None'); } return $out; break; } return ""; break; } return ""; }