static function displayOrderTypeForm($order_type, $packages_id, $package) { global $CFG_GLPI; $subtypes = array('check' => __("Audits", 'fusioninventory'), 'file' => __("Files", 'fusioninventory'), 'action' => __("Actions", 'fusioninventory')); $json_subtypes = array('check' => 'checks', 'file' => 'associatedFiles', 'action' => 'actions'); $rand = mt_rand(); $order = new PluginFusioninventoryDeployOrder($order_type, $packages_id); $datas = json_decode($order->fields['json'], TRUE); $orders_id = $order->fields['id']; $order_type_label = PluginFusioninventoryDeployOrder::getOrderTypeLabel($order->fields['type']); /** * Display an error if the package modification is not possible **/ $error_msg = $package->getEditErrorMessage($order_type_label); if (!empty($error_msg)) { Session::addMessageAfterRedirect($error_msg); Html::displayMessageAfterRedirect(); echo "<div id='package_order_" . $orders_id . "_span'>"; } echo "<table class='tab_cadre_fixe' id='package_order_" . $orders_id . "'>"; /** * Display the lists of each subtypes of a package **/ foreach ($subtypes as $subtype => $label) { echo "<tr>"; echo "<th id='th_title_{$subtype}_{$rand}'>"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/pics/{$subtype}.png' />"; echo " " . __($label, 'fusioninventory'); $package->plusButtonSubtype($package->getID(), $orders_id, $subtype, $rand); echo "</th>"; echo "</tr>"; /** * File's form must be encoded as multipart/form-data **/ $multipart = ""; if ($subtype == "file") { $multipart = "enctype='multipart/form-data'"; } echo "<tr>"; echo "<td style='vertical-align:top'>"; /** * Display subtype form **/ echo "<form name='addition{$subtype}' method='post' " . $multipart . " action='deploypackage.form.php'>"; echo "<input type='hidden' name='orders_id' value='{$orders_id}' />"; echo "<input type='hidden' name='itemtype' value='PluginFusioninventoryDeploy" . ucfirst($subtype) . "' />"; $classname = "PluginFusioninventoryDeploy" . ucfirst($subtype); $classname::displayForm($order, $datas, $rand, "init"); Html::closeForm(); $json_subtype = $json_subtypes[$subtype]; /** * Display stored actions datas **/ if (isset($datas['jobs'][$json_subtype]) && !empty($datas['jobs'][$json_subtype])) { echo "<div id='drag_" . $order_type_label . "_" . $subtype . "s'>"; echo "<form name='remove" . $subtype . "s' " . "method='post' action='deploypackage.form.php' " . "id='" . $subtype . "sList" . $rand . "'>"; echo "<input type='hidden' name='remove_item' />"; echo "<input type='hidden' name='itemtype' value='" . $classname . "' />"; echo "<input type='hidden' name='orders_id' value='" . $order->fields['id'] . "' />"; $classname::displayList($order, $datas, $rand); Html::closeForm(); echo "</div>"; } /** * Initialize drag and drop on subtype lists **/ echo "<script type='text/javascript'>"; echo "redipsInit('{$order_type_label}', '{$subtype}', {$orders_id});"; echo "</script>"; echo "</td>"; echo "</tr>"; } if ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) { // === debug === echo "<tr><td>"; echo "<span id='package_json_debug'>"; self::display_json_debug($order); echo "</sp3an>"; echo "</td></tr>"; } echo "</table>"; if (!empty($error_msg)) { echo "</div>"; echo "<script type='text/javascript'>\n Ext.onReady(function() {\n Ext.select('#package_order_" . $orders_id . "_span').mask();\n });\n </script>"; } }