static function displayTabContentForPDF(PluginPdfSimplePDF $pdf, CommonGLPI $item, $tab) { if ($item->getType() == 'PluginProjetProjet') { if ($tab == 1) { PluginProjetProjet_Projet::pdfHierarchyForProjet($pdf, $item); PluginProjetProjet_Projet::pdfHierarchyForProjet($pdf, $item, 1); } else { if ($tab == 2) { self::pdfGanttForProjet($pdf, $item); } else { if ($tab == 3) { PluginProjetProjet_Item::pdfForProjet($pdf, $item); } } } } else { return false; } return true; }
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); Html::back(); }
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; } } } }