Beispiel #1
0
 /**
  * @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&amp;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();
 }