static function showHierarchy($ID, $parents = 0) { global $DB, $CFG_GLPI; $first = false; $projet = new PluginProjetTask(); $query = "SELECT `glpi_plugin_projet_tasks`.* "; if ($parents != 0) { $parent = "plugin_projet_tasks_id_1"; $child = "plugin_projet_tasks_id_2"; } else { $parent = "plugin_projet_tasks_id_2"; $child = "plugin_projet_tasks_id_1"; } $query .= " FROM `glpi_plugin_projet_tasks`"; $query .= " LEFT JOIN `glpi_plugin_projet_tasks_tasks` \n ON (`glpi_plugin_projet_tasks_tasks`.`{$child}` = `glpi_plugin_projet_tasks`.`id`)"; $query .= " WHERE `glpi_plugin_projet_tasks_tasks`.`{$parent}` = '{$ID}' "; if ($projet->maybeTemplate()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $query .= $LINK . "`glpi_plugin_projet_tasks`.`is_template` = '0' "; } // Add is_deleted if item have it if ($projet->maybeDeleted()) { $LINK = " AND "; if ($first) { $LINK = " "; $first = false; } $query .= $LINK . "`glpi_plugin_projet_tasks`.`is_deleted` = '0' "; } $LINK = " AND "; $query .= getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_tasks", '', '', $projet->maybeRecursive()); $query .= " ORDER BY `glpi_plugin_projet_tasks`.`name`"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; if (Session::isMultiEntitiesMode()) { $colsup = 1; } else { $colsup = 0; } if ($number != "0") { echo "<div align='center'><table class='tab_cadre_fixe'>"; $title = _n('Child task', 'Child tasks', 2, 'projet'); if ($parents != 0) { $title = __('Parent task', 'projet'); } echo "<tr><th colspan='" . (7 + $colsup) . "'>" . $title . "</th></tr>"; echo "<tr><th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } echo "<th>" . __('Progress') . "</th>"; echo "<th>" . _n('User', 'Users', 1) . "</th>"; echo "<th>" . _n('Group', 'Groups', 1) . "</th>"; echo "<th>" . __('State') . "</th>"; echo "</tr>"; while ($data = $DB->fetch_array($result)) { $start = 0; $output_type = Search::HTML_OUTPUT; $del = false; if ($data["is_deleted"] == '0') { echo "<tr class='tab_bg_1'>"; } else { echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>"; } echo Search::showItem($output_type, "<a href=\"./task.form.php?id=" . $data["id"] . "\">" . $data["name"] . ($_SESSION["glpiis_ids_visible"] || empty($data["name"]) ? ' (' . $data["id"] . ') ' : '') . "</a>", $item_num, $i - $start + 1, ''); if (Session::isMultiEntitiesMode()) { echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>"; } echo Search::showItem($output_type, PluginProjetProjet::displayProgressBar('100', $data["advance"], array("simple" => true)), $item_num, $i - $start + 1, "align='center'"); echo Search::showItem($output_type, getUserName($data['users_id']), $item_num, $i - $start + 1, ''); echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $data['groups_id']), $item_num, $i - $start + 1, ''); echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_plugin_projet_taskstates", $data['plugin_projet_taskstates_id']), $item_num, $i - $start + 1, "bgcolor='" . PluginProjetTaskState::getStatusColor($data['plugin_projet_taskstates_id']) . "' align='center'"); echo "</tr>"; } echo "</table></div>"; } }
/** * Show for PDF an projet * * @param $pdf object for the output * @param $ID of the projet */ function show_PDF($pdf) { $pdf->setColumnsSize(100); $col1 = '<b>' . __('ID') . ' ' . $this->fields['id'] . '</b>'; $pdf->displayTitle($col1); $pdf->displayLine('<b><i>' . __('Name') . ' :</i></b> ' . $this->fields['name']); $pdf->setColumnsSize(50, 50); $pdf->displayLine('<b><i>' . __('User') . ' :</i></b> ' . Html::clean(getUserName($this->fields["users_id"])), '<b><i>' . __('Group') . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id"]))); $pdf->displayLine('<b><i>' . __('Start date') . ' :</i></b> ' . Html::convDate($this->fields["date_begin"]), '<b><i>' . __('End date') . ' :</i></b> ' . Html::convDate($this->fields["date_end"])); $pdf->displayLine('<b><i>' . __('State') . ' :</i></b> ' . Html::clean(Dropdown::getDropdownName("glpi_plugin_projet_projetstates", $this->fields['plugin_projet_projetstates_id'])), '<b><i>' . __('Progress') . ' :</i></b> ' . PluginProjetProjet::displayProgressBar('100', $this->fields["advance"], array("simple" => true))); $pdf->setColumnsSize(100); $pdf->displayText('<b><i>' . __('Comments') . ' :</i></b>', $this->fields['comment']); $pdf->setColumnsSize(100); $pdf->displayText('<b><i>' . __('Description') . ' :</i></b>', $this->fields['description']); $pdf->displaySpace(); }
/** * 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(); }
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 ""; }
function getDatasForTemplate($event, $options = array()) { global $CFG_GLPI, $DB; if ($event == 'AlertExpiredTasks') { $this->datas['##projet.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']); $this->datas['##lang.projet.entity##'] = __('Entity'); $this->datas['##projet.action##'] = __('Outdated tasks', 'projet'); $this->datas['##lang.task.name##'] = __('Name'); $this->datas['##lang.task.type##'] = __('Type'); $this->datas['##lang.task.users##'] = __('User'); $this->datas['##lang.task.groups##'] = __('Group'); $this->datas['##lang.task.datebegin##'] = __('Start date'); $this->datas['##lang.task.dateend##'] = __('End date'); $this->datas['##lang.task.planned##'] = __('Used for planning', 'projet'); $this->datas['##lang.task.realtime##'] = __('Effective duration', 'projet'); $this->datas['##lang.task.comment##'] = __('Comments'); $this->datas['##lang.task.projet##'] = PluginProjetProjet::getTypeName(1); foreach ($options['tasks'] as $id => $task) { $tmp = array(); $tmp['##task.name##'] = $task['name']; $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_projet_tasktypes', $task['plugin_projet_tasktypes_id']); $tmp['##task.users##'] = Html::clean(getUserName($task['users_id'])); $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']); $restrict = " `plugin_projet_tasks_id` = '" . $task['id'] . "' "; $plans = getAllDatasFromTable("glpi_plugin_projet_taskplannings", $restrict); if (!empty($plans)) { foreach ($plans as $plan) { $tmp['##task.datebegin##'] = Html::convDateTime($plan["begin"]); $tmp['##task.dateend##'] = Html::convDateTime($plan["end"]); } } else { $tmp['##task.datebegin##'] = ''; $tmp['##task.dateend##'] = ''; } $tmp['##task.planned##'] = ''; $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]); $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment'])); $tmp['##task.comment##'] = Html::clean($comment); $tmp['##task.projet##'] = Dropdown::getDropdownName('glpi_plugin_projet_projets', $task['plugin_projet_projets_id']); $this->datas['tasks'][] = $tmp; } } else { $events = $this->getAllEvents(); $this->datas['##lang.projet.title##'] = $events[$event]; $this->datas['##lang.projet.entity##'] = __('Entity'); $this->datas['##projet.entity##'] = Dropdown::getDropdownName('glpi_entities', $this->obj->getField('entities_id')); $this->datas['##projet.id##'] = $this->obj->getField("id"); $this->datas['##lang.projet.name##'] = __('Name'); $this->datas['##projet.name##'] = $this->obj->getField("name"); $this->datas['##lang.projet.datebegin##'] = __('Start date'); $this->datas['##projet.datebegin##'] = Html::convDate($this->obj->getField('date_begin')); $this->datas['##lang.projet.dateend##'] = __('End date'); $this->datas['##projet.dateend##'] = Html::convDate($this->obj->getField('date_end')); $this->datas['##lang.projet.users##'] = __('User'); $this->datas['##projet.users##'] = Html::clean(getUserName($this->obj->getField("users_id"))); $this->datas['##lang.projet.groups##'] = __('Group'); $this->datas['##projet.groups##'] = Dropdown::getDropdownName('glpi_groups', $this->obj->getField('groups_id')); $this->datas['##lang.projet.status##'] = __('State'); $this->datas['##projet.status##'] = Dropdown::getDropdownName('glpi_plugin_projet_projetstates', $this->obj->getField('plugin_projet_projetstates_id')); $this->datas['##lang.projet.parent##'] = __('Parent project', 'projet'); $this->datas['##projet.parent##'] = PluginProjetProjet_Projet::displayLinkedProjetsTo($this->obj->getField('id'), true); $this->datas['##lang.projet.advance##'] = __('Progress'); $this->datas['##projet.advance##'] = PluginProjetProjet::displayProgressBar('100', $this->obj->getField('advance'), array('simple' => true)); $this->datas['##lang.projet.gantt##'] = __('Display on the global Gantt', 'projet'); $this->datas['##projet.gantt##'] = Dropdown::getYesNo($this->obj->getField('show_gantt')); $this->datas['##lang.projet.comment##'] = __('Comments'); $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("comment"))); $this->datas['##projet.comment##'] = Html::clean($comment); $this->datas['##lang.projet.description##'] = __('Description'); $description = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->obj->getField("description"))); $this->datas['##projet.description##'] = Html::clean($description); $this->datas['##lang.projet.helpdesk##'] = __('Associable to a ticket'); $this->datas['##projet.helpdesk##'] = Dropdown::getYesNo($this->obj->getField('is_helpdesk_visible')); $this->datas['##lang.projet.url##'] = __('URL'); $this->datas['##projet.url##'] = urldecode($CFG_GLPI["url_base"] . "/index.php?redirect=plugin_projet_" . $this->obj->getField("id")); //old values infos if (isset($this->target_object->oldvalues) && !empty($this->target_object->oldvalues) && $event == 'update') { $this->datas['##lang.update.title##'] = __('Modifications', 'projet'); $tmp = array(); if (isset($this->target_object->oldvalues['name'])) { if (empty($this->target_object->oldvalues['name'])) { $tmp['##update.name##'] = "---"; } else { $tmp['##update.name##'] = $this->target_object->oldvalues['name']; } } if (isset($this->target_object->oldvalues['date_begin'])) { if (empty($this->target_object->oldvalues['date_begin'])) { $tmp['##update.datebegin##'] = "---"; } else { $tmp['##update.datebegin##'] = Html::convDate($this->target_object->oldvalues['date_begin']); } } if (isset($this->target_object->oldvalues['date_end'])) { if (empty($this->target_object->oldvalues['date_end'])) { $tmp['##update.dateend##'] = "---"; } else { $tmp['##update.dateend##'] = Html::convDate($this->target_object->oldvalues['date_end']); } } if (isset($this->target_object->oldvalues['users_id'])) { if (empty($this->target_object->oldvalues['users_id'])) { $tmp['##update.users##'] = "---"; } else { $tmp['##update.users##'] = Html::clean(getUserName($this->target_object->oldvalues['users_id'])); } } if (isset($this->target_object->oldvalues['groups_id'])) { if (empty($this->target_object->oldvalues['groups_id'])) { $tmp['##update.groups##'] = "---"; } else { $tmp['##update.groups##'] = Dropdown::getDropdownName('glpi_groups', $this->target_object->oldvalues['groups_id']); } } if (isset($this->target_object->oldvalues['plugin_projet_projetstates_id'])) { if (empty($this->target_object->oldvalues['plugin_projet_projetstates_id'])) { $tmp['##update.status##'] = "---"; } else { $tmp['##update.status##'] = Dropdown::getDropdownName('glpi_plugin_projet_projetstates', $this->target_object->oldvalues['plugin_projet_projetstates_id']); } } if (isset($this->target_object->oldvalues['plugin_projet_projets_id'])) { if (empty($this->target_object->oldvalues['plugin_projet_projets_id'])) { $tmp['##update.plugin_projet_projets_id##'] = "---"; } else { $tmp['##update.plugin_projet_projets_id##'] = Dropdown::getDropdownName('glpi_plugin_projet_projets', $this->target_object->oldvalues['plugin_projet_projets_id']); } } if (isset($this->target_object->oldvalues['advance'])) { if (empty($this->target_object->oldvalues['advance'])) { $tmp['##update.advance##'] = "---"; } else { $tmp['##update.advance##'] = PluginProjetProjet::displayProgressBar('100', $this->target_object->oldvalues['advance'], array('simple' => true)); } } if (isset($this->target_object->oldvalues['comment'])) { if (empty($this->target_object->oldvalues['comment'])) { $tmp['##update.comment##'] = "---"; } else { $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->target_object->oldvalues['comment'])); $tmp['##update.comment##'] = Html::clean($comment); } } if (isset($this->target_object->oldvalues['description'])) { if (empty($this->target_object->oldvalues['description'])) { $tmp['##update.description##'] = "---"; } else { $description = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $this->target_object->oldvalues['description'])); $tmp['##update.description##'] = Html::clean($description); } } if (isset($this->target_object->oldvalues['show_gantt'])) { if (empty($this->target_object->oldvalues['show_gantt'])) { $tmp['##update.gantt##'] = "---"; } else { $tmp['##update.gantt##'] = Dropdown::getYesNo($this->target_object->oldvalues['show_gantt']); } } if (isset($this->target_object->oldvalues['is_helpdesk_visible'])) { if (empty($this->target_object->oldvalues['is_helpdesk_visible'])) { $tmp['##update.helpdesk##'] = "---"; } else { $tmp['##update.helpdesk##'] = Dropdown::getYesNo($this->target_object->oldvalues['is_helpdesk_visible']); } } $this->datas['updates'][] = $tmp; } // Projet followup $restrict = "`plugin_projet_projets_id`='" . $this->obj->getField('id') . "'"; if (isset($options['followups_id']) && $options['followups_id']) { $restrict .= " AND `glpi_plugin_projet_followups`.`id` = '" . $options['followups_id'] . "'"; } $restrict .= " ORDER BY `date` DESC"; $followups = getAllDatasFromTable('glpi_plugin_projet_followups', $restrict); $this->datas['##lang.followup.description##'] = __('Content'); $this->datas['##lang.followup.date##'] = __('Date'); $this->datas['##lang.followup.recipient##'] = __('Writer'); if (!empty($followups)) { $this->datas['##lang.followup.title##'] = _n('Associated followup', 'Associated followups', 2, 'projet'); foreach ($followups as $followup) { $tmp = array(); $tmp['##followup.recipient##'] = Html::clean(getUserName($followup['users_id'])); $tmp['##followup.date##'] = Html::convDate($followup['date']); $content = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $followup['content'])); $tmp['##followup.description##'] = Html::clean($content); $this->datas['followups'][] = $tmp; } } //task infos $restrict = "`plugin_projet_projets_id`='" . $this->obj->getField('id') . "'"; if (isset($options['tasks_id']) && $options['tasks_id']) { $restrict .= " AND `glpi_plugin_projet_tasks`.`id` = '" . $options['tasks_id'] . "'"; } $restrict .= " ORDER BY `name` DESC"; $tasks = getAllDatasFromTable('glpi_plugin_projet_tasks', $restrict); $this->datas['##lang.task.title##'] = _n('Associated task', 'Associated tasks', 2, 'projet'); $this->datas['##lang.task.name##'] = __('Name'); $this->datas['##lang.task.users##'] = __('User'); $this->datas['##lang.task.groups##'] = __('Group'); $this->datas['##lang.task.contacts##'] = __('Supplier'); $this->datas['##lang.task.type##'] = __('Type'); $this->datas['##lang.task.status##'] = __('State'); $this->datas['##lang.task.advance##'] = __('Progress'); $this->datas['##lang.task.priority##'] = __('Priority'); $this->datas['##lang.task.comment##'] = __('Comments'); $this->datas['##lang.task.sub##'] = __('Results'); $this->datas['##lang.task.others##'] = __('Others participants', 'projet'); $this->datas['##lang.task.affect##'] = __('Affected people', 'projet'); $this->datas['##lang.task.parenttask##'] = __('Parent task', 'projet'); $this->datas['##lang.task.gantt##'] = __('Display on the Gantt', 'projet'); $this->datas['##lang.task.depends##'] = __('Dependent', 'projet'); $this->datas['##lang.task.realtime##'] = __('Effective duration', 'projet'); $this->datas['##lang.task.location##'] = __('Location'); $this->datas['##lang.task.projet##'] = _n('Project', 'Projects', 2, 'projet'); if (!empty($tasks)) { $this->datas['##task.title##'] = _n('Associated task', 'Associated tasks', 2, 'projet'); foreach ($tasks as $task) { $tmp = array(); $tmp['##task.name##'] = $task['name']; $tmp['##task.users##'] = Html::clean(getUserName($task['users_id'])); $tmp['##task.groups##'] = Dropdown::getDropdownName('glpi_groups', $task['groups_id']); $tmp['##task.contacts##'] = Dropdown::getDropdownName('glpi_contacts', $task['contacts_id']); $tmp['##task.type##'] = Dropdown::getDropdownName('glpi_plugin_projet_tasktypes', $task['plugin_projet_tasktypes_id']); $tmp['##task.status##'] = Dropdown::getDropdownName('glpi_plugin_projet_taskstates', $task['plugin_projet_taskstates_id']); $tmp['##task.advance##'] = PluginProjetProjet::displayProgressBar('100', $task['advance'], array('simple' => true)); $tmp['##task.priority##'] = Ticket::getPriorityName($task['priority']); $comment = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['comment'])); $tmp['##task.comment##'] = Html::clean($comment); $sub = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['sub'])); $tmp['##task.sub##'] = Html::clean($sub); $others = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['others'])); $tmp['##task.others##'] = Html::clean($others); $affect = stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), "<br/>", $task['affect'])); $tmp['##task.affect##'] = Html::clean($affect); $tmp['##task.parenttask##'] = PluginProjetTask_Task::displayLinkedProjetTasksTo($task['id'], true); $tmp['##task.gantt##'] = Dropdown::getYesNo($task['show_gantt']); $tmp['##task.depends##'] = Dropdown::getYesNo($task['depends']); $tmp['##task.realtime##'] = Ticket::getActionTime($task["actiontime"]); $tmp['##task.location##'] = Dropdown::getDropdownName('glpi_locations', $task['locations_id']); $tmp['##task.projet##'] = Dropdown::getDropdownName('glpi_plugin_projet_projets', $task['plugin_projet_projets_id']); $this->datas['tasks'][] = $tmp; } } } }
/** * 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(); }