static function showForItem(CommonDBTM $item) { global $DB, $LANG; if (!$item->canView()) { return false; } // if (PluginSimcardSimcard::canCreate()) { // if ($item->canEdit($item->getField('id'))) { // $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard'); // $url.= "?itemtype=".$item->getType()."&items_id=".$item->getID()."&id=-1"; // echo "<div class='center'><a href='$url'>".__s('New SIM card', 'simcard')."</a></div><br>"; // } // } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'"); 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'>" . __s('Associated item') . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . __s('Entity') . "</th>"; echo "<th>" . __s('Name') . "</th>"; echo "<th>" . __s('IMSI') . "</th>"; echo "<th>" . __s('Inventory number') . "</th>"; echo "</tr>"; foreach ($results as $data) { $tmp = new PluginSimcardSimcard(); $tmp->getFromDB($data['plugin_simcard_simcards_id']); echo "<tr>"; echo "<td>"; if (PluginSimcardSimcard::canDelete()) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']); echo "</td>"; echo "<td>"; echo $tmp->getLink(); echo "</td>"; echo "<td>"; echo $tmp->fields['serial']; echo "</td>"; echo "<td>"; echo $tmp->fields['otherserial']; echo "</td>"; echo "</tr>"; } } if (PluginSimcardSimcard::canUpdate()) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; $used = array(); $query = "SELECT `id`\n FROM `glpi_plugin_simcard_simcards`\n WHERE `is_template`='0'\n AND `id` IN (SELECT `plugin_simcard_simcards_id`\n FROM `glpi_plugin_simcard_simcards_items`)"; foreach ($DB->request($query) as $use) { $used[] = $use['id']; } Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used)); echo "</td>"; echo "<td colspan='2' class='center' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Save') . "\" 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 showForItem(CommonDBTM $item) { global $DB, $LANG; if (!$item->can($item->getID(), 'r')) { return false; } if (Session::haveRight('simcard', 'w')) { $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard'); $url .= "?itemtype=" . $item->getType() . "&items_id=" . $item->getID() . "&id=-1"; echo "<div class='center'><a href='{$url}'>" . $LANG['plugin_simcard'][10] . "</a></div><br>"; } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'"); 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['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) { $tmp = new PluginSimcardSimcard(); $tmp->getFromDB($data['plugin_simcard_simcards_id']); echo "<tr>"; echo "<td>"; if (Session::haveRight('simcard', 'w')) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']); echo "</td>"; echo "<td>"; echo $tmp->getLink(); echo "</td>"; echo "<td>"; echo $tmp->fields['serial']; echo "</td>"; echo "<td>"; echo $tmp->fields['otherserial']; echo "</td>"; echo "</tr>"; } } if (Session::haveRight('simcard', 'w')) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; $used = array(); $query = "SELECT `id`\n FROM `glpi_plugin_simcard_simcards`\n WHERE `is_template`='0'\n AND `id` IN (SELECT `plugin_simcard_simcards_id`\n FROM `glpi_plugin_simcard_simcards_items`)"; foreach ($DB->request($query) as $use) { $used[$use['id']] = $use['id']; } Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used)); 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>"; }