Esempio n. 1
0
 public function submit($problem_id)
 {
     try {
         $problem = new Problem($problem_id);
         $language = fRequest::get('language', 'integer');
         if (!array_key_exists($language, static::$languages)) {
             throw new fValidationException('Invalid language.');
         }
         fSession::set('last_language', $language);
         $code = trim(fRequest::get('code', 'string'));
         if (strlen($code) == 0) {
             throw new fValidationException('Code cannot be empty.');
         }
         if ($problem->isSecretNow()) {
             if (!User::can('view-any-problem')) {
                 throw new fAuthorizationException('Problem is secret now. You are not allowed to submit this problem.');
             }
         }
         $record = new Record();
         $record->setOwner(fAuthorization::getUserToken());
         $record->setProblemId($problem->getId());
         $record->setSubmitCode($code);
         $record->setCodeLanguage($language);
         $record->setSubmitDatetime(Util::currentTime());
         $record->setJudgeStatus(JudgeStatus::PENDING);
         $record->setJudgeMessage('Judging... PROB=' . $problem->getId() . ' LANG=' . static::$languages[$language]);
         $record->setVerdict(Verdict::UNKNOWN);
         $record->store();
         Util::redirect('/status');
     } catch (fException $e) {
         fMessaging::create('error', $e->getMessage());
         fMessaging::create('code', '/submit', fRequest::get('code', 'string'));
         Util::redirect("/submit?problem={$problem_id}");
     }
 }
Esempio n. 2
0
 public function fetchTimestamp()
 {
     try {
         $p = new Problem(fRequest::get('pid', 'integer'));
         echo $p->getLastModified();
     } catch (fException $e) {
         echo -1;
     }
 }
Esempio n. 3
0
 /**
  * Is the current user have right to create the current task ?
  *
  * @return boolean
  **/
 function canCreateItem()
 {
     if (!parent::canReadITILItem()) {
         return false;
     }
     $problem = new Problem();
     if ($problem->getFromDB($this->fields['problems_id'])) {
         return Session::haveRight("edit_all_problem", "1") || Session::haveRight("show_my_problem", "1") && ($problem->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $problem->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']));
     }
     return false;
 }
Esempio n. 4
0
 private function checkAuthor($username)
 {
     foreach ($this->getProblems() as $problem_id) {
         try {
             $problem = new Problem($problem_id);
             if ($problem->getAuthor() == $username) {
                 return TRUE;
             }
         } catch (Exception $e) {
             continue;
         }
     }
     return FALSE;
 }
Esempio n. 5
0
 public function save()
 {
     if (UserSession::getInstance()->getAccessLevel() < 3) {
         die("<h1>Forbidden resource for you.</h1>");
     }
     $model = new Problem();
     $model->setFields($this->params);
     $modelId = $model->get("prb_id");
     if (!isset($modelId)) {
         $status = $this->saveNew($model);
         return $status;
     } else {
         $status = $this->update($model);
         return $status;
     }
 }
 static function beforeUpdate(Problem $problem)
 {
     if (!is_array($problem->input) || !count($problem->input)) {
         // Already cancel by another plugin
         return false;
     }
     //    Toolbox::logDebug("PluginBehaviorsProblem::beforeUpdate(), Problem=", $problem);
     $config = PluginBehaviorsConfig::getInstance();
     // Check is the connected user is a tech
     if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('problem', UPDATE)) {
         return false;
         // No check
     }
     $soltyp = isset($problem->input['solutiontypes_id']) ? $problem->input['solutiontypes_id'] : $problem->fields['solutiontypes_id'];
     // Wand to solve/close the problem
     if (isset($problem->input['solutiontypes_id']) && $problem->input['solutiontypes_id'] || isset($problem->input['solution']) && $problem->input['solution'] || isset($problem->input['status']) && in_array($problem->input['status'], array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray()))) {
         if ($config->getField('is_problemsolutiontype_mandatory')) {
             if (!$soltyp) {
                 unset($problem->input['status']);
                 unset($problem->input['solution']);
                 unset($problem->input['solutiontypes_id']);
                 Session::addMessageAfterRedirect(__('You cannot close a problem without solution type', 'behaviors'), true, ERROR);
             }
         }
     }
 }
Esempio n. 7
0
 public function index()
 {
     $data = array();
     $data['rain_problems'] = Problem::recentByBasin('RAIN', 'OR');
     $data['water_problems'] = Problem::recentByBasin('WATER', 'OR');
     $data['stats'] = Problem::todayStat();
     return View::make('home/index', $data);
 }
Esempio n. 8
0
 /**
  * View all problems
  * @param string    $status     status of problem ("all", "marked", "unmarked")
  * @param string    $data_type  WATER / RAIN
  * @return mixed
  */
 public function index($status, $data_type)
 {
     $params = $this->getParams($status, $data_type);
     $data = $this->dataForForm($status, $data_type);
     $data['selectDate'] = true;
     $data['title'] = 'Error Log';
     Log::info($params);
     $data['problems'] = Problem::allForTable($params);
     return View::make('errorlog/index', $data);
 }
Esempio n. 9
0
 public function index($status, $data_type)
 {
     $params = $this->getParams($status, $data_type);
     $data = $this->dataForForm($status, $data_type);
     // $params['start_date'] = date('Y-m-d', getTime());
     // $params['start_time'] = '07:01';
     $params['end_date_after'] = date('Y-m-d', getTime());
     $params['end_time_after'] = '07:01';
     $data['selectDate'] = false;
     $data['title'] = 'Daily Operations';
     $data['problems'] = Problem::allForTable($params);
     return View::make('dailyop/index', $data);
 }
Esempio n. 10
0
 public function generateDailyReport()
 {
     /*
       {
           "key": "HAIIEMAILKEY",
           "num": 6,
           "date": "2014-10-14 20:43",
           "rain": [
             {
               "name": "Out of Ranges",
               "stations": [
                 "TPTN",
                 "PUAA",
                 "PPCH"
               ]
             },
             {
               "name": "Missing Pattern",
               "stations": [
                 "ABCD"
               ]
             }
           ],
           "water": [
             {
               "name": "Out of Ranges",
               "stations": [
                 "WATER"
               ]
             }
           ]
         }
     */
     $data = Problem::yesterdayReport();
     $num = count($data["water"]["OR"]["stations"]) + count($data["water"]["MG"]["stations"]) + count($data["water"]["FV"]["stations"]) + count($data["rain"]["OR"]["stations"]) + count($data["rain"]["MG"]["stations"]) + count($data["rain"]["FV"]["stations"]);
     $input = array("key" => "HAIIEMAILKEY", "num" => $num, "date" => self::getStartDate('Y-m-d 07:00'), "rain" => $data["rain"], "water" => $data["water"]);
     return APIEmailController::sendEmail($input, 'daily');
 }
Esempio n. 11
0
 public function index()
 {
     $this->cache_control('private', 5);
     if ($pid = fRequest::get('id', 'integer')) {
         Util::redirect('/problem/' . $pid);
     }
     $view_any = User::can('view-any-problem');
     $this->page = fRequest::get('page', 'integer', 1);
     $this->title = trim(fRequest::get('title', 'string'));
     $this->author = trim(fRequest::get('author', 'string'));
     $this->problems = Problem::find($view_any, $this->page, $this->title, $this->author);
     $this->page_url = SITE_BASE . '/problems?';
     if (!empty($this->title)) {
         $this->page_url .= 'title=' . fHTML::encode($this->title) . '&';
     }
     if (!empty($this->author)) {
         $this->page_url .= 'author=' . fHTML::encode($this->author) . '&';
     }
     $this->page_url .= 'page=';
     $this->page_records = $this->problems;
     $this->nav_class = 'problems';
     $this->render('problem/index');
 }
Esempio n. 12
0
<?php 
global $user;
if (isset($mo_request[1]) && is_numeric($mo_request[1])) {
    $problem = new Problem($mo_request[1]);
    $problem->load();
    if (!$problem->getPID()) {
        require_once $mo_theme_floder . '404.php';
    }
    if (isset($_POST['lang']) && isset($_POST['code']) && $user->getUID()) {
        // 提交solution
        if (!b_check_code()) {
            echo '提交错误!请检查格式以及是否已经登录!';
        } else {
            $new_sid = mo_add_new_solution($mo_request[1], $_POST['lang'], $_POST['code']);
            echo '提交成功!<a href="/?r=solution/' . $new_sid . '">点此</a>查看详情!';
        }
    }
    echo '<h2>' . $problem->getInfo('title') . '</h2>';
    echo '<em>标签:' . $problem->getInfo('tag') . '<br>';
    echo '时间限制:' . $problem->getInfo('time_limit') . 'MS 内存限制:' . $problem->getInfo('memory_limit') . 'MB</em>';
    echo '<h3>问题描述</h3>';
    echo $problem->getInfo('description');
    echo '<br>提交人数:' . $problem->getInfo('try') . ' AC人数:' . $problem->getInfo('solved') . '<br>';
    echo '<h3>提交代码</h3>';
    echo '<form name="form1" method="post" action="">
				语言:
				<p>
				  <label>
					<input name="lang" type="radio" required id="lang-1" value="1" checked>
					C/C++</label>
				  </p>
Esempio n. 13
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     if (!static::canView()) {
         return false;
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '37';
     $default_use_notif = Entity::getUsedConfig('is_notif_enable_default', $_SESSION['glpiactive_entity'], '', 1);
     // Set default options
     if (!$ID) {
         $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_suppliers_id_assign_notif' => array('use_notification' => $default_use_notif, 'alternative_email' => ''), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
         foreach ($values as $key => $val) {
             if (!isset($options[$key])) {
                 $options[$key] = $val;
             }
         }
         if (isset($options['tickets_id'])) {
             $ticket = new Ticket();
             if ($ticket->getFromDB($options['tickets_id'])) {
                 $options['content'] = $ticket->getField('content');
                 $options['name'] = $ticket->getField('name');
                 $options['impact'] = $ticket->getField('impact');
                 $options['urgency'] = $ticket->getField('urgency');
                 $options['priority'] = $ticket->getField('priority');
                 $options['itilcategories_id'] = $ticket->getField('itilcategories_id');
                 $options['due_date'] = $ticket->getField('due_date');
             }
         }
         if (isset($options['problems_id'])) {
             $problem = new Problem();
             if ($problem->getFromDB($options['problems_id'])) {
                 $options['content'] = $problem->getField('content');
                 $options['name'] = $problem->getField('name');
                 $options['impact'] = $problem->getField('impact');
                 $options['urgency'] = $problem->getField('urgency');
                 $options['priority'] = $problem->getField('priority');
                 $options['itilcategories_id'] = $problem->getField('itilcategories_id');
                 $options['due_date'] = $problem->getField('due_date');
             }
         }
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $options);
     }
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<th class='left' width='{$colsize1}%'>" . __('Opening date') . "</th>";
     echo "<td class='left' width='{$colsize2}%'>";
     if (isset($options['tickets_id'])) {
         echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
     }
     if (isset($options['problems_id'])) {
         echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
     }
     $date = $this->fields["date"];
     if (!$ID) {
         $date = date("Y-m-d H:i:s");
     }
     Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Due date') . "</th>";
     echo "<td width='{$colsize2}%' class='left'>";
     if ($this->fields["due_date"] == 'NULL') {
         $this->fields["due_date"] = '';
     }
     Html::showDateTimeField("due_date", array('value' => $this->fields["due_date"], 'timestep' => 1));
     echo "</td></tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'><th>" . __('By') . "</th><td>";
         User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         echo "</td>";
         echo "<th>" . __('Last update') . "</th>";
         echo "<td>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
         if ($this->fields['users_id_lastupdater'] > 0) {
             printf(__('%1$s: %2$s'), __('By'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td></tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th>" . __('Date of solving') . "</th>";
         echo "<td>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th>" . __('Closing date') . "</th>";
             echo "<td>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     echo "<table class='tab_cadre_fixe' id='mainformtable2'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
     ChangeValidation::alertValidation($this, 'status');
     echo "</td>";
     echo "<th width='{$colsize1}%'>" . __('Urgency') . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Only change during creation OR when allowed to change priority OR when user is the creator
     $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Category') . "</th>";
     echo "<td >";
     $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_change`='1'");
     ITILCategory::dropdown($opt);
     echo "</td>";
     echo "<th>" . __('Impact') . "</th>";
     echo "<td>";
     $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Total duration') . "</th>";
     echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>";
     echo "<th class='left'>" . __('Priority') . "</th>";
     echo "<td>";
     $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
     $idajax = 'change_priority_' . mt_rand();
     echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => 'dropdown_priority' . $idpriority);
     Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     $this->showActorsPartForm($ID, $options);
     echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . __('Title') . "</th>";
     echo "<td colspan='3'>";
     echo "<input type='text' size='90' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Description') . "</th>";
     echo "<td colspan='3'>";
     $rand = mt_rand();
     echo "<textarea id='content{$rand}' name='content' cols='90' rows='6'>" . Html::clean(Html::entity_decode_deep($this->fields["content"])) . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $options['colspan'] = 3;
     $this->showFormButtons($options);
     return true;
 }
Esempio n. 14
0
        $prob = new Problem($cleaned["id"]);
        $prob->remove();
        break;
    case "addToLog":
        $prob = new Problem($cleaned["id"]);
        $prob->addToLog($cleaned["msg"]);
        break;
    case "getLog":
        $prob = new Problem($cleaned["id"]);
        $log = $prob->getLog();
        header("Content-type: application/json");
        echo json_encode($log);
        break;
    case "getLocation":
        header("Content-type: application/json");
        $prob = new Problem($cleaned["id"]);
        echo json_encode($prob->getLocation());
        break;
}
pg_close($conn);
function prob_output($problems, $format, $outProj)
{
    if ($format == "xml") {
        header("Content-type: text/xml");
        $xml = "";
        $xml .= "<freemap><projection>{$outProj}</projection>";
        foreach ($problems as $prob) {
            $xml .= $prob->output("xml", $outProj);
        }
        $xml .= "</freemap>";
        echo $xml;
Esempio n. 15
0
 /**
  * Generic Function to display Items
  *
  * @param $itemtype              item type
  * @param $ID                    ID of the SEARCH_OPTION item
  * @param $data            array containing data results
  * @param $num                   item num in the request
  * @param $meta                  is a meta item ? (default 0)
  * @param $addobjectparams array added parameters for union search
  *
  * @return string to print
  **/
 static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array())
 {
     global $CFG_GLPI, $DB;
     $searchopt =& self::getOptions($itemtype);
     if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) {
         if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) {
             return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']);
         }
         return self::giveItem($data["TYPE"], $ID, $data, $num, $meta);
     }
     if (count($addobjectparams)) {
         $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams);
     }
     // Plugin can override core definition for its type
     if ($plug = isPluginItemType($itemtype)) {
         $function = 'plugin_' . $plug['plugin'] . '_giveItem';
         if (function_exists($function)) {
             $out = $function($itemtype, $ID, $data, $num);
             if (!empty($out)) {
                 return $out;
             }
         }
     }
     $NAME = "ITEM_";
     //       if ($meta) {
     //          $NAME = "META_";
     //       }
     if (isset($searchopt[$ID]["table"])) {
         $table = $searchopt[$ID]["table"];
         $field = $searchopt[$ID]["field"];
         $linkfield = $searchopt[$ID]["linkfield"];
         /// TODO try to clean all specific cases using SpecificToDisplay
         switch ($table . '.' . $field) {
             case "glpi_users.name":
                 // USER search case
                 if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) {
                     $out = "";
                     $count_display = 0;
                     $added = array();
                     $showuserlink = 0;
                     if (Session::haveRight('user', READ)) {
                         $showuserlink = 1;
                     }
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0 || isset($data[$num][$k][2]) && $data[$num][$k][2] != '') {
                             if ($count_display) {
                                 $out .= self::LBBR;
                             }
                             if ($itemtype == 'Ticket') {
                                 if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0) {
                                     $userdata = getUserName($data[$num][$k]['name'], 2);
                                     $tooltip = "";
                                     if (Session::haveRight('user', READ)) {
                                         $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                                     }
                                     $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip);
                                     $count_display++;
                                 }
                             } else {
                                 $out .= getUserName($data[$num][$k]['name'], $showuserlink);
                                 $count_display++;
                             }
                             // Manage alternative_email for tickets_users
                             if ($itemtype == 'Ticket' && isset($data[$num][$k][2])) {
                                 $split = explode(self::LONGSEP, $data[$num][$k][2]);
                                 for ($l = 0; $l < count($split); $l++) {
                                     $split2 = explode(" ", $split[$l]);
                                     if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) {
                                         if ($count_display) {
                                             $out .= self::LBBR;
                                         }
                                         $count_display++;
                                         $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>";
                                     }
                                 }
                             }
                         }
                     }
                     return $out;
                 }
                 if ($itemtype != 'User') {
                     $toadd = '';
                     if ($itemtype == 'Ticket' && $data[$num][0]['id'] > 0) {
                         $userdata = getUserName($data[$num][0]['id'], 2);
                         $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false));
                     }
                     $usernameformat = formatUserName($data[$num][0]['id'], $data[$num][0]['name'], $data[$num][0]['realname'], $data[$num][0]['firstname'], 1);
                     return sprintf(__('%1$s %2$s'), $usernameformat, $toadd);
                 }
                 break;
             case "glpi_profiles.name":
                 if ($itemtype == 'User' && $ID == 20) {
                     $out = "";
                     $count_display = 0;
                     $added = array();
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (strlen(trim($data[$num][$k]['name'])) > 0) {
                             $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_entities', $data[$num][$k]['entities_id']));
                             $comp = '';
                             if ($data[$num][$k]['is_recursive']) {
                                 $comp = __('R');
                                 if ($data[$num][$k]['is_dynamic']) {
                                     $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                                 }
                             }
                             if ($data[$num][$k]['is_dynamic']) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                             }
                             if (!empty($comp)) {
                                 $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                             }
                             if (!in_array($text, $added)) {
                                 if ($count_display) {
                                     $out .= self::LBBR;
                                 }
                                 $count_display++;
                                 $out .= $text;
                                 $added[] = $text;
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "glpi_entities.completename":
                 if ($itemtype == 'User') {
                     $out = "";
                     $added = array();
                     $count_display = 0;
                     for ($k = 0; $k < $data[$num]['count']; $k++) {
                         if (strlen(trim($data[$num][$k]['name'])) > 0) {
                             $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_profiles', $data[$num][$k]['profiles_id']));
                             $comp = '';
                             if ($data[$num][$k]['is_recursive']) {
                                 $comp = __('R');
                                 if ($data[$num][$k]['is_dynamic']) {
                                     $comp = sprintf(__('%1$s%2$s'), $comp, ", ");
                                 }
                             }
                             if ($data[$num][$k]['is_dynamic']) {
                                 $comp = sprintf(__('%1$s%2$s'), $comp, __('D'));
                             }
                             if (!empty($comp)) {
                                 $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")");
                             }
                             if (!in_array($text, $added)) {
                                 if ($count_display) {
                                     $out .= self::LBBR;
                                 }
                                 $count_display++;
                                 $out .= $text;
                                 $added[] = $text;
                             }
                         }
                     }
                     return $out;
                 }
                 break;
             case "glpi_documenttypes.icon":
                 if (!empty($data[$num][0]['name'])) {
                     return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>";
                 }
                 return "&nbsp;";
             case "glpi_documents.filename":
                 $doc = new Document();
                 if ($doc->getFromDB($data['id'])) {
                     return $doc->getDownloadLink();
                 }
                 return NOT_AVAILABLE;
             case "glpi_tickets_tickets.tickets_id_1":
                 $out = "";
                 $displayed = array();
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     $linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2'];
                     if ($linkid > 0 && !isset($displayed[$linkid])) {
                         $text = "<a ";
                         $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">";
                         $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>";
                         if (count($displayed)) {
                             $out .= self::LBBR;
                         }
                         $displayed[$linkid] = $linkid;
                         $out .= $text;
                     }
                 }
                 return $out;
             case "glpi_problems.id":
                 if ($searchopt[$ID]["datatype"] == 'count') {
                     if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) {
                         if ($itemtype == 'ITILCategory') {
                             $options['criteria'][0]['field'] = 7;
                             $options['criteria'][0]['searchtype'] = 'equals';
                             $options['criteria'][0]['value'] = $data['id'];
                             $options['criteria'][0]['link'] = 'AND';
                         } else {
                             $options['criteria'][0]['field'] = 12;
                             $options['criteria'][0]['searchtype'] = 'equals';
                             $options['criteria'][0]['value'] = 'all';
                             $options['criteria'][0]['link'] = 'AND';
                             $options['metacriteria'][0]['itemtype'] = $itemtype;
                             $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name');
                             $options['metacriteria'][0]['searchtype'] = 'equals';
                             $options['metacriteria'][0]['value'] = $data['id'];
                             $options['metacriteria'][0]['link'] = 'AND';
                         }
                         $options['reset'] = 'reset';
                         $out = "<a id='problem{$itemtype}" . $data['id'] . "' ";
                         $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                         $out .= $data[$num][0]['name'] . "</a>";
                         return $out;
                     }
                 }
                 break;
             case "glpi_tickets.id":
                 if ($searchopt[$ID]["datatype"] == 'count') {
                     if ($data[$num][0]['name'] > 0 && Session::haveRight("ticket", Ticket::READALL)) {
                         if ($itemtype == 'User') {
                             // Requester
                             if ($ID == 60) {
                                 $options['criteria'][0]['field'] = 4;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                             // Writer
                             if ($ID == 61) {
                                 $options['criteria'][0]['field'] = 22;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                             // Assign
                             if ($ID == 64) {
                                 $options['criteria'][0]['field'] = 5;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             }
                         } else {
                             if ($itemtype == 'ITILCategory') {
                                 $options['criteria'][0]['field'] = 7;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = $data['id'];
                                 $options['criteria'][0]['link'] = 'AND';
                             } else {
                                 $options['criteria'][0]['field'] = 12;
                                 $options['criteria'][0]['searchtype'] = 'equals';
                                 $options['criteria'][0]['value'] = 'all';
                                 $options['criteria'][0]['link'] = 'AND';
                                 $options['metacriteria'][0]['itemtype'] = $itemtype;
                                 $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name');
                                 $options['metacriteria'][0]['searchtype'] = 'equals';
                                 $options['metacriteria'][0]['value'] = $data['id'];
                                 $options['metacriteria'][0]['link'] = 'AND';
                             }
                         }
                         $options['reset'] = 'reset';
                         $out = "<a id='ticket{$itemtype}" . $data['id'] . "' ";
                         $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&amp;') . "\">";
                         $out .= $data[$num][0]['name'] . "</a>";
                         return $out;
                     }
                 }
                 break;
             case "glpi_tickets.due_date":
             case "glpi_problems.due_date":
             case "glpi_changes.due_date":
                 // Due date + progress
                 if ($ID == 151) {
                     $out = Html::convDate($data[$num][0]['name']);
                     // No due date in waiting status
                     if ($data[$num][0]['status'] == CommonITILObject::WAITING) {
                         return '';
                     }
                     if (empty($data[$num][0]['name'])) {
                         return '';
                     }
                     if ($data[$num][0]['status'] == Ticket::SOLVED || $data[$num][0]['status'] == Ticket::CLOSED) {
                         return $out;
                     }
                     $itemtype = getItemTypeForTable($table);
                     $item = new $itemtype();
                     $item->getFromDB($data['id']);
                     $percentage = 0;
                     $totaltime = 0;
                     $currenttime = 0;
                     if ($item->isField('slas_id') && $item->fields['slas_id'] != 0) {
                         // Have SLA
                         $sla = new SLA();
                         $sla->getFromDB($item->fields['slas_id']);
                         $currenttime = $sla->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s'));
                         $totaltime = $sla->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']);
                     } else {
                         $calendars_id = Entity::getUsedConfig('calendars_id', $item->fields['entities_id']);
                         if ($calendars_id != 0) {
                             // Ticket entity have calendar
                             $calendar = new Calendar();
                             $calendar->getFromDB($calendars_id);
                             $currenttime = $calendar->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s'));
                             $totaltime = $calendar->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']);
                         } else {
                             // No calendar
                             $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($item->fields['date']);
                             $totaltime = strtotime($data[$num][0]['name']) - strtotime($item->fields['date']);
                         }
                     }
                     if ($totaltime != 0) {
                         $percentage = round(100 * $currenttime / $totaltime);
                     } else {
                         // Total time is null : no active time
                         $percentage = 100;
                     }
                     if ($percentage > 100) {
                         $percentage = 100;
                     }
                     $percentage_text = $percentage;
                     if ($_SESSION['glpiduedatewarning_unit'] == '%') {
                         $less_warn_limit = $_SESSION['glpiduedatewarning_less'];
                         $less_warn = 100 - $percentage;
                     } else {
                         if ($_SESSION['glpiduedatewarning_unit'] == 'hour') {
                             $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP;
                             $less_warn = $totaltime - $currenttime;
                         } else {
                             if ($_SESSION['glpiduedatewarning_unit'] == 'day') {
                                 $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP;
                                 $less_warn = $totaltime - $currenttime;
                             }
                         }
                     }
                     if ($_SESSION['glpiduedatecritical_unit'] == '%') {
                         $less_crit_limit = $_SESSION['glpiduedatecritical_less'];
                         $less_crit = 100 - $percentage;
                     } else {
                         if ($_SESSION['glpiduedatecritical_unit'] == 'hour') {
                             $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP;
                             $less_crit = $totaltime - $currenttime;
                         } else {
                             if ($_SESSION['glpiduedatecritical_unit'] == 'day') {
                                 $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP;
                                 $less_crit = $totaltime - $currenttime;
                             }
                         }
                     }
                     $color = $_SESSION['glpiduedateok_color'];
                     if ($less_crit < $less_crit_limit) {
                         $color = $_SESSION['glpiduedatecritical_color'];
                     } else {
                         if ($less_warn < $less_warn_limit) {
                             $color = $_SESSION['glpiduedatewarning_color'];
                         }
                     }
                     //Calculate bar progress
                     $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n                            border: 1px solid #9BA563; position: relative;' >";
                     $out .= "<div style='position:absolute;'>&nbsp;" . $percentage_text . "%</div>";
                     $out .= "<div class='center' style='background-color: " . $color . ";\n                            width: " . $percentage . "%; height: 12px' ></div>";
                     $out .= "</div>";
                     return $out;
                 }
                 break;
             case "glpi_softwarelicenses.number":
                 if ($data[$num][0]['min'] == -1) {
                     return __('Unlimited');
                 }
                 if (empty($data[$num][0]['name'])) {
                     return 0;
                 }
                 return $data[$num][0]['name'];
             case "glpi_auth_tables.name":
                 return Auth::getMethodName($data[$num][0]['name'], $data[$num][0]['auths_id'], 1, $data[$num][0]['ldapname'] . $data[$num][0]['mailname']);
             case "glpi_reservationitems.comment":
                 if (empty($data[$num][0]['name'])) {
                     return "<a title=\"" . __s('Modify the comment') . "\"\n                           href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>";
                 }
                 return "<a title=\"" . __s('Modify the comment') . "\"\n                        href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$num][0]['name']) . "</a>";
             case 'glpi_crontasks.description':
                 $tmp = new CronTask();
                 return $tmp->getDescription($data[$num][0]['name']);
             case 'glpi_changes.status':
                 $status = Change::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Change::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_problems.status':
                 $status = Problem::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Problem::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_tickets.status':
                 $status = Ticket::getStatus($data[$num][0]['name']);
                 return "<img src=\"" . Ticket::getStatusIconURL($data[$num][0]['name']) . "\"\n                        alt=\"{$status}\" title=\"{$status}\">&nbsp;{$status}";
             case 'glpi_projectstates.name':
                 $out = '';
                 $query = "SELECT `color`\n                         FROM `glpi_projectstates`\n                         WHERE `name` = '" . $data[$num][0]['name'] . "'";
                 foreach ($DB->request($query) as $color) {
                     $color = $color['color'];
                     $out = "<div style=\"background-color:" . $color . ";\">";
                     $name = $data[$num][0]['name'];
                     if (isset($data[$num][0]['trans'])) {
                         $name = $data[$num][0]['trans'];
                     }
                     if ($itemtype == 'ProjectState') {
                         $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/front/projectstate.form.php?id=" . $data[$num][0]["id"] . "'>" . $name . "</a></div>";
                     } else {
                         $out .= $name . "</div>";
                     }
                 }
                 return $out;
             case 'glpi_items_tickets.items_id':
             case 'glpi_items_problems.items_id':
                 if (!empty($data[$num])) {
                     $items = array();
                     foreach ($data[$num] as $key => $val) {
                         if (is_numeric($key)) {
                             if (!empty($val['itemtype']) && ($item = getItemForItemtype($val['itemtype']))) {
                                 if ($item->getFromDB($val['name'])) {
                                     $items[] = $item->getLink(array('comments' => true));
                                 }
                             }
                         }
                     }
                     if (!empty($items)) {
                         return implode("<br>", $items);
                     }
                 }
                 return '&nbsp;';
             case 'glpi_items_tickets.itemtype':
             case 'glpi_items_problems.itemtype':
                 if (!empty($data[$num])) {
                     $itemtypes = array();
                     foreach ($data[$num] as $key => $val) {
                         if (is_numeric($key)) {
                             if (!empty($val['name'])) {
                                 if (substr($val['name'], 0, 6) == 'Plugin') {
                                     $plug = new $val['name']();
                                     $name = $plug->getTypeName();
                                     $itemtypes[] = __($name);
                                 } else {
                                     $itemtypes[] = __($val['name']);
                                 }
                             }
                         }
                     }
                     if (!empty($itemtypes)) {
                         return implode("<br>", $itemtypes);
                     }
                 }
                 return '&nbsp;';
             case 'glpi_tickets.name':
             case 'glpi_problems.name':
             case 'glpi_changes.name':
                 if (isset($data[$num][0]['content']) && isset($data[$num][0]['id']) && isset($data[$num][0]['status'])) {
                     $link = Toolbox::getItemTypeFormURL($itemtype);
                     $out = "<a id='{$itemtype}" . $data[$num][0]['id'] . "' href=\"" . $link;
                     $out .= strstr($link, '?') ? '&amp;' : '?';
                     $out .= 'id=' . $data[$num][0]['id'];
                     // Force solution tab if solved
                     if ($item = getItemForItemtype($itemtype)) {
                         if (in_array($data[$num][0]['status'], $item->getSolvedStatusArray())) {
                             $out .= "&amp;forcetab={$itemtype}\$2";
                         }
                     }
                     $out .= "\">";
                     $name = $data[$num][0]['name'];
                     if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) {
                         $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][0]['id']);
                     }
                     $out .= $name . "</a>";
                     $hdecode = Html::entity_decode_deep($data[$num][0]['content']);
                     $content = Toolbox::unclean_cross_side_scripting_deep($hdecode);
                     $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br(Html::Clean($content)), array('applyto' => $itemtype . $data[$num][0]['id'], 'display' => false)));
                     return $out;
                 }
             case 'glpi_ticketvalidations.status':
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if ($data[$num][$k]['name']) {
                         $status = TicketValidation::getStatus($data[$num][$k]['name']);
                         $bgcolor = TicketValidation::getStatusColor($data[$num][$k]['name']);
                         $out .= (empty($out) ? '' : self::LBBR) . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>';
                     }
                 }
                 return $out;
             case 'glpi_ticketsatisfactions.satisfaction':
                 if (self::$output_type == self::HTML_OUTPUT) {
                     return TicketSatisfaction::displaySatisfaction($data[$num][0]['name']);
                 }
                 break;
             case 'glpi_projects._virtual_planned_duration':
                 return Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($data["id"]), false);
             case 'glpi_projects._virtual_effective_duration':
                 return Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($data["id"]), false);
             case 'glpi_cartridgeitems._virtual':
                 return Cartridge::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_printers._virtual':
                 return Cartridge::getCountForPrinter($data["id"], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_consumableitems._virtual':
                 return Consumable::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT);
             case 'glpi_links._virtual':
                 $out = '';
                 $link = new Link();
                 if (($item = getItemForItemtype($itemtype)) && $item->getFromDB($data['id']) && $link->getfromDB($data[$num][0]['id']) && $item->fields['entities_id'] == $link->fields['entities_id']) {
                     if (count($data[$num])) {
                         $count_display = 0;
                         foreach ($data[$num] as $val) {
                             if (is_array($val)) {
                                 $links = Link::getAllLinksFor($item, $val);
                                 foreach ($links as $link) {
                                     if ($count_display) {
                                         $out .= self::LBBR;
                                     }
                                     $out .= $link;
                                     $count_display++;
                                 }
                             }
                         }
                     }
                 }
                 return $out;
             case 'glpi_reservationitems._virtual':
                 if ($data[$num][0]['is_active']) {
                     return "<a href='reservation.php?reservationitems_id=" . $data["refID"] . "' title=\"" . __s('See planning') . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>";
                 } else {
                     return "&nbsp;";
                 }
         }
     }
     //// Default case
     // Link with plugin tables : need to know left join structure
     if (isset($table)) {
         if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) {
             if (count($matches) == 2) {
                 $plug = $matches[1];
                 $function = 'plugin_' . $plug . '_giveItem';
                 if (function_exists($function)) {
                     $out = $function($itemtype, $ID, $data, $num);
                     if (!empty($out)) {
                         return $out;
                     }
                 }
             }
         }
     }
     $unit = '';
     if (isset($searchopt[$ID]['unit'])) {
         $unit = $searchopt[$ID]['unit'];
     }
     // Preformat items
     if (isset($searchopt[$ID]["datatype"])) {
         switch ($searchopt[$ID]["datatype"]) {
             case "itemlink":
                 $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]);
                 $out = "";
                 $count_display = 0;
                 $separate = self::LBBR;
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = self::LBHR;
                 }
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (isset($data[$num][$k]['id'])) {
                         if ($count_display) {
                             $out .= $separate;
                         }
                         $count_display++;
                         $page = $linkitemtype::getFormUrl();
                         $page .= strpos($page, '?') ? '&id' : '?id';
                         $name = Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit);
                         if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][$k]['name'])) {
                             $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][$k]['id']);
                         }
                         $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $data[$num][$k]['id'] . "' href='{$page}=" . $data[$num][$k]['id'] . "'>" . $name . "</a>";
                     }
                 }
                 return $out;
             case "text":
                 $separate = self::LBBR;
                 if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
                     $separate = self::LBHR;
                 }
                 $out = '';
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= $separate;
                         }
                         $count_display++;
                         $text = "";
                         if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) {
                             $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($data[$num][$k]['name'])));
                         } else {
                             $text = nl2br($data[$num][$k]['name']);
                         }
                         if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) {
                             $rand = mt_rand();
                             $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false)));
                         } else {
                             $out .= $text;
                         }
                     }
                 }
                 return $out;
             case "date":
             case "date_delay":
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) {
                         $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel'];
                     } else {
                         $out .= (empty($out) ? '' : self::LBBR) . Html::convDate($data[$num][$k]['name']);
                     }
                 }
                 return $out;
             case "datetime":
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) {
                         $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel'];
                     } else {
                         $out .= (empty($out) ? '' : self::LBBR) . Html::convDateTime($data[$num][$k]['name']);
                     }
                 }
                 return $out;
             case "timestamp":
                 $withseconds = false;
                 if (isset($searchopt[$ID]['withseconds'])) {
                     $withseconds = $searchopt[$ID]['withseconds'];
                 }
                 $withdays = true;
                 if (isset($searchopt[$ID]['withdays'])) {
                     $withdays = $searchopt[$ID]['withdays'];
                 }
                 $out = '';
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($data[$num][$k]['name'], $withseconds, $withdays);
                 }
                 return $out;
             case "email":
                 $out = '';
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if ($count_display) {
                         $out .= self::LBBR;
                     }
                     $count_display++;
                     if (!empty($data[$num][$k]['name'])) {
                         $out .= empty($out) ? '' : self::LBBR;
                         $out .= "<a href='mailto:" . $data[$num][$k]['name'] . "'>" . $data[$num][$k]['name'];
                         $out .= "</a>";
                     }
                 }
                 return empty($out) ? "&nbsp;" : $out;
             case "weblink":
                 $orig_link = trim($data[$num][0]['name']);
                 if (!empty($orig_link)) {
                     // strip begin of link
                     $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link);
                     $link = preg_replace('/\\/$/', '', $link);
                     if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) {
                         $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "...";
                     }
                     return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>";
                 }
                 return "&nbsp;";
             case "count":
             case "number":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                             $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                         } else {
                             $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$num][$k]['name'], false, 0));
                             $out .= Dropdown::getValueWithUnit($number, $unit);
                         }
                     }
                 }
                 return $out;
             case "decimal":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                             $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                         } else {
                             $number = str_replace(' ', '&nbsp;', Html::formatNumber($data[$num][$k]['name']));
                             $out .= Dropdown::getValueWithUnit($number, $unit);
                         }
                     }
                 }
                 return $out;
             case "bool":
                 $out = "";
                 $count_display = 0;
                 for ($k = 0; $k < $data[$num]['count']; $k++) {
                     if (strlen(trim($data[$num][$k]['name'])) > 0) {
                         if ($count_display) {
                             $out .= self::LBBR;
                         }
                         $count_display++;
                         $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$num][$k]['name']), $unit);
                     }
                 }
                 return $out;
             case "itemtypename":
                 if ($obj = getItemForItemtype($data[$num][0]['name'])) {
                     return $obj->getTypeName();
                 }
                 return "";
             case "language":
                 if (isset($CFG_GLPI['languages'][$data[$num][0]['name']])) {
                     return $CFG_GLPI['languages'][$data[$num][0]['name']][0];
                 }
                 return __('Default value');
         }
     }
     // Manage items with need group by / group_concat
     $out = "";
     $count_display = 0;
     $separate = self::LBBR;
     if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) {
         $separate = self::LBHR;
     }
     for ($k = 0; $k < $data[$num]['count']; $k++) {
         if (strlen(trim($data[$num][$k]['name'])) > 0) {
             if ($count_display) {
                 $out .= $separate;
             }
             $count_display++;
             // Get specific display if available
             $itemtype = getItemTypeForTable($table);
             if ($item = getItemForItemtype($itemtype)) {
                 $tmpdata = $data[$num][$k];
                 // Copy name to real field
                 $tmpdata[$field] = $data[$num][$k]['name'];
                 $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true, 'searchopt' => $searchopt[$ID]));
             }
             if (!empty($specific)) {
                 $out .= $specific;
             } else {
                 if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) {
                     $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']];
                 } else {
                     // Empty is 0 or empty
                     if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) {
                         $out .= $searchopt[$ID]['emptylabel'];
                     } else {
                         // Trans field exists
                         if (isset($data[$num][$k]['trans']) && !empty($data[$num][$k]['trans'])) {
                             $out .= Dropdown::getValueWithUnit($data[$num][$k]['trans'], $unit);
                         } else {
                             $out .= Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit);
                         }
                     }
                 }
             }
         }
     }
     return $out;
     // Trans in group concat
     if (count($split) == 3 && !empty($split[1])) {
         return Dropdown::getValueWithUnit($split[1], $unit);
     }
     return Dropdown::getValueWithUnit($split[0], $unit);
 }
Esempio n. 16
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     if (!static::canView()) {
         return false;
     }
     // Set default options
     if (!$ID) {
         $values = array('_users_id_requester' => Session::getLoginUserID(), '_users_id_requester_notif' => array('use_notification' => 1), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1), '_groups_id_observer' => 0, '_suppliers_id_assign' => 0, 'priority' => 3, 'urgency' => 3, 'impact' => 3, 'content' => '', 'entities_id' => $_SESSION['glpiactive_entity'], 'name' => '', 'itilcategories_id' => 0);
         foreach ($values as $key => $val) {
             if (!isset($options[$key])) {
                 $options[$key] = $val;
             }
         }
         if (isset($options['tickets_id'])) {
             $ticket = new Ticket();
             if ($ticket->getFromDB($options['tickets_id'])) {
                 $options['content'] = $ticket->getField('content');
                 $options['name'] = $ticket->getField('name');
                 $options['impact'] = $ticket->getField('impact');
                 $options['urgency'] = $ticket->getField('urgency');
                 $options['priority'] = $ticket->getField('priority');
                 $options['itilcategories_id'] = $ticket->getField('itilcategories_id');
             }
         }
         if (isset($options['problems_id'])) {
             $problem = new Problem();
             if ($problem->getFromDB($options['problems_id'])) {
                 $options['content'] = $problem->getField('content');
                 $options['name'] = $problem->getField('name');
                 $options['impact'] = $problem->getField('impact');
                 $options['urgency'] = $problem->getField('urgency');
                 $options['priority'] = $problem->getField('priority');
                 $options['itilcategories_id'] = $problem->getField('itilcategories_id');
             }
         }
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w', $options);
     }
     $showuserlink = 0;
     if (Session::haveRight('user', 'r')) {
         $showuserlink = 1;
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr>";
     echo "<th class='left' colspan='2'>";
     if (isset($options['tickets_id'])) {
         echo "<input type='hidden' name='_tickets_id' value='" . $options['tickets_id'] . "'>";
     }
     if (isset($options['problems_id'])) {
         echo "<input type='hidden' name='_problems_id' value='" . $options['problems_id'] . "'>";
     }
     echo "<table>";
     echo "<tr>";
     echo "<td><span class='tracking_small'>" . __('Opening date') . "</span></td>";
     echo "<td>";
     $date = $this->fields["date"];
     if (!$ID) {
         $date = date("Y-m-d H:i:s");
     }
     Html::showDateTimeFormItem("date", $date, 1, false);
     echo "</td></tr>";
     if ($ID) {
         echo "<tr><td><span class='tracking_small'>" . __('By') . "</span></td><td>";
         User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         echo "</td></tr>";
     }
     echo "</table>";
     echo "</th>";
     echo "<th class='left' colspan='2'>";
     echo "<table>";
     if ($ID) {
         echo "<tr><td><span class='tracking_small'>" . __('Last update') . "</span></td>";
         echo "<td><span class='tracking_small'>" . Html::convDateTime($this->fields["date_mod"]) . "\n";
         if ($this->fields['users_id_lastupdater'] > 0) {
             //TRANS: %s is the user name
             printf(__('By %s'), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</span>";
         echo "</td></tr>";
     }
     // SLA
     echo "<tr>";
     echo "<td><span class='tracking_small'>" . __('Due date') . "</span></td>";
     echo "<td>";
     if ($this->fields["due_date"] == 'NULL') {
         $this->fields["due_date"] = '';
     }
     Html::showDateTimeFormItem("due_date", $this->fields["due_date"], 1, true);
     echo "</td></tr>";
     if ($ID) {
         switch ($this->fields["status"]) {
             case self::CLOSED:
                 echo "<tr>";
                 echo "<td><span class='tracking_small'>" . __('Close date') . "</span></td>";
                 echo "<td>";
                 Html::showDateTimeFormItem("closedate", $this->fields["closedate"], 1, false);
                 echo "</td></tr>";
                 break;
             case self::SOLVED:
             case self::OBSERVED:
                 echo "<tr>";
                 echo "<td><span class='tracking_small'>" . __('Resolution date') . "</span></td>";
                 echo "<td>";
                 Html::showDateTimeFormItem("solvedate", $this->fields["solvedate"], 1, false);
                 echo "</td></tr>";
                 break;
         }
     }
     echo "</table>";
     echo "</th></tr>";
     echo "<tr>";
     echo "<th>" . __('Status') . "</th>";
     echo "<td>";
     self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
     echo "</td>";
     echo "<th>" . __('Urgency') . "</th>";
     echo "<td>";
     // Only change during creation OR when allowed to change priority OR when user is the creator
     $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Category') . "</th>";
     echo "<td >";
     $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]);
     ITILCategory::dropdown($opt);
     echo "</td>";
     echo "<th>" . __('Impact') . "</th>";
     echo "<td>";
     $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Total duration') . "</th>";
     echo "<td>" . parent::getActionTime($this->fields["actiontime"]) . "</td>";
     echo "<th class='left'>" . __('Priority') . "</th>";
     echo "<td>";
     $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
     $idajax = 'change_priority_' . mt_rand();
     echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
     Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     $this->showActorsPartForm($ID, $options);
     echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='10%'>" . __('Title') . "</th>";
     echo "<td colspan='3'>";
     $rand = mt_rand();
     echo "<script type='text/javascript' >\n";
     echo "function showName{$rand}() {\n";
     echo "Ext.get('name{$rand}').setDisplayed('none');";
     $params = array('maxlength' => 250, 'size' => 50, 'name' => 'name', 'data' => rawurlencode($this->fields["name"]));
     Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params);
     echo "}";
     echo "</script>\n";
     echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n";
     if (empty($this->fields["name"])) {
         _e('Without title');
     } else {
         echo $this->fields["name"];
     }
     echo "</div>\n";
     echo "<div id='viewname{$rand}'></div>\n";
     if (!$ID) {
         echo "<script type='text/javascript' >\n\n         showName{$rand}();\n         </script>";
     }
     echo "</td>";
     echo "<td colspan='2' width='50%'>&nbsp;</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . __('Description') . "</th>";
     echo "<td colspan='3'>";
     $rand = mt_rand();
     echo "<script type='text/javascript' >\n";
     echo "function showDesc{$rand}() {\n";
     echo "Ext.get('desc{$rand}').setDisplayed('none');";
     $params = array('rows' => 6, 'cols' => 50, 'name' => 'content', 'data' => rawurlencode($this->fields["content"]));
     Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params);
     echo "}";
     echo "</script>\n";
     echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n";
     if (!empty($this->fields["content"])) {
         echo nl2br($this->fields["content"]);
     } else {
         _e('Empty description');
     }
     echo "</div>\n";
     echo "<div id='viewdesc{$rand}'></div>\n";
     if (!$ID) {
         echo "<script type='text/javascript' >\n\n         showDesc{$rand}();\n         </script>";
     }
     echo "</td>";
     echo "<td colspan='2' width='50%'>&nbsp;</td>";
     echo "</tr>";
     $options['colspan'] = 3;
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Esempio n. 17
0
 function getSearchOptions()
 {
     $tab = array();
     $tab += $this->getSearchOptionsMain();
     $tab[155]['table'] = $this->getTable();
     $tab[155]['field'] = 'time_to_own';
     $tab[155]['name'] = __('Time to own');
     $tab[155]['datatype'] = 'datetime';
     $tab[155]['maybefuture'] = true;
     $tab[155]['massiveaction'] = false;
     $tab[155]['additionalfields'] = array('status');
     $tab[158]['table'] = $this->getTable();
     $tab[158]['field'] = 'time_to_own';
     $tab[158]['name'] = __('Time to own + Progress');
     $tab[158]['massiveaction'] = false;
     $tab[158]['nosearch'] = true;
     $tab[158]['additionalfields'] = array('status');
     $tab[159]['table'] = $this->getTable();
     $tab[159]['field'] = 'is_late';
     $tab[159]['name'] = __('Time to own exceedeed');
     $tab[159]['datatype'] = 'bool';
     $tab[159]['massiveaction'] = false;
     $tab[159]['computation'] = "IF(TABLE.`time_to_own` IS NOT NULL\n                                            AND TABLE.`status` <> " . self::WAITING . "\n                                            AND (TABLE.`takeintoaccount_delay_stat`\n                                                        > TIME_TO_SEC(TIMEDIFF(TABLE.`time_to_own`,\n                                                                               TABLE.`date`))\n                                                 OR (TABLE.`takeintoaccount_delay_stat` = 0\n                                                      AND TABLE.`time_to_own` < NOW())),\n                                            1, 0)";
     $tab[14]['table'] = $this->getTable();
     $tab[14]['field'] = 'type';
     $tab[14]['name'] = __('Type');
     $tab[14]['searchtype'] = 'equals';
     $tab[14]['datatype'] = 'specific';
     $tab[13]['table'] = 'glpi_items_tickets';
     $tab[13]['field'] = 'items_id';
     $tab[13]['name'] = _n('Associated element', 'Associated elements', Session::getPluralNumber());
     $tab[13]['datatype'] = 'specific';
     $tab[13]['comments'] = true;
     $tab[13]['nosort'] = true;
     $tab[13]['nosearch'] = true;
     $tab[13]['additionalfields'] = array('itemtype');
     $tab[13]['joinparams'] = array('jointype' => 'child');
     $tab[13]['forcegroupby'] = true;
     $tab[13]['massiveaction'] = false;
     $tab[131]['table'] = 'glpi_items_tickets';
     $tab[131]['field'] = 'itemtype';
     $tab[131]['name'] = _n('Associated item type', 'Associated item types', Session::getPluralNumber());
     $tab[131]['datatype'] = 'itemtypename';
     $tab[131]['itemtype_list'] = 'ticket_types';
     $tab[131]['nosort'] = true;
     $tab[131]['additionalfields'] = array('itemtype');
     $tab[131]['joinparams'] = array('jointype' => 'child');
     $tab[131]['forcegroupby'] = true;
     $tab[131]['massiveaction'] = false;
     $tab[9]['table'] = 'glpi_requesttypes';
     $tab[9]['field'] = 'name';
     $tab[9]['name'] = __('Request source');
     $tab[9]['datatype'] = 'dropdown';
     // Can't use Location::getSearchOptionsToAdd because id conflicts
     $tab[83]['table'] = 'glpi_locations';
     $tab[83]['field'] = 'completename';
     $tab[83]['name'] = __('Location');
     $tab[83]['datatype'] = 'dropdown';
     $tab[80]['table'] = 'glpi_entities';
     $tab[80]['field'] = 'completename';
     $tab[80]['name'] = __('Entity');
     $tab[80]['massiveaction'] = false;
     $tab[80]['datatype'] = 'dropdown';
     // For ticket template
     $tab[142]['table'] = 'glpi_documents';
     $tab[142]['field'] = 'name';
     $tab[142]['name'] = _n('Document', 'Documents', Session::getPluralNumber());
     $tab[142]['forcegroupby'] = true;
     $tab[142]['usehaving'] = true;
     $tab[142]['nosearch'] = true;
     $tab[142]['nodisplay'] = true;
     $tab[142]['datatype'] = 'dropdown';
     $tab[142]['massiveaction'] = false;
     $tab[142]['joinparams'] = array('jointype' => 'items_id', 'beforejoin' => array('table' => 'glpi_documents_items', 'joinparams' => array('jointype' => 'itemtype_item')));
     $tab += $this->getSearchOptionsActors();
     $tab['slt'] = __('SLT');
     $tab[37]['table'] = 'glpi_slts';
     $tab[37]['field'] = 'name';
     $tab[37]['linkfield'] = 'slts_tto_id';
     $tab[37]['name'] = __('SLT') . "&nbsp;" . __('Time to own');
     $tab[37]['massiveaction'] = false;
     $tab[37]['datatype'] = 'dropdown';
     $tab[37]['joinparams'] = array('condition' => "AND NEWTABLE.`type` = '" . SLT::TTO . "'");
     $tab[37]['condition'] = "`glpi_slts`.`type` = '" . SLT::TTO . "'";
     $tab[30]['table'] = 'glpi_slts';
     $tab[30]['field'] = 'name';
     $tab[30]['linkfield'] = 'slts_ttr_id';
     $tab[30]['name'] = __('SLT') . "&nbsp;" . __('Time to resolve');
     $tab[30]['massiveaction'] = false;
     $tab[30]['datatype'] = 'dropdown';
     $tab[30]['joinparams'] = array('condition' => "AND NEWTABLE.`type` = '" . SLT::TTR . "'");
     $tab[30]['condition'] = "`glpi_slts`.`type` = '" . SLT::TTR . "'";
     $tab[32]['table'] = 'glpi_slalevels';
     $tab[32]['field'] = 'name';
     $tab[32]['name'] = __('Escalation level');
     $tab[32]['massiveaction'] = false;
     $tab[32]['datatype'] = 'dropdown';
     $tab[32]['joinparams'] = array('beforejoin' => array('table' => 'glpi_slalevels_tickets', 'joinparams' => array('jointype' => 'child')));
     $tab[32]['forcegroupby'] = true;
     $tab += TicketValidation::getSearchOptionsToAdd();
     $tab['satisfaction'] = __('Satisfaction survey');
     $tab[31]['table'] = 'glpi_ticketsatisfactions';
     $tab[31]['field'] = 'type';
     $tab[31]['name'] = __('Type');
     $tab[31]['massiveaction'] = false;
     $tab[31]['searchtype'] = array('equals', 'notequals');
     $tab[31]['searchequalsonfield'] = true;
     $tab[31]['joinparams'] = array('jointype' => 'child');
     $tab[31]['datatype'] = 'specific';
     $tab[60]['table'] = 'glpi_ticketsatisfactions';
     $tab[60]['field'] = 'date_begin';
     $tab[60]['name'] = __('Creation date');
     $tab[60]['datatype'] = 'datetime';
     $tab[60]['massiveaction'] = false;
     $tab[60]['joinparams'] = array('jointype' => 'child');
     $tab[61]['table'] = 'glpi_ticketsatisfactions';
     $tab[61]['field'] = 'date_answered';
     $tab[61]['name'] = __('Response date');
     $tab[61]['datatype'] = 'datetime';
     $tab[61]['massiveaction'] = false;
     $tab[61]['joinparams'] = array('jointype' => 'child');
     $tab[62]['table'] = 'glpi_ticketsatisfactions';
     $tab[62]['field'] = 'satisfaction';
     $tab[62]['name'] = __('Satisfaction');
     $tab[62]['datatype'] = 'number';
     $tab[62]['massiveaction'] = false;
     $tab[62]['joinparams'] = array('jointype' => 'child');
     $tab[63]['table'] = 'glpi_ticketsatisfactions';
     $tab[63]['field'] = 'comment';
     $tab[63]['name'] = __('Comments');
     $tab[63]['datatype'] = 'text';
     $tab[63]['massiveaction'] = false;
     $tab[63]['joinparams'] = array('jointype' => 'child');
     $tab['followup'] = _n('Followup', 'Followups', Session::getPluralNumber());
     $followup_condition = '';
     if (!Session::haveRight('followup', TicketFollowup::SEEPRIVATE)) {
         $followup_condition = "AND (`NEWTABLE`.`is_private` = '0'\n                                     OR `NEWTABLE`.`users_id` = '" . Session::getLoginUserID() . "')";
     }
     $tab[25]['table'] = 'glpi_ticketfollowups';
     $tab[25]['field'] = 'content';
     $tab[25]['name'] = __('Description');
     $tab[25]['forcegroupby'] = true;
     $tab[25]['splititems'] = true;
     $tab[25]['massiveaction'] = false;
     $tab[25]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[25]['datatype'] = 'text';
     $tab[36]['table'] = 'glpi_ticketfollowups';
     $tab[36]['field'] = 'date';
     $tab[36]['name'] = __('Date');
     $tab[36]['datatype'] = 'datetime';
     $tab[36]['massiveaction'] = false;
     $tab[36]['forcegroupby'] = true;
     $tab[36]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[27]['table'] = 'glpi_ticketfollowups';
     $tab[27]['field'] = 'id';
     $tab[27]['name'] = _x('quantity', 'Number of followups');
     $tab[27]['forcegroupby'] = true;
     $tab[27]['usehaving'] = true;
     $tab[27]['datatype'] = 'count';
     $tab[27]['massiveaction'] = false;
     $tab[27]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[29]['table'] = 'glpi_requesttypes';
     $tab[29]['field'] = 'name';
     $tab[29]['name'] = __('Request source');
     $tab[29]['datatype'] = 'dropdown';
     $tab[29]['forcegroupby'] = true;
     $tab[29]['massiveaction'] = false;
     $tab[29]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketfollowups', 'joinparams' => array('jointype' => 'child', 'condition' => $followup_condition)));
     $tab[91]['table'] = 'glpi_ticketfollowups';
     $tab[91]['field'] = 'is_private';
     $tab[91]['name'] = __('Private followup');
     $tab[91]['datatype'] = 'bool';
     $tab[91]['forcegroupby'] = true;
     $tab[91]['splititems'] = true;
     $tab[91]['massiveaction'] = false;
     $tab[91]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[93]['table'] = 'glpi_users';
     $tab[93]['field'] = 'name';
     $tab[93]['name'] = __('Writer');
     $tab[93]['datatype'] = 'itemlink';
     $tab[93]['right'] = 'all';
     $tab[93]['forcegroupby'] = true;
     $tab[93]['massiveaction'] = false;
     $tab[93]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketfollowups', 'joinparams' => array('jointype' => 'child', 'condition' => $followup_condition)));
     $tab += $this->getSearchOptionsStats();
     $tab[150]['table'] = $this->getTable();
     $tab[150]['field'] = 'takeintoaccount_delay_stat';
     $tab[150]['name'] = __('Take into account time');
     $tab[150]['datatype'] = 'timestamp';
     $tab[150]['forcegroupby'] = true;
     $tab[150]['massiveaction'] = false;
     if (Session::haveRightsOr(self::$rightname, array(self::READALL, self::READASSIGN, self::OWN))) {
         $tab['linktickets'] = _n('Linked ticket', 'Linked tickets', Session::getPluralNumber());
         $tab[40]['table'] = 'glpi_tickets_tickets';
         $tab[40]['field'] = 'tickets_id_1';
         $tab[40]['name'] = __('All linked tickets');
         $tab[40]['massiveaction'] = false;
         $tab[40]['forcegroupby'] = true;
         $tab[40]['searchtype'] = 'equals';
         $tab[40]['joinparams'] = array('jointype' => 'item_item');
         $tab[40]['additionalfields'] = array('tickets_id_2');
         $tab[47]['table'] = 'glpi_tickets_tickets';
         $tab[47]['field'] = 'tickets_id_1';
         $tab[47]['name'] = __('Duplicated tickets');
         $tab[47]['massiveaction'] = false;
         $tab[47]['searchtype'] = 'equals';
         $tab[47]['joinparams'] = array('jointype' => 'item_item', 'condition' => "AND NEWTABLE.`link` = " . Ticket_Ticket::DUPLICATE_WITH);
         $tab[47]['additionalfields'] = array('tickets_id_2');
         $tab[47]['forcegroupby'] = true;
         $tab[41]['table'] = 'glpi_tickets_tickets';
         $tab[41]['field'] = 'id';
         $tab[41]['name'] = __('Number of all linked tickets');
         $tab[41]['massiveaction'] = false;
         $tab[41]['datatype'] = 'count';
         $tab[41]['usehaving'] = true;
         $tab[41]['joinparams'] = array('jointype' => 'item_item');
         $tab[46]['table'] = 'glpi_tickets_tickets';
         $tab[46]['field'] = 'id';
         $tab[46]['name'] = __('Number of duplicated tickets');
         $tab[46]['massiveaction'] = false;
         $tab[46]['datatype'] = 'count';
         $tab[46]['usehaving'] = true;
         $tab[46]['joinparams'] = array('jointype' => 'item_item', 'condition' => "AND NEWTABLE.`link` = " . Ticket_Ticket::DUPLICATE_WITH);
         $tab += TicketTask::getSearchOptionsToAdd();
         $tab += $this->getSearchOptionsSolution();
         if (Session::haveRight('ticketcost', READ)) {
             $tab += TicketCost::getSearchOptionsToAdd();
         }
         $tab['problem'] = Problem::getTypeName(Session::getPluralNumber());
         $tab[141]['table'] = 'glpi_problems_tickets';
         $tab[141]['field'] = 'id';
         $tab[141]['name'] = _x('quantity', 'Number of problems');
         $tab[141]['forcegroupby'] = true;
         $tab[141]['usehaving'] = true;
         $tab[141]['datatype'] = 'count';
         $tab[141]['massiveaction'] = false;
         $tab[141]['joinparams'] = array('jointype' => 'child');
     }
     // Filter search fields for helpdesk
     if (!Session::isCron() && (!isset($_SESSION['glpiactiveprofile']['interface']) || $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk')) {
         $tokeep = array('common', 'requester', 'satisfaction');
         if (Session::haveRightsOr('ticketvalidation', array_merge(TicketValidation::getValidateRights(), TicketValidation::getCreateRights()))) {
             $tokeep[] = 'validation';
         }
         $keep = false;
         foreach ($tab as $key => $val) {
             if (!is_array($val)) {
                 $keep = in_array($key, $tokeep);
             }
             if (!$keep) {
                 if (is_array($val)) {
                     $tab[$key]['nosearch'] = true;
                 }
             }
         }
         // last updater no search
         $tab[64]['nosearch'] = true;
     }
     return $tab;
 }
Esempio n. 18
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.83
*/
if (!defined('GLPI_ROOT')) {
    include '../inc/includes.php';
}
$link = new Problem_User();
$item = new Problem();
Session::checkLoginUser();
Html::popHeader(__('Email followup'), $_SERVER['PHP_SELF']);
if (isset($_POST["update"])) {
    $link->check($_POST["id"], UPDATE);
    $link->update($_POST);
} else {
    if (isset($_POST['delete'])) {
        $link->check($_POST['id'], DELETE);
        $link->delete($_POST);
        Event::log($link->fields['problems_id'], "problem", 4, "maintain", sprintf(__('%s deletes an actor'), $_SESSION["glpiname"]));
        if ($item->can($link->fields["problems_id"], READ)) {
            Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $link->fields['problems_id']);
        }
        Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this item'), true, ERROR);
        Html::redirect($CFG_GLPI["root_doc"] . "/front/problem.php");
Esempio n. 19
0
<?php

try {
    include "problemdata.php";
    $database = new Problem();
    $result = $database->checkAnswer($_POST["problem_no"] * 1, $_POST["answer"]);
    $checkpast = $database->checkRepeatSolve($_POST["user_id"], $_POST["problem_no"] * 1);
    $ret = "problem.php?case=" . $_POST["case"] * 1;
    if ($result == 'good') {
        if ($_POST["user_id"] != 'null' && $checkpast == 0) {
            $database->insertAnswer($_POST["user_id"], $_POST["problem_no"] * 1, $_POST["answer"], 1);
        } else {
        }
        ?>
<script> alert("정답");location.replace("<?php 
        echo $ret;
        ?>
")</script><?php 
    } else {
        if ($_POST["user_id"] != 'null' && $checkpast == 0) {
            $database->insertAnswer($_POST["user_id"], $_POST["problem_no"] * 1, $_POST["answer"], 0);
        } else {
        }
        ?>
<script> alert("틀렸어");location.replace("<?php 
        echo $ret;
        ?>
")</script><?php 
    }
} catch (Exception $e) {
    header("Loaction:error.php");
Esempio n. 20
0
require_once "api.php";
if (!$app->user->isLogin()) {
    die('<center><a href=\'admin/status.php?action=login&url=../index.php\'>Please login or register first!</a></center>');
}
require_once "classes/Problem.php";
$start = $app->setting->get("startTime", time() + 10);
if ($start > time()) {
    die('<center><h1><a href="index.php" style="color: #000000;">Contest not start !</a></h1></center></body></html>');
}
$end = $app->setting->get("endTime", time() + 10);
if ($end < time()) {
    die('<center><h1><a href="index.php" style="color: #000000;">Contest have finished !</a></h1></center></body></html>');
}
$db = new MySQL();
$info = $db->from("Problem")->where("`id` = '" . $_GET['id'] . "'")->select()->fetch_one();
$pro = new Problem($info['pid'], $info['oj']);
if (isset($_POST['lang']) && isset($_POST['code'])) {
    if (isset($_SESSION['lasttime'])) {
        if (time() - intval($_SESSION['lasttime']) < 10) {
            die('<center><a href=\'index.php\'>Please submit 10s later !</a></center>');
        }
    }
    $_SESSION['lasttime'] = time();
    $pro->submitCode($_POST['lang'], $_POST['code']);
    header("Location: result.php?id=" . $_SESSION['last_id']);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php 
Esempio n. 21
0
 function getSearchOptions()
 {
     $tab = array();
     $tab['common'] = __('Characteristics');
     $tab[1]['table'] = $this->getTable();
     $tab[1]['field'] = 'name';
     $tab[1]['name'] = __('Title');
     $tab[1]['searchtype'] = 'contains';
     $tab[1]['datatype'] = 'itemlink';
     $tab[1]['massiveaction'] = false;
     $tab[21]['table'] = $this->getTable();
     $tab[21]['field'] = 'content';
     $tab[21]['name'] = __('Description');
     $tab[21]['massiveaction'] = false;
     $tab[21]['datatype'] = 'text';
     $tab[2]['table'] = $this->getTable();
     $tab[2]['field'] = 'id';
     $tab[2]['name'] = __('ID');
     $tab[2]['massiveaction'] = false;
     $tab[2]['datatype'] = 'number';
     $tab[12]['table'] = $this->getTable();
     $tab[12]['field'] = 'status';
     $tab[12]['name'] = __('Status');
     $tab[12]['searchtype'] = 'equals';
     $tab[12]['datatype'] = 'specific';
     $tab[14]['table'] = $this->getTable();
     $tab[14]['field'] = 'type';
     $tab[14]['name'] = __('Type');
     $tab[14]['searchtype'] = 'equals';
     $tab[14]['datatype'] = 'specific';
     $tab[10]['table'] = $this->getTable();
     $tab[10]['field'] = 'urgency';
     $tab[10]['name'] = __('Urgency');
     $tab[10]['searchtype'] = 'equals';
     $tab[10]['datatype'] = 'specific';
     $tab[11]['table'] = $this->getTable();
     $tab[11]['field'] = 'impact';
     $tab[11]['name'] = __('Impact');
     $tab[11]['searchtype'] = 'equals';
     $tab[11]['datatype'] = 'specific';
     $tab[3]['table'] = $this->getTable();
     $tab[3]['field'] = 'priority';
     $tab[3]['name'] = __('Priority');
     $tab[3]['searchtype'] = 'equals';
     $tab[3]['datatype'] = 'specific';
     $tab[15]['table'] = $this->getTable();
     $tab[15]['field'] = 'date';
     $tab[15]['name'] = __('Opening date');
     $tab[15]['datatype'] = 'datetime';
     $tab[15]['massiveaction'] = false;
     $tab[16]['table'] = $this->getTable();
     $tab[16]['field'] = 'closedate';
     $tab[16]['name'] = __('Closing date');
     $tab[16]['datatype'] = 'datetime';
     $tab[16]['massiveaction'] = false;
     $tab[18]['table'] = $this->getTable();
     $tab[18]['field'] = 'due_date';
     $tab[18]['name'] = __('Due date');
     $tab[18]['datatype'] = 'datetime';
     $tab[18]['maybefuture'] = true;
     $tab[18]['massiveaction'] = false;
     $tab[151]['table'] = $this->getTable();
     $tab[151]['field'] = 'due_date';
     $tab[151]['name'] = __('Due date + Progress');
     $tab[151]['massiveaction'] = false;
     $tab[151]['nosearch'] = true;
     $tab[82]['table'] = $this->getTable();
     $tab[82]['field'] = 'is_late';
     $tab[82]['name'] = __('Late');
     $tab[82]['datatype'] = 'bool';
     $tab[82]['massiveaction'] = false;
     $tab[17]['table'] = $this->getTable();
     $tab[17]['field'] = 'solvedate';
     $tab[17]['name'] = __('Resolution date');
     $tab[17]['datatype'] = 'datetime';
     $tab[17]['massiveaction'] = false;
     $tab[19]['table'] = $this->getTable();
     $tab[19]['field'] = 'date_mod';
     $tab[19]['name'] = __('Last update');
     $tab[19]['datatype'] = 'datetime';
     $tab[19]['massiveaction'] = false;
     $tab[7]['table'] = 'glpi_itilcategories';
     $tab[7]['field'] = 'completename';
     $tab[7]['name'] = __('Category');
     $tab[7]['datatype'] = 'dropdown';
     if (!Session::isCron() && isset($_SESSION['glpiactiveprofile']['interface']) && $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
         $tab[7]['condition'] = "`is_helpdeskvisible`='1'";
     }
     $tab[13]['table'] = $this->getTable();
     $tab[13]['field'] = 'items_id';
     $tab[13]['name'] = __('Associated element');
     $tab[13]['datatype'] = 'specific';
     $tab[13]['nosearch'] = true;
     $tab[13]['nosort'] = true;
     $tab[13]['massiveaction'] = false;
     $tab[13]['additionalfields'] = array('itemtype');
     $tab[131]['table'] = $this->getTable();
     $tab[131]['field'] = 'itemtype';
     $tab[131]['name'] = __('Associated item type');
     $tab[131]['datatype'] = 'itemtypename';
     $tab[131]['itemtype_list'] = 'ticket_types';
     $tab[131]['nosort'] = true;
     $tab[131]['massiveaction'] = false;
     $tab[9]['table'] = 'glpi_requesttypes';
     $tab[9]['field'] = 'name';
     $tab[9]['name'] = __('Request source');
     $tab[9]['datatype'] = 'dropdown';
     // Can't use Location::getSearchOptionsToAdd because id conflicts
     $tab[83]['table'] = 'glpi_locations';
     $tab[83]['field'] = 'completename';
     $tab[83]['name'] = __('Location');
     $tab[83]['datatype'] = 'dropdown';
     $tab[80]['table'] = 'glpi_entities';
     $tab[80]['field'] = 'completename';
     $tab[80]['name'] = __('Entity');
     $tab[80]['massiveaction'] = false;
     $tab[80]['datatype'] = 'dropdown';
     $tab[45]['table'] = $this->getTable();
     $tab[45]['field'] = 'actiontime';
     $tab[45]['name'] = __('Total duration');
     $tab[45]['datatype'] = 'timestamp';
     $tab[45]['withdays'] = false;
     $tab[45]['massiveaction'] = false;
     $tab[45]['nosearch'] = true;
     $tab[64]['table'] = 'glpi_users';
     $tab[64]['field'] = 'name';
     $tab[64]['linkfield'] = 'users_id_lastupdater';
     $tab[64]['name'] = __('Last updater');
     $tab[64]['massiveaction'] = false;
     $tab[64]['datatype'] = 'dropdown';
     $tab[64]['right'] = 'all';
     $tab += $this->getSearchOptionsActors();
     $tab['sla'] = __('SLA');
     $tab[30]['table'] = 'glpi_slas';
     $tab[30]['field'] = 'name';
     $tab[30]['name'] = __('SLA');
     $tab[30]['massiveaction'] = false;
     $tab[30]['datatype'] = 'dropdown';
     $tab[32]['table'] = 'glpi_slalevels';
     $tab[32]['field'] = 'name';
     $tab[32]['name'] = __('Escalation level');
     $tab[32]['massiveaction'] = false;
     $tab[32]['datatype'] = 'dropdown';
     $tab['validation'] = __('Approval');
     $tab[52]['table'] = $this->getTable();
     $tab[52]['field'] = 'global_validation';
     $tab[52]['name'] = __('Approval');
     $tab[52]['searchtype'] = 'equals';
     $tab[52]['datatype'] = 'specific';
     $tab[53]['table'] = 'glpi_ticketvalidations';
     $tab[53]['field'] = 'comment_submission';
     $tab[53]['name'] = sprintf(__('%1$s: %2$s'), __('Request'), __('Comments'));
     $tab[53]['datatype'] = 'text';
     $tab[53]['forcegroupby'] = true;
     $tab[53]['massiveaction'] = false;
     $tab[53]['joinparams'] = array('jointype' => 'child');
     $tab[54]['table'] = 'glpi_ticketvalidations';
     $tab[54]['field'] = 'comment_validation';
     $tab[54]['name'] = sprintf(__('%1$s: %2$s'), __('Approval'), __('Comments'));
     $tab[54]['datatype'] = 'text';
     $tab[54]['forcegroupby'] = true;
     $tab[54]['massiveaction'] = false;
     $tab[54]['joinparams'] = array('jointype' => 'child');
     $tab[55]['table'] = 'glpi_ticketvalidations';
     $tab[55]['field'] = 'status';
     $tab[55]['datatype'] = 'specific';
     $tab[55]['name'] = sprintf(__('%1$s: %2$s'), __('Approval'), __('Status'));
     $tab[55]['searchtype'] = 'equals';
     $tab[55]['forcegroupby'] = true;
     $tab[55]['massiveaction'] = false;
     $tab[55]['joinparams'] = array('jointype' => 'child');
     $tab[56]['table'] = 'glpi_ticketvalidations';
     $tab[56]['field'] = 'submission_date';
     $tab[56]['name'] = sprintf(__('%1$s: %2$s'), __('Request'), __('Date'));
     $tab[56]['datatype'] = 'datetime';
     $tab[56]['forcegroupby'] = true;
     $tab[56]['massiveaction'] = false;
     $tab[56]['joinparams'] = array('jointype' => 'child');
     $tab[57]['table'] = 'glpi_ticketvalidations';
     $tab[57]['field'] = 'validation_date';
     $tab[57]['name'] = sprintf(__('%1$s: %2$s'), __('Approval'), __('Date'));
     $tab[57]['datatype'] = 'datetime';
     $tab[57]['forcegroupby'] = true;
     $tab[57]['massiveaction'] = false;
     $tab[57]['joinparams'] = array('jointype' => 'child');
     $tab[58]['table'] = 'glpi_users';
     $tab[58]['field'] = 'name';
     $tab[58]['name'] = __('Requester');
     $tab[58]['datatype'] = 'itemlink';
     $tab[58]['right'] = array('create_incident_validation', 'create_request_validation');
     $tab[58]['forcegroupby'] = true;
     $tab[58]['massiveaction'] = false;
     $tab[58]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketvalidations', 'joinparams' => array('jointype' => 'child')));
     $tab[59]['table'] = 'glpi_users';
     $tab[59]['field'] = 'name';
     $tab[59]['linkfield'] = 'users_id_validate';
     $tab[59]['name'] = __('Approver');
     $tab[59]['datatype'] = 'itemlink';
     $tab[59]['right'] = array('validate_request', 'validate_incident');
     $tab[59]['forcegroupby'] = true;
     $tab[59]['massiveaction'] = false;
     $tab[59]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketvalidations', 'joinparams' => array('jointype' => 'child')));
     $tab['satisfaction'] = __('Satisfaction survey');
     $tab[31]['table'] = 'glpi_ticketsatisfactions';
     $tab[31]['field'] = 'type';
     $tab[31]['name'] = __('Type');
     $tab[31]['massiveaction'] = false;
     $tab[31]['searchtype'] = 'equals';
     $tab[31]['joinparams'] = array('jointype' => 'child');
     $tab[31]['datatype'] = 'specific';
     $tab[60]['table'] = 'glpi_ticketsatisfactions';
     $tab[60]['field'] = 'date_begin';
     $tab[60]['name'] = __('Creation date');
     $tab[60]['datatype'] = 'datetime';
     $tab[60]['massiveaction'] = false;
     $tab[60]['joinparams'] = array('jointype' => 'child');
     $tab[61]['table'] = 'glpi_ticketsatisfactions';
     $tab[61]['field'] = 'date_answered';
     $tab[61]['name'] = __('Response date');
     $tab[61]['datatype'] = 'datetime';
     $tab[61]['massiveaction'] = false;
     $tab[61]['joinparams'] = array('jointype' => 'child');
     $tab[62]['table'] = 'glpi_ticketsatisfactions';
     $tab[62]['field'] = 'satisfaction';
     $tab[62]['name'] = __('Satisfaction');
     $tab[62]['datatype'] = 'number';
     $tab[62]['massiveaction'] = false;
     $tab[62]['joinparams'] = array('jointype' => 'child');
     $tab[63]['table'] = 'glpi_ticketsatisfactions';
     $tab[63]['field'] = 'comment';
     $tab[63]['name'] = __('Comments');
     $tab[63]['datatype'] = 'text';
     $tab[63]['massiveaction'] = false;
     $tab[63]['joinparams'] = array('jointype' => 'child');
     $tab['followup'] = _n('Followup', 'Followups', 2);
     $followup_condition = '';
     if (!Session::haveRight('show_full_ticket', 1)) {
         $followup_condition = "AND (`NEWTABLE`.`is_private` = '0'\n                                     OR `NEWTABLE`.`users_id` = '" . Session::getLoginUserID() . "')";
     }
     $tab[25]['table'] = 'glpi_ticketfollowups';
     $tab[25]['field'] = 'content';
     $tab[25]['name'] = __('Description');
     $tab[25]['forcegroupby'] = true;
     $tab[25]['splititems'] = true;
     $tab[25]['massiveaction'] = false;
     $tab[25]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[25]['datatype'] = 'text';
     $tab[27]['table'] = 'glpi_ticketfollowups';
     $tab[27]['field'] = 'count';
     $tab[27]['name'] = __('Number of followups');
     $tab[27]['forcegroupby'] = true;
     $tab[27]['usehaving'] = true;
     $tab[27]['datatype'] = 'number';
     $tab[27]['massiveaction'] = false;
     $tab[27]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[29]['table'] = 'glpi_requesttypes';
     $tab[29]['field'] = 'name';
     $tab[29]['name'] = __('Request source');
     $tab[29]['datatype'] = 'dropdown';
     $tab[29]['forcegroupby'] = true;
     $tab[29]['massiveaction'] = false;
     $tab[29]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketfollowups', 'joinparams' => array('jointype' => 'child', 'condition' => $followup_condition)));
     $tab[91]['table'] = 'glpi_ticketfollowups';
     $tab[91]['field'] = 'is_private';
     $tab[91]['name'] = __('Private followup');
     $tab[91]['datatype'] = 'bool';
     $tab[91]['forcegroupby'] = true;
     $tab[91]['splititems'] = true;
     $tab[91]['massiveaction'] = false;
     $tab[91]['joinparams'] = array('jointype' => 'child', 'condition' => $followup_condition);
     $tab[93]['table'] = 'glpi_users';
     $tab[93]['field'] = 'name';
     $tab[93]['name'] = __('Writer');
     $tab[93]['datatype'] = 'itemlink';
     $tab[93]['right'] = 'all';
     $tab[93]['forcegroupby'] = true;
     $tab[93]['massiveaction'] = false;
     $tab[93]['joinparams'] = array('beforejoin' => array('table' => 'glpi_ticketfollowups', 'joinparams' => array('jointype' => 'child', 'condition' => $followup_condition)));
     $tab += $this->getSearchOptionsStats();
     $tab[150]['table'] = $this->getTable();
     $tab[150]['field'] = 'takeintoaccount_delay_stat';
     $tab[150]['name'] = __('Take into account time');
     $tab[150]['datatype'] = 'timestamp';
     $tab[150]['forcegroupby'] = true;
     $tab[150]['massiveaction'] = false;
     if (Session::haveRight("show_all_ticket", "1") || Session::haveRight("show_assign_ticket", "1") || Session::haveRight("own_ticket", "1")) {
         $tab['linktickets'] = _n('Linked ticket', 'Linked tickets', 2);
         $tab[40]['table'] = 'glpi_tickets';
         $tab[40]['field'] = 'name';
         $tab[40]['name'] = __('All linked tickets');
         $tab[40]['massiveaction'] = false;
         $tab[40]['joinparams'] = array('jointype' => 'item_item_revert', 'condition' => "AND NEWTABLE.`id` <> `glpi_tickets`.`id`", 'beforejoin' => array('table' => 'glpi_tickets_tickets', 'joinparams' => array('jointype' => 'item_item')));
         $tab[40]['datatype'] = 'dropdown';
         $tab[40]['forcegroupby'] = true;
         $tab[47]['table'] = 'glpi_tickets';
         $tab[47]['field'] = 'name';
         $tab[47]['name'] = __('Duplicated tickets');
         $tab[47]['massiveaction'] = false;
         $tab[47]['joinparams'] = array('jointype' => 'item_item_revert', 'condition' => "AND NEWTABLE.`id` <> `glpi_tickets`.`id`", 'beforejoin' => array('table' => 'glpi_tickets_tickets', 'joinparams' => array('jointype' => 'item_item', 'condition' => "AND NEWTABLE.`link` = " . Ticket_Ticket::DUPLICATE_WITH)));
         $tab[47]['datatype'] = 'dropdown';
         $tab[47]['forcegroupby'] = true;
         $tab[41]['table'] = 'glpi_tickets_tickets';
         $tab[41]['field'] = 'count';
         $tab[41]['name'] = __('Number of all linked tickets');
         $tab[41]['massiveaction'] = false;
         $tab[41]['datatype'] = 'number';
         $tab[41]['usehaving'] = true;
         $tab[41]['joinparams'] = array('jointype' => 'item_item');
         $tab[46]['table'] = 'glpi_tickets_tickets';
         $tab[46]['field'] = 'count';
         $tab[46]['name'] = __('Number of duplicated tickets');
         $tab[46]['massiveaction'] = false;
         $tab[46]['datatype'] = 'number';
         $tab[46]['usehaving'] = true;
         $tab[46]['joinparams'] = array('jointype' => 'item_item', 'condition' => "AND NEWTABLE.`link` = " . Ticket_Ticket::DUPLICATE_WITH);
         $tab['task'] = _n('Task', 'Tasks', 2);
         $tab[26]['table'] = 'glpi_tickettasks';
         $tab[26]['field'] = 'content';
         $tab[26]['name'] = __('Description');
         $tab[26]['datatype'] = 'text';
         $tab[26]['forcegroupby'] = true;
         $tab[26]['splititems'] = true;
         $tab[26]['massiveaction'] = false;
         $tab[26]['joinparams'] = array('jointype' => 'child');
         $tab[28]['table'] = 'glpi_tickettasks';
         $tab[28]['field'] = 'count';
         $tab[28]['name'] = __('Number of tasks');
         $tab[28]['forcegroupby'] = true;
         $tab[28]['usehaving'] = true;
         $tab[28]['datatype'] = 'number';
         $tab[28]['massiveaction'] = false;
         $tab[28]['joinparams'] = array('jointype' => 'child');
         $tab[20]['table'] = 'glpi_taskcategories';
         $tab[20]['field'] = 'name';
         $tab[20]['datatype'] = 'dropdown';
         $tab[20]['name'] = __('Task category');
         $tab[20]['forcegroupby'] = true;
         $tab[20]['splititems'] = true;
         $tab[20]['massiveaction'] = false;
         $tab[20]['joinparams'] = array('beforejoin' => array('table' => 'glpi_tickettasks', 'joinparams' => array('jointype' => 'child')));
         $tab[92]['table'] = 'glpi_tickettasks';
         $tab[92]['field'] = 'is_private';
         $tab[92]['name'] = __('Private task');
         $tab[92]['datatype'] = 'bool';
         $tab[92]['forcegroupby'] = true;
         $tab[92]['splititems'] = true;
         $tab[92]['massiveaction'] = false;
         $tab[92]['joinparams'] = array('jointype' => 'child');
         $tab[94]['table'] = 'glpi_users';
         $tab[94]['field'] = 'name';
         $tab[94]['name'] = __('Writer');
         $tab[94]['datatype'] = 'itemlink';
         $tab[94]['right'] = 'all';
         $tab[94]['forcegroupby'] = true;
         $tab[94]['massiveaction'] = false;
         $tab[94]['joinparams'] = array('beforejoin' => array('table' => 'glpi_tickettasks', 'joinparams' => array('jointype' => 'child')));
         $tab[95]['table'] = 'glpi_users';
         $tab[95]['field'] = 'name';
         $tab[95]['linkfield'] = 'users_id_tech';
         $tab[95]['name'] = __('Technician');
         $tab[95]['datatype'] = 'itemlink';
         $tab[95]['right'] = 'own_ticket';
         $tab[95]['forcegroupby'] = true;
         $tab[95]['massiveaction'] = false;
         $tab[95]['joinparams'] = array('beforejoin' => array('table' => 'glpi_tickettasks', 'joinparams' => array('jointype' => 'child')));
         $tab[96]['table'] = 'glpi_tickettasks';
         $tab[96]['field'] = 'actiontime';
         $tab[96]['name'] = __('Duration');
         $tab[96]['datatype'] = 'timestamp';
         $tab[96]['massiveaction'] = false;
         $tab[96]['joinparams'] = array('jointype' => 'child');
         $tab[97]['table'] = 'glpi_tickettasks';
         $tab[97]['field'] = 'date';
         $tab[97]['name'] = __('Date');
         $tab[97]['datatype'] = 'datetime';
         $tab[97]['massiveaction'] = false;
         $tab[97]['joinparams'] = array('jointype' => 'child');
         $tab['solution'] = _n('Solution', 'Solutions', 1);
         $tab[23]['table'] = 'glpi_solutiontypes';
         $tab[23]['field'] = 'name';
         $tab[23]['name'] = __('Solution type');
         $tab[23]['datatype'] = 'dropdown';
         $tab[24]['table'] = $this->getTable();
         $tab[24]['field'] = 'solution';
         $tab[24]['name'] = _n('Solution', 'Solutions', 1);
         $tab[24]['datatype'] = 'text';
         $tab[24]['htmltext'] = true;
         $tab[24]['massiveaction'] = false;
         $tab['cost'] = __('Cost');
         $tab[48]['table'] = 'glpi_ticketcosts';
         $tab[48]['field'] = 'totalcost';
         $tab[48]['name'] = __('Total cost');
         $tab[48]['datatype'] = 'decimal';
         $tab[48]['forcegroupby'] = true;
         $tab[48]['usehaving'] = true;
         $tab[48]['massiveaction'] = false;
         $tab[48]['joinparams'] = array('jointype' => 'child');
         $tab[42]['table'] = 'glpi_ticketcosts';
         $tab[42]['field'] = 'cost_time';
         $tab[42]['name'] = __('Time cost');
         $tab[42]['datatype'] = 'decimal';
         $tab[42]['forcegroupby'] = true;
         $tab[42]['massiveaction'] = false;
         $tab[42]['joinparams'] = array('jointype' => 'child');
         $tab[49]['table'] = 'glpi_ticketcosts';
         $tab[49]['field'] = 'actiontime';
         $tab[49]['name'] = sprintf(__('%1$s - %2$s'), __('Cost'), __('Duration'));
         $tab[49]['datatype'] = 'timestamp';
         $tab[49]['forcegroupby'] = true;
         $tab[49]['massiveaction'] = false;
         $tab[49]['joinparams'] = array('jointype' => 'child');
         $tab[43]['table'] = 'glpi_ticketcosts';
         $tab[43]['field'] = 'cost_fixed';
         $tab[43]['name'] = __('Fixed cost');
         $tab[43]['datatype'] = 'decimal';
         $tab[43]['forcegroupby'] = true;
         $tab[43]['massiveaction'] = false;
         $tab[43]['joinparams'] = array('jointype' => 'child');
         $tab[44]['table'] = 'glpi_ticketcosts';
         $tab[44]['field'] = 'cost_material';
         $tab[44]['name'] = __('Material cost');
         $tab[44]['datatype'] = 'decimal';
         $tab[44]['forcegroupby'] = true;
         $tab[44]['massiveaction'] = false;
         $tab[44]['joinparams'] = array('jointype' => 'child');
         $tab['problem'] = Problem::getTypeName(2);
         $tab[141]['table'] = 'glpi_problems_tickets';
         $tab[141]['field'] = 'count';
         $tab[141]['name'] = __('Number of problems');
         $tab[141]['forcegroupby'] = true;
         $tab[141]['usehaving'] = true;
         $tab[141]['datatype'] = 'number';
         $tab[141]['massiveaction'] = false;
         $tab[141]['joinparams'] = array('jointype' => 'child');
     }
     // Filter search fields for helpdesk
     if (!Session::isCron() && (!isset($_SESSION['glpiactiveprofile']['interface']) || $_SESSION['glpiactiveprofile']['interface'] == 'helpdesk')) {
         $tokeep = array('common', 'requester');
         if (Session::haveRight('validate_request', 1) || Session::haveRight('validate_incident', 1) || Session::haveRight('create_incident_validation', 1) || Session::haveRight('create_request_validation', 1)) {
             $tokeep[] = 'validation';
         }
         $keep = false;
         foreach ($tab as $key => $val) {
             if (!is_array($val)) {
                 $keep = in_array($key, $tokeep);
             }
             if (!$keep) {
                 if (is_array($val)) {
                     $tab[$key]['nosearch'] = true;
                 }
             }
         }
         // last updater no search
         $tab[64]['nosearch'] = true;
     }
     return $tab;
 }
Esempio n. 22
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../inc/includes.php';
if (empty($_GET["id"])) {
    $_GET["id"] = '';
}
Session::checkLoginUser();
$problem = new Problem();
if (isset($_POST["add"])) {
    $problem->check(-1, 'w', $_POST);
    $newID = $problem->add($_POST);
    Event::log($newID, "problem", 4, "maintain", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $problem->check($_POST["id"], 'd');
        $problem->delete($_POST);
        Event::log($_POST["id"], "problem", 4, "maintain", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $problem->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $problem->check($_POST["id"], 'd');
            $problem->restore($_POST);
Esempio n. 23
0
require_once "api.php";
if (!$app->user->isLogin()) {
    die('<center><a href=\'admin/status.php?action=login&url=../index.php\'>Please login or register first!</a></center>');
}
if ($app->user->getPower() != 0) {
    die('<center><a href=\'admin/status.php?action=login&url=../index.php\'>Please login or register first!</a></center>');
}
if (isset($_GET['action'])) {
    if ($_GET['action'] == "delete") {
        $db = new MySQL();
        $db->from("Problem")->where("`id`='" . intval($_GET['id']) . "'")->delete();
    }
}
if (isset($_POST['submit'])) {
    require_once "classes/Problem.php";
    $pro = new Problem($_POST['pid'], $_POST['oj']);
    $pro_info = $pro->getInfo();
    $db = new MySQL();
    $num = $db->from("Problem")->select("max(cast(id as signed))")->fetch_one();
    //Just a hack for PHP <= 5.3
    $db->value(array('id' => intval($num['max(cast(id as signed))']) + 1, 'pid' => $_POST['pid'], 'title' => get_magic_quotes_gpc() ? $pro_info['title'] : addslashes($pro_info['title']), 'oj' => $_POST['oj']))->insert("Problem");
    $alert = "Problem " . $pro_info['title'] . " added !";
}
if (isset($_POST['time'])) {
    $app->setting->set("startTime", strtotime($_POST['stime']));
    $app->setting->set("endTime", strtotime($_POST['etime']));
    $alert = "Start at " . $_POST['stime'] . " and end at " . $_POST['etime'];
}
if (isset($_POST['clean'])) {
    $db = new MySQL();
    $db->from("Problem")->delete();
Esempio n. 24
0
<?php

include_once 'functions/problems.php';
$pid = convert_str($_GET['pid']);
if ($pid == "") {
    $pid = "0";
}
$show_problem = new Problem();
$show_problem->set_problem($pid);
if ($show_problem->is_valid() && $show_problem->get_val("hide") == 0) {
    $pagetitle = "Statistics of Problem " . $pid;
} else {
    $pagetitle = "Problem Unavailable";
}
include_once "header.php";
include_once "functions/sidebars.php";
?>
        <div class="span8">
          <h3>Leaderboard of <a href="problem_show.php?pid=<?php 
echo $pid;
?>
">Problem <?php 
echo $pid;
?>
</a></h3>
          <table class="table table-hover table-striped" id="pleader">
            <thead>
              <tr>
                <th width="10%">Rank</th>
                <th width="10%">ACs</th>
                <th width="10%">Runid</th>
Esempio n. 25
0
 /**
  * Print the Life Cycles form for the current profile
  *
  * @param $openform   boolean  open the form (true by default)
  * @param $closeform  boolean  close the form (true by default)
  **/
 function showFormLifeCycle($openform = true, $closeform = true)
 {
     if (!self::canView()) {
         return false;
     }
     echo "<div class='spaced'>";
     if (($canedit = Session::haveRightsOr(self::$rightname, array(CREATE, UPDATE, PURGE))) && $openform) {
         echo "<form method='post' action='" . $this->getFormURL() . "'>";
     }
     $this->displayLifeCycleMatrix(__('Life cycle of tickets'), '_cycle_ticket', 'ticket_status', Ticket::getAllStatusArray(), $canedit);
     $this->displayLifeCycleMatrix(__('Life cycle of problems'), '_cycle_problem', 'problem_status', Problem::getAllStatusArray(), $canedit);
     $this->displayLifeCycleMatrix(__('Life cycle of changes'), '_cycle_change', 'change_status', Change::getAllStatusArray(), $canedit);
     if ($canedit && $closeform) {
         echo "<div class='center'>";
         echo "<input type='hidden' name='id' value='" . $this->fields['id'] . "'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</div>\n";
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $problem = Problem::findOrFail($id);
     $problem->delete();
     return redirect()->route('problems.index');
 }
 /**
  * @since version 0.84
  **/
 static function title()
 {
     global $PLUGIN_HOOKS, $CFG_GLPI;
     $opt_list["Ticket"] = __('Tickets');
     $stat_list["Ticket"]["Ticket_Global"]["name"] = __('Global');
     $stat_list["Ticket"]["Ticket_Global"]["file"] = "stat.global.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Ticket"]["name"] = __('By ticket');
     $stat_list["Ticket"]["Ticket_Ticket"]["file"] = "stat.tracking.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Location"]["name"] = __('By hardware characteristics');
     $stat_list["Ticket"]["Ticket_Location"]["file"] = "stat.location.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Item"]["name"] = __('By hardware');
     $stat_list["Ticket"]["Ticket_Item"]["file"] = "stat.item.php";
     if (Problem::canView()) {
         $opt_list["Problem"] = _n('Problem', 'Problems', Session::getPluralNumber());
         $stat_list["Problem"]["Problem_Global"]["name"] = __('Global');
         $stat_list["Problem"]["Problem_Global"]["file"] = "stat.global.php?itemtype=Problem";
         $stat_list["Problem"]["Problem_Problem"]["name"] = __('By problem');
         $stat_list["Problem"]["Problem_Problem"]["file"] = "stat.tracking.php?itemtype=Problem";
     }
     if (Change::canView()) {
         $opt_list["Change"] = _n('Change', 'Changes', Session::getPluralNumber());
         $stat_list["Change"]["Change_Global"]["name"] = __('Global');
         $stat_list["Change"]["Change_Global"]["file"] = "stat.global.php?itemtype=Change";
         $stat_list["Change"]["Change_Change"]["name"] = __('By change');
         $stat_list["Change"]["Change_Change"]["file"] = "stat.tracking.php?itemtype=Change";
     }
     //Affichage du tableau de presentation des stats
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Select statistics to be displayed') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     $values = array($CFG_GLPI["root_doc"] . '/front/stat.php' => Dropdown::EMPTY_VALUE);
     $i = 0;
     $selected = -1;
     $count = count($stat_list);
     foreach ($opt_list as $opt => $group) {
         while ($data = each($stat_list[$opt])) {
             $name = $data[1]["name"];
             $file = $data[1]["file"];
             $comment = "";
             if (isset($data[1]["comment"])) {
                 $comment = $data[1]["comment"];
             }
             $key = $CFG_GLPI["root_doc"] . "/front/" . $file;
             $values[$group][$key] = $name;
             if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
                 $selected = $key;
             }
         }
     }
     // Manage plugins
     $names = array();
     $optgroup = array();
     if (isset($PLUGIN_HOOKS["stats"]) && is_array($PLUGIN_HOOKS["stats"])) {
         foreach ($PLUGIN_HOOKS["stats"] as $plug => $pages) {
             if (is_array($pages) && count($pages)) {
                 foreach ($pages as $page => $name) {
                     $names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
                     $optgroup[$plug] = Plugin::getInfo($plug, 'name');
                 }
             }
         }
         asort($names);
     }
     foreach ($optgroup as $opt => $title) {
         $group = $title;
         foreach ($names as $key => $val) {
             if ($opt == $val["plug"]) {
                 $file = $CFG_GLPI["root_doc"] . "/plugins/" . $key;
                 $values[$group][$file] = $val["name"];
                 if (stripos($_SERVER['REQUEST_URI'], $file) !== false) {
                     $selected = $file;
                 }
             }
         }
     }
     Dropdown::showFromArray('statmenu', $values, array('on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
Esempio n. 28
0
 /**
  * Show problems for a ticket
  *
  * @param $ticket Ticket object
  **/
 static function showForTicket(Ticket $ticket)
 {
     global $DB, $CFG_GLPI;
     $ID = $ticket->getField('id');
     if (!Session::haveRight("problem", Problem::READALL) || !$ticket->can($ID, READ)) {
         return false;
     }
     $canedit = $ticket->can($ID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `glpi_problems_tickets`.`id` AS linkID,\n                                `glpi_problems`.*\n                FROM `glpi_problems_tickets`\n                LEFT JOIN `glpi_problems`\n                     ON (`glpi_problems_tickets`.`problems_id` = `glpi_problems`.`id`)\n                WHERE `glpi_problems_tickets`.`tickets_id` = '{$ID}'\n                ORDER BY `glpi_problems`.`name`";
     $result = $DB->query($query);
     $problems = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $problems[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='problemticket_form{$rand}' id='problemticket_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a problem') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td>";
         echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
         $condition = "`glpi_problems`.`status` NOT IN ('" . implode("', '", array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray())) . "')";
         Problem::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID(), 'condition' => $condition));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td><td>";
         echo "<a href='" . Toolbox::getItemTypeFormURL('Problem') . "?tickets_id={$ID}'>";
         _e('Create a problem from this ticket');
         echo "</a>";
         echo "</td></tr></table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr class='noHover'><th colspan='12'>" . Problem::getTypeName($numrows) . "</th>";
     echo "</tr>";
     if ($numrows) {
         Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
         Session::initNavigateListItems('Problem', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
         $i = 0;
         foreach ($problems as $data) {
             Session::addToNavigateListItems('Problem', $data["id"]);
             Problem::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
             $i++;
         }
         Problem::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Esempio n. 29
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     switch ($item->getType()) {
         case 'Problem':
             self::showForProblem($item);
             break;
         default:
             Problem::showListForItem($item);
     }
     return true;
 }
 /**
  * @see NotificationTargetCommonITILObject::getDatasForObject()
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI;
     // Common ITIL datas
     $datas = parent::getDatasForObject($item, $options, $simple);
     $datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
     $datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
     $datas['##ticket.content##'] = $datas['##ticket.description##'];
     // Specific datas
     $datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
     $datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
     $datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
     $datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
     $autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
     $datas['##ticket.autoclose##'] = __('Never');
     $datas['##lang.ticket.autoclosewarning##'] = "";
     if ($autoclose_value > 0) {
         $datas['##ticket.autoclose##'] = $autoclose_value;
         $datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
     }
     $datas['##ticket.sla##'] = '';
     if ($item->getField('slas_id')) {
         $datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
     }
     $datas['##ticket.location##'] = '';
     if ($item->getField('locations_id')) {
         $datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
     }
     // is ticket deleted
     $datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
     //Tags associated with the object linked to the ticket
     $datas['##ticket.itemtype##'] = '';
     $datas['##ticket.item.name##'] = '';
     $datas['##ticket.item.serial##'] = '';
     $datas['##ticket.item.otherserial##'] = '';
     $datas['##ticket.item.location##'] = '';
     $datas['##ticket.item.contact##'] = '';
     $datas['##ticket.item.contactnumber##'] = '';
     $datas['##ticket.item.user##'] = '';
     $datas['##ticket.item.group##'] = '';
     $datas['##ticket.item.model##'] = '';
     $item_ticket = new Item_Ticket();
     $items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
     $datas['items'] = array();
     if (count($items)) {
         foreach ($items as $val) {
             if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
                 $tmp = array();
                 //Object type
                 $tmp['##ticket.itemtype##'] = $hardware->getTypeName();
                 //Object name
                 $tmp['##ticket.item.name##'] = $hardware->getField('name');
                 //Object serial
                 if ($hardware->isField('serial')) {
                     $tmp['##ticket.item.serial##'] = $hardware->getField('serial');
                 }
                 //Object contact
                 if ($hardware->isField('contact')) {
                     $tmp['##ticket.item.contact##'] = $hardware->getField('contact');
                 }
                 //Object contact num
                 if ($hardware->isField('contact_num')) {
                     $tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
                 }
                 //Object otherserial
                 if ($hardware->isField('otherserial')) {
                     $tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
                 }
                 //Object location
                 if ($hardware->isField('locations_id')) {
                     $tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
                 }
                 //Object user
                 if ($hardware->getField('users_id')) {
                     $user_tmp = new User();
                     if ($user_tmp->getFromDB($hardware->getField('users_id'))) {
                         $tmp['##ticket.item.user##'] = $user_tmp->getName();
                     }
                 }
                 //Object group
                 if ($hardware->getField('groups_id')) {
                     $tmp['##ticket.item.group##'] = Dropdown::getDropdownName('glpi_groups', $hardware->getField('groups_id'));
                 }
                 $modeltable = getSingular($hardware->getTable()) . "models";
                 $modelfield = getForeignKeyFieldForTable($modeltable);
                 if ($hardware->isField($modelfield)) {
                     $tmp['##ticket.item.model##'] = Dropdown::getDropdownName($modeltable, $hardware->getField($modelfield));
                 }
                 $datas['items'][] = $tmp;
             }
         }
     }
     $datas['##ticket.numberofitems##'] = count($datas['items']);
     // Get followups, log, validation, satisfaction, linked tickets
     if (!$simple) {
         // Linked tickets
         $linked_tickets = Ticket_Ticket::getLinkedTicketsTo($item->getField('id'));
         $datas['linkedtickets'] = array();
         if (count($linked_tickets)) {
             $linkedticket = new Ticket();
             foreach ($linked_tickets as $data) {
                 if ($linkedticket->getFromDB($data['tickets_id'])) {
                     $tmp = array();
                     $tmp['##linkedticket.id##'] = $data['tickets_id'];
                     $tmp['##linkedticket.link##'] = Ticket_Ticket::getLinkName($data['link']);
                     $tmp['##linkedticket.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $data['tickets_id']);
                     $tmp['##linkedticket.title##'] = $linkedticket->getField('name');
                     $tmp['##linkedticket.content##'] = $linkedticket->getField('content');
                     $datas['linkedtickets'][] = $tmp;
                 }
             }
         }
         $datas['##ticket.numberoflinkedtickets##'] = count($datas['linkedtickets']);
         $restrict = "`tickets_id`='" . $item->getField('id') . "'";
         $problems = getAllDatasFromTable('glpi_problems_tickets', $restrict);
         $datas['problems'] = array();
         if (count($problems)) {
             $problem = new Problem();
             foreach ($problems as $data) {
                 if ($problem->getFromDB($data['problems_id'])) {
                     $tmp = array();
                     $tmp['##problem.id##'] = $data['problems_id'];
                     $tmp['##problem.date##'] = $problem->getField('date');
                     $tmp['##problem.title##'] = $problem->getField('name');
                     $tmp['##problem.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "problem_" . $data['problems_id']);
                     $tmp['##problem.content##'] = $problem->getField('content');
                     $datas['problems'][] = $tmp;
                 }
             }
         }
         $datas['##ticket.numberofproblems##'] = count($datas['problems']);
         $restrict = "`tickets_id`='" . $item->getField('id') . "'";
         $changes = getAllDatasFromTable('glpi_changes_tickets', $restrict);
         $datas['changes'] = array();
         if (count($changes)) {
             $change = new Change();
             foreach ($changes as $data) {
                 if ($change->getFromDB($data['changes_id'])) {
                     $tmp = array();
                     $tmp['##change.id##'] = $data['changes_id'];
                     $tmp['##change.date##'] = $change->getField('date');
                     $tmp['##change.title##'] = $change->getField('name');
                     $tmp['##change.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "change_" . $data['changes_id']);
                     $tmp['##change.content##'] = $change->getField('content');
                     $datas['changes'][] = $tmp;
                 }
             }
         }
         $datas['##ticket.numberofchanges##'] = count($datas['changes']);
         if (!isset($options['additionnaloption']['show_private']) || !$options['additionnaloption']['show_private']) {
             $restrict .= " AND `is_private` = '0'";
         }
         $restrict .= " ORDER BY `date` DESC, `id` ASC";
         //Followup infos
         $followups = getAllDatasFromTable('glpi_ticketfollowups', $restrict);
         $datas['followups'] = array();
         foreach ($followups as $followup) {
             $tmp = array();
             $tmp['##followup.isprivate##'] = Dropdown::getYesNo($followup['is_private']);
             $tmp['##followup.author##'] = Html::clean(getUserName($followup['users_id']));
             $tmp['##followup.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $followup['requesttypes_id']);
             $tmp['##followup.date##'] = Html::convDateTime($followup['date']);
             $tmp['##followup.description##'] = $followup['content'];
             $datas['followups'][] = $tmp;
         }
         $datas['##ticket.numberoffollowups##'] = count($datas['followups']);
         // Approbation of solution
         $restrict .= " LIMIT 1";
         $replysolved = getAllDatasFromTable('glpi_ticketfollowups', $restrict);
         $data = current($replysolved);
         $datas['##ticket.solution.approval.description##'] = $data['content'];
         $datas['##ticket.solution.approval.date##'] = Html::convDateTime($data['date']);
         $datas['##ticket.solution.approval.author##'] = Html::clean(getUserName($data['users_id']));
         //Validation infos
         $restrict = "`tickets_id`='" . $item->getField('id') . "'";
         if (isset($options['validation_id']) && $options['validation_id']) {
             $restrict .= " AND `glpi_ticketvalidations`.`id` = '" . $options['validation_id'] . "'";
         }
         $restrict .= " ORDER BY `submission_date` DESC, `id` ASC";
         $validations = getAllDatasFromTable('glpi_ticketvalidations', $restrict);
         $datas['validations'] = array();
         foreach ($validations as $validation) {
             $tmp = array();
             $tmp['##validation.submission.title##'] = sprintf(__('An approval request has been submitted by %s'), Html::clean(getUserName($validation['users_id'])));
             $tmp['##validation.answer.title##'] = sprintf(__('An answer to an an approval request was produced by %s'), Html::clean(getUserName($validation['users_id_validate'])));
             $tmp['##validation.author##'] = Html::clean(getUserName($validation['users_id']));
             $tmp['##validation.status##'] = TicketValidation::getStatus($validation['status']);
             $tmp['##validation.storestatus##'] = $validation['status'];
             $tmp['##validation.submissiondate##'] = Html::convDateTime($validation['submission_date']);
             $tmp['##validation.commentsubmission##'] = $validation['comment_submission'];
             $tmp['##validation.validationdate##'] = Html::convDateTime($validation['validation_date']);
             $tmp['##validation.validator##'] = Html::clean(getUserName($validation['users_id_validate']));
             $tmp['##validation.commentvalidation##'] = $validation['comment_validation'];
             $datas['validations'][] = $tmp;
         }
         // Ticket Satisfaction
         $inquest = new TicketSatisfaction();
         $datas['##satisfaction.type##'] = '';
         $datas['##satisfaction.datebegin##'] = '';
         $datas['##satisfaction.dateanswered##'] = '';
         $datas['##satisfaction.satisfaction##'] = '';
         $datas['##satisfaction.description##'] = '';
         if ($inquest->getFromDB($item->getField('id'))) {
             // internal inquest
             if ($inquest->fields['type'] == 1) {
                 $datas['##ticket.urlsatisfaction##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . '_Ticket$3');
                 // external inquest
             } else {
                 if ($inquest->fields['type'] == 2) {
                     $datas['##ticket.urlsatisfaction##'] = Entity::generateLinkSatisfaction($item);
                 }
             }
             $datas['##satisfaction.type##'] = $inquest->getTypeInquestName($inquest->getfield('type'));
             $datas['##satisfaction.datebegin##'] = Html::convDateTime($inquest->fields['date_begin']);
             $datas['##satisfaction.dateanswered##'] = Html::convDateTime($inquest->fields['date_answered']);
             $datas['##satisfaction.satisfaction##'] = $inquest->fields['satisfaction'];
             $datas['##satisfaction.description##'] = $inquest->fields['comment'];
         }
     }
     return $datas;
 }