function plugin_init_projet() { global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['projet'] = true; $PLUGIN_HOOKS['change_profile']['projet'] = array('PluginProjetProfile', 'changeProfile'); $PLUGIN_HOOKS['assign_to_ticket']['projet'] = true; if (Session::getLoginUserID()) { Plugin::registerClass('PluginProjetProjet', array('linkgroup_types' => true, 'linkuser_types' => true, 'doc_types' => true, 'contract_types' => true, 'helpdesk_types' => true, 'helpdesk_visible_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginProjetTaskPlanning', array('planning_types' => true)); Plugin::registerClass('PluginProjetProfile', array('addtabon' => 'Profile')); // Display a menu entry ? if (plugin_projet_haveRight("projet", "r")) { $PLUGIN_HOOKS['menu_entry']['projet'] = 'front/projet.php'; $PLUGIN_HOOKS['submenu_entry']['projet']['search'] = 'front/projet.php'; $PLUGIN_HOOKS['redirect_page']['projet'] = "front/projet.form.php"; } if (plugin_projet_haveRight("projet", "w")) { $PLUGIN_HOOKS['submenu_entry']['projet']['add'] = 'front/setup.templates.php?add=1'; $PLUGIN_HOOKS['submenu_entry']['projet']['template'] = 'front/setup.templates.php?add=0'; } if (plugin_projet_haveRight("task", "r")) { $PLUGIN_HOOKS['submenu_entry']['projet']["<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' title='" . __('Tasks list', 'projet') . "' alt='" . __('Tasks list', 'projet') . "'>"] = 'front/task.php'; } if (class_exists('PluginProjetProjet_Item')) { // only if plugin activated $PLUGIN_HOOKS['pre_item_purge']['projet'] = array('Profile' => array('PluginProjetProfile', 'purgeProfiles')); } // Add specific files to add to the header : javascript or css //$PLUGIN_HOOKS['add_javascript']['example']="example.js"; $PLUGIN_HOOKS['add_css']['projet'] = "projet.css"; //Planning hook $PLUGIN_HOOKS['planning_populate']['projet'] = array('PluginProjetTaskPlanning', 'populatePlanning'); $PLUGIN_HOOKS['display_planning']['projet'] = array('PluginProjetTaskPlanning', 'displayPlanningItem'); // End init, when all types are registered $PLUGIN_HOOKS['post_init']['projet'] = 'plugin_projet_postinit'; if (class_exists('PluginPdfCommon')) { $PLUGIN_HOOKS['plugin_pdf']['PluginProjetProjet'] = 'PluginProjetProjetPDF'; } } //Planning hook $PLUGIN_HOOKS['display_planning']['projet'] = array('PluginProjetTaskPlanning', 'displayPlanningItem'); // End init, when all types are registered $PLUGIN_HOOKS['post_init']['projet'] = 'plugin_projet_postinit'; }
/** * Show for PDF an resources : tasks informations * * @param $pdf object for the output * @param $ID of the resources */ static function pdfForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli) { global $DB; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_projet_haveRight("projet", "r")) { return false; } $query = "SELECT * \n FROM `glpi_plugin_projet_tasks` \n WHERE `plugin_projet_projets_id` = '{$ID}'\n AND `is_deleted` ='0'"; $result = $DB->query($query); $number = $DB->numrows($result); $i = $j = 0; $pdf->setColumnsSize(100); if ($number > 0) { $pdf->displayTitle('<b>' . _n('Associated task', 'Associated tasks', 2, 'projet') . '</b>'); $pdf->setColumnsSize(14, 14, 14, 14, 16, 14, 14); $pdf->displayTitle('<b><i>' . __('Name'), _n('Type', 'Types', 1), __('Description'), __('Duration'), __('Planning'), _n('User', 'Users', 1), _n('Group', 'Groups', 1) . '</i></b>'); $i++; while ($j < $number) { $tID = $DB->result($result, $j, "id"); $actiontime_ID = $DB->result($result, $j, "actiontime"); $actiontime = ''; $units = Toolbox::getTimestampTimeUnits($actiontime_ID); $hour = $units['hour']; $minute = $units['minute']; if ($hour) { $actiontime = sprintf(__('%1$d hours'), $hour); } if ($minute || !$hour) { $actiontime .= sprintf(__('%1$d minutes'), $minute); } $restrict = " `plugin_projet_tasks_id` = '" . $tID . "' "; $plans = getAllDatasFromTable("glpi_plugin_projet_taskplannings", $restrict); if (!empty($plans)) { foreach ($plans as $plan) { $planification = Html::convDateTime($plan["begin"]) . " -> " . Html::convDateTime($plan["end"]); } } else { $planification = __('None'); } $users_id = $DB->result($result, $j, "users_id"); $managers = Html::clean(getUserName($users_id)); $name = $DB->result($result, $j, "name"); $task_type = $DB->result($result, $j, "plugin_projet_tasktypes_id"); $comment = $DB->result($result, $j, "comment"); $groups_id = $DB->result($result, $j, "groups_id"); $pdf->displayLine(Html::clean($name), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_tasktypes", $task_type)), $comment, $actiontime, Html::clean($planification), $managers, Html::clean(Dropdown::getDropdownName("glpi_groups", $groups_id))); $j++; } } else { $pdf->displayLine(__('No item found')); } $pdf->displaySpace(); }
/** * Display linked projets to a projet * * @param $ID ID of the projet id * * @return nothing display **/ static function displayLinkedProjetTasksTo($ID, $notif = false) { global $DB, $CFG_GLPI; $tasks = self::getParentProjetTasksTo($ID); $canupdate = plugin_projet_haveRight('task', 'w'); $task = new PluginProjetTask(); if (is_array($tasks) && count($tasks)) { foreach ($tasks as $linkID => $data) { if ($notif) { return Dropdown::getDropdownName("glpi_plugin_projet_tasks", $data['plugin_projet_tasks_id']); } else { echo self::getLinkName($data['link']) . " "; if (!$_SESSION['glpiis_ids_visible']) { echo __('ID') . " " . $data['plugin_projet_tasks_id'] . " : "; } if ($task->getFromDB($data['plugin_projet_tasks_id'])) { echo $task->getLink(); if ($canupdate) { echo " "; Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/projet/front/task.form.php', 'delete_link', _x('button', 'Delete permanently'), array('delete_link' => 'delete_link', 'id' => $linkID, 'plugin_projet_tasks_id' => $ID), $CFG_GLPI["root_doc"] . "/pics/delete.png"); } } } } } }
/** * Show for PDF an projet * * @param $pdf object for the output * @param $ID of the projet */ static function pdfGanttForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli) { global $CFG_GLPI, $gtitle, $gdata, $gconst, $gdate_begin, $gdate_end; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_projet_haveRight("projet", "r")) { return false; } //nom $gantt_p_name = $appli->fields["name"]; //type de gantt $int = hexdec(PluginProjetProjetState::getStatusColor($appli->fields["plugin_projet_projetstates_id"])); $gantt_p_bgcolor = array(0xff & $int >> 0x10, 0xff & $int >> 0x8, 0xff & $int); $gantt_p_date_begin = date("Y-m-d"); $gantt_p_date_end = date("Y-m-d"); if (!empty($appli->fields["date_begin"])) { $gantt_p_date_begin = $appli->fields["date_begin"]; } if (!empty($appli->fields["date_end"])) { $gantt_p_date_end = $appli->fields["date_end"]; } $gdata[] = array("type" => 'group', "projet" => $ID, "name" => $gantt_p_name, "date_begin" => $gantt_p_date_begin, "date_end" => $gantt_p_date_end, "advance" => $appli->fields["advance"], "bg_color" => $gantt_p_bgcolor); PluginProjetTask::showTaskTreeGantt(array('plugin_projet_projets_id' => $ID)); if (!empty($gdate_begin) && !empty($gdate_end)) { $gtitle = $gtitle . "<DateBeg> / <DateEnd>"; $gdate_begin = date("Y", $gdate_begin) . "-" . date("m", $gdate_begin) . "-" . date("d", $gdate_begin); $gdate_end = date("Y", $gdate_end) . "-" . date("m", $gdate_end) . "-" . date("d", $gdate_end); } $ImgName = self::writeGantt($gtitle, $gdata, $gconst, $gdate_begin, $gdate_end); $image = GLPI_PLUGIN_DOC_DIR . "/projet/" . $ImgName; $pdf->newPage(); $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . __('Gantt', 'projet') . '</b>'); $size = GetImageSize($image); $src_w = $size[0]; $src_h = $size[1]; $pdf->addPngFromFile($image, $src_w / 2, $src_h / 2); $pdf->displaySpace(); unlink($image); }
/** * Show for PDF an projet - Hierarchy * * @param $pdf object for the output * @param $ID of the projet */ static function pdfHierarchyForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli, $parents = 0) { global $DB, $CFG_GLPI; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_projet_haveRight("projet", "r")) { return false; } $pdf->setColumnsSize(100); if ($parents) { $pdf->displayTitle('<b>' . __('Parent project', 'projet') . '</b>'); } else { $pdf->displayTitle('<b>' . _n('Child project', 'Child projects', 2, 'projet') . '</b>'); } $first = false; $query = "SELECT `" . $appli->gettable() . "`.* "; if ($parents != 0) { $parent = "plugin_projet_projets_id_1"; $child = "plugin_projet_projets_id_2"; } else { $parent = "plugin_projet_projets_id_2"; $child = "plugin_projet_projets_id_1"; } $query .= " FROM `glpi_plugin_projet_projets`"; $query .= " LEFT JOIN `glpi_plugin_projet_projets_projets` \n ON (`glpi_plugin_projet_projets_projets`.`{$child}` = `glpi_plugin_projet_projets`.`id`)"; $query .= " WHERE `glpi_plugin_projet_projets_projets`.`{$parent}` = '{$ID}' "; if ($appli->maybeTemplate()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $query .= $LINK . "`" . $appli->getTable() . "`.`is_template` = '0' "; } // Add is_deleted if item have it if ($appli->maybeDeleted()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $query .= $LINK . "`" . $appli->getTable() . "`.`is_deleted` = '0' "; } $LINK = " AND "; $query .= getEntitiesRestrictRequest(" AND ", $appli->gettable(), '', '', $appli->maybeRecursive()); $query .= " ORDER BY `" . $appli->gettable() . "`.`name`"; $result = $DB->query($query); $number = $DB->numrows($result); if (!$number) { $pdf->displayLine(__('No item found')); } else { if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(17, 17, 17, 17, 16, 16); $pdf->displayTitle('<b><i>' . __('Name'), __('Entity'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>'); } else { $pdf->setColumnsSize(20, 17, 17, 17, 17); $pdf->displayTitle('<b><i>' . __('Name'), __('Progress'), _n('State', 'States', 1), __('Start date'), __('End date') . '</i></b>'); } while ($data = $DB->fetch_array($result)) { $items_id_display = ""; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $items_id_display = " (" . $data["id"] . ")"; } $name = $data["name"] . $items_id_display; $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entities_id'])); if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(17, 17, 17, 17, 16, 16); $pdf->displayLine($name, $entity, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"])); } else { $pdf->setColumnsSize(20, 17, 17, 17, 17); $pdf->displayLine($name, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $data['plugin_projet_projetstates_id'])), Html::convdate($data["date_begin"]), Html::convdate($data["date_end"])); } } } $pdf->displaySpace(); }
static function canView() { return plugin_projet_haveRight('projet', 'r'); }
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 ""; }
/** * Permet d'afficher une ligne de suivi dans la liste de suivi */ function showInFollowupSummary(PluginProjetProjet $projet, $rand) { global $DB, $CFG_GLPI; $canedit = PluginProjetProjet_Item::isProjetParticipant($projet->fields["id"]) && plugin_projet_haveRight('projet', 'w'); echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditFollowup" . $this->fields['plugin_projet_projets_id'] . $this->fields['id'] . "{$rand}();\"" : '') . " id='viewfollowup" . $this->fields['plugin_projet_projets_id'] . $this->fields["id"] . "{$rand}'>"; echo "<td class='left'>" . nl2br($this->fields["content"]) . "</td>"; echo "<td>"; if ($canedit) { echo "\n<script type='text/javascript' >\n"; echo "function viewEditFollowup" . $this->fields['plugin_projet_projets_id'] . $this->fields["id"] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'parenttype' => 'PluginProjetProjet', 'plugin_projet_projets_id' => $this->fields["plugin_projet_projets_id"], 'id' => $this->fields["id"]); Ajax::updateItemJsCode("viewfollowup" . $this->fields['plugin_projet_projets_id'] . "{$rand}", "../ajax/viewsubitem.php", $params); echo "};"; echo "</script>\n"; } echo Html::convDateTime($this->fields["date"]) . "</td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td>"; echo "</tr>\n"; }
/** * Show for PDF an projet - associated devices * * @param $pdf object for the output * @param $appli object of the projet */ static function pdfForProjet(PluginPdfSimplePDF $pdf, PluginProjetProjet $appli, $material = false) { global $DB, $CFG_GLPI; $ID = $appli->fields['id']; if (!$appli->can($ID, "r")) { return false; } if (!plugin_projet_haveRight("projet", "r")) { return false; } $pdf->setColumnsSize(100); if ($material) { $pdf->displayTitle('<b>' . _n('Associated item', 'Associated items', 2) . '</b>'); } else { $pdf->displayTitle('<b>' . __('Unknown project task', 'projet') . '</b>'); } if ($material) { $select = "'User','Group','Supplier','Contract'"; $in = "NOT IN"; } else { $select = "'User','Group','Supplier'"; $in = "IN"; } $query = "SELECT DISTINCT `itemtype` \n FROM `glpi_plugin_projet_projets_items` \n WHERE `plugin_projet_projets_id` = '{$ID}' \n AND `itemtype` {$in} (" . $select . ")\n ORDER BY `itemtype` "; $result = $DB->query($query); $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(12, 27, 25, 18, 18); $pdf->displayTitle('<b><i>' . _n('Type', 'Types', 2), __('Name'), __('Entity'), __('Serial number'), __('Inventory number') . '</i></b>'); } else { $pdf->setColumnsSize(25, 31, 22, 22); $pdf->displayTitle('<b><i>' . _n('Type', 'Types', 2), __('Name'), __('Serial number'), __('Inventory number') . '</i></b>'); } if (!$number) { $pdf->displayLine(__('No item found')); } else { for ($i = 0; $i < $number; $i++) { $type = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($type))) { continue; } if ($item->canView()) { $column = "name"; $table = getTableForItemType($type); $items = new $type(); $query = "SELECT `" . $table . "`.*, `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_projet_projets_items`, `" . $table . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $table . "`.`entities_id`) " . " WHERE `" . $table . "`.`id` = `glpi_plugin_projet_projets_items`.`items_id` \n AND `glpi_plugin_projet_projets_items`.`itemtype` = '{$type}' \n AND `glpi_plugin_projet_projets_items`.`plugin_projet_projets_id` = '{$ID}' "; if ($type != 'User') { $query .= getEntitiesRestrictRequest(" AND ", $table, '', '', $items->maybeRecursive()); } if ($items->maybeTemplate()) { $query .= " AND `" . $table . "`.`is_template` = '0'"; } $query .= " ORDER BY `glpi_entities`.`completename`, `" . $table . "`.`{$column}`"; if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { if (!$items->getFromDB($data["id"])) { continue; } $items_id_display = ""; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $items_id_display = " (" . $data["id"] . ")"; } if ($type == 'User') { $name = Html::clean(getUserName($data["id"])) . $items_id_display; } else { $name = $data["name"] . $items_id_display; } if ($type != 'User') { $entity = Html::clean(Dropdown::getDropdownName("glpi_entities", $data['entity'])); } else { $entity = "-"; } if (Session::isMultiEntitiesMode()) { $pdf->setColumnsSize(12, 27, 25, 18, 18); $pdf->displayLine($items->getTypeName(), $name, $entity, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-"); } else { $pdf->setColumnsSize(25, 31, 22, 22); $pdf->displayTitle($items->getTypeName(), $name, isset($data["serial"]) ? "" . $data["serial"] . "" : "-", isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-"); } } // Each device } } // numrows device } // type right } // each type } $pdf->displaySpace(); // numrows type }