示例#1
0
 public function build()
 {
     $planning = new Planning($this->id, $this->name, $this->group_id, $this->backlog_title, $this->plan_title, $this->backlog_tracker_id, $this->planning_tracker_id);
     if ($this->planning_tracker) {
         $planning->setPlanningTracker($this->planning_tracker);
     }
     return $planning;
 }
 private function getMappingCollection(Planning $planning, Cardwall_OnTop_Config_ColumnCollection $columns, Cardwall_FieldProviders_IProvideFieldGivenAnArtifact $field_provider, Cardwall_OnTop_Config $config)
 {
     $trackers_used_on_cardwall = array();
     foreach ($planning->getBacklogTrackers() as $backlog_tracker) {
         $trackers_used_on_cardwall[] = $backlog_tracker->getChildren();
     }
     return $config->getCardwallMappings($this->getIndexedStatusFieldsOf($trackers_used_on_cardwall, $field_provider), $columns);
 }
 /**
  * Returns the cardwall configuration of the given planning
  *
  * @param Planning $planning
  *
  * @return Cardwall_OnTop_Config | null
  */
 public function getOnTopConfigByPlanning(Planning $planning)
 {
     $tracker = $planning->getPlanningTracker();
     if ($this->getOnTopDao()->isEnabled($tracker->getId())) {
         return $this->getOnTopConfig($tracker);
     }
     return null;
 }
 private function thereIsAtLeastOneBacklogTrackerNotDeleted(Planning $planning)
 {
     $there_is_an_active_tracker = false;
     foreach ($planning->getBacklogTrackers() as $backlog_tracker) {
         $there_is_an_active_tracker = $there_is_an_active_tracker || !$backlog_tracker->isDeleted();
     }
     return $there_is_an_active_tracker;
 }
 /**
  * @param Cardwall_Board     $board              The board
  * @param Cardwall_QrCode    $qrcode             QrCode to display. false if no qrcode (thus no typehinting)
  * @param string             $redirect_parameter the redirect paramter to add to various url
  * @param Planning           $planning           The concerned planning
  * @param Planning_Milestone $milestone          The milestone
  */
 public function __construct(Cardwall_Board $board, $qrcode, $redirect_parameter, $switch_display_username_url, $is_display_avatar_selected, Planning $planning, Planning_Milestone $milestone, Cardwall_EffortProgressPresenter $progress_presenter)
 {
     parent::__construct($board, $qrcode, $redirect_parameter);
     $this->nifty = '';
     $this->swimline_title = $GLOBALS['Language']->getText('plugin_cardwall', 'swimline_title');
     $this->has_swimline_header = true;
     $this->switch_display_username_url = $switch_display_username_url;
     $this->is_display_avatar_selected = $is_display_avatar_selected;
     $this->display_avatar_label = $GLOBALS['Language']->getText('plugin_cardwall', 'display_avatar_label');
     $this->display_avatar_title = $GLOBALS['Language']->getText('plugin_cardwall', 'display_avatar_title');
     $this->search_cardwall_placeholder = $GLOBALS['Language']->getText('plugin_cardwall', 'search_cardwall_placeholder');
     $this->planning_id = $planning->getId();
     $this->milestone = $milestone;
     $this->progress_presenter = $progress_presenter;
 }
示例#6
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if ($item->getType() == __CLASS__) {
         switch ($tabnum) {
             case 1:
                 // all
                 Planning::showSelectionForm($_POST['type'], $_POST['date'], 'my', 0, $_POST["limititemtype"]);
                 Planning::showPlanning($_SESSION['glpiID'], $_POST["gID"], $_POST["date"], $_POST["type"], $_POST["limititemtype"]);
                 break;
             case 2:
                 Planning::showSelectionForm($_POST['type'], $_POST['date'], 'mygroups', 0, $_POST["limititemtype"]);
                 Planning::showPlanning($_SESSION['glpiID'], 'mine', $_POST["date"], $_POST["type"], $_POST["limititemtype"]);
                 break;
             case 3:
                 Planning::showSelectionForm($_POST['type'], $_POST['date'], 'users', $_POST["uID"], $_POST["limititemtype"]);
                 Planning::showPlanning($_POST['uID'], 0, $_POST["date"], $_POST["type"], $_POST["limititemtype"]);
                 break;
             case 4:
                 Planning::showSelectionForm($_POST['type'], $_POST['date'], 'groups', $_POST["gID"], $_POST["limititemtype"]);
                 Planning::showPlanning(0, $_POST['gID'], $_POST["date"], $_POST["type"], $_POST["limititemtype"]);
                 break;
         }
     }
     return true;
 }
示例#7
0
 private function exportPermissions(SimpleXMLElement $planning_node, Planning $planning)
 {
     $ugroups = $this->planning_permissions_manager->getGroupIdsWhoHasPermissionOnPlanning($planning->getId(), $planning->getGroupId(), PlanningPermissionsManager::PERM_PRIORITY_CHANGE);
     if (!empty($ugroups)) {
         foreach ($ugroups as $ugroup_id) {
             if (($ugroup = array_search($ugroup_id, $GLOBALS['UGROUPS'])) !== false && $ugroup_id < 100) {
                 if (!isset($planning_node->permissions)) {
                     $permission_nodes = $planning_node->addChild(self::NODE_PERMISSIONS);
                 }
                 $permission_node = $permission_nodes->addChild(self::NODE_PERMISSION);
                 $permission_node->addAttribute('ugroup', $ugroup);
                 $permission_node->addAttribute('type', PlanningPermissionsManager::PERM_PRIORITY_CHANGE);
                 unset($permission_node);
             }
         }
     }
 }
示例#8
0
 public function build(User $user, Project $project, Tracker_CrossSearch_Query $cross_search_query, array $already_planned_artifact_ids, $backlog_tracker_id, Planning $planning, $planning_redirect_parameter)
 {
     $backlog_hierarchy = $this->hierarchy_factory->getHierarchy(array($backlog_tracker_id));
     $report = $this->getReport($user);
     $criteria = $this->getCriteria($user, $project, $report, $cross_search_query);
     $tracker_ids = $backlog_hierarchy->flatten();
     $artifacts = $this->getHierarchicallySortedArtifacts($user, $project, $tracker_ids, $cross_search_query, $already_planned_artifact_ids);
     // The following lines allows to tailor/rebuild the result before display
     // As of today (aug-12), we decided to display everything and to wait for
     // user feedback to see if we need to enable one of them.
     //$visitor     = new Planning_BacklogItemFilterVisitor($backlog_tracker_id, $this->hierarchy_factory, $already_planned_artifact_ids);
     //$artifacts   = $artifacts->accept($visitor);
     //$visitor     = new Planning_GroupByParentsVisitor($user);
     //$artifacts->accept($visitor);
     $backlog_actions_presenter = new Planning_BacklogActionsPresenter($planning->getBacklogTracker(), $planning_redirect_parameter);
     return new Planning_SearchContentView($report, $criteria, $artifacts, Tracker_ArtifactFactory::instance(), $this->form_element_factory, $user, $backlog_actions_presenter, $planning, $planning_redirect_parameter);
 }
示例#9
0
 /**
  * @see Tracker_Artifact::getAllowedChildrenTypes()
  */
 public function getAllowedChildrenTypes()
 {
     $trackers = $this->artifact->getAllowedChildrenTypes();
     if ($this->getTracker() == $this->planning->getPlanningTracker()) {
         $trackers[] = $this->planning->getBacklogTracker();
     }
     return $trackers;
 }
示例#10
0
 private function redirectToPlanning($params, $requested_planning, Planning $planning)
 {
     $redirect_to_artifact = $requested_planning['artifact_id'];
     if ($redirect_to_artifact == -1) {
         $redirect_to_artifact = $params['artifact']->getId();
     }
     $GLOBALS['Response']->redirect('/plugins/agiledashboard/?' . http_build_query(array('group_id' => $planning->getGroupId(), 'planning_id' => $planning->getId(), 'action' => 'show', 'aid' => $redirect_to_artifact)));
 }
示例#11
0
 static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $private)
 {
     global $CFG_GLPI, $DB;
     $ID = $job->getField('id');
     //////////////Tasks///////////
     $RESTRICT = "";
     if (!$private) {
         // Don't show private'
         $RESTRICT = " AND `is_private` = '0' ";
     } else {
         if (!Session::haveRight("show_full_ticket", "1")) {
             // No right, only show connected user private one
             $RESTRICT = " AND (`is_private` = '0'\n                          OR `users_id` ='" . Session::getLoginUserID() . "' ) ";
         }
     }
     $query = "SELECT *\n                FROM `glpi_tickettasks`\n                WHERE `tickets_id` = '{$ID}'\n                      {$RESTRICT}\n                ORDER BY `date` DESC";
     $result = $DB->query($query);
     if (!$DB->numrows($result)) {
         $pdf->setColumnsSize(100);
         $pdf->displayLine(__('No task found.'));
     } else {
         $pdf->displayTitle("<b>" . TicketTask::getTypeName($DB->numrows($result) . "</b>"));
         $pdf->setColumnsSize(20, 20, 20, 20, 20);
         $pdf->displayTitle("<b><i>" . __('Type') . "</i></b>", "<b><i>" . __('Date') . "</i></b>", "<b><i>" . __('Duration') . "</i></b>", "<b><i>" . __('Writer') . "</i></b>", "<b><i>" . __('Planning') . "</i></b>");
         while ($data = $DB->fetch_array($result)) {
             $actiontime = Html::timestampToString($data['actiontime'], false);
             $planification = '';
             if (empty($data['begin'])) {
                 if (isset($data["state"])) {
                     $planification = Planning::getState($data["state"]) . "<br>";
                 }
                 $planification .= _e('None');
             } else {
                 if (isset($data["state"])) {
                     $planification = sprintf(__('%1$s: %2$s'), _x('item', 'State'), Planning::getState($data["state"]));
                 }
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, Html::convDateTime($data["begin"]) . " -> " . Html::convDateTime($data["end"]));
                 $planificiation = sprintf(__('%1$s - %2$s'), $planification, sprintf(__('%1$s  %2$s'), __('By'), getUserName($data["users_id_tech"])));
             }
             if ($data['taskcategories_id']) {
                 $lib = Dropdown::getDropdownName('glpi_taskcategories', $data['taskcategories_id']);
             } else {
                 $lib = '';
             }
             if ($data['is_private']) {
                 $lib = sprintf(__('%1$s (%2$s)'), $lib, __('Private'));
             }
             toolbox::logdebug("lib", $data);
             $pdf->displayLine(Html::clean($lib), Html::convDateTime($data["date"]), Html::timestampToString($data["actiontime"], 0), Html::clean(getUserName($data["users_id"])), Html::clean($planification), 1);
             $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Description') . "</i></b>", Html::clean($data["content"]), 1));
         }
     }
     $pdf->displaySpace();
 }
示例#12
0
 /**
  * Allow to create artifacts when the item comes from the planning tracker and if
  * the backlog tracker is at the root of the hierarchy.
  *
  * Example:
  * Given I have a planning Epic -> Release
  * And Epic has not parent (root of hierarchy)
  * Then I can create an Epic right in the release
  *
  * Counter example:
  * Given I have a planning Story -> Sprint
  * And I have a hierarchy Epic -> Story
  * Then I cannot create Story directly below Sprint
  *
  * @param array $allowed_trackers
  * @return type
  */
 private function appendBacklogTrackerIfRoot(array $allowed_trackers)
 {
     $backlog_tracker = array();
     if ($this->getTracker() == $this->planning->getPlanningTracker()) {
         $backlog_hierarchy = $this->planning->getBacklogTracker()->getHierarchy();
         if ($backlog_hierarchy->isRoot($this->planning->getBacklogTrackerId())) {
             $backlog_tracker = array($this->planning->getBacklogTracker());
         }
     }
     return array_merge($allowed_trackers, $backlog_tracker);
 }
示例#13
0
 /**
  * @param $field
  * @param $name               (default '')
  * @param $values             (default '')
  * @param $options      array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'refresh_rate':
             return Planning::dropdownState($name, $values[$field], false);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
 private function redirectToPlanning(Tracker_Artifact $artifact, $requested_planning, Planning $planning, Tracker_Artifact_Redirect $redirect)
 {
     $redirect_to_artifact = $requested_planning[AgileDashboard_PaneRedirectionExtractor::ARTIFACT_ID];
     if ($redirect_to_artifact == -1) {
         $redirect_to_artifact = $artifact->getId();
     }
     $redirect->base_url = '/plugins/agiledashboard/';
     $redirect->query_parameters = array('group_id' => $planning->getGroupId(), 'planning_id' => $planning->getId(), 'action' => 'show', 'aid' => $redirect_to_artifact, 'pane' => $requested_planning[AgileDashboard_PaneRedirectionExtractor::PANE]);
 }
 /**
  * Print the config form for default user prefs
  *
  * @param $data array containing datas
  * (CFG_GLPI for global config / glpi_users fields for user prefs)
  *
  * @return Nothing (display)
  **/
 function showFormUserPrefs($data = array())
 {
     global $DB, $CFG_GLPI;
     $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central";
     $userpref = false;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     if (array_key_exists('last_login', $data)) {
         $userpref = true;
         if ($data["id"] === Session::getLoginUserID()) {
             $url = $CFG_GLPI['root_doc'] . "/front/preference.php";
         } else {
             $url = $CFG_GLPI['root_doc'] . "/front/user.form.php";
         }
     }
     echo "<form name='form' action='{$url}' method='post'>";
     // Only set id for user prefs
     if ($userpref) {
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . ($userpref ? __('Language') : __('Default language')) . "</td>";
     echo "<td width='20%'>";
     if (Config::canUpdate() || !GLPI_DEMO_MODE) {
         Dropdown::showLanguages("language", array('value' => $data["language"]));
     } else {
         echo "&nbsp;";
     }
     echo "<td width='30%'>" . __('Date format') . "</td>";
     echo "<td width='20%'>";
     $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY'));
     Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Results to display by page') . "</td><td>";
     // Limit using global config
     $value = $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'];
     Dropdown::showNumber('list_limit', array('value' => $value, 'min' => 5, 'max' => $CFG_GLPI['list_limit_max'], 'step' => 5));
     echo "</td>";
     echo "<td>" . __('Number format') . "</td>";
     $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56', 3 => '1234.56', 4 => '1234,56');
     echo "<td>";
     Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Display order of surnames firstnames') . "</td><td>";
     $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname'));
     Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"]));
     echo "</td>";
     echo "<td>" . __("Color palette") . "</td><td>";
     $themes_files = scandir(GLPI_ROOT . "/css/palettes/");
     echo "<select name='palette' id='theme-selector'>";
     foreach ($themes_files as $key => $file) {
         if (strpos($file, ".css") !== false) {
             $name = substr($file, 0, -4);
             $selected = "";
             if ($data["palette"] == $name) {
                 $selected = "selected='selected'";
             }
             echo "<option value='{$name}' {$selected}>" . ucfirst($name) . "</option>";
         }
     }
     echo Html::scriptBlock("\n         function formatThemes(theme) {\n             return \"&nbsp;<img src='../css/palettes/previews/\" + theme.text.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + theme.text;\n         }\n         \$(\"#theme-selector\").select2({\n             formatResult: formatThemes,\n             formatSelection: formatThemes,\n             width: '100%',\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>";
         Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) {
         echo "<td>" . __('Display counts in tabs') . "</td><td>";
         $values = array(0 => __('No'), 1 => __('Yes'));
         if (!$userpref) {
             $values[-1] = __('Never');
         }
         Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"]));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Show GLPI ID') . "</td><td>";
         Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<td>" . __('CSV delimiter') . "</td><td>";
     $values = array(';' => ';', ',' => ',');
     Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Notifications for my changes') . "</td><td>";
     Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]);
     echo "</td>";
     if ($oncentral) {
         echo "<td>" . __('Results to display on home page') . "</td><td>";
         Dropdown::showNumber('display_count_on_home', array('value' => $data['display_count_on_home'], 'min' => 0, 'max' => 30));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('PDF export font') . "</td><td>";
     Dropdown::showFromArray("pdffont", GLPIPDF::getFontList(), array('value' => $data["pdffont"], 'width' => 200));
     echo "</td>";
     echo "<td>" . __('Keep devices when purging an item') . "</td><td>";
     Dropdown::showYesNo('keep_devices_when_purging_item', $data['keep_devices_when_purging_item']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Go to created item after creation') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("backcreated", $data["backcreated"]);
     echo "</td>";
     echo "<td>" . __('Layout') . "</td><td>";
     $layout_options = array('lefttab' => __("Tabs on left"), 'classic' => __("Classic view"), 'vsplit' => __("Vertical split"));
     echo "<select name='layout' id='layout-selector'>";
     foreach ($layout_options as $key => $name) {
         $selected = "";
         if ($data["layout"] == $key) {
             $selected = "selected='selected'";
         }
         echo "<option value='{$key}' {$selected}>" . ucfirst($name) . "</option>";
     }
     echo Html::scriptBlock("\n         function formatLayout(layout) {\n             return \"&nbsp;<img src='../pics/layout_\" + layout.id.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + layout.text;\n         }\n         \$(\"#layout-selector\").select2({\n             formatResult: formatLayout,\n             formatSelection: formatLayout,\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Enable ticket timeline') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('ticket_timeline', $data['ticket_timeline']);
     echo "</td>";
     echo "<td>" . __('Keep tabs replaced by the ticket timeline') . "</td><td>";
     Dropdown::showYesNo('ticket_timeline_keep_replaced_tabs', $data['ticket_timeline_keep_replaced_tabs']);
     echo "</td></tr>";
     if ($oncentral) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Private followups by default') . "</td><td>";
         Dropdown::showYesNo("followup_private", $data["followup_private"]);
         echo "</td><td>" . __('Show new tickets on the home page') . "</td><td>";
         if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN))) {
             Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo " </td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>";
         Dropdown::showYesNo("task_private", $data["task_private"]);
         echo "</td><td> " . __('Request sources by default') . "</td><td>";
         RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id"));
         echo "</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Tasks state by default') . "</td><td>";
         Planning::dropdownState("task_state", $data["task_state"]);
         echo "</td><td colspan='2'>&nbsp;</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>";
         if (!$userpref || Session::haveRight('ticket', Ticket::OWN)) {
             Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>";
         Dropdown::showNumber('refresh_ticket_list', array('value' => $data["refresh_ticket_list"], 'min' => 1, 'max' => 30, 'step' => 1, 'toadd' => array(0 => __('Never'))));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Priority colors') . "</td>";
         echo "<td colspan='3'>";
         echo "<table><tr>";
         echo "<td>1&nbsp;";
         Html::showColorField('priority_1', array('value' => $data["priority_1"]));
         echo "</td>";
         echo "<td>2&nbsp;";
         Html::showColorField('priority_2', array('value' => $data["priority_2"]));
         echo "</td>";
         echo "<td>3&nbsp;";
         Html::showColorField('priority_3', array('value' => $data["priority_3"]));
         echo "</td>";
         echo "<td>4&nbsp;";
         Html::showColorField('priority_4', array('value' => $data["priority_4"]));
         echo "</td>";
         echo "<td>5&nbsp;";
         Html::showColorField('priority_5', array('value' => $data["priority_5"]));
         echo "</td>";
         echo "<td>6&nbsp;";
         Html::showColorField('priority_6', array('value' => $data["priority_6"]));
         echo "</td>";
         echo "</tr></table>";
         echo "</td></tr>";
     }
     // Only for user
     if (array_key_exists('personal_token', $data)) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Remote access key');
         if (!empty($data["personal_token"])) {
             //TRANS: %s is the generation date
             echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"]));
         }
         echo "</td><td colspan='3'>";
         echo "<input type='checkbox' name='_reset_personal_token'>&nbsp;" . __('Regenerate');
         echo "</td></tr>";
     }
     echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedateok_color', array('value' => $data["duedateok_color"]));
     echo "</td><td colspan='2'>&nbsp;</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Warning state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatewarning_color', array('value' => $data["duedatewarning_color"]));
     echo "</td>";
     echo "<td>" . __('Warning state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less']));
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     echo "&nbsp;";
     Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatecritical_color', array('value' => $data["duedatecritical_color"]));
     echo "</td>";
     echo "<td>" . __('Critical state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less']));
     echo "&nbsp;";
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     Html::closeForm();
 }
 public function planningPlanTitle()
 {
     return $this->planning->getPlanTitle();
 }
示例#17
0
 /**
  * @since version 0.84
  *
  * @param $field
  * @param $name            (default '')
  * @param $values          (default '')
  * @param $options   array
  *
  * @return string
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'priority':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             $options['withmajor'] = 1;
             return CommonITILObject::dropdownPriority($options);
         case 'visibility':
             $options['name'] = $name;
             $options['value'] = $values[$field];
             return self::dropdownVisibility($options);
         case 'state':
             return Planning::dropdownState($name, $values[$field], false);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
示例#18
0
    /** form for Task
     *
     * @param $ID        Integer : Id of the task
     * @param $options   array
     *     -  parent Object : the object
     **/
    function showForm($ID, $options = array())
    {
        global $DB, $CFG_GLPI;
        $rand_template = mt_rand();
        $rand_text = mt_rand();
        $rand_type = mt_rand();
        $rand_time = mt_rand();
        if (isset($options['parent']) && !empty($options['parent'])) {
            $item = $options['parent'];
        }
        $fkfield = $item->getForeignKeyField();
        if ($ID > 0) {
            $this->check($ID, READ);
        } else {
            // Create item
            $options[$fkfield] = $item->getField('id');
            $this->check(-1, CREATE, $options);
        }
        $rand = mt_rand();
        $this->showFormHeader($options);
        $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
        $rowspan = 5;
        if ($this->maybePrivate()) {
            $rowspan++;
        }
        if (isset($this->fields["state"])) {
            $rowspan++;
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td rowspan='{$rowspan}' style='width:100px'>" . __('Description') . "</td>";
        echo "<td rowspan='{$rowspan}' style='width:50%' id='content{$rand_text}'>" . "<textarea name='content' style='width: 95%; height: 160px' id='task{$rand_text}'>" . $this->fields["content"] . "</textarea>";
        echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });");
        echo "</td>";
        echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
        echo "</td></tr>\n";
        echo "<tr class='tab_bg_1'>";
        echo "<td style='width:100px'>" . _n('Task template', 'Task templates', 1) . "</td><td>";
        TaskTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'on_change' => 'tasktemplate_update(this.value)'));
        echo "</td>";
        echo "</tr>";
        echo Html::scriptBlock('
         function tasktemplate_update(value) {
            jQuery.ajax({
               url: "' . $CFG_GLPI["root_doc"] . '/ajax/task.php",
               type: "POST",
               data: {
                  tasktemplates_id: value
               }
            }).done(function(datas) {
               datas.taskcategories_id = isNaN(parseInt(datas.taskcategories_id)) ? 0 : parseInt(datas.taskcategories_id);
               datas.actiontime = isNaN(parseInt(datas.actiontime)) ? 0 : parseInt(datas.actiontime);

               $("#task' . $rand_text . '").html(datas.content);
               $("#dropdown_taskcategories_id' . $rand_type . '").select2("val", parseInt(datas.taskcategories_id));
               $("#dropdown_actiontime' . $rand_time . '").select2("val", parseInt(datas.actiontime));
            });
         }
      ');
        if ($ID > 0) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Date') . "</td>";
            echo "<td>";
            Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
            echo "</tr>";
        } else {
            echo "<tr class='tab_bg_1'>";
            echo "<td colspan='2'>&nbsp;";
            echo "</tr>";
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Category') . "</td><td>";
        TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'rand' => $rand_type, 'entity' => $item->fields["entities_id"], 'condition' => "`is_active` = '1'"));
        echo "</td></tr>\n";
        if (isset($this->fields["state"])) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Status') . "</td><td>";
            Planning::dropdownState("state", $this->fields["state"]);
            echo "</td></tr>\n";
        }
        if ($this->maybePrivate()) {
            echo "<tr class='tab_bg_1'>";
            echo "<td>" . __('Private') . "</td>";
            echo "<td>";
            Dropdown::showYesNo('is_private', $this->fields["is_private"]);
            echo "</td>";
            echo "</tr>";
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('Duration') . "</td><td>";
        $toadd = array();
        for ($i = 9; $i <= 100; $i++) {
            $toadd[] = $i * HOUR_TIMESTAMP;
        }
        Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'rand' => $rand_time, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
        echo "</td></tr>\n";
        if ($ID <= 0) {
            Document_Item::showSimpleAddForItem($item);
        }
        echo "<tr class='tab_bg_1'>";
        echo "<td>" . __('By') . "</td>";
        echo "<td colspan='2'>";
        echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . "&nbsp;";
        echo _n('User', 'Users', 1);
        $rand_user = mt_rand();
        $params = array('name' => "users_id_tech", 'value' => $ID > -1 ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"], 'width' => '');
        $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
        User::dropdown($params);
        echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
        echo "&nbsp;<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
        echo "</a>";
        Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
        echo "<br />";
        echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . "&nbsp;";
        echo _n('Group', 'Groups', 1) . "&nbsp;";
        $rand_group = mt_rand();
        $params = array('name' => "groups_id_tech", 'value' => $ID > -1 ? $this->fields["groups_id_tech"] : Dropdown::EMPTY_VALUE, 'condition' => "is_task", 'rand' => $rand_group, 'entity' => $item->fields["entities_id"]);
        $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "group_available{$rand_group}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
        Group::dropdown($params);
        echo "</td>\n";
        echo "<td>";
        if ($canplan) {
            echo __('Planning');
        }
        if (!empty($this->fields["begin"])) {
            if (Session::haveRight('planning', Planning::READMY)) {
                echo "<script type='text/javascript' >\n";
                echo "function showPlan" . $ID . $rand_text . "() {\n";
                echo Html::jsHide("plan{$rand_text}");
                $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'groups_id' => $this->fields["groups_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
                Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
                echo "}";
                echo "</script>\n";
                echo "<div id='plan{$rand_text}' onClick='showPlan" . $ID . $rand_text . "()'>\n";
                echo "<span class='showplan'>";
            }
            if (isset($this->fields["state"])) {
                echo Planning::getState($this->fields["state"]) . "<br>";
            }
            printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
            if (isset($this->fields["users_id_tech"]) && $this->fields["users_id_tech"] > 0) {
                echo "<br>" . getUserName($this->fields["users_id_tech"]);
            }
            if (isset($this->fields["groups_id_tech"]) && $this->fields["groups_id_tech"] > 0) {
                echo "<br>" . Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"]);
            }
            if (Session::haveRight('planning', Planning::READMY)) {
                echo "</span>";
                echo "</div>\n";
                echo "<div id='viewplan{$rand_text}'></div>\n";
            }
        } else {
            if ($canplan) {
                echo "<script type='text/javascript' >\n";
                echo "function showPlanUpdate{$rand_text}() {\n";
                echo Html::jsHide("plan{$rand_text}");
                $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'entity' => $item->fields['entities_id'], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
                Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
                echo "};";
                echo "</script>";
                if ($canplan) {
                    echo "<div id='plan{$rand_text}'  onClick='showPlanUpdate{$rand_text}()'>\n";
                    echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                    echo "</div>\n";
                    echo "<div id='viewplan{$rand_text}'></div>\n";
                }
            } else {
                _e('None');
            }
        }
        echo "</td></tr>";
        if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
            echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
            PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
            echo "</td><td colspan='2'></td></tr>";
        }
        $this->showFormButtons($options);
        return true;
    }
示例#19
0
 /**
  * Retrieve the project trackers that can be used as planning trackers.
  * 
  * @param Planning $planning The planning for which we want to know the available trackers.
  * 
  * @return Array of Tracker
  */
 public function getAvailablePlanningTrackers(Planning $planning)
 {
     $planning_trackers = array($planning->getPlanningTracker());
     foreach ($this->dao->searchNonPlanningTrackersByGroupId($planning->getGroupId()) as $row) {
         $planning_trackers[] = $this->tracker_factory->getInstanceFromRow($row);
     }
     return $planning_trackers;
 }
 public function getPlanningId()
 {
     return $this->planning->getId();
 }
示例#21
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimeline($rand)
 {
     global $CFG_GLPI, $DB;
     //get ticket actors
     $ticket_users_keys = $this->getTicketActors();
     $user = new User();
     $followup_obj = new TicketFollowup();
     $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline";
     $timeline = $this->getTimelineItems();
     //include lib for parsing url
     require GLPI_ROOT . "/lib/urllinker/urllinker.php";
     //display timeline
     echo "<div class='timeline_history'>";
     $tmp = array_values($timeline);
     $first_item = array_shift($tmp);
     // show approbation form on top when ticket is solved
     if ($this->fields["status"] == CommonITILObject::SOLVED) {
         echo "<div class='approbation_form' id='approbation_form{$rand}'>";
         $followup_obj->showApprobationForm($this);
         echo "</div>";
     }
     // show title for timeline
     self::showTimelineHeader();
     $timeline_index = 0;
     foreach ($timeline as $item) {
         $item_i = $item['item'];
         // don't display empty followup (ex : solution approbation)
         if ($item['type'] == 'TicketFollowup' && empty($item_i['content'])) {
             continue;
         }
         $date = "";
         if (isset($item_i['date'])) {
             $date = $item_i['date'];
         }
         if (isset($item_i['date_mod'])) {
             $date = $item_i['date_mod'];
         }
         // check if curent item user is assignee or requester
         $user_position = 'left';
         if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') {
             $user_position = 'right';
         }
         //display solution in middle
         if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) {
             $user_position .= ' middle';
         }
         echo "<div class='h_item {$user_position}'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>";
         if ($item_i['users_id'] !== false) {
             echo "<div class='h_user'>";
             if (isset($item_i['users_id']) && $item_i['users_id'] != 0) {
                 $user->getFromDB($item_i['users_id']);
                 echo "<div class='tooltip_picture_border'>";
                 echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
                 echo "</div>";
                 echo $user->getLink();
             } else {
                 _e("Requester");
             }
             echo "</div>";
             // h_user
         }
         echo "</div>";
         //h_date
         echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'";
         if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) {
             echo " ondblclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this)'";
         }
         echo ">";
         if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) {
             echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />";
         }
         if (isset($item_i['content'])) {
             $content = $item_i['content'];
             $content = linkUrlsInTrustedHtml($content);
             //$content = nl2br($content);
             $long_text = "";
             if (substr_count($content, "<br") > 30 || strlen($content) > 2000) {
                 $long_text = "long_text";
             }
             echo "<div class='item_content {$long_text}'>";
             echo "<p>{$content}</p>";
             if (!empty($long_text)) {
                 echo "<p class='read_more'>";
                 echo "<a class='read_more_button'>.....</a>";
                 echo "</p>";
             }
             echo "</div>";
         }
         echo "<div class='b_right'>";
         if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) {
             echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>";
         }
         if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) {
             echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>";
         }
         if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) {
             echo "<span class='actiontime'>";
             echo Html::timestampToString($item_i['actiontime'], false);
             echo "</span>";
         }
         if (isset($item_i['state'])) {
             echo "<span class='state state_" . $item_i['state'] . "'>";
             echo Planning::getState($item_i['state']);
             echo "</span>";
         }
         if (isset($item_i['begin'])) {
             echo "<span class='planification'>";
             echo Html::convDateTime($item_i["begin"]);
             echo " &rArr; ";
             echo Html::convDateTime($item_i["end"]);
             echo "</span>";
         }
         if (isset($item_i['users_id_tech'])) {
             echo "<div class='users_id_tech'>";
             $user->getFromDB($item_i['users_id_tech']);
             echo "<div class='tooltip_picture_border'>";
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
             echo "</div>";
             echo $user->getLink();
             echo "</div>";
         }
         // show "is_private" icon
         if (isset($item_i['is_private']) && $item_i['is_private']) {
             echo "<div class='private'>" . __('Private') . "</div>";
         }
         echo "</div>";
         // b_right
         if ($item['type'] == 'Document_Item') {
             $filename = $item_i['filename'];
             $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
             echo "<img src='";
             if (empty($filename)) {
                 $filename = $item_i['name'];
             }
             if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) {
                 echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png";
             } else {
                 echo "{$pics_url}/file.png";
             }
             echo "' title='file' />&nbsp;";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}";
             if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) {
                 echo "<div class='timeline_img_preview'>";
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>";
                 echo "</div>";
             }
             echo "</a>";
             if (!empty($item_i['mime'])) {
                 echo "&nbsp;(" . $item_i['mime'] . ")";
             }
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>";
             echo "<img src='{$pics_url}/edit.png' /></a>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>";
             echo "<img src='{$pics_url}/delete.png' /></a>";
         }
         echo "</div>";
         //end h_content
         echo "</div>";
         //end  h_info
         $timeline_index++;
     }
     // end foreach timeline
     echo "<div class='break'></div>";
     // recall ticket content (not needed in classic and splitted layout)
     if (!CommonGLPI::isLayoutWithMain()) {
         echo "<div class='h_item middle'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>";
         echo "<div class='h_user'>";
         if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) {
             $user->getFromDB($this->fields['users_id_recipient']);
             echo "<div class='tooltip_picture_border'>";
             $picture = "";
             if (isset($user->fields['picture'])) {
                 $picture = $user->fields['picture'];
             }
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>";
             echo "</div>";
             echo $user->getLink();
         } else {
             _e("Requester");
         }
         echo "</div>";
         // h_user
         echo "</div>";
         //h_info
         echo "<div class='h_content TicketContent'>";
         echo "<div class='b_right'>" . __("Ticket recall") . "</div>";
         echo "<div class='ticket_title'>";
         echo html_entity_decode($this->fields['name']);
         echo "</div>";
         echo "<div class='ticket_description'>";
         echo Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         echo "</div>";
         echo "</div>";
         // h_content TicketContent
         echo "</div>";
         // h_item middle
         echo "<div class='break'></div>";
     }
     // end timeline
     echo "</div>";
     // h_item $user_position
     echo "<script type='text/javascript'>read_more();</script>";
 }
示例#22
0
 /**
  * Prepare a set of events for jquery fullcalendar.
  * Call populatePlanning functions for all $CFG_GLPI['planning_types'] types
  *
  * @since 9.1
  *
  * @param array $options: must contains this keys :
  *  - begin : planning start .
  *       (should be an ISO_8601 date, but could be anything wo can be parsed by strtotime)
  *  - end : planning end .
  *       (should be an ISO_8601 date, but could be anything wo can be parsed by strtotime)
  * @return array $events : array with events in fullcalendar.io format
  */
 static function constructEventsArray($options = array())
 {
     global $CFG_GLPI;
     $param['start'] = '';
     $param['end'] = '';
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $param[$key] = $val;
         }
     }
     $param['begin'] = date("Y-m-d H:i:s", strtotime($param['start']));
     $param['end'] = date("Y-m-d H:i:s", strtotime($param['end']));
     $raw_events = array();
     foreach ($CFG_GLPI['planning_types'] as $planning_type) {
         if ($_SESSION['glpi_plannings']['filters'][$planning_type]['display']) {
             $event_type_color = $_SESSION['glpi_plannings']['filters'][$planning_type]['color'];
             foreach ($_SESSION['glpi_plannings']['plannings'] as $actor => $actor_params) {
                 $actor_params['event_type_color'] = $event_type_color;
                 $actor_params['planning_type'] = $planning_type;
                 self::constructEventsArraySingleLine($actor, array_merge($param, $actor_params), $raw_events);
             }
         }
     }
     // construct events (in fullcalendar format)
     $events = array();
     foreach ($raw_events as $event) {
         $users_id = isset($event['users_id_tech']) && !empty($event['users_id_tech']) ? $event['users_id_tech'] : $event['users_id'];
         $content = Planning::displayPlanningItem($event, $users_id, 'in', true);
         $begin = date('c', strtotime($event['begin']));
         $end = date('c', strtotime($event['end']));
         // retreive all day events
         if (strpos($event['begin'], "00:00:00") != false && (strtotime($event['end']) - strtotime($event['begin'])) % DAY_TIMESTAMP == 0) {
             $begin = date('Y-m-d', strtotime($event['begin']));
             $end = date('Y-m-d', strtotime($event['end']));
         }
         $index_color = array_search("user_{$users_id}", array_keys($_SESSION['glpi_plannings']));
         $events[] = array('title' => $event['name'], 'content' => $content, 'start' => $begin, 'end' => $end, 'editable' => isset($event['editable']) ? $event['editable'] : false, 'color' => empty($event['color']) ? Planning::$palette_bg[$index_color] : $event['color'], 'borderColor' => empty($event['event_type_color']) ? self::$event_type_color[$event['itemtype']] : $event['event_type_color'], 'textColor' => Planning::$palette_fg[$index_color], 'typeColor' => empty($event['event_type_color']) ? self::$event_type_color[$event['itemtype']] : $event['event_type_color'], 'url' => isset($event['url']) ? $event['url'] : "", 'ajaxurl' => isset($event['ajaxurl']) ? $event['ajaxurl'] : "", 'itemtype' => $event['itemtype'], 'parentitemtype' => isset($event['parentitemtype']) ? $event['parentitemtype'] : "", 'items_id' => $event['id'], 'priority' => isset($event['priority']) ? $event['priority'] : "");
     }
     return $events;
 }
示例#23
0
 /**
  * Display a Planning Item
  *
  * @param $val       array of the item to display
  * @param $who             ID of the user (0 if all)
  * @param $type            position of the item in the time block (in, through, begin or end)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return Nothing (display function)
  **/
 static function displayPlanningItem(array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $users_id = "";
     // show users_id reminder
     $img = "rdv_private.png";
     // default icon for reminder
     if ($val["users_id"] != Session::getLoginUserID()) {
         $users_id = "<br>" . sprintf(__('%1$s: %2$s'), __('By'), getUserName($val["users_id"]));
         $img = "rdv_public.png";
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . $img . "' alt='' title=\"" . self::getTypeName(1) . "\">&nbsp;";
     echo "<a id='reminder_" . $val["reminders_id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/reminder.form.php?id=" . $val["reminders_id"] . "'>";
     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 "through":
             echo 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;
     }
     echo $users_id;
     echo "</a>";
     $recall = '';
     if (isset($val['reminders_id'])) {
         $pr = new PlanningRecall();
         if ($pr->getFromDBForItemAndUser($val['itemtype'], $val['reminders_id'], Session::getLoginUserID())) {
             $recall = "<br><span class='b'>" . sprintf(__('Recall on %s'), Html::convDateTime($pr->fields['when'])) . "<span>";
         }
     }
     if ($complete) {
         echo "<br><span class='b'>" . Planning::getState($val["state"]) . "</span><br>";
         echo $val["text"] . $recall;
     } else {
         Html::showToolTip("<span class='b'>" . Planning::getState($val["state"]) . "</span><br>\n                              " . $val["text"] . $recall, array('applyto' => "reminder_" . $val["reminders_id"] . $rand));
     }
     echo "";
 }
示例#24
0
 public function itCreatesNewPlanningWithValidBacklogAndPlanningTrackers()
 {
     $backlog_tracker = mock('Tracker');
     $planning_tracker = mock('Tracker');
     $form_element_factory = mock('Tracker_FormElementFactory');
     stub($backlog_tracker)->getId()->returns(78);
     stub($planning_tracker)->getId()->returns(45);
     $my_planning = new Planning(null, null, null, null, null, array(78), 45);
     $my_planning->setBacklogTrackers(array($backlog_tracker))->setPlanningTracker($planning_tracker);
     stub($this->planning_factory)->getRootPlanning()->returns($my_planning);
     stub($this->tracker_factory)->getTrackerById(45)->returns($backlog_tracker);
     stub($this->tracker_factory)->getTrackerById(78)->returns($planning_tracker);
     $planning = $this->planning_factory->getVirtualTopPlanning($this->user, 56);
     $this->assertIsA($planning, 'Planning');
     $this->assertIsA($planning->getPlanningTracker(), 'Tracker');
     $backlog_trackers = $planning->getBacklogTrackers();
     $this->assertIsA($backlog_trackers[0], 'Tracker');
 }
示例#25
0
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimeline($rand)
 {
     global $CFG_GLPI, $DB, $autolink_options;
     //get ticket actors
     $ticket_users_keys = $this->getTicketActors();
     $user = new User();
     $group = new Group();
     $followup_obj = new TicketFollowup();
     $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline";
     $timeline = $this->getTimelineItems();
     $autolink_options['strip_protocols'] = false;
     //display timeline
     echo "<div class='timeline_history'>";
     $tmp = array_values($timeline);
     $first_item = array_shift($tmp);
     // show approbation form on top when ticket is solved
     if ($this->fields["status"] == CommonITILObject::SOLVED) {
         echo "<div class='approbation_form' id='approbation_form{$rand}'>";
         $followup_obj->showApprobationForm($this);
         echo "</div>";
     }
     // show title for timeline
     self::showTimelineHeader();
     $timeline_index = 0;
     foreach ($timeline as $item) {
         $options = array('parent' => $this, 'rand' => $rand);
         if ($obj = getItemForItemtype($item['type'])) {
             $obj->fields = $item['item'];
         } else {
             $obj = $item;
         }
         Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options));
         if (is_array($obj)) {
             $item_i = $obj['item'];
         } else {
             $item_i = $obj->fields;
         }
         $date = "";
         if (isset($item_i['date'])) {
             $date = $item_i['date'];
         }
         if (isset($item_i['date_mod'])) {
             $date = $item_i['date_mod'];
         }
         // check if curent item user is assignee or requester
         $user_position = 'left';
         if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') {
             $user_position = 'right';
         }
         //display solution in middle
         if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) {
             $user_position .= ' middle';
         }
         echo "<div class='h_item {$user_position}'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>";
         if ($item_i['users_id'] !== false) {
             echo "<div class='h_user'>";
             if (isset($item_i['users_id']) && $item_i['users_id'] != 0) {
                 $user->getFromDB($item_i['users_id']);
                 echo "<div class='tooltip_picture_border'>";
                 echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
                 echo "</div>";
                 echo "<span class='h_user_name'>";
                 $userdata = getUserName($item_i['users_id'], 2);
                 echo $user->getLink() . "&nbsp;";
                 echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
                 echo "</span>";
             } else {
                 _e("Requester");
             }
             echo "</div>";
             // h_user
         }
         echo "</div>";
         //h_date
         echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'" . "id='viewitem" . $item['type'] . $item_i['id'] . $rand . "'>";
         if (isset($item_i['can_edit']) && $item_i['can_edit']) {
             echo "<div class='edit_item_content'></div>";
             echo "<span class='cancel_edit_item_content'></span>";
         }
         echo "<div class='displayed_content'>";
         if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) {
             echo "<span class='edit_item' ";
             echo "onclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this, \"viewitem" . $item['type'] . $item_i['id'] . $rand . "\")'";
             echo "></span>";
         }
         if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) {
             echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />";
         }
         if (isset($item_i['content'])) {
             $content = $item_i['content'];
             $content = autolink($content, 40);
             //$content = nl2br($content);
             $long_text = "";
             if (substr_count($content, "<br") > 30 || strlen($content) > 2000) {
                 $long_text = "long_text";
             }
             echo "<div class='item_content {$long_text}'>";
             echo "<p>";
             if (isset($item_i['state'])) {
                 $onClick = "onclick='change_task_state(" . $item_i['id'] . ", this)'";
                 if (!$item_i['can_edit']) {
                     $onClick = "style='cursor: not-allowed;'";
                 }
                 echo "<span class='state state_" . $item_i['state'] . "'\n                           {$onClick}\n                           title='" . Planning::getState($item_i['state']) . "'>";
                 echo "</span>";
             }
             echo $content;
             echo "</p>";
             if (!empty($long_text)) {
                 echo "<p class='read_more'>";
                 echo "<a class='read_more_button'>.....</a>";
                 echo "</p>";
             }
             echo "</div>";
         }
         echo "<div class='b_right'>";
         if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) {
             echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>";
         }
         if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) {
             echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>";
         }
         if (isset($item_i['requesttypes_id']) && !empty($item_i['requesttypes_id'])) {
             echo Dropdown::getDropdownName("glpi_requesttypes", $item_i['requesttypes_id']) . "<br>";
         }
         if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) {
             echo "<span class='actiontime'>";
             echo Html::timestampToString($item_i['actiontime'], false);
             echo "</span>";
         }
         if (isset($item_i['begin'])) {
             echo "<span class='planification'>";
             echo Html::convDateTime($item_i["begin"]);
             echo " &rArr; ";
             echo Html::convDateTime($item_i["end"]);
             echo "</span>";
         }
         if (isset($item_i['users_id_tech']) && $item_i['users_id_tech'] > 0) {
             echo "<div class='users_id_tech' id='users_id_tech_" . $item_i['users_id_tech'] . "'>";
             $user->getFromDB($item_i['users_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . "&nbsp;";
             $userdata = getUserName($item_i['users_id_tech'], 2);
             echo $user->getLink() . "&nbsp;";
             echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
             echo "</div>";
         }
         if (isset($item_i['groups_id_tech']) && $item_i['groups_id_tech'] > 0) {
             echo "<div class='groups_id_tech'>";
             $group->getFromDB($item_i['groups_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . "&nbsp;";
             echo $group->getLink() . "&nbsp;";
             echo Html::showToolTip($group->getComments(), array('link' => $group->getLinkURL()));
             echo "</div>";
         }
         // show "is_private" icon
         if (isset($item_i['is_private']) && $item_i['is_private']) {
             echo "<div class='private'>" . __('Private') . "</div>";
         }
         echo "</div>";
         // b_right
         if ($item['type'] == 'Document_Item') {
             $filename = $item_i['filename'];
             $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
             echo "<img src='";
             if (empty($filename)) {
                 $filename = $item_i['name'];
             }
             if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) {
                 echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png";
             } else {
                 echo "{$pics_url}/file.png";
             }
             echo "' title='file' />&nbsp;";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}";
             if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) {
                 echo "<div class='timeline_img_preview'>";
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>";
                 echo "</div>";
             }
             echo "</a>";
             if (!empty($item_i['mime'])) {
                 echo "&nbsp;(" . $item_i['mime'] . ")";
             }
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>";
             echo "<img src='{$pics_url}/edit.png' /></a>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>";
             echo "<img src='{$pics_url}/delete.png' /></a>";
         }
         echo "</div>";
         // displayed_content
         echo "</div>";
         //end h_content
         echo "</div>";
         //end  h_info
         $timeline_index++;
         Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options));
     }
     // end foreach timeline
     echo "<div class='break'></div>";
     // recall ticket content (not needed in classic and splitted layout)
     if (!CommonGLPI::isLayoutWithMain()) {
         echo "<div class='h_item middle'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>";
         echo "<div class='h_user'>";
         $dem = '0';
         foreach ($DB->request("glpi_tickets_users", "`tickets_id` = " . $this->fields['id'] . " AND `type` = 1") as $req) {
             $dem = $req['users_id'];
         }
         if ((!isset($item_i['users_id_recipient']) || $item_i['users_id_recipient'] == 0) && $dem == 0) {
             _e("Requester");
         } else {
             if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) {
                 $user->getFromDB($this->fields['users_id_recipient']);
             } else {
                 if ($dem > 0) {
                     $requester = new User();
                     if ($requester->getFromDB($dem)) {
                         $user = $requester;
                     }
                 }
             }
             echo "<div class='tooltip_picture_border'>";
             $picture = "";
             if (isset($user->fields['picture'])) {
                 $picture = $user->fields['picture'];
             }
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>";
             echo "</div>";
             echo $user->getLink();
         }
         echo "</div>";
         // h_user
         echo "</div>";
         //h_info
         echo "<div class='h_content TicketContent'>";
         echo "<div class='b_right'>" . __("Ticket recall") . "</div>";
         echo "<div class='ticket_title'>";
         echo html_entity_decode($this->fields['name']);
         echo "</div>";
         echo "<div class='ticket_description'>";
         echo $this->setSimpleTextContent($this->fields['content']);
         echo "</div>";
         echo "</div>";
         // h_content TicketContent
         echo "</div>";
         // h_item middle
         echo "<div class='break'></div>";
     }
     // end timeline
     echo "</div>";
     // h_item $user_position
     echo "<script type='text/javascript'>read_more();</script>";
 }
示例#26
0
 /**
  * Loads all open milestones for the given project and planning
  *
  * @param User $user
  * @param Project $project
  * @param Planning $planning
  *
  * @return Array of \Planning_Milestone
  */
 public function getAllMilestones(User $user, Planning $planning)
 {
     $project = $planning->getPlanningTracker()->getProject();
     $milestones = array();
     $artifacts = $this->artifact_factory->getArtifactsByTrackerIdUserCanView($user, $planning->getPlanningTrackerId());
     foreach ($artifacts as $artifact) {
         $planned_artifacts = $this->getPlannedArtifacts($user, $artifact);
         $milestones[] = new Planning_ArtifactMilestone($project, $planning, $artifact, $planned_artifacts);
     }
     return $milestones;
 }
 public function getChildrenPlanning(Planning $planning)
 {
     $children = $this->tracker_factory->getHierarchyFactory()->getChildren($planning->getPlanningTrackerId());
     if (count($children) == 0) {
         return null;
     } else {
         $planning_tracker = array_shift($children);
         return $this->getPlanningByPlanningTracker($planning_tracker);
     }
 }
示例#28
0
         //ajouter
         try {
             $result = $contact->contactAdd($_POST);
             $contact = null;
             header('Location: /admin/contact-edit.php?id=' . $result);
         } catch (Exception $e) {
             echo 'Erreur contactez votre administrateur <br> :', $e->getMessage(), "\n";
             $contact = null;
             exit;
         }
     }
 }
 // ----------------------------------------------------------- //
 // ---- Traitement du Bon de commande /planning -------------- //
 if ($_POST['reference'] == 'planning') {
     $planning = new Planning();
     $imageManager = new ImageManager();
     $source = $_SERVER['DOCUMENT_ROOT'] . $_POST['pdf'];
     if (strstr($source, 'uploads')) {
         $source = $_SERVER['DOCUMENT_ROOT'] . $_POST['pdf'];
         $filenameDest = $imageManager->fileDestManagement($source, date('Ymd'));
         //Image
         $destination = $_SERVER['DOCUMENT_ROOT'] . '/photos/bdc' . $filenameDest;
         //print_r($source);exit();
         if (!copy($source, $destination)) {
             throw new Exception('Erreur contactez votre administrateur <br> Le PDF error:', $e->getMessage(), "\n");
             exit;
         }
         //Vignette
         $_POST['pdf'] = $filenameDest;
     }
示例#29
0
 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, CREATE, $options);
     }
     $rand = mt_rand();
     $this->showFormHeader($options);
     $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
     $rowspan = 3;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     if (isset($this->fields["state"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea id ='content{$rand}' name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea>";
     echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });");
     echo "</td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     Document_Item::showSimpleAddForItem($item);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('By');
     echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
     echo "</a>";
     Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
     echo "</td>";
     echo "<td class='center'>";
     $rand_user = mt_rand();
     $params = array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"] ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"]);
     $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
     User::dropdown($params);
     echo "</td>\n";
     if ($canplan) {
         echo "<td>" . __('Planning') . "</td>";
     }
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if ($canplan) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"], 'rand_user' => $rand_user, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             if ($canplan) {
                 echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
                 echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                 echo "</div>\n";
                 echo "<div id='viewplan'></div>\n";
             }
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
示例#30
0
 public function selectedIfPlanningTracker()
 {
     if ($this->tracker->getId() == $this->planning->getPlanningTrackerId()) {
         return 'selected';
     }
 }