/** * Show projet for a ticket / problem * * @param $item Ticket or Problem object **/ static function showForHelpdesk($item) { global $DB, $CFG_GLPI; $ID = $item->getField('id'); if (!$item->can($ID, 'r')) { return false; } $canedit = $item->can($ID, 'w'); $rand = mt_rand(); echo "<form name='projetlink_form{$rand}' id='projetlink_form{$rand}' method='post'\n action='"; echo Toolbox::getItemTypeFormURL("PluginProjetProjet") . "'>"; echo "<div class='center'><table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='7'>" . _n('Project', 'Projects', 2, 'projet') . " - "; echo "<a href='" . Toolbox::getItemTypeFormURL('PluginProjetProjet') . "?helpdesk_id={$ID}&helpdesk_itemtype=" . $item->gettype() . "'>"; $nav = ""; if ($item->gettype() == "Ticket") { _e('Create a project from this ticket', 'projet'); $nav = _n('Ticket', 'Tickets', 2); } else { _e('Create a project from this problem', 'projet'); $nav = _n('Problem', 'Problems', 2); } echo "</a>"; echo "</th></tr>"; $query = "SELECT `glpi_plugin_projet_projets_items`.`id` AS items_id,\n `glpi_plugin_projet_projets`.* " . " FROM `glpi_plugin_projet_projets_items`,`glpi_plugin_projet_projets` " . " LEFT JOIN `glpi_entities` \n ON (`glpi_entities`.`id` = `glpi_plugin_projet_projets`.`entities_id`) " . " WHERE `glpi_plugin_projet_projets_items`.`items_id` = '" . $ID . "' \n AND `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item->gettype() . "' \n AND `glpi_plugin_projet_projets_items`.`plugin_projet_projets_id` = `glpi_plugin_projet_projets`.`id` \n AND `glpi_plugin_projet_projets`.`is_template` = '0' "; $query .= "ORDER BY `glpi_plugin_projet_projets`.`name`"; $result = $DB->query($query); $used = array(); if ($DB->numrows($result) > 0) { PluginProjetProjet::commonListHeader(Search::HTML_OUTPUT, $canedit); Session::initNavigateListItems('PluginProjetProjet', $nav . " = " . $item->fields["name"]); $i = 0; while ($data = $DB->fetch_array($result)) { $used[$data['id']] = $data['id']; Session::addToNavigateListItems('PluginProjetProjet', $data["id"]); echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>"; if ($canedit && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["is_recursive"])) { echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php?id=" . $data["id"] . "'>" . $data["name"]; if ($_SESSION["glpiis_ids_visible"]) { echo " (" . $data["id"] . ")"; } echo "</a></td>"; } else { echo "<td class='center'>" . $data["name"]; if ($_SESSION["glpiis_ids_visible"]) { echo " (" . $data["id"] . ")"; } echo "</td>"; } if (Session::isMultiEntitiesMode()) { echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_entities", $data['entities_id']); echo "</td>"; } echo "<td align='center'>" . $data["description"] . "</td>"; echo "<td align='center'>"; echo PluginProjetProjet::displayProgressBar('100', $data["advance"]); echo "</td>"; echo "<td class='center'>" . Html::convdate($data["date_begin"]) . "</td>"; if ($data["date_end"] <= date('Y-m-d') && !empty($data["date_end"])) { echo "<td class='center'>"; echo "<span class='red'>" . Html::convdate($data["date_end"]) . "</span></td>"; } else { echo "<td class='center'>"; echo "<span class='green'>" . Html::convdate($data["date_end"]) . "</span></td>"; } if ($canedit) { echo "<td class='center tab_bg_2'>"; Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/projet/front/projet.form.php', 'deletedevice', _x('button', 'Delete permanently'), array('id' => $data['items_id'])); echo "</td>"; } echo "</tr>"; $i++; } } if ($canedit) { echo "<tr class='tab_bg_2'><td class='right' colspan='6'>"; echo "<input type='hidden' name='items_id' value='{$ID}'>"; echo "<input type='hidden' name='itemtype' value='" . $item->gettype() . "'>"; echo "<input type='hidden' name='helpdesk_itemtype' value='" . $item->gettype() . "'>"; Dropdown::show('PluginProjetProjet', array('used' => $used, 'entity' => $item->getEntityID(), 'name' => 'plugin_projet_projets_id')); echo "</td><td class='center'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; } echo "</table></div>"; /*if ($canedit) { Html::openArrowMassives("projetlink_form$rand", true); Html::closeArrowMassives(array('delete' => _sx('button','Delete')); }*/ Html::closeForm(); }