Skip to content

Commit cde943e

Browse files
authored
Profile Twig UI Part 3 (Lifecycle, Management and Tools)
1 parent 51394fd commit cde943e

File tree

6 files changed

+234
-186
lines changed

6 files changed

+234
-186
lines changed

src/Profile.php

Lines changed: 15 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,30 +1286,9 @@ public function showFormToolsHelpdesk()
12861286
return false;
12871287
}
12881288

1289-
echo "<div class='spaced'>";
1290-
if ($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) {
1291-
echo "<form method='post' action='" . $this->getFormURL() . "' data-track-changes='true'>";
1292-
}
1293-
1294-
$matrix_options = ['canedit' => $canedit,
1295-
'default_class' => 'tab_bg_2',
1296-
];
1297-
1298-
$matrix_options['title'] = __('Tools');
1299-
$this->displayRightsChoiceMatrix(self::getRightsForForm('helpdesk', 'tools', 'general'), $matrix_options);
1300-
1301-
if ($canedit) {
1302-
echo "<div class='center'>";
1303-
echo "<input type='hidden' name='id' value='" . $this->getID() . "'>";
1304-
echo Html::submit(_x('button', 'Save'), [
1305-
'class' => 'btn btn-primary mt-2',
1306-
'icon' => 'ti ti-device-floppy',
1307-
'name' => 'update',
1308-
]);
1309-
echo "</div>";
1310-
Html::closeForm();
1311-
}
1312-
echo "</div>";
1289+
TemplateRenderer::getInstance()->display('pages/admin/profile/tools_simple.html.twig', [
1290+
'item' => $this,
1291+
]);
13131292
}
13141293

13151294
/**
@@ -1382,55 +1361,9 @@ public function showFormManagement($openform = true, $closeform = true)
13821361
return false;
13831362
}
13841363

1385-
echo "<div class='spaced'>";
1386-
1387-
if (
1388-
($canedit = Session::haveRightsOr(self::$rightname, [UPDATE, CREATE, PURGE]))
1389-
&& $openform
1390-
) {
1391-
echo "<form method='post' action='" . $this->getFormURL() . "' data-track-changes='true'>";
1392-
}
1393-
1394-
$matrix_options = ['canedit' => $canedit,
1395-
'default_class' => 'tab_bg_2',
1396-
];
1397-
1398-
$matrix_options['title'] = __('Management');
1399-
$this->displayRightsChoiceMatrix(self::getRightsForForm('central', 'management', 'general'), $matrix_options);
1400-
1401-
echo "<div class='tab_cadre_fixehov mx-n2'>";
1402-
$rand = rand();
1403-
echo "<label for='dropdown_managed_domainrecordtypes$rand'>" . __s('Manageable domain records') . "</label>";
1404-
$values = ['-1' => __('All')];
1405-
$values += $this->getDomainRecordTypes();
1406-
Dropdown::showFromArray(
1407-
'managed_domainrecordtypes',
1408-
$values,
1409-
[
1410-
'display' => true,
1411-
'multiple' => true,
1412-
'size' => 3,
1413-
'rand' => $rand,
1414-
'values' => $this->fields['managed_domainrecordtypes'],
1415-
]
1416-
);
1417-
echo "</div>";
1418-
1419-
if (
1420-
$canedit
1421-
&& $closeform
1422-
) {
1423-
echo "<div class='center'>";
1424-
echo "<input type='hidden' name='id' value='" . $this->getID() . "'>";
1425-
echo Html::submit(_x('button', 'Save'), [
1426-
'class' => 'btn btn-primary mt-2',
1427-
'icon' => 'ti ti-device-floppy',
1428-
'name' => 'update',
1429-
]);
1430-
echo "</div>";
1431-
Html::closeForm();
1432-
}
1433-
echo "</div>";
1364+
TemplateRenderer::getInstance()->display('pages/admin/profile/management.html.twig', [
1365+
'item' => $this,
1366+
]);
14341367
}
14351368

14361369
/**
@@ -1447,40 +1380,9 @@ public function showFormTools($openform = true, $closeform = true)
14471380
return false;
14481381
}
14491382

1450-
echo "<div class='spaced'>";
1451-
1452-
if (
1453-
($canedit = Session::haveRightsOr(self::$rightname, [UPDATE, CREATE, PURGE]))
1454-
&& $openform
1455-
) {
1456-
echo "<form method='post' action='" . $this->getFormURL() . "' data-track-changes='true'>";
1457-
}
1458-
1459-
$matrix_options = ['canedit' => $canedit,
1460-
'default_class' => 'tab_bg_2',
1461-
];
1462-
1463-
$matrix_options['title'] = __('Tools');
1464-
$this->displayRightsChoiceMatrix(self::getRightsForForm('central', 'tools', 'general'), $matrix_options);
1465-
1466-
$matrix_options['title'] = _n('Project', 'Projects', Session::getPluralNumber());
1467-
$this->displayRightsChoiceMatrix(self::getRightsForForm('central', 'tools', 'projects'), $matrix_options);
1468-
1469-
if (
1470-
$canedit
1471-
&& $closeform
1472-
) {
1473-
echo "<div class='center'>";
1474-
echo "<input type='hidden' name='id' value='" . $this->getID() . "'>";
1475-
echo Html::submit(_x('button', 'Save'), [
1476-
'class' => 'btn btn-primary mt-2',
1477-
'icon' => 'ti ti-device-floppy',
1478-
'name' => 'update',
1479-
]);
1480-
echo "</div>";
1481-
Html::closeForm();
1482-
}
1483-
echo "</div>";
1383+
TemplateRenderer::getInstance()->display('pages/admin/profile/tools.html.twig', [
1384+
'item' => $this,
1385+
]);
14841386
}
14851387

14861388
/**
@@ -1740,54 +1642,9 @@ public function showFormLifeCycle($openform = true, $closeform = true)
17401642
return false;
17411643
}
17421644

1743-
echo "<div class='spaced'>";
1744-
1745-
if (
1746-
($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE]))
1747-
&& $openform
1748-
) {
1749-
echo "<form method='post' action='" . $this->getFormURL() . "' data-track-changes='true'>";
1750-
}
1751-
1752-
$this->displayLifeCycleMatrix(
1753-
__('Life cycle of tickets'),
1754-
'_cycle_ticket',
1755-
'ticket_status',
1756-
Ticket::getAllStatusArray(),
1757-
$canedit
1758-
);
1759-
1760-
$this->displayLifeCycleMatrix(
1761-
__('Life cycle of problems'),
1762-
'_cycle_problem',
1763-
'problem_status',
1764-
Problem::getAllStatusArray(),
1765-
$canedit
1766-
);
1767-
1768-
$this->displayLifeCycleMatrix(
1769-
__('Life cycle of changes'),
1770-
'_cycle_change',
1771-
'change_status',
1772-
Change::getAllStatusArray(),
1773-
$canedit
1774-
);
1775-
1776-
if (
1777-
$canedit
1778-
&& $closeform
1779-
) {
1780-
echo "<div class='center'>";
1781-
echo "<input type='hidden' name='id' value='" . $this->getID() . "'>";
1782-
echo Html::submit(_x('button', 'Save'), [
1783-
'class' => 'btn btn-primary mt-2',
1784-
'icon' => 'ti ti-device-floppy',
1785-
'name' => 'update',
1786-
]);
1787-
echo "</div>";
1788-
Html::closeForm();
1789-
}
1790-
echo "</div>";
1645+
TemplateRenderer::getInstance()->display('pages/admin/profile/lifecycle.html.twig', [
1646+
'item' => $this,
1647+
]);
17911648
}
17921649

17931650
/**
@@ -1874,37 +1731,9 @@ public function showFormLifeCycleHelpdesk($openform = true, $closeform = true)
18741731
return false;
18751732
}
18761733

1877-
echo "<div class='spaced'>";
1878-
1879-
if (
1880-
($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE]))
1881-
&& $openform
1882-
) {
1883-
echo "<form method='post' action='" . $this->getFormURL() . "' data-track-changes='true'>";
1884-
}
1885-
1886-
$this->displayLifeCycleMatrixTicketHelpdesk(
1887-
__('Life cycle of tickets'),
1888-
'_cycle_ticket',
1889-
'ticket_status',
1890-
$canedit
1891-
);
1892-
1893-
if (
1894-
$canedit
1895-
&& $closeform
1896-
) {
1897-
echo "<div class='center'>";
1898-
echo "<input type='hidden' name='id' value='" . $this->getID() . "'>";
1899-
echo Html::submit(_x('button', 'Save'), [
1900-
'class' => 'btn btn-primary mt-2',
1901-
'icon' => 'ti ti-device-floppy',
1902-
'name' => 'update',
1903-
]);
1904-
echo "</div>";
1905-
Html::closeForm();
1906-
}
1907-
echo "</div>";
1734+
TemplateRenderer::getInstance()->display('pages/admin/profile/lifecycle_simple.html.twig', [
1735+
'item' => $this,
1736+
]);
19081737
}
19091738

19101739
/**
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{#
2+
# ---------------------------------------------------------------------
3+
#
4+
# GLPI - Gestionnaire Libre de Parc Informatique
5+
#
6+
# http://glpi-project.org
7+
#
8+
# @copyright 2015-2025 Teclib' and contributors.
9+
# @licence https://www.gnu.org/licenses/gpl-3.0.html
10+
#
11+
# ---------------------------------------------------------------------
12+
#
13+
# LICENSE
14+
#
15+
# This file is part of GLPI.
16+
#
17+
# This program is free software: you can redistribute it and/or modify
18+
# it under the terms of the GNU General Public License as published by
19+
# the Free Software Foundation, either version 3 of the License, or
20+
# (at your option) any later version.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
#
30+
# ---------------------------------------------------------------------
31+
#}
32+
33+
{% extends 'pages/admin/profile/base_tab.html.twig' %}
34+
35+
{% block content %}
36+
{{ _self.displayLifecycleMatrix(
37+
__('Life cycle of tickets'),
38+
'_cycle_ticket',
39+
'ticket_status',
40+
call('Ticket::getAllStatusArray')
41+
) }}
42+
{{ _self.displayLifecycleMatrix(
43+
__('Life cycle of problems'),
44+
'_cycle_problem',
45+
'problem_status',
46+
call('Problem::getAllStatusArray')
47+
) }}
48+
{{ _self.displayLifecycleMatrix(
49+
__('Life cycle of changes'),
50+
'_cycle_change',
51+
'change_status',
52+
call('Change::getAllStatusArray')
53+
) }}
54+
{% endblock %}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{#
2+
# ---------------------------------------------------------------------
3+
#
4+
# GLPI - Gestionnaire Libre de Parc Informatique
5+
#
6+
# http://glpi-project.org
7+
#
8+
# @copyright 2015-2025 Teclib' and contributors.
9+
# @licence https://www.gnu.org/licenses/gpl-3.0.html
10+
#
11+
# ---------------------------------------------------------------------
12+
#
13+
# LICENSE
14+
#
15+
# This file is part of GLPI.
16+
#
17+
# This program is free software: you can redistribute it and/or modify
18+
# it under the terms of the GNU General Public License as published by
19+
# the Free Software Foundation, either version 3 of the License, or
20+
# (at your option) any later version.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
#
30+
# ---------------------------------------------------------------------
31+
#}
32+
33+
{% extends 'pages/admin/profile/base_tab.html.twig' %}
34+
35+
{% block content %}
36+
{% do item.displayLifeCycleMatrixTicketHelpdesk(
37+
__('Life cycle of tickets'),
38+
'_cycle_ticket',
39+
'ticket_status',
40+
has_profile_right('profile', constant('CREATE')) or has_profile_right('profile', constant('UPDATE')) or has_profile_right('profile', constant('PURGE'))
41+
) %}
42+
{% endblock %}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{#
2+
# ---------------------------------------------------------------------
3+
#
4+
# GLPI - Gestionnaire Libre de Parc Informatique
5+
#
6+
# http://glpi-project.org
7+
#
8+
# @copyright 2015-2025 Teclib' and contributors.
9+
# @licence https://www.gnu.org/licenses/gpl-3.0.html
10+
#
11+
# ---------------------------------------------------------------------
12+
#
13+
# LICENSE
14+
#
15+
# This file is part of GLPI.
16+
#
17+
# This program is free software: you can redistribute it and/or modify
18+
# it under the terms of the GNU General Public License as published by
19+
# the Free Software Foundation, either version 3 of the License, or
20+
# (at your option) any later version.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
#
30+
# ---------------------------------------------------------------------
31+
#}
32+
33+
{% extends 'pages/admin/profile/base_tab.html.twig' %}
34+
{% import 'components/form/fields_macros.html.twig' as fields %}
35+
36+
{% block content %}
37+
{{ _self.displayRightsMatrix(item, 'central', 'management', 'general', __('Management')) }}
38+
{{ fields.dropdownArrayField(
39+
'managed_domainrecordtypes',
40+
'',
41+
{'-1': __('All')} + item.getDomainRecordTypes(),
42+
__('Manageable domain records'),
43+
{
44+
multiple: true,
45+
values: item.fields['managed_domainrecordtypes'],
46+
}
47+
) }}
48+
{% endblock %}

0 commit comments

Comments
 (0)