diff --git a/ajax/formanswer.php b/ajax/formanswer.php
new file mode 100644
index 000000000..bd26f1aab
--- /dev/null
+++ b/ajax/formanswer.php
@@ -0,0 +1,103 @@
+.
+ * ---------------------------------------------------------------------
+ * @copyright Copyright © 2011 - 2021 Teclib'
+ * @license http://www.gnu.org/licenses/gpl.txt GPLv3+
+ * @link https://github.com/pluginsGLPI/formcreator/
+ * @link https://pluginsglpi.github.io/formcreator/
+ * @link http://plugins.glpi-project.org/#/plugin/formcreator
+ * ---------------------------------------------------------------------
+ */
+
+include ('../../../inc/includes.php');
+
+if (!isset($_REQUEST['id']) || !isset($_REQUEST['action'])) {
+ http_response_code(400);
+ die();
+}
+
+if ($_POST['action'] == 'submit_formcreator') {
+ unset($_SESSION['MESSAGE_AFTER_REDIRECT']);
+ // Save form
+ $formAnswer = PluginFormcreatorCommon::getFormAnswer();
+ $form = PluginFormcreatorCommon::getForm();
+ $form->getFromDB($_POST['id']);
+ $_POST['plugin_formcreator_forms_id'] = (int) $_POST['id'];
+ unset($_POST['id']);
+ if ($formAnswer->add($_POST) === false) {
+ http_response_code(400);
+ die();
+ }
+ $form->increaseUsageCount();
+
+ if ($_SESSION['glpiname'] == 'formcreator_temp_user') {
+ // Form was saved by an annymous user
+ unset($_SESSION['glpiname']);
+ // don't show notifications
+ unset($_SESSION['MESSAGE_AFTER_REDIRECT']);
+ echo json_encode([
+ 'redirect' => 'formdisplay.php?answer_saved',
+ ], JSON_OBJECT_AS_ARRAY);
+ http_response_code(200);
+ die();
+ }
+
+ // redirect to created item
+ if ($_SESSION['glpibackcreated']) {
+ if (count($formAnswer->targetList) == 1) {
+ $target = current($formAnswer->targetList);
+ echo json_encode([
+ 'redirect' => $target->getFormURLWithID($target->getID()),
+ ], JSON_OBJECT_AS_ARRAY);
+ http_response_code(200);
+ die();
+ }
+ echo json_encode([
+ 'redirect' => PluginFormcreatorFormAnswer::getFormURLWithID($formAnswer->getID()),
+ ], JSON_OBJECT_AS_ARRAY);
+ http_response_code(200);
+ die();
+ }
+
+ if (plugin_formcreator_replaceHelpdesk()) {
+ // Form was saved from the service catalog
+ echo json_encode([
+ 'redirect' => PluginFormcreatorIssue::getSearchUrl(),
+ ], JSON_OBJECT_AS_ARRAY);
+ http_response_code(200);
+ die();
+ }
+ if (strpos($_SERVER['HTTP_REFERER'], 'formdisplay.php') !== false) {
+ // Form was saved from helpdesk (assistance > forms)
+ http_response_code(200);
+ echo json_encode([
+ 'redirect' => $_SERVER['HTTP_REFERER'],
+ ], JSON_OBJECT_AS_ARRAY);
+ die();
+ }
+ // Form was saved from preview tab, go back to the preview
+ http_response_code(200);
+ echo json_encode([
+ 'redirect' => $_SERVER['HTTP_REFERER'],
+ ], JSON_OBJECT_AS_ARRAY);
+}
\ No newline at end of file
diff --git a/ajax/showfields.php b/ajax/showfields.php
index 9a179af20..b72b9c2b8 100644
--- a/ajax/showfields.php
+++ b/ajax/showfields.php
@@ -38,13 +38,13 @@
}
$formFk = PluginFormcreatorForm::getForeignKeyField();
-if (!isset($_POST[$formFk])) {
+if (!isset($_POST['id'])) {
http_response_code(403);
exit();
}
$form = PluginFormcreatorCommon::getForm();
-$form->getFromDB((int) $_POST['plugin_formcreator_forms_id']);
+$form->getFromDB((int) $_POST['id']);
if (!Session::haveRight(PluginFormcreatorForm::$rightname, UPDATE) && ($form->isDeleted() || $form->fields['is_active'] == '0')) {
http_response_code(403);
exit();
diff --git a/front/form.form.php b/front/form.form.php
index df2c8b984..38db326bd 100644
--- a/front/form.form.php
+++ b/front/form.form.php
@@ -126,52 +126,6 @@
$form->importJson($_REQUEST);
Html::back();
-} else if (isset($_POST['submit_formcreator'])) {
- // Save form to target
- if (!$form->getFromDB($_POST['plugin_formcreator_forms_id'])) {
- Html::back();
- }
-
- // If user is not authenticated, create temporary user
- if (!isset($_SESSION['glpiname'])) {
- $_SESSION['glpiname'] = 'formcreator_temp_user';
- }
-
- // Save form
- $formAnswer = PluginFormcreatorCommon::getFormAnswer();
- if ($formAnswer->add($_POST) === false) {
- Html::back();
- }
- $form->increaseUsageCount();
-
- if ($_SESSION['glpiname'] == 'formcreator_temp_user') {
- // Form was saved by an annymous user
- unset($_SESSION['glpiname']);
- // don't show notifications
- unset($_SESSION['MESSAGE_AFTER_REDIRECT']);
- Html::redirect('formdisplay.php?answer_saved');
- }
-
- // redirect to created item
- if ($_SESSION['glpibackcreated']) {
- if (count($formAnswer->targetList) == 1) {
- $target = current($formAnswer->targetList);
- Html::redirect($target->getFormURLWithID($target->getID()));
- }
- Html::redirect(PluginFormcreatorFormAnswer::getFormURLWithID($formAnswer->getID()));
- }
-
- if (plugin_formcreator_replaceHelpdesk()) {
- // Form was saved from the service catalog
- Html::redirect('issue.php');
- }
- if (strpos($_SERVER['HTTP_REFERER'], 'formdisplay.php') !== false) {
- // Form was saved from helpdesk (assistance > forms)
- Html::redirect('formlist.php');
- }
- // Form was saved from preview tab, go back to the preview
- Html::back();
-
} else {
// Show forms form
Session::checkRight(PluginFormcreatorForm::$rightname, READ);
diff --git a/front/formdisplay.php b/front/formdisplay.php
index 422f9a34a..1ac3988d0 100644
--- a/front/formdisplay.php
+++ b/front/formdisplay.php
@@ -37,7 +37,9 @@
Html::displayNotFoundError();
}
-PluginFormcreatorCommon::header();
+if (!isset($_REQUEST['modal'])) {
+ PluginFormcreatorCommon::header();
+}
if (isset($_REQUEST['id'])
&& is_numeric($_REQUEST['id'])) {
@@ -54,12 +56,20 @@
// If the form has restriced access and user is not logged in, send to login form
if ($form->fields['access_rights'] != PluginFormcreatorForm::ACCESS_PUBLIC && Session::getLoginUserID() === false) {
- Session::redirectIfNotLoggedIn();
+ if (!(new Plugin())->isActivated('formcreator')) {
+ Session::redirectIfNotLoggedIn();
+ } else {
+ http_response_code(403);
+ }
exit();
}
if (!$form->canViewForRequest()) {
- Html::displayRightError();
+ if (!(new Plugin())->isActivated('formcreator')) {
+ Html::displayRightError();
+ } else {
+ http_response_code(403);
+ }
exit();
}
if (($form->fields['access_rights'] == PluginFormcreatorForm::ACCESS_PUBLIC) && (!isset($_SESSION['glpiID']))) {
@@ -75,6 +85,7 @@
? "'" . implode("', '", $subentities) . "'"
: "'" . $form->fields['entities_id'] . "'";
$_SESSION['glpilanguage'] = $form->getBestLanguage();
+ $CFG_GLPI['plugin_formcreator']['form_transition'] = PluginFormcreatorEntityConfig::getUsedConfig('form_transition', $form->fields['entities_id'], 'form_transition', );
}
}
@@ -91,4 +102,6 @@
Html::displayTitle($CFG_GLPI['root_doc']."/pics/ok.png", $message, $message);
}
-PluginFormcreatorCommon::footer();
+if (!isset($_REQUEST['modal'])) {
+ PluginFormcreatorCommon::footer();
+}
diff --git a/inc/entityconfig.class.php b/inc/entityconfig.class.php
index 3b7fa5640..a88ce064b 100644
--- a/inc/entityconfig.class.php
+++ b/inc/entityconfig.class.php
@@ -69,6 +69,8 @@ class PluginFormcreatorEntityconfig extends CommonDBTM {
const CONFIG_UI_FORM_MASONRY = 0;
const CONFIG_UI_FORM_UNIFORM_HEIGHT = 1;
+ const CONFIG_FORM_TRANSITION_PAGE = 0;
+ const CONFIG_FORM_TRANSITION_MODAL = 1;
/**
* @var bool $dohistory maintain history
@@ -158,6 +160,14 @@ public static function getEnumUIForm() : array {
];
}
+ public static function getEnumFormTransition(): array {
+ return [
+ self::CONFIG_PARENT => __('Inheritance of the parent entity'),
+ self::CONFIG_FORM_TRANSITION_PAGE => __('Full page', 'formcreator'),
+ self::CONFIG_FORM_TRANSITION_MODAL => __('Modal', 'formcreator'),
+ ];
+ }
+
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) {
if ($item->getType() == 'Entity') {
$config = new self();
@@ -208,6 +218,7 @@ protected static function createDefaultsForEntity($entityId): self {
'is_search_visible' => self::CONFIG_PARENT,
'is_dashboard_visible' => self::CONFIG_PARENT,
'is_header_visible' => self::CONFIG_PARENT,
+ 'form_transition' => self::CONFIG_PARENT,
]);
return $entityConfig;
@@ -382,6 +393,22 @@ public function showFormForEntity(Entity $entity) {
]);
echo '';
+ // Form transition
+ $elements = self::getEnumFormTransition();
+ if ($entityId == 0) {
+ unset($elements[self::CONFIG_PARENT]);
+ }
+ echo "
";
echo "";
@@ -457,6 +484,66 @@ public function rawSearchOptions() {
'massiveaction' => true,
];
+ $tab[] = [
+ 'id' => '9',
+ 'table' => self::getTable(),
+ 'name' => __('Default Form list mode', 'formcreator'),
+ 'field' => 'default_form_list_mode',
+ 'datatype' => 'integer',
+ 'nosearch' => true,
+ 'massiveaction' => true,
+ ];
+
+ $tab[] = [
+ 'id' => '10',
+ 'table' => self::getTable(),
+ 'name' => __('Search', 'formcreator'),
+ 'field' => 'is_search_visible',
+ 'datatype' => 'integer',
+ 'nosearch' => true,
+ 'massiveaction' => true,
+ ];
+
+ $tab[] = [
+ 'id' => '11',
+ 'table' => self::getTable(),
+ 'name' => __('Counters dashboard', 'formcreator'),
+ 'field' => 'is_dashboard_visible',
+ 'datatype' => 'integer',
+ 'nosearch' => true,
+ 'massiveaction' => true,
+ ];
+
+ $tab[] = [
+ 'id' => '12',
+ 'table' => self::getTable(),
+ 'name' => __('Search issue', 'formcreator'),
+ 'field' => 'is_search_issue_visible',
+ 'datatype' => 'integer',
+ 'nosearch' => true,
+ 'massiveaction' => true,
+ ];
+
+ $tab[] = [
+ 'id' => '13',
+ 'table' => self::getTable(),
+ 'name' => __('Tile design', 'formcreator'),
+ 'field' => 'tile_design',
+ 'datatype' => 'integer',
+ 'nosearch' => false,
+ 'massiveaction' => true,
+ ];
+
+ $tab[] = [
+ 'id' => '14',
+ 'table' => self::getTable(),
+ 'name' => __('Form transition', 'formcreator'),
+ 'field' => 'form_transition',
+ 'datatype' => 'integer',
+ 'nosearch' => false,
+ 'massiveaction' => true,
+ ];
+
return $tab;
}
@@ -491,7 +578,6 @@ static function getUsedConfig($fieldref, $entities_id, $fieldval = '', $default_
if (!is_numeric($default_value)) {
return $entityConfig->fields[$fieldval];
}
-
}
}
@@ -502,7 +588,6 @@ static function getUsedConfig($fieldref, $entities_id, $fieldval = '', $default_
$ret = self::getUsedConfig($fieldref, $entity->fields['entities_id'], $fieldval,
$default_value);
return $ret;
-
}
}
diff --git a/inc/fields.class.php b/inc/fields.class.php
index 08be75b01..63b8015f9 100644
--- a/inc/fields.class.php
+++ b/inc/fields.class.php
@@ -366,7 +366,7 @@ public static function isVisible(PluginFormcreatorConditionnableInterface $item,
*/
public static function updateVisibility($input) {
$form = PluginFormcreatorCommon::getForm();
- $form->getFromDB((int) $input['plugin_formcreator_forms_id']);
+ $form->getFromDB((int) $input['id']);
$fields = $form->getFields();
foreach ($fields as $id => $field) {
$fields[$id]->parseAnswerValues($input, true);
diff --git a/inc/form.class.php b/inc/form.class.php
index ef4d8ffd2..6e68ba6de 100644
--- a/inc/form.class.php
+++ b/inc/form.class.php
@@ -541,7 +541,7 @@ public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $
case 2:
echo ' ';
- $item->displayUserForm();
+ $item->displayUserForm(true);
echo ' ';
break;
@@ -937,10 +937,11 @@ protected function showMyLastForms() : void {
/**
* Display the Form end-user form to be filled
+ * @param bool $forcePage Force display as page
*
* @return void
*/
- public function displayUserForm() : void {
+ public function displayUserForm(bool $forcePage = false) : void {
global $TRANSLATE;
// Print css media
@@ -958,16 +959,23 @@ public function displayUserForm() : void {
}
$formanswer = new PluginFormcreatorFormAnswer();
$formanswer->loadAnswersFromSession();
+ $options = [
+ 'columns' => PluginFormcreatorSection::COLUMNS,
+ 'domain' => $domain, // For translation
+ 'public' => isset($_SESSION['formcreator_public']),
+ 'formanswer' => $formanswer,
+ 'use_captcha' => ($this->fields['access_rights'] == PluginFormcreatorForm::ACCESS_PUBLIC
+ && $this->fields['is_captcha_enabled'] != '0'),
+ ];
+ $options['target'] = "javascript:;";
+ $options['formoptions'] = sprintf('onsubmit="plugin_formcreator.submitForm(this)"');
+ // if (!$forcePage && PluginFormcreatorEntityConfig::getUsedConfig('form_transition', Session::getActiveEntity()) == PluginFormcreatorEntityConfig::CONFIG_FORM_TRANSITION_MODAL) {
+ // $options['target'] = "javascript:;";
+ // $options['formoptions'] = sprintf('onsubmit="plugin_formcreator.submitForm(this)"');
+ // }
TemplateRenderer::getInstance()->display('@formcreator/pages/userform.html.twig', [
'item' => $this,
- 'options' => [
- 'columns' => PluginFormcreatorSection::COLUMNS,
- 'domain' => $domain, // For translation
- 'public' => isset($_SESSION['formcreator_public']),
- 'formanswer' => $formanswer,
- 'use_captcha' => ($this->fields['access_rights'] == PluginFormcreatorForm::ACCESS_PUBLIC
- && $this->fields['is_captcha_enabled'] != '0'),
- ]
+ 'options' => $options
]);
// Delete saved answers if any
unset($_SESSION['formcreator']['data']);
diff --git a/install/mysql/plugin_formcreator_empty.sql b/install/mysql/plugin_formcreator_empty.sql
index 506cc10ff..300060c03 100644
--- a/install/mysql/plugin_formcreator_empty.sql
+++ b/install/mysql/plugin_formcreator_empty.sql
@@ -10,6 +10,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_answers` (
INDEX `plugin_formcreator_formanswers_id` (`plugin_formcreator_formanswers_id`),
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_categories` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -28,6 +29,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_categories` (
INDEX `knowbaseitemcategories_id` (`knowbaseitemcategories_id`),
INDEX `plugin_formcreator_categories_id` (`plugin_formcreator_categories_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_entityconfigs` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`entities_id` int unsigned NOT NULL DEFAULT '0',
@@ -41,9 +43,11 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_entityconfigs` (
`is_search_issue_visible` int(11) NOT NULL DEFAULT '-2',
`tile_design` int(11) NOT NULL DEFAULT '-2',
`header` text,
+ `form_transition` int(11) NOT NULL DEFAULT '-2',
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`entities_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -73,6 +77,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms` (
INDEX `plugin_formcreator_categories_id` (`plugin_formcreator_categories_id`),
FULLTEXT KEY `Search` (`name`,`description`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -92,6 +97,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_formanswers` (
INDEX `users_id_validator` (`users_id_validator`),
INDEX `groups_id_validator` (`groups_id_validator`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_profiles` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0',
@@ -100,6 +106,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_profiles` (
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`profiles_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_users` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_forms_id` int unsigned NOT NULL,
@@ -108,6 +115,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_users` (
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`users_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_groups` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_forms_id` int unsigned NOT NULL,
@@ -116,6 +124,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_groups` (
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`groups_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_validators` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0',
@@ -125,6 +134,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_validators` (
PRIMARY KEY (`id`),
UNIQUE KEY `unicity` (`plugin_formcreator_forms_id`,`itemtype`,`items_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questions` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -145,6 +155,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questions` (
INDEX `plugin_formcreator_sections_id` (`plugin_formcreator_sections_id`),
FULLTEXT KEY `Search` (`name`,`description`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_conditions` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itemtype` varchar(255) NOT NULL DEFAULT '' COMMENT 'itemtype of the item affected by the condition',
@@ -159,6 +170,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_conditions` (
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`),
INDEX `item` (`itemtype`, `items_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_sections` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -169,6 +181,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_sections` (
PRIMARY KEY (`id`),
INDEX `plugin_formcreator_forms_id` (`plugin_formcreator_forms_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targetchanges` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -207,6 +220,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targetchanges` (
`uuid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -249,6 +263,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targettickets` (
PRIMARY KEY (`id`),
INDEX `tickettemplates_id` (`tickettemplates_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targetproblems` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
@@ -273,6 +288,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targetproblems` (
PRIMARY KEY (`id`),
INDEX `problemtemplates_id` (`problemtemplates_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targets_actors` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`itemtype` varchar(255) DEFAULT NULL,
@@ -286,6 +302,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_targets_actors` (
UNIQUE KEY `unicity` (`itemtype`,`items_id`, `actor_role`, `actor_type`, `actor_value`),
INDEX `item` (`itemtype`, `items_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_issues` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NULL DEFAULT NULL,
@@ -323,6 +340,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_issues` (
INDEX `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_items_targettickets` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_targettickets_id` int unsigned NOT NULL DEFAULT '0',
@@ -334,6 +352,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_items_targettickets` (
INDEX `plugin_formcreator_targettickets_id` (`plugin_formcreator_targettickets_id`),
INDEX `item` (`itemtype`,`items_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questiondependencies` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_questions_id` int unsigned NOT NULL DEFAULT '0',
@@ -344,6 +363,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questiondependencies` (
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`),
INDEX `plugin_formcreator_questions_id_2` (`plugin_formcreator_questions_id_2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionregexes` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_questions_id` int unsigned NOT NULL DEFAULT '0',
@@ -353,6 +373,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionregexes` (
PRIMARY KEY (`id`),
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionranges` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_questions_id` int unsigned NOT NULL DEFAULT '0',
@@ -363,6 +384,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_questionranges` (
PRIMARY KEY (`id`),
INDEX `plugin_formcreator_questions_id` (`plugin_formcreator_questions_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;
+
CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms_languages` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`plugin_formcreator_forms_id` int unsigned NOT NULL DEFAULT '0',
diff --git a/install/upgrade_to_2.14.php b/install/upgrade_to_2.14.php
index 68c3c2d19..5a620f636 100644
--- a/install/upgrade_to_2.14.php
+++ b/install/upgrade_to_2.14.php
@@ -36,35 +36,37 @@ class PluginFormcreatorUpgradeTo2_14 {
* @param Migration $migration
*/
public function upgrade(Migration $migration) {
- $this->migration = $migration;
+ $this->migration = $migration;
$this->addTtoToIssues();
$this->addRights();
$this->addPropertiesToCategories();
$this->addTargetActorUnicity();
+ $this->addFormTransition();
}
public function addTtoToIssues() {
- $table = (new DBUtils())->getTableForItemType(PluginFormcreatorIssue::class);
- $this->migration->addField($table, 'time_to_own', 'timestamp', ['after' => 'users_id_recipient']);
- $this->migration->addField($table, 'time_to_resolve', 'timestamp', ['after' => 'time_to_own']);
- $this->migration->addField($table, 'internal_time_to_own', 'timestamp', ['after' => 'time_to_resolve']);
- $this->migration->addField($table, 'internal_time_to_resolve', 'timestamp', ['after' => 'internal_time_to_own']);
- $this->migration->addField($table, 'solvedate', 'timestamp', ['after' => 'internal_time_to_resolve']);
- $this->migration->addField($table, 'date', 'timestamp', ['after' => 'solvedate']);
- $this->migration->addField($table, 'takeintoaccount_delay_stat', 'int', ['after' => 'date']);
+ $table = (new DBUtils())->getTableForItemType(PluginFormcreatorIssue::class);
+ $this->migration->addField($table, 'time_to_own', 'timestamp', ['after' => 'users_id_recipient']);
+ $this->migration->addField($table, 'time_to_resolve', 'timestamp', ['after' => 'time_to_own']);
+ $this->migration->addField($table, 'internal_time_to_own', 'timestamp', ['after' => 'time_to_resolve']);
+ $this->migration->addField($table, 'internal_time_to_resolve', 'timestamp', ['after' => 'internal_time_to_own']);
+ $this->migration->addField($table, 'solvedate', 'timestamp', ['after' => 'internal_time_to_resolve']);
+ $this->migration->addField($table, 'date', 'timestamp', ['after' => 'solvedate']);
+ $this->migration->addField($table, 'takeintoaccount_delay_stat', 'int', ['after' => 'date']);
- $this->migration->addKey($table, 'time_to_own');
- $this->migration->addKey($table, 'time_to_resolve');
- $this->migration->addKey($table, 'internal_time_to_own');
- $this->migration->addKey($table, 'internal_time_to_resolve');
- $this->migration->addKey($table, 'solvedate');
- $this->migration->addKey($table, 'date');
+ $this->migration->addKey($table, 'time_to_own');
+ $this->migration->addKey($table, 'time_to_resolve');
+ $this->migration->addKey($table, 'internal_time_to_own');
+ $this->migration->addKey($table, 'internal_time_to_resolve');
+ $this->migration->addKey($table, 'solvedate');
+ $this->migration->addKey($table, 'date');
}
public function addRights() {
- // Add rights
+ /** @var DBmysql $DB */
global $DB;
+
$profiles = $DB->request([
'SELECT' => ['id'],
'FROM' => Profile::getTable(),
@@ -92,6 +94,7 @@ public function isResyncIssuesRequiresd() {
}
public function addPropertiesToCategories() {
+ /** @var DBmysql $DB */
global $DB;
$table = (new DBUtils())->getTableForItemType(PluginFormcreatorCategory::class);
@@ -131,4 +134,10 @@ public function addTargetActorUnicity() {
// Set unicity
$this->migration->addKey($table, $unicity, 'unicity', 'UNIQUE');
}
+
+ public function addFormTransition() {
+ $table = (new DBUtils())->getTableForItemType(PluginFormcreatorEntityConfig::class);
+ $this->migration->addField($table, 'form_transition', 'integer', ['after' => 'header', 'value' => '-2']);
+ $this->migration->addPostQuery("UPDATE `$table` SET `form_transition`='0' WHERE `entities_id`='0'");
+ }
}
diff --git a/js/scripts.js b/js/scripts.js
index 53c52ccfd..2cf7516b8 100644
--- a/js/scripts.js
+++ b/js/scripts.js
@@ -419,7 +419,8 @@ function buildCategoryList(tree) {
function buildTiles(list) {
$(document).on('click', '.plugin_formcreator_formTile', function(){
- document.location = $(this).children('a').attr('href');
+ // document.location = $(this).children('a').attr('href');
+ $(this).children('a').trigger('click');
});
var html = '';
@@ -470,10 +471,11 @@ function buildTiles(list) {
}
if (item.type == 'form') {
+ url = 'plugin_formcreator.showUserForm(event, ' + item.id + ')';
forms.push(
' |