Skip to content

Commit bd9b865

Browse files
committed
feat(issue): validation_percent
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 429453d commit bd9b865

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

inc/common.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public static function getTicketStatusForIssue(Ticket $item) : array {
267267
'timeline_position ASC'
268268
], 1);
269269
$user = 0;
270+
$validationPercent = $item->fields['validation_percent'];
270271
$ticketValidationCount = count($ticketValidations);
271272
if ($ticketValidationCount) {
272273
$row = array_shift($ticketValidations);
@@ -289,7 +290,7 @@ public static function getTicketStatusForIssue(Ticket $item) : array {
289290
}
290291
}
291292

292-
return ['status' => $status, 'user' => $user];
293+
return ['status' => $status, 'user' => $user, 'validation_percent' => $validationPercent];
293294
}
294295

295296
/**

inc/issue.class.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
104104
'groups_id_validator as groups_id_validator',
105105
'comment as comment'
106106
],
107+
new QueryExpression("IF(`$formAnswerTable`.`status` = '" . PluginFormcreatorFormAnswer::STATUS_ACCEPTED . "', '100', '0') as `validation_percent`"),
107108
],
108109
'DISTINCT' => true,
109110
'FROM' => $formAnswerTable,
@@ -160,6 +161,7 @@ public static function getSyncIssuesRequest() : AbstractQuery {
160161
"$ticketUserTable.users_id as requester_id",
161162
new QueryExpression("IF(`$ticketValidationTable`.`users_id_validate` IS NULL, 0, `$ticketValidationTable`.`users_id_validate`) as users_id_validator"),
162163
new QueryExpression('0 as groups_id_validator'),
164+
'validation_percent as validation_percent',
163165
"$ticketTable.content as comment",
164166
],
165167
'DISTINCT' => true,
@@ -410,7 +412,7 @@ public function rawSearchOptions() {
410412

411413
$tab[] = [
412414
'id' => '1',
413-
'table' => $this::getTable(),
415+
'table' => self::getTable(),
414416
'field' => 'name',
415417
'name' => __('Name'),
416418
'datatype' => 'itemlink',
@@ -423,7 +425,7 @@ public function rawSearchOptions() {
423425

424426
$tab[] = [
425427
'id' => '2',
426-
'table' => $this::getTable(),
428+
'table' => self::getTable(),
427429
'field' => 'display_id',
428430
'name' => __('ID'),
429431
'datatype' => 'string',
@@ -432,7 +434,7 @@ public function rawSearchOptions() {
432434

433435
$tab[] = [
434436
'id' => '3',
435-
'table' => $this::getTable(),
437+
'table' => self::getTable(),
436438
'field' => 'sub_itemtype',
437439
'name' => __('Type'),
438440
'searchtype' => [
@@ -445,7 +447,7 @@ public function rawSearchOptions() {
445447

446448
$tab[] = [
447449
'id' => '4',
448-
'table' => $this::getTable(),
450+
'table' => self::getTable(),
449451
'field' => 'status',
450452
'name' => __('Status'),
451453
'searchtype' => [
@@ -457,7 +459,7 @@ public function rawSearchOptions() {
457459

458460
$tab[] = [
459461
'id' => '5',
460-
'table' => $this::getTable(),
462+
'table' => self::getTable(),
461463
'field' => 'date_creation',
462464
'name' => __('Opening date'),
463465
'datatype' => 'datetime',
@@ -466,7 +468,7 @@ public function rawSearchOptions() {
466468

467469
$tab[] = [
468470
'id' => '6',
469-
'table' => $this::getTable(),
471+
'table' => self::getTable(),
470472
'field' => 'date_mod',
471473
'name' => __('Last update'),
472474
'datatype' => 'datetime',

install/mysql/plugin_formcreator_empty.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_issues` (
253253
`requester_id` int(11) NOT NULL DEFAULT '0',
254254
`users_id_validator` int(11) NOT NULL DEFAULT '0',
255255
`groups_id_validator` int(11) NOT NULL DEFAULT '0',
256+
`validation_percent` int(11) NOT NULL DEFAULT '0',
256257
`comment` longtext,
257258
PRIMARY KEY (`id`),
258259
INDEX `original_id_sub_itemtype` (`original_id`, `sub_itemtype`),

install/upgrade_to_2.12.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function upgrade(Migration $migration) {
4747
$table = 'glpi_plugin_formcreator_issues';
4848
$migration->changeField($table, 'date_creation', 'date_creation', 'timestamp'. ' NOT NULL DEFAULT CURRENT_TIMESTAMP');
4949
$migration->changeField($table, 'date_mod', 'date_mod', 'timestamp'. ' NOT NULL DEFAULT CURRENT_TIMESTAMP');
50+
$this->addValidationPercent();
5051

5152
$this->changeDropdownTreeSettings();
5253

@@ -89,4 +90,10 @@ public function changeDropdownTreeSettings() {
8990
$DB->update($table, ['values' => $newValues], ['id' => $row['id']]);
9091
}
9192
}
93+
94+
public function addValidationPercent() {
95+
$table = 'glpi_plugin_formcreator_issues';
96+
$this->migration->addField($table, 'validation_percent', 'integer', ['after' => 'groups_id_validator']);
97+
$this->migration->addPostQuery("UPDATE `$table` as `i` INNER JOIN `glpi_tickets` as `t` ON (`i`.`original_id` = `t`.`id` AND `i`.`sub_itemtype` = 'Ticket') SET `i`.`validation_percent`=`t`.`validation_percent`");
98+
}
9299
}

0 commit comments

Comments
 (0)