static function selectGroupOnAdd($item)
{
global $CFG_GLPI, $DB;
if (isset($item->input['_auto_import']) || isset($item->input['bypassgrouponadd'])) {
return;
}
$peGroup_group = new self();
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
$peConfig = new PluginEscalationConfig();
if ($peConfig->getValue('workflow', $item->fields['entities_id']) == '1') {
if (isset($_POST['_groups_id_assign']) && $_POST['_groups_id_assign'] > 0) {
if (isset($_SESSION['plugin_escalation_files'])) {
$_FILES = $_SESSION['plugin_escalation_files'];
}
return;
} else {
$group = new Group();
Html::header(__('Administration'), '', "maintain", "ticket");
if (isset($_POST['dropdown__groups_id_requester']) && $_POST['dropdown__groups_id_requester'] > 0) {
$_SESSION['plugin_escalation_groups_id_requester'] = $_POST['dropdown__groups_id_requester'];
}
if (isset($_FILES)) {
foreach ($_FILES['filename']['tmp_name'] as $numfile => $datafile) {
if ($datafile != '') {
$split = explode("/", $datafile);
Document::renameForce($datafile, GLPI_DOC_DIR . "/_tmp/" . end($split));
$_FILES['filename']['tmp_name'][$numfile] = GLPI_DOC_DIR . "/_tmp/" . end($split);
}
}
$_SESSION['plugin_escalation_files'] = $_FILES;
}
echo '<form action="' . $CFG_GLPI['root_doc'] . '/front/ticket.form.php"
enctype="multipart/form-data" name="form_ticket" method="post">';
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='2'>Sélection du groupe de techniciens</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>";
echo __('Group in charge of the ticket') . " :";
echo "</td>";
echo "<td>";
$a_groups = array();
foreach ($_SESSION['glpigroups'] as $groups_id) {
$group->getFromDB($groups_id);
$a_groups[$groups_id] = $group->getName();
$queryg = "SELECT * FROM `" . $peGroup_group->getTable() . "`\n WHERE `groups_id_source` = '" . $groups_id . "' ";
$resultg = $DB->query($queryg);
while ($datag = $DB->fetch_array($resultg)) {
$group->getFromDB($datag['groups_id_destination']);
$a_groups[$groups_id . "_" . $datag['groups_id_destination']] = " > " . $group->getName();
}
}
$rand = Dropdown::showFromArray("_groups_id_assign_escalation", $a_groups);
$params = array('groups_id' => '__VALUE__', 'entity' => $_POST['entities_id'], 'rand' => $rand);
Ajax::updateItemOnSelectEvent("dropdown__groups_id_assign" . $rand, "show_assignuser{$rand}", $CFG_GLPI["root_doc"] . "/plugins/escalation/ajax/dropdownUserassign.php", $params);
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2'>";
foreach ($_POST as $key => $value) {
if (is_array($value)) {
foreach ($value as $keyy => $valuee) {
echo '<input type="hidden" name="' . $key . '[' . $keyy . ']" value="' . $valuee . '" />';
}
} else {
if ($key == 'content') {
$value = Html::cleanPostForTextArea(Toolbox::clean_cross_side_scripting_deep($value));
echo '<textarea name="' . $key . '" style="display:none;">' . $value . '</textarea>';
} else {
if ($key == 'dropdown__groups_id_requester') {
echo '<input type="hidden" name="_groups_id_requester" value="' . $value . '" />';
} else {
$value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
}
}
}
if (!isset($_POST['_users_id_assign']) or $_POST['_users_id_assign'] == '0') {
echo "<span id='show_assignuser{$rand}'></span>";
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' align='center'>";
echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
Html::footer();
exit;
}
}
}
}