static function showForSimcard(PluginSimcardSimcard $simcard) { global $DB, $LANG; if (!$simcard->canView()) { return false; } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`plugin_simcard_simcards_id` = '" . $simcard->getID() . "'"); echo "<div class='spaced'>"; echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='6'>" . __("Associated item") . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . __s("Type") . "</th>"; echo "<th>" . __s("Entity") . "</th>"; echo "<th>" . __s("Name") . "</th>"; echo "<th>" . __s("Serial number") . "</th>"; echo "<th>" . __s("Inventory number") . "</th>"; echo "</tr>"; foreach ($results as $data) { $item = new $data['itemtype'](); $item->getFromDB($data['items_id']); echo "<tr>"; echo "<td>"; if (PluginSimcardSimcard::canUpdate()) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo call_user_func(array($data['itemtype'], 'getTypeName')); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); echo "</td>"; echo "<td>"; echo $item->getLink(); echo "</td>"; echo "<td>"; echo $item->fields['serial']; echo "</td>"; echo "<td>"; echo $item->fields['otherserial']; echo "</td>"; echo "</tr>"; } } if (PluginSimcardsimcard::canUpdate()) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; if (empty($results)) { echo "<input type='hidden' name='plugin_simcard_simcards_id' value='" . $simcard->getID() . "'>"; // TODO : Dropdown::showAllItems is deprecated, use Dropdown::showSelectItemFromItemtypes instead Dropdown::showAllItems("items_id", 0, 0, $simcard->fields['entities_id'], self::getClasses()); echo "</td>"; echo "<td colspan='2' class='center' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>"; } if (!empty($results)) { Html::openArrowMassives('items', true); Html::closeArrowMassives(array('delete_items' => _sx('button', 'Disconnect'))); } } echo "</table>"; Html::closeForm(); echo "</div>"; }
static function showForSimcard(PluginSimcardSimcard $simcard) { global $DB, $LANG; if (!$simcard->can($simcard->getID(), 'r')) { return false; } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`plugin_simcard_simcards_id` = '" . $simcard->getID() . "'"); echo "<div class='spaced'>"; echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='6'>" . $LANG['document'][19] . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . $LANG['common'][17] . "</th>"; echo "<th>" . $LANG['entity'][0] . "</th>"; echo "<th>" . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['common'][19] . "</th>"; echo "<th>" . $LANG['common'][20] . "</th>"; echo "</tr>"; foreach ($results as $data) { $item = new $data['itemtype'](); $item->getFromDB($data['items_id']); echo "<tr>"; echo "<td>"; if (Session::haveRight('simcard', 'w')) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo call_user_func(array($data['itemtype'], 'getTypeName')); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); echo "</td>"; echo "<td>"; echo $item->getLink(); echo "</td>"; echo "<td>"; echo $item->fields['serial']; echo "</td>"; echo "<td>"; echo $item->fields['otherserial']; echo "</td>"; echo "</tr>"; } } if (Session::haveRight('simcard', 'w')) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; if (empty($results)) { echo "<input type='hidden' name='plugin_simcard_simcards_id' value='" . $simcard->getID() . "'>"; Dropdown::showAllItems("items_id", 0, 0, $simcard->fields['entities_id'], self::getClasses()); echo "</td>"; echo "<td colspan='2' class='center' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>"; } if (!empty($results)) { Html::openArrowMassives('items'); Html::closeArrowMassives(array('delete_items' => $LANG['buttons'][10])); } } echo "</table>"; Html::closeForm(); echo "</div>"; }