/** * Display the add Definition form * * @param $typocrit_id typocrit ID **/ static function showForCriteria(PluginTypologyTypologyCriteria $typocrit) { global $DB; $typocrit_id = $typocrit->getField('id'); $query = "SELECT `glpi_plugin_typology_typologycriteriadefinitions`.`id`,\n `glpi_plugin_typology_typologycriterias`.`itemtype`,\n `glpi_plugin_typology_typologycriterias`.`link`,\n `glpi_plugin_typology_typologycriteriadefinitions`.`field`,\n `glpi_plugin_typology_typologycriteriadefinitions`.`action_type`,\n `glpi_plugin_typology_typologycriteriadefinitions`.`value`,\n `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`\n FROM `glpi_plugin_typology_typologycriteriadefinitions`\n LEFT JOIN `glpi_plugin_typology_typologycriterias`\n ON (`glpi_plugin_typology_typologycriterias`.`id`\n = `glpi_plugin_typology_typologycriteriadefinitions`.`plugin_typology_typologycriterias_id`)\n WHERE `plugin_typology_typologycriterias_id` = '" . $typocrit_id . "'\n ORDER BY `glpi_plugin_typology_typologycriteriadefinitions`.`id`"; echo "<div class='firstbloc'>"; if ($result = $DB->query($query)) { echo "<form method='post' action='./typologycriteria.form.php'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='6'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(1) . "</tr>"; echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>"; echo "<input type='hidden' name='entities_id' value='" . $typocrit->getField('entities_id') . "'>"; echo "<input type='hidden' name='is_recursive' value='" . $typocrit->getField('is_recursive') . "'>"; echo "<tr class='tab_bg_1 center'>"; echo "<td>" . _n('Field', 'Fields', 2) . "</td><td>"; PluginTypologyTypologyCriteriaDefinition::dropdownFields($typocrit_id); echo "</td>"; echo "<td>"; echo "<span id='span_actions' name='span_actions'></span></td>"; echo "<td>"; echo "<span id='span_values' name='span_values'></span></td>"; echo "<td class='tab_bg_2 left' width='80px'>"; echo "<input type='submit' name='add_action' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>\n"; echo "</table>"; Html::closeForm(); echo "</div>"; if ($DB->num_fields($result) > 0) { if (plugin_typology_haveRight('typology', 'w')) { echo "<form name='critDef_form' id='critDef_form' method='post' action='./typologycriteria.form.php'>"; } echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . PluginTypologyTypologyCriteriaDefinition::getTypeName(2) . "</th></tr>"; echo "<tr class='tab_bg_1 center'>"; echo "<th colspan='2'>" . _n('Field', 'Fields', 2) . "</th>"; echo "<th class='center b'>" . __('Logical operator') . "</th>"; echo "<th class='center b'>" . __('Value') . "</th>"; echo "</tr>"; while ($ligne = $DB->fetch_array($result)) { echo "<tr class='tab_bg_2'>"; if (plugin_typology_haveRight('typology', 'w')) { echo "<td width='10'>"; echo "<input type='checkbox' name='item[" . $ligne["id"] . "]' value='1'>"; echo "<input type='hidden' name='plugin_typology_typologycriterias_id' value='{$typocrit_id}'>"; echo "</td>"; } self::showMinimalDefinitionForm($ligne); echo "</tr>"; } if (plugin_typology_haveRight('typology', 'w')) { Html::openArrowMassives("critDef_form", true); Html::closeArrowMassives(array('delete_action' => __('Delete permanently'))); } echo "</table></div>"; if (plugin_typology_haveRight('typology', 'w')) { Html::closeForm(); } } } }