static function showMinimalList($params = array()) { global $DB, $CFG_GLPI; $item = new self(); $itemtype = $item->getType(); $itemtable = $item->getTable(); // Default values of parameters $p['link'] = array(); // $p['field'] = array(); // $p['contains'] = array(); // $p['searchtype'] = array(); // $p['sort'] = '1'; // $p['order'] = 'ASC'; // $p['start'] = 0; // $p['is_deleted'] = 0; $p['id'] = 0; $p['export_all'] = 0; $p['link2'] = ''; // $p['contains2'] = ''; // $p['field2'] = ''; // $p['itemtype2'] = ''; $p['searchtype2'] = ''; $p['withtemplate'] = 0; foreach ($params as $key => $val) { $p[$key] = $val; } if (isset($_POST["start"])) { $p['start'] = $_POST["start"]; } else { $p['start'] = 0; } if (isset($_POST["sort"])) { $p['sort'] = $_POST["sort"]; } else { $p['sort'] = 1; } if (isset($_POST["order"]) && $_POST["order"] == "DESC") { $p['order'] = "DESC"; } else { $p['order'] = "ASC"; } $PluginProjetProjet = new PluginProjetProjet(); $PluginProjetProjet->getFromDB($p['id']); $canedit = $PluginProjetProjet->can($p['id'], 'w'); // Manage defautll seachtype value : for bookmark compatibility if (count($p['contains'])) { foreach ($p['contains'] as $key => $val) { if (!isset($p['searchtype'][$key])) { $p['searchtype'][$key] = 'contains'; } } } if (is_array($p['contains2']) && count($p['contains2'])) { foreach ($p['contains2'] as $key => $val) { if (!isset($p['searchtype2'][$key])) { $p['searchtype2'][$key] = 'contains'; } } } $target = Toolbox::getItemTypeSearchURL($itemtype); $limitsearchopt = Search::getCleanedOptions($itemtype); $LIST_LIMIT = $_SESSION['glpilist_limit']; // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET['display_type'])) { $output_type = $_GET['display_type']; // Limit to 10 element if ($_GET['display_type'] == Search::GLOBAL_SEARCH) { $LIST_LIMIT = Search::GLOBAL_DISPLAY_COUNT; } } $entity_restrict = $item->isEntityAssign(); // Get the items to display $toview = Search::addDefaultToView($itemtype); // Add items to display depending of personal prefs $displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID()); if (count($displaypref)) { foreach ($displaypref as $val) { array_push($toview, $val); } } // Add searched items if (count($p['field']) > 0) { foreach ($p['field'] as $key => $val) { if (!in_array($val, $toview) && $val != 'all' && $val != 'view') { array_push($toview, $val); } } } // Add order item if (!in_array($p['sort'], $toview)) { array_push($toview, $p['sort']); } // Clean toview array $toview = array_unique($toview); foreach ($toview as $key => $val) { if (!isset($limitsearchopt[$val])) { unset($toview[$key]); } } $toview_count = count($toview); //// 1 - SELECT $query = "SELECT " . Search::addDefaultSelect($itemtype); // Add select for all toview item foreach ($toview as $key => $val) { $query .= Search::addSelect($itemtype, $val, $key, 0); } $query .= "`" . $itemtable . "`.`id` AS id "; //// 2 - FROM AND LEFT JOIN // Set reference table $query .= " FROM `" . $itemtable . "`"; // Init already linked tables array in order not to link a table several times $already_link_tables = array(); // Put reference table array_push($already_link_tables, $itemtable); // Add default join $COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables); $query .= $COMMONLEFTJOIN; $searchopt = array(); $searchopt[$itemtype] =& Search::getOptions($itemtype); // Add all table for toview items foreach ($toview as $key => $val) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]); } // Search all case : if (in_array("all", $p['field'])) { foreach ($searchopt[$itemtype] as $key => $val) { // Do not search on Group Name if (is_array($val)) { $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]); } } } $query .= " WHERE `" . $itemtable . "`.`plugin_projet_projets_id` = '" . $p['id'] . "'"; $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' "; //// 7 - Manage GROUP BY $GROUPBY = ""; // Meta Search / Search All / Count tickets if (in_array('all', $p['field'])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } if (empty($GROUPBY)) { foreach ($toview as $key2 => $val2) { if (!empty($GROUPBY)) { break; } if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) { $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`"; } } } $query .= $GROUPBY; //// 4 - ORDER $ORDER = " ORDER BY `id` "; foreach ($toview as $key => $val) { if ($p['sort'] == $val) { $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key); } } $query .= $ORDER; // Get it from database if ($result = $DB->query($query)) { $numrows = $DB->numrows($result); $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']); $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto; if ($output_type == Search::GLOBAL_SEARCH) { if (class_exists($itemtype)) { echo "<div class='center'><h2>" . $item::getTypeName(); // More items if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) { echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } if ($p['start'] < $numrows) { if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) { echo "<div align='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=23&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>"; echo "</div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $search_config = ""; if ($item->canCreate() && $canedit) { $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\""; $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config .= $tmp . ">"; } //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']); } if ($output_type == Search::HTML_OUTPUT) { Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows, $search_config); echo "<br>"; } // Define begin and end var for loop // Search case $begin_display = $p['start']; $end_display = $p['start'] + $LIST_LIMIT; // Export All case if ($p['export_all']) { $begin_display = 0; $end_display = $numrows; } //massive action $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { Html::openMassiveActionsForm('massform' . $itemtype); $massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => true, 'is_deleted' => $p['is_deleted']); Html::showMassiveActions($itemtype, $massiveactionparams); } // Add toview elements $nbcols = $toview_count; if ($output_type == Search::HTML_OUTPUT) { // HTML display - massive modif $nbcols++; } // Display List Header echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols, 1); $header_num = 1; // Display column Headers for toview items $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; echo Search::showNewLine($output_type); if ($output_type == Search::HTML_OUTPUT && $item->canCreate() && $canedit) { // HTML display - massive modif $headers_line_top .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); $headers_line_bottom .= Search::showHeaderItem($output_type, Html::getCheckAllAsCheckbox('massform' . $itemtype), $header_num, "", 0, $p['order']); } // Display column Headers for toview items foreach ($toview as $key => $val) { $linkto = ''; if (!isset($searchopt[$itemtype][$val]['nosort']) || !$searchopt[$itemtype][$val]['nosort']) { $linkto = "javascript:reloadTab('sort=" . $val . "&order=" . ($p['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $p['start'] . $globallinkto . "')"; } $headers_line .= Search::showHeaderItem($output_type, $searchopt[$itemtype][$val]["name"], $header_num, $linkto, $p['sort'] == $val, $p['order']); } // End Line for column headers $headers_line .= Search::showEndLine($output_type); $headers_line_top .= $headers_line; $headers_line_bottom .= $headers_line; echo $headers_line_top; $DB->data_seek($result, $p['start']); // Define begin and end var for loop // Search case $i = $begin_display; // Init list of items displayed if ($output_type == Search::HTML_OUTPUT) { Session::initNavigateListItems($itemtype, PluginProjetProjet::getTypeName(2) . " = " . (empty($PluginProjetProjet->fields['name']) ? "(" . $p['id'] . ")" : $PluginProjetProjet->fields['name'])); } // Num of the row (1=header_line) $row_num = 1; // Display Loop while ($i < $numrows && $i < $end_display) { $item_num = 1; $data = $DB->fetch_array($result); $i++; $row_num++; echo Search::showNewLine($output_type, $i % 2); Session::addToNavigateListItems($itemtype, $data['id']); $tmpcheck = ""; if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $sel = ""; $tmpcheck = "<input type='checkbox' name='item[" . $data["id"] . "]' value='1' {$sel}>"; } echo Search::showItem($output_type, $tmpcheck, $item_num, $row_num, "width='10'"); foreach ($toview as $key => $val) { echo Search::showItem($output_type, Search::giveItem($itemtype, $val, $data, $key), $item_num, $row_num, Search::displayConfigItem($itemtype, $val, $data, $key)); } echo Search::showEndLine($output_type); } // Close Table $title = ""; // Create title if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) { $title .= __('Tasks list', 'projet'); } // Display footer echo Search::showFooter($output_type, $title); //massive action if ($item->canCreate() && $canedit && $output_type == Search::HTML_OUTPUT && $p['withtemplate'] != 2) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($itemtype, $massiveactionparams); // End form for delete item Html::closeForm(); } else { echo "</table></div>"; } // Pager if ($output_type == Search::HTML_OUTPUT) { echo "<br>"; Html::printAjaxPager(self::getTypeName(2), $p['start'], $numrows); } } else { echo Search::showError($output_type); } } }
$projet_item->addItem($_POST); } Html::back(); } else { if (isset($_POST["deleteitem"])) { foreach ($_POST["item"] as $key => $val) { if ($val == 1) { $projet_item->check($key, 'w'); $projet_item->delete(array('id' => $key)); } } Html::back(); } else { if (isset($_POST["deletedevice"])) { $projet_item->check($_POST["id"], 'w'); $projet_item->delete(array('id' => $_POST["id"])); Html::back(); } else { $projet->checkGlobal("r"); Html::header(PluginProjetProjet::getTypeName(2), '', "plugins", "projet"); $projet->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"], 'helpdesk_id' => $_GET["helpdesk_id"], 'helpdesk_itemtype' => $_GET["helpdesk_itemtype"])); Html::footer(); } } } } } } } } }
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); }
function plugin_projet_getAddSearchOptions($itemtype) { $sopt = array(); if (plugin_projet_haveRight("projet", "r")) { if (in_array($itemtype, PluginProjetProjet::getTypes(true))) { $sopt[2310]['table'] = 'glpi_plugin_projet_projets'; $sopt[2310]['field'] = 'name'; $sopt[2310]['massiveaction'] = false; $sopt[2310]['name'] = PluginProjetProjet::getTypeName(2) . " - " . __('Name'); $sopt[2310]['forcegroupby'] = true; $sopt[2310]['datatype'] = 'itemlink'; $sopt[2310]['itemlink_type'] = 'PluginProjetProjet'; $sopt[2310]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_projet_projets_items', 'joinparams' => array('jointype' => 'itemtype_item'))); $sopt[2311]['table'] = 'glpi_plugin_projet_projetstates'; $sopt[2311]['field'] = 'name'; $sopt[2311]['massiveaction'] = false; $sopt[2311]['datatype'] = 'dropdown'; $sopt[2311]['name'] = PluginProjetProjet::getTypeName(2) . " - " . _n('Project state', 'Project states', 1, 'projet'); $sopt[2311]['forcegroupby'] = true; $sopt[2311]['joinparams'] = array('beforejoin' => array(array('table' => 'glpi_plugin_projet_projets', 'joinparams' => $sopt[2310]['joinparams']))); } } return $sopt; }
/** * 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; } } } }
/** * Show items links to a projet * * @since version 0.84 * * @param $projet PluginProjetProjet object * * @return nothing (HTML display) **/ public static function showForProjet(PluginProjetProjet $projet, $withtemplate = '', $material = false) { global $DB; $instID = $projet->fields['id']; if (!$projet->can($instID, 'r')) { return false; } $rand = mt_rand(); $canedit = $projet->can($instID, 'w'); if (empty($withtemplate)) { $withtemplate = 0; } 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` = '{$instID}' \n AND `itemtype` {$in} (" . $select . ")\n ORDER BY `itemtype` \n LIMIT " . count(PluginProjetProjet::getTypes(true)); $result = $DB->query($query); $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { $colsup = 1; } else { $colsup = 0; } if ($canedit && $withtemplate < 2) { echo "<div class='firstbloc'>"; echo "<form method='post' name='projet_form{$rand}' id='projet_form{$rand}'\n action='" . Toolbox::getItemTypeFormURL("PluginProjetProjet") . "'>"; echo "<table class='tab_cadre_fixe'>"; if ($material) { echo "<tr class='tab_bg_2'><th colspan='" . ($canedit ? 5 + $colsup : 4 + $colsup) . "'>" . __('Add an item') . "</th></tr>"; } else { echo "<tr class='tab_bg_2'><th colspan='" . ($canedit ? 5 + $colsup : 4 + $colsup) . "'>" . __('Add a participant', 'projet') . "</th></tr>"; } echo "<tr class='tab_bg_1'><td colspan='" . (3 + $colsup) . "' class='center'>"; echo "<input type='hidden' name='plugin_projet_projets_id' value='{$instID}'>"; if ($material) { $types = PluginProjetProjet::getTypes(); $trans = array_flip($types); unset($trans['User']); unset($trans['Group']); unset($trans['Supplier']); unset($trans['Contract']); $types = array_flip($trans); } else { $types[] = 'User'; $types[] = 'Group'; $types[] = 'Supplier'; } Dropdown::showAllItems("items_id", 0, 0, $projet->fields['is_recursive'] ? -1 : $projet->fields['entities_id'], $types); echo "</td>"; echo "<td colspan='2' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number && $withtemplate < 2) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array(); Html::showMassiveActions(__CLASS__, $massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $number && $withtemplate < 2) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Type') . "</th>"; echo "<th>" . __('Name') . "</th>"; if (Session::isMultiEntitiesMode()) { echo "<th>" . __('Entity') . "</th>"; } if ($material) { echo "<th>" . __('Serial Number') . "</th>"; echo "<th>" . __('Inventory number') . "</th>"; } echo "</tr>"; for ($i = 0; $i < $number; $i++) { $itemType = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemType))) { continue; } if ($item->canView()) { $column = "name"; $itemTable = getTableForItemType($itemType); $query = "SELECT `" . $itemTable . "`.*,\n `glpi_plugin_projet_projets_items`.`id` AS items_id,\n `glpi_entities`.`id` AS entity " . " FROM `glpi_plugin_projet_projets_items`, `" . $itemTable . "` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemTable . "`.`entities_id`) " . " WHERE `" . $itemTable . "`.`id` = `glpi_plugin_projet_projets_items`.`items_id`\n AND `glpi_plugin_projet_projets_items`.`itemtype` = '{$itemType}'\n AND `glpi_plugin_projet_projets_items`.`plugin_projet_projets_id` = '{$instID}' "; if ($itemType != 'User') { $query .= getEntitiesRestrictRequest(" AND ", $itemTable, '', '', $item->maybeRecursive()); } if ($item->maybeTemplate()) { $query .= " AND `" . $itemTable . "`.`is_template` = '0'"; } $query .= " ORDER BY `glpi_entities`.`completename`, `" . $itemTable . "`.`{$column}`"; if ($result_linked = $DB->query($query)) { if ($DB->numrows($result_linked)) { Session::initNavigateListItems($itemType, PluginProjetProjet::getTypeName(2) . " = " . $projet->fields['name']); while ($data = $DB->fetch_assoc($result_linked)) { $item->getFromDB($data["id"]); Session::addToNavigateListItems($itemType, $data["id"]); $ID = ""; if ($itemType == 'User') { $format = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"], 1); } else { $format = $data["name"]; } if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $ID = " (" . $data["id"] . ")"; } $link = Toolbox::getItemTypeFormURL($itemType); $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $format; if ($itemType != 'User') { $name .= " " . $ID; } $name .= "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit && $withtemplate < 2) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["items_id"]); echo "</td>"; } echo "<td class='center'>" . $item::getTypeName(1) . "</td>"; echo "<td class='center' " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>"; if (Session::isMultiEntitiesMode()) { if ($itemType != 'User') { echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>"; } else { echo "<td class='center'>-</td>"; } } if ($material) { echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; } echo "</tr>"; } } } } } echo "</table>"; if ($canedit && $number && $withtemplate < 2) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }