/**
  * Display state of an item of a taskjob
  *
  * @param $items_id integer id of the item
  * @param $itemtype value type of the item
  * @param $state value (all or each state : running, finished, nostarted)
  *
  * @return nothing
  *
  **/
 function stateTaskjobItem($items_id, $itemtype, $state = 'all')
 {
     global $DB, $CFG_GLPI;
     $pfTaskjoblog = new PluginFusioninventoryTaskjoblog();
     $icon = "";
     $title = "";
     $pfTaskjoblog->javascriptHistory();
     switch ($state) {
         case 'running':
             $search = " AND `state`!='" . self::FINISHED . "'";
             $title = __('Running tasks', 'fusioninventory');
             $icon = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/task_running.png'/>";
             break;
         case 'finished':
             $search = " AND `state`='" . self::FINISHED . "'";
             $title = __('Finished tasks', 'fusioninventory');
             $icon = "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/task_finished.png'/>";
             break;
         case 'all':
             $search = "";
             $title = _n('Task', 'Tasks', 2);
             $icon = "";
             break;
     }
     if (!isset($search)) {
         return;
     }
     $a_taskjobs = array();
     if (isset($search)) {
         $query = "SELECT * FROM `" . $this->getTable() . "`\n                   WHERE `items_id`='" . $items_id . "' AND `itemtype`='" . $itemtype . "'" . $search . "\n                   ORDER BY `" . $this->getTable() . "`.`id` DESC";
         $a_taskjobs = array();
         $result = $DB->query($query);
         if ($result) {
             while ($data = $DB->fetch_array($result)) {
                 $a_taskjobs[] = $data;
             }
         }
     }
     echo "<div align='center'>";
     echo "<table  class='tab_cadre' width='950'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th  width='32'>";
     echo $icon;
     echo "</th>";
     echo "<td>";
     if (count($a_taskjobs) > 0) {
         echo "<table class='tab_cadre' width='950'>";
         echo "<tr>";
         echo "<th></th>";
         echo "<th>" . __('Unique id', 'fusioninventory') . "</th>";
         echo "<th>" . __('Job', 'fusioninventory') . "</th>";
         echo "<th>" . __('Agent', 'fusioninventory') . "</th>";
         echo "<th>";
         echo __('Date');
         echo "</th>";
         echo "<th>";
         echo __('Status');
         echo "</th>";
         $nb_td = 6;
         if ($state == 'running') {
             $nb_td++;
             echo "<th>";
             echo __('Comments');
             echo "</th>";
         }
         echo "</tr>";
         foreach ($a_taskjobs as $data) {
             $pfTaskjoblog->showHistoryLines($data['id'], 0, 1, $nb_td);
         }
         echo "</table>";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<br/>";
     echo "</div>";
 }