static function displayAjaxValues($config, $request_data, $rand, $mode)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployOrder = new PluginFusioninventoryDeployOrder();
     if (isset($request_data['orders_id'])) {
         $pfDeployOrder->getFromDB($request_data['orders_id']);
         $pfDeployPackage->getFromDB($pfDeployOrder->fields['plugin_fusioninventory_deploypackages_id']);
     } else {
         $pfDeployPackage->getEmpty();
     }
     /*
      * Get type from request params
      */
     $type = NULL;
     if ($mode === 'create') {
         $type = $request_data['values'];
     } else {
         $type = $config['type'];
         $config_data = $config['data'];
     }
     /*
      * Set default values
      */
     $value_type_1 = "input";
     $value_1 = "";
     $value_2 = "";
     $retChecks = NULL;
     /*
      * set values from element's config in 'edit' mode
      */
     switch ($type) {
         case 'move':
         case 'copy':
             $value_label_1 = __("From", 'fusioninventory');
             $name_label_1 = "from";
             $value_label_2 = __("To", 'fusioninventory');
             $name_label_2 = "to";
             if ($mode === 'edit') {
                 $value_1 = $config_data['from'];
                 $value_2 = $config_data['to'];
             }
             break;
         case 'cmd':
             $value_label_1 = __("exec", 'fusioninventory');
             $name_label_1 = "exec";
             $value_label_2 = FALSE;
             $value_type_1 = "textarea";
             if ($mode === 'edit') {
                 $value_1 = $config_data['exec'];
                 if (isset($config_data['retChecks'])) {
                     $retChecks = $config_data['retChecks'];
                 }
             }
             break;
         case 'delete':
         case 'mkdir':
             $value_label_1 = __("path", 'fusioninventory');
             $name_label_1 = "list[]";
             $value_label_2 = FALSE;
             if ($mode === 'edit') {
                 /*
                  * TODO : Add list input like `retChecks` on `mkdir` and `delete`
                  * because those methods are defined as list in specification
                  */
                 $value_1 = array_shift($config_data['list']);
             }
             break;
         default:
             return FALSE;
     }
     echo "<table class='package_item'>";
     echo "<tr>";
     echo "<th>{$value_label_1}</th>";
     echo "<td>";
     switch ($value_type_1) {
         case "input":
             echo "<input type='text' name='{$name_label_1}' value='{$value_1}' />";
             break;
         case "textarea":
             echo "<textarea name='{$name_label_1}' rows='3'>{$value_1}</textarea>";
             break;
     }
     echo "</td>";
     echo "</tr>";
     if ($value_label_2 !== FALSE) {
         echo "<tr>";
         echo "<th>{$value_label_2}</th>";
         echo "<td><input type='text' name='{$name_label_2}' value='{$value_2}'/></td>";
         echo "</tr>";
     }
     //specific case for cmd : add retcheck form
     if ($type == "cmd") {
         echo "<tr>";
         echo "<th>" . __("Execution checks", 'fusioninventory');
         PluginFusioninventoryDeployPackage::plusButton("retchecks", ".table_retchecks.template");
         echo "</th>";
         echo "<td>";
         $display = "style='display:none'";
         if ($retChecks) {
             $display = "style='display:block'";
         }
         echo "<span id='retchecks' style='display:block'>";
         if (is_array($retChecks) && count($retChecks)) {
             foreach ($retChecks as $retcheck) {
                 echo "<table class='table_retchecks'>";
                 echo "<tr>";
                 echo "<td>";
                 Dropdown::showFromArray('retchecks_type[]', self::retchecks_entries(), array('value' => $retcheck['type']));
                 echo "</td>";
                 echo "<td>";
                 echo "<input type='text' name='retchecks_value[]' value='" . $retcheck['values'][0] . "' />";
                 echo "</td>";
                 echo "<td><a class='edit' onclick='removeLine(this)'><img src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' /></a></td>";
                 echo "</tr>";
                 echo "</table>";
             }
         }
         echo "<table class='table_retchecks template' style='display:none'>";
         echo "<tr>";
         echo "<td>";
         //Toolbox::logDebug(self::retchecks_entries());
         Dropdown::showFromArray('retchecks_type[]', self::retchecks_entries(), array());
         echo "</td>";
         echo "<td><input type='text' name='retchecks_value[]' /></td>";
         echo "<td><a class='edit' onclick='removeLine(this)'><img src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' /></a></td>";
         echo "</tr>";
         echo "</table>";
         echo "</span>";
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr>";
     echo "<td></td><td>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         if ($mode === 'edit') {
             echo "<input type='submit' name='save_item' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
         }
     }
     echo "</td>";
     echo "</tr></table>";
     echo "<script type='text/javascript'>\n         function removeLine(item) {\n            var tag_table = item.parentNode.parentNode.parentNode.parentNode;\n            var parent = tag_table.parentNode;\n               parent.removeChild(tag_table);\n         }\n      </script>";
 }
 static function displayAjaxValues($config, $request_data, $rand, $mode)
 {
     global $CFG_GLPI;
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployOrder = new PluginFusioninventoryDeployOrder();
     if (isset($request_data['orders_id'])) {
         $pfDeployOrder->getFromDB($request_data['orders_id']);
         $pfDeployPackage->getFromDB($pfDeployOrder->fields['plugin_fusioninventory_deploypackages_id']);
     } else {
         $pfDeployPackage->getEmpty();
     }
     $p2p = 0;
     $p2p_retention_duration = 0;
     $uncompress = 0;
     if ($mode === 'create') {
         $source = $request_data['value'];
         /**
          * No need to continue if there is no selected source
          */
         if ($source === '0') {
             return;
         }
     } else {
         $p2p = $config['data']['p2p'];
         $p2p_retention_duration = $config['data']['p2p-retention-duration'];
         $uncompress = $config['data']['uncompress'];
     }
     echo "<table class='package_item'>";
     /*
      * Display file upload input only in 'create' mode
      */
     echo "<tr>";
     echo "<th>" . __("File", 'fusioninventory') . "</th>";
     echo "<td>";
     if ($mode === 'create') {
         switch ($source) {
             case "Computer":
                 echo "<input type='file' name='file' value='" . __("filename", 'fusioninventory') . "' />";
                 echo "<i>" . self::getMaxUploadSize() . "</i>";
                 break;
             case "Server":
                 echo "<input type='text' name='filename' id='server_filename{$rand}'" . " style='width:120px;float:left' />";
                 echo "<input type='button' class='submit' value='" . __("Choose", 'fusioninventory') . "' onclick='fileModal{$rand}.dialog(\"open\");' />";
                 Ajax::createModalWindow("fileModal{$rand}", $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/ajax/deployfilemodal.php", array('title' => __('Select the file on server', 'fusioninventory'), 'extraparams' => array('rand' => $rand)));
                 break;
         }
     } else {
         /*
          * Display only name in 'edit' mode
          */
         echo $config['data']['name'];
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th>" . __("Uncompress", 'fusioninventory') . "<img style='float:right' " . "src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory//pics/uncompress.png' /></th>";
     echo "<td>";
     Html::showCheckbox(array('name' => 'uncompress', 'checked' => $uncompress));
     echo "</td>";
     echo "</tr><tr>";
     echo "<th>" . __("P2P", 'fusioninventory') . "<img style='float:right' src='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory//pics/p2p.png' /></th>";
     echo "<td>";
     Html::showCheckbox(array('name' => 'p2p', 'checked' => $p2p));
     echo "</td>";
     echo "</tr><tr>";
     echo "<th>" . __("retention days", 'fusioninventory') . "</th>";
     echo "<td>";
     /*
      * TODO: use task periodicity input to propose days, months and years
      */
     Dropdown::showNumber('p2p-retention-duration', array('value' => $p2p_retention_duration, 'min' => 0, 'max' => 400));
     echo "</td>";
     echo "</tr><tr>";
     echo "<td>";
     echo "</td><td>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         if ($mode === 'edit') {
             echo "<input type='submit' name='save_item' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
         }
     }
     echo "</td>";
     echo "</tr></table>";
 }
 static function displayAjaxValues($config, $request_data, $rand, $mode)
 {
     $pfDeployPackage = new PluginFusioninventoryDeployPackage();
     $pfDeployOrder = new PluginFusioninventoryDeployOrder();
     if (isset($request_data['orders_id'])) {
         $pfDeployOrder->getFromDB($request_data['orders_id']);
         $pfDeployPackage->getFromDB($pfDeployOrder->fields['plugin_fusioninventory_deploypackages_id']);
     } else {
         $pfDeployPackage->getEmpty();
     }
     /*
      * Get type from request params
      */
     $type = NULL;
     if ($mode === 'create') {
         $type = $request_data['value'];
         $config_data = NULL;
     } else {
         $type = $config['type'];
         $config_data = $config['data'];
     }
     $values = self::getValues($type, $config_data, $mode);
     if ($values === FALSE) {
         return FALSE;
     }
     echo "<table class='package_item'>";
     echo "<tr>";
     echo "<th>{$values['path_label']}</th>";
     echo "<td><input type='text' name='path' id='check_path{$rand}' value='{$values['path_value']}' /></td>";
     echo "</tr>";
     if ($values['value_label'] !== FALSE) {
         echo "<tr>";
         echo "<th>{$values['value_label']}</th>";
         switch ($values['value_type']) {
             case "textarea":
                 echo "<td><textarea name='value' id='check_value{$rand}' rows='5'>" . $values['value'] . "</textarea></td>";
                 break;
             case "input":
                 echo "<td><input type='text' name='value' id='check_value{$rand}' value='" . $values['value'] . "' /></td>";
                 break;
             case "input+unit":
                 $value = $values['value'];
                 // freespaceGreater check is saved as MiB
                 if ($type == 'freespaceGreater') {
                     $value = $value * 1024 * 1024;
                 }
                 $options['value'] = 'KB';
                 if ($mode === 'edit') {
                     if ($value >= self::getUnitSize('GB')) {
                         $value = $value / self::getUnitSize('GB');
                         $options['value'] = 'GB';
                     } elseif ($value >= self::getUnitSize('MB')) {
                         $value = $value / self::getUnitSize('MB');
                         $options['value'] = 'MB';
                     } elseif ($value >= self::getUnitSize('KB')) {
                         $value = $value / self::getUnitSize('KB');
                         $options['value'] = 'KB';
                     } else {
                         $options['value'] = 'B';
                     }
                 }
                 echo "<td>";
                 echo "<input " . "type='text' " . "name='value' " . "id='check_value{$rand}' " . "value='{$value}' " . "/>";
                 echo "</td>";
                 echo "</tr><tr>";
                 echo "<th>" . __("Unit", 'fusioninventory') . "</th>";
                 echo "<td>";
                 $unit_labels = self::getUnitLabel();
                 /*
                  * The freespaceGreater check does not need to propose KiB or B
                  * because its value is based on MiB according to REST API.
                  *                               -- Kevin 'kiniou' Roy
                  */
                 if ($type == 'freespaceGreater') {
                     unset($unit_labels['KB']);
                     unset($unit_labels['B']);
                 }
                 Dropdown::showFromArray('unit', $unit_labels, $options);
                 echo "</td>";
                 break;
         }
         echo "</tr>";
     }
     echo "<tr>";
     echo "<th>" . __("In case of error", 'fusioninventory') . "</th>";
     echo "<td>";
     Dropdown::showFromArray('return', array("error" => __('Error', 'fusioninventory'), "ignore" => __("Ignore", 'fusioninventory')), array('value' => $values['return']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><td></td><td>";
     if ($pfDeployPackage->can($pfDeployPackage->getID(), UPDATE)) {
         if ($mode === 'edit') {
             echo "<input type='submit' name='save_item' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
         } else {
             echo "<input type='submit' name='add_item' value=\"" . _sx('button', 'Add') . "\" class='submit' >";
         }
     }
     echo "</td></tr>";
     echo "</table>";
 }