/** * 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(); }
-------------------------------------------------------------------------- */ include '../../../inc/includes.php'; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } if (!isset($_GET["helpdesk_id"])) { $_GET["helpdesk_id"] = ""; } if (!isset($_GET["helpdesk_itemtype"])) { $_GET["helpdesk_itemtype"] = ""; } $projet = new PluginProjetProjet(); $projet_item = new PluginProjetProjet_Item(); $projet_projet = new PluginProjetProjet_Projet(); //Project if (isset($_POST["add"])) { if (isset($_POST["helpdesk_id"]) && !empty($_POST['helpdesk_id'])) { $projet->check(-1, 'w', $_POST); $newID = $projet->add($_POST); $values["items_id"] = $_POST["helpdesk_id"]; $values["itemtype"] = $_POST["helpdesk_itemtype"]; $values["plugin_projet_projets_id"] = $newID; $projet_item->addItem($values); Html::redirect($CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php"); } else { $projet->check(-1, 'w', $_POST); $newID = $projet->add($_POST);
https://forge.indepnet.net/projects/projet ------------------------------------------------------------------------- LICENSE This file is part of Projet. Projet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Projet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Projet. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $projet = new PluginProjetProjet(); Html::header(PluginProjetProjet::getTypeName(2), '', "plugins", "projet"); if ($projet->canView() || Session::haveRight("config", "w")) { Search::show("PluginProjetProjet"); PluginProjetProjet::showGlobalGantt(); } else { Html::displayRightError(); } Html::footer();
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>"; } }
https://forge.indepnet.net/projects/projet ------------------------------------------------------------------------- LICENSE This file is part of Projet. Projet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Projet is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Projet. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $projet = new PluginProjetProjet(); Html::header(PluginProjetProjet::getTypeName(2), '', "plugins", "projet"); if ($projet->canView() || Session::haveRight("config", "w")) { $projet->listOfTemplates($CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php", $_GET["add"]); } else { Html::displayRightError(); } Html::footer();
/** * 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(); }
Html::redirect(Toolbox::getItemTypeFormURL('PluginProjetProjet') . "?id=" . $_POST["plugin_projet_projets_id"]); } else { if (isset($_POST["addtaskitem"])) { if ($task->canCreate()) { $task_item->addTaskItem($_POST); } Html::back(); } else { if (isset($_POST["deletetaskitem"])) { if ($task->canCreate()) { $task_item->delete(array('id' => $_POST["id"])); } Html::back(); } else { if (isset($_POST['delete_link'])) { $task_task->check($_POST['id'], 'w'); $task_task->delete(array('id' => $_POST["id"])); Html::redirect($CFG_GLPI["root_doc"] . "/plugins/projet/front/task.form.php?id=" . $_POST['plugin_projet_tasks_id']); } else { $task->checkGlobal("r"); Html::header(PluginProjetProjet::getTypeName(2), '', "plugins", "projet"); $task->showForm($_GET["id"], array('plugin_projet_projets_id' => $_GET["plugin_projet_projets_id"], 'withtemplate' => $_GET["withtemplate"])); Html::footer(); } } } } } } } }
function plugin_projet_MassiveActionsDisplay($options = array()) { $projet = new PluginProjetProjet(); if (in_array($options['itemtype'], PluginProjetProjet::getTypes(true))) { $projet->dropdownProjet("plugin_projet_projets_id"); echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . _sx('button', 'Post') . "\" >"; } return ""; }
function showForm($ID, $options = array()) { if (!Session::haveRight("profile", "r")) { return false; } $prof = new Profile(); if ($ID) { $this->getFromDBByProfile($ID); $prof->getFromDB($ID); } $this->showFormHeader($options); echo "<tr class='tab_bg_2'>"; echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), self::getTypeName(1), $prof->fields["name"]) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginProjetProjet::getTypeName(2) . ":</td><td>"; Profile::dropdownNoneReadWrite("projet", $this->fields["projet"], 1, 1, 1); echo "</td>"; echo "<td>" . PluginProjetTask::getTypeName(2) . ":</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("task", $this->fields["task"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Associable items to a ticket') . " - " . PluginProjetProjet::getTypeName(2) . "</td><td>"; if ($prof->fields['create_ticket']) { Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]); } else { echo Dropdown::getYesNo(0); } echo "</td>"; echo "<td></td><td>"; echo "</td>"; echo "</tr>"; echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">"; $options['candel'] = false; $this->showFormButtons($options); }
/** * Display a Planning Item * * @param $parm Array of the item to display * @return Nothing (display function) **/ static function displayPlanningItem(array $val, $who, $type = "", $complete = 0) { global $CFG_GLPI; $rand = mt_rand(); echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/task.form.php?id=" . $val["id"] . "'"; echo " onmouseout=\"cleanhide('content_task_" . $val["id"] . $rand . "')\" \n onmouseover=\"cleandisplay('content_task_" . $val["id"] . $rand . "')\""; echo ">"; switch ($type) { case "in": //TRANS: %1$s is the start time of a planned item, %2$s is the end $beginend = sprintf(__('From %1$s to %2$s :'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"]))); printf(__('%1$s %2$s'), $beginend, Html::resume_text($val["name"], 80)); break; case "begin": $start = sprintf(__('Start at %s'), date("H:i", strtotime($val["begin"]))); printf(__('%1$s: %2$s'), $start, Html::resume_text($val["name"], 80)); break; case "end": $end = sprintf(__('End at %s'), date("H:i", strtotime($val["end"]))); printf(__('%1$s: %2$s'), $end, Html::resume_text($val["name"], 80)); break; } if ($val["users_id"] && $who == 0) { echo " - " . __('User') . " " . getUserName($val["users_id"]); } echo "</a><br>"; echo PluginProjetProjet::getTypeName(1) . " : <a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php?id=" . $val["plugin_projet_projets_id"] . "'"; echo ">" . $val["project"] . "</a>"; echo "<div class='over_link' id='content_task_" . $val["id"] . $rand . "'>"; if ($val["end"]) { echo "<strong>" . __('End date') . "</strong> : " . Html::convdatetime($val["end"]) . "<br>"; } if ($val["type"]) { echo "<strong>" . PluginProjetTaskType::getTypeName(1) . "</strong> : " . $val["type"] . "<br>"; } if ($val["state"]) { echo "<strong>" . __('State') . "</strong> : " . $val['state'] . "<br>"; } if ($val["location"]) { echo "<strong>" . _n('Location', 'Locations', 1) . "</strong>: " . $val["location"] . "<br>"; } if ($val["priority"]) { echo "<strong>" . __('Priority') . "</strong> : " . Ticket::getPriorityName($val["priority"]) . "<br>"; } if ($val["content"]) { echo "<strong>" . __('Description') . "</strong> : " . $val["content"]; } echo "</div>"; }
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; } } } }
function pre_deleteItem() { global $CFG_GLPI; if ($CFG_GLPI["use_mailing"] && isset($this->input['delete'])) { $projet = new PluginProjetProjet(); $options = array('followups_id' => $this->fields["id"]); if ($projet->getFromDB($this->fields["plugin_projet_projets_id"])) { NotificationEvent::raiseEvent("delete_followup", $projet, $options); } } return true; }
/** * 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(); }
function showItemFromPlugin($instID, $withtemplate = '') { global $DB, $CFG_GLPI; if (empty($withtemplate)) { $withtemplate = 0; } $PluginProjetTask = new PluginProjetTask(); if ($PluginProjetTask->getFromDB($instID)) { $plugin_projet_projets_id = $PluginProjetTask->fields["plugin_projet_projets_id"]; $PluginProjetProjet = new PluginProjetProjet(); $PluginProjetProjet->getFromDB($plugin_projet_projets_id); $canedit = $PluginProjetProjet->can($plugin_projet_projets_id, 'w'); $query = "SELECT `items_id`, `itemtype` \n FROM `" . $this->getTable() . "` \n WHERE `plugin_projet_tasks_id` = '{$instID}' \n ORDER BY `itemtype` "; $result = $DB->query($query); $number = $DB->numrows($result); echo "<form method='post' name='addtaskitem' action=\"./task.form.php\">"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan='" . ($canedit ? 3 : 2) . "'>" . _n('Associated item', 'Associated items', 2); echo "</th></tr>"; echo "<tr><th>" . _n('Type', 'Types', 2) . "</th>"; echo "<th>" . __('Name') . "</th>"; if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<th> </th>"; } echo "</tr>"; $used = array(); if ($number != "0") { for ($i = 0; $i < $number; $i++) { $type = $DB->result($result, $i, "itemtype"); $items_id = $DB->result($result, $i, "items_id"); if (!class_exists($type)) { continue; } $item = new $type(); if ($item->canView()) { $table = getTableForItemType($type); $query = "SELECT `" . $table . "`.*, `" . $this->getTable() . "`.`id` as items_id \n FROM `" . $this->getTable() . "` \n INNER JOIN `" . $table . "` ON (`" . $table . "`.`id` = `" . $this->getTable() . "`.`items_id`) \n WHERE `" . $this->getTable() . "`.`itemtype` = '" . $type . "' \n AND `" . $this->getTable() . "`.`items_id` = '" . $items_id . "' \n AND `" . $this->getTable() . "`.`plugin_projet_tasks_id` = '{$instID}' "; $query .= "ORDER BY `" . $table . "`.`name` "; $result_linked = $DB->query($query); if ($DB->numrows($result_linked)) { while ($data = $DB->fetch_assoc($result_linked)) { $ID = ""; $itemID = $data["id"]; $used[] = $itemID; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $ID = " (" . $data["id"] . ")"; } $itemname = $data["name"]; if ($type == 'User') { $itemname = getUserName($itemID); } $link = Toolbox::getItemTypeFormURL($type); $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $itemname . "{$ID}</a>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . $item->getTypeName() . "</td>"; echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] == '1' ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<td class='center tab_bg_2'>"; Html::showSimpleForm($CFG_GLPI['root_doc'] . '/plugins/projet/front/task.form.php', 'deletetaskitem', _x('button', 'Delete permanently'), array('id' => $data['items_id'])); echo "</td>"; } echo "</tr>"; } } } } } if ($canedit && $this->canCreate() && $withtemplate < 2) { echo "<tr class='tab_bg_1'><td colspan='2' class='right'>"; echo "<input type='hidden' name='plugin_projet_tasks_id' value='{$instID}'>"; $this->dropdownTaskItems($plugin_projet_projets_id, "item_item", $used); echo "</td>"; echo "<td class='center' colspan='2' class='tab_bg_2'>"; echo "<input type='submit' name='addtaskitem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div>"; } else { echo "</table></div>"; } Html::closeForm(); echo "<br>"; } }