function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'" . "enctype='multipart/form-data'>";
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'>";
     $models = PluginDatainjectionModel::getModels(Session::getLoginUserID(), 'name', $_SESSION['glpiactive_entity'], false);
     echo "<tr><th>" . __('Use an existing model', 'datainjection') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     if (count($models) > 0) {
         echo "<td class='center'>" . __('Model') . "&nbsp;";
         PluginDatainjectionModel::dropdown();
     } else {
         $text = __('No model currently available', 'datainjection');
         if (Session::haveRight(static::$rightname, UPDATE)) {
             $text = sprintf(__('%1$s %2$s'), $text . ". ", sprintf(__('%1$s: %2$s'), __('You can start the model creation by hitting the button', 'datainjection'), PluginDatainjectionModel::getTypeName()));
         }
         echo "<td class='center' colspan='2'>" . $text;
     }
     echo "</td></tr></table><br>";
     echo "<span id='span_injection' name='span_injection'></span>";
     Html::closeForm();
     echo "</div>";
     if (PluginDatainjectionSession::getParam('models_id')) {
         $p['models_id'] = PluginDatainjectionSession::getParam('models_id');
         switch (PluginDatainjectionSession::getParam('step')) {
             case self::STEP_UPLOAD:
                 $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/ajax/dropdownSelectModel.php";
                 Ajax::updateItem("span_injection", $url, $p);
                 break;
             case self::STEP_RESULT:
                 $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/ajax/results.php";
                 Ajax::updateItem("span_injection", $url, $p);
                 break;
         }
     }
 }
Beispiel #2
0
/**
 * Used for filter list of models
 *
 * @param $itemtype
**/
function plugin_datainjection_addDefaultWhere($itemtype)
{
    switch ($itemtype) {
        case 'PluginDatainjectionModel':
            $models = PluginDatainjectionModel::getModels(Session::getLoginUserID(), 'name', $_SESSION['glpiactive_entity'], true);
            if (count($models) > 0) {
                $tab = array();
                foreach ($models as $model) {
                    $tab[] = $model['id'];
                }
                if (count($tab) > 0) {
                    $where = "`glpi_plugin_datainjection_models`.`id` IN ('" . implode("','", $tab) . "')";
                }
                return $where;
            }
            return false;
    }
}