/** * * Display additional information form from Model form * @param PluginDatainjectionModel $model */ static function showFormInfos(PluginDatainjectionModel $model) { $canedit = $model->can($model->fields['id'], UPDATE); self::showAddInfo($model, $canedit); $model->loadInfos(); $nb = count($model->getInfos()); if ($nb > 0) { echo "<form method='post' name='info_form' id='info_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit) { echo "<th> </th>"; } echo "<th>" . __('Tables', 'datainjection') . "</th>"; echo "<th>" . __('Fields', 'datainjection') . "</th>"; echo "<th>" . __('Mandatory information', 'datainjection') . "</th>"; echo "</tr>"; foreach ($model->getInfos() as $info) { $info->fields = Toolbox::stripslashes_deep($info->fields); $infos_id = $info->fields['id']; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='item[" . $infos_id . "]' value='1' {$sel}>"; echo "</td>"; } echo "<td class='center'>"; $rand = PluginDatainjectionInjectionType::dropdownLinkedTypes($info, array('primary_type' => $model->fields['itemtype'])); echo "</td>"; echo "<td class='center'><span id='span_field_{$infos_id}'></span></td>"; echo "<td class='center'><span id='span_mandatory_{$infos_id}'></span></td></tr>"; } if ($canedit) { echo "<tr>"; echo "<td class='tab_bg_2 center' colspan='4'>"; echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>"; echo "<input type='submit' name='update' value='" . _sx('button', 'Save') . "' class='submit'>"; echo "</td></tr>"; Html::openArrowMassives("info_form", true); Html::closeArrowMassives(array('delete' => __('Delete permanently'))); } echo "</table>"; Html::closeForm(); } }
/** * @param $model PluginDatainjectionModel object **/ static function showFormMappings(PluginDatainjectionModel $model) { global $CFG_GLPI; $canedit = $model->can($model->fields['id'], UPDATE); if (isset($_SESSION['datainjection']['lines'])) { $lines = unserialize($_SESSION['datainjection']['lines']); } else { $lines = array(); } echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; //Display link to the preview popup if (isset($_SESSION['datainjection']['lines']) && !empty($lines)) { $nblines = $_SESSION['datainjection']['nblines']; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center'>"; $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/front/popup.php?popup=preview&models_id=" . $model->getID(); echo "<a href=# onClick=\"var w = window.open('{$url}' , 'glpipopup', " . "'height=400, width=600, top=100, left=100, scrollbars=yes' );w.focus();\"/>"; echo __('See the file', 'datainjection') . "</a>"; echo "</td></tr>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __('Header of the file', 'datainjection') . "</th>"; echo "<th>" . __('Tables', 'datainjection') . "</th>"; echo "<th>" . _n('Field', 'Fields', 2) . "</th>"; echo "<th>" . __('Link field', 'datainjection') . "</th>"; echo "</tr>"; $model->loadMappings(); foreach ($model->getMappings() as $mapping) { $mapping->fields = Toolbox::stripslashes_deep($mapping->fields); $mappings_id = $mapping->getID(); echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . $mapping->fields['name'] . "</td>"; echo "<td class='center'>"; $options = array('primary_type' => $model->fields['itemtype']); PluginDatainjectionInjectionType::dropdownLinkedTypes($mapping, $options); echo "</td>"; echo "<td class='center'><span id='span_field_{$mappings_id}'>"; echo "</span></td>"; echo "<td class='center'><span id='span_mandatory_{$mappings_id}'></span></td>"; } if ($canedit) { echo "<tr> <td class='tab_bg_2 center' colspan='4'>"; echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>"; echo "<input type='submit' name='update' value='" . _sx('button', 'Save') . "' class='submit'>"; echo "</td></tr>"; } echo "</table>"; Html::closeForm(); }