/**
  * Show items links to a shellcommands
  *
  * @since version 0.84
  *
  * @param $shellcommand PluginShellcommandsShellcommand object
  *
  * @return nothing (HTML display)
  * */
 public static function showForShellcommands(PluginShellcommandsShellcommand $shellcommand)
 {
     global $DB, $CFG_GLPI;
     $shell_id = $shellcommand->getField('id');
     $canedit = $shellcommand->can($shell_id, UPDATE);
     $rand = mt_rand();
     if (!Session::haveRight("link", READ) || !$shellcommand->can($shell_id, READ)) {
         return false;
     }
     $query = "SELECT *\n                FROM `glpi_plugin_shellcommands_shellcommands_items`\n                WHERE `plugin_shellcommands_shellcommands_id` = '{$shell_id}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $types = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $types[$data['id']] = $data;
             $used[$data['itemtype']] = $data['itemtype'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL('PluginShellcommandsShellcommand') . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item type') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='right'>";
         echo "<input type='hidden' name='plugin_shellcommands_shellcommands_id' value='{$shell_id}'>";
         Dropdown::showItemTypes('itemtype', PluginShellcommandsShellcommand::getTypes(true));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('item' => __CLASS__, 'container' => 'mass' . __CLASS__ . $rand, 'num_displayed' => $numrows);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "</tr>";
     foreach ($types as $data) {
         $typename = NOT_AVAILABLE;
         if ($item = getItemForItemtype($data['itemtype'])) {
             $typename = $item->getTypeName(1);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$typename}</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
 /**
  * Function show for record model
  * 
  * @param type $item
  * @return boolean
  */
 function showForShellcommand($item)
 {
     if (!$this->canView() || !$this->canCreate()) {
         return false;
     }
     $used = array();
     $dataGroup = $this->find('`plugin_shellcommands_shellcommands_id` = ' . $item->fields['id'], "`rank`");
     $shellcommand = new PluginShellcommandsShellcommand();
     $canedit = $shellcommand->can($item->fields['id'], UPDATE);
     if ($dataGroup) {
         foreach ($dataGroup as $field) {
             $used[] = $field['plugin_shellcommands_shellcommands_id'];
         }
     }
     if ($canedit) {
         echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL('PluginShellcommandsCommandGroup_Item') . "'>";
         echo "<div align='center'><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='6'>" . __('Add a command group', 'shellcommands') . "</th></tr>";
         echo "<tr class='tab_bg_1'>";
         // Dropdown group
         echo "<td class='center'>";
         echo PluginShellcommandsShellcommand::getTypeName() . '&nbsp;';
         Dropdown::show("PluginShellcommandsCommandGroup", array('name' => 'plugin_shellcommands_commandgroups_id', 'used' => $used));
         echo "</td>";
         echo "</tr>";
         echo "<tr>";
         echo "<td class='tab_bg_2 center' colspan='6'>";
         echo "<input type='submit' name='add' class='submit' value='" . _sx('button', 'Add') . "' >";
         echo "<input type='hidden' name='plugin_shellcommands_shellcommands_id' class='submit' value='" . $item->fields['id'] . "' >";
         echo "</td>";
         echo "</tr>";
         echo "</table></div>";
         Html::closeForm();
     }
     if ($dataGroup) {
         $this->listItemsForShellCommand($dataGroup, $canedit);
     }
 }