Program: CWE-94
Project: CVE-2022-24780
Buggy source:
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
  <constants>
    <constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string"
              _delta="define"><![CDATA[SELECT SLT AS slt JOIN lnkSLAToSLT AS l1 ON l1.slt_id=slt.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkCustomerContractToService AS l2 ON l2.sla_id=sla.id JOIN CustomerContract AS sc ON l2.customercontract_id=sc.id WHERE slt.metric = :metric AND l2.service_id = :this->service_id AND sc.org_id = :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
  </constants>
  <classes>
    <class id="Ticket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <php_parent>
        <name>_Ticket</name>
      </php_parent>
      <properties>
        <comment><![CDATA[/**
 * Persistent classes for a CMDB
 *
 * @copyright   Copyright (C) 2010-2017 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */]]></comment>
        <category>bizmodel,searchable,structure</category>
        <abstract>true</abstract>
        <key_type>autoincrement</key_type>
        <db_table>ticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field>finalclass</db_final_class_field>
        <naming>
          <attributes>
            <attribute id="ref"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ref"/>
            <attribute id="finalclass"/>
          </attributes>
        </reconciliation>
        <indexes>
          <index id="ref">
            <attributes>
              <attribute id="ref"/>
            </attributes>
          </index>
        </indexes>
        <uniqueness_rules>
          <rule id="ref">
            <attributes>
              <attribute id="ref"/>
            </attributes>
            <is_blocking>false</is_blocking>
          </rule>
        </uniqueness_rules>
      </properties>
      <fields>
        <field id="operational_status" xsi:type="AttributeMetaEnum">
          <values>
            <value id="ongoing">ongoing</value>
            <value id="resolved">resolved</value>
            <value id="closed">closed</value>
          </values>
          <sql>operational_status</sql>
          <default_value>ongoing</default_value>
          <mappings>
            <mapping id="Ticket">
              <attcode>status</attcode>
              <metavalues>
                <metavalue id="resolved">
                  <values>
                    <value id="resolved"/>
                  </values>
                </metavalue>
                <metavalue id="closed">
                  <values>
                    <value id="closed"/>
                    <value id="rejected"/>
                  </values>
                </metavalue>
              </metavalues>
            </mapping>
          </mappings>
        </field>
        <field id="ref" xsi:type="AttributeString">
          <sql>ref</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="org_id" xsi:type="AttributeExternalKey">
          <sql>org_id</sql>
          <target_class>Organization</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="org_name" xsi:type="AttributeExternalField">
          <extkey_attcode>org_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="caller_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person WHERE org_id = :this->org_id]]></filter>
          <dependencies>
            <attribute id="org_id"/>
          </dependencies>
          <sql>caller_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="caller_name" xsi:type="AttributeExternalField">
          <extkey_attcode>caller_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="team_id" xsi:type="AttributeExternalKey">
          <sql>team_id</sql>
          <target_class>Team</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="team_name" xsi:type="AttributeExternalField">
          <extkey_attcode>team_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="agent_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person AS p JOIN lnkPersonToTeam AS l ON l.person_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->team_id]]></filter>
          <dependencies>
            <attribute id="team_id"/>
          </dependencies>
          <sql>agent_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
          <allow_target_creation>false</allow_target_creation>
        </field>
        <field id="agent_name" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="title" xsi:type="AttributeString">
          <sql>title</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="description" xsi:type="AttributeText">
          <sql>description</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
          <format>html</format>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <always_load_in_tables>true</always_load_in_tables>
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="end_date" xsi:type="AttributeDateTime">
          <sql>end_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="last_update" xsi:type="AttributeDateTime">
          <sql>last_update</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
          <tracking_level>none</tracking_level>
        </field>
        <field id="close_date" xsi:type="AttributeDateTime">
          <sql>close_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="private_log" xsi:type="AttributeCaseLog">
          <sql>private_log</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="contacts_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkContactToTicket</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
          <ext_key_to_remote>contact_id</ext_key_to_remote>
          <duplicates/>
        </field>
        <field id="functionalcis_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkFunctionalCIToTicket</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
          <ext_key_to_remote>functionalci_id</ext_key_to_remote>
          <duplicates/>
        </field>
        <field id="workorders_list" xsi:type="AttributeLinkedSet">
          <linked_class>WorkOrder</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
        </field>
      </fields>
      <methods>
        <method id="DBInsertNoReload">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
    public function DBInsertNoReload()
    {
          $iNextId = ItopCounter::IncClass(get_class($this));
          $sRef = $this->MakeTicketRef($iNextId);
          $this->SetIfNull('ref', $sRef);
          $iKey = parent::DBInsertNoReload();
          return $iKey;
    }
        ]]></code>
        </method>
        <method id="MakeTicketRef">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
        protected function MakeTicketRef($iNextId)
        {
                return sprintf(static::GetTicketRefFormat(), $iNextId);
        }
        ]]></code>
        </method>
        <method id="GetTicketRefFormat">
          <static>true</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
        public static function GetTicketRefFormat()
        {
                return 'T-%06d';
        }
        ]]></code>
        </method>
      </methods>
      <presentation>
        <details>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="caller_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="title">
              <rank>60</rank>
            </item>
            <item id="description">
              <rank>70</rank>
            </item>
            <item id="operational_status">
              <rank>75</rank>
            </item>
            <item id="start_date">
              <rank>80</rank>
            </item>
            <item id="end_date">
              <rank>90</rank>
            </item>
            <item id="last_update">
              <rank>100</rank>
            </item>
            <item id="close_date">
              <rank>110</rank>
            </item>
            <item id="private_log">
              <rank>120</rank>
            </item>
            <item id="contacts_list">
              <rank>130</rank>
            </item>
            <item id="functionalcis_list">
              <rank>140</rank>
            </item>
            <item id="workorders_list">
              <rank>150</rank>
            </item>
          </items>
        </details>
        <default_search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="caller_id">
              <rank>30</rank>
            </item>
            <item id="org_id">
              <rank>35</rank>
            </item>
          </items>
        </default_search>
        <search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="description">
              <rank>30</rank>
            </item>
            <item id="operational_status">
              <rank>35</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="end_date">
              <rank>50</rank>
            </item>
            <item id="last_update">
              <rank>60</rank>
            </item>
            <item id="close_date">
              <rank>70</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="title">
              <rank>30</rank>
            </item>
            <item id="caller_id">
              <rank>40</rank>
            </item>
            <item id="team_id">
              <rank>50</rank>
            </item>
            <item id="agent_id">
              <rank>60</rank>
            </item>
            <item id="operational_status">
              <rank>65</rank>
            </item>
            <item id="start_date">
              <rank>70</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkContactToTicket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnkcontacttoticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="contact_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="contact_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="contact_id" xsi:type="AttributeExternalKey">
          <sql>contact_id</sql>
          <target_class>Contact</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="contact_email" xsi:type="AttributeExternalField">
          <extkey_attcode>contact_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="role" xsi:type="AttributeString">
          <sql>role</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="role_code" xsi:type="AttributeEnum">
          <values>
            <value id="manual">manual</value>
            <value id="computed">computed</value>
            <value id="do_not_notify">do_not_notify</value>
          </values>
          <sql>impact_code</sql>
          <default_value>manual</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkFunctionalCIToTicket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnkfunctionalcitoticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="functionalci_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="functionalci_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="ticket_title" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>title</target_attcode>
        </field>
        <field id="functionalci_id" xsi:type="AttributeExternalKey">
          <sql>functionalci_id</sql>
          <target_class>FunctionalCI</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="functionalci_name" xsi:type="AttributeExternalField">
          <extkey_attcode>functionalci_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="impact" xsi:type="AttributeString">
          <sql>impact</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="impact_code" xsi:type="AttributeEnum">
          <values>
            <value id="manual">manual</value>
            <value id="computed">computed</value>
            <value id="not_impacted">not_impacted</value>
          </values>
          <sql>impact_code</sql>
          <default_value>manual</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="WorkOrder" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <category>bizmodel,searchable,incidentmgmt,requestmgmt,changemgmt,m2prequest</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>workorder</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="name"/>
          </attributes>
        </naming>
        <display_template/>
        <icon>images/workorder.png</icon>
        <reconciliation>
          <attributes>
            <attribute id="name"/>
            <attribute id="ticket_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="name" xsi:type="AttributeString">
          <sql>name</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="status" xsi:type="AttributeEnum">
          <values>
            <value id="open">open</value>
            <value id="closed">closed</value>
          </values>
          <sql>status</sql>
          <default_value>open</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
        <field id="description" xsi:type="AttributeText">
          <sql>description</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="team_id" xsi:type="AttributeExternalKey">
          <filter>SELECT Team</filter>
          <sql>team_id</sql>
          <target_class>Team</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
        </field>
        <field id="team_name" xsi:type="AttributeExternalField">
          <extkey_attcode>team_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="agent_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person AS p JOIN lnkPersonToTeam AS l ON l.person_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->team_id]]></filter>
          <dependencies>
            <attribute id="team_id"/>
          </dependencies>
          <sql>owner_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <allow_target_creation>false</allow_target_creation>
        </field>
        <field id="agent_email" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="end_date" xsi:type="AttributeDateTime">
          <sql>end_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="log" xsi:type="AttributeCaseLog">
          <sql>log</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
      </fields>
      <lifecycle>
        <attribute>status</attribute>
        <stimuli>
          <stimulus id="ev_close" xsi:type="StimulusUserAction"/>
        </stimuli>
        <states>
          <state id="open">
            <flags/>
            <transitions>
              <transition id="ev_close">
                <target>closed</target>
                <actions/>
              </transition>
            </transitions>
          </state>
          <state id="closed">
            <flags/>
            <transitions/>
          </state>
        </states>
      </lifecycle>
      <methods>
        <method id="UpdateParentTicketLog">
          <static>false</static>
          <access>public</access>
          <type>StimulusUserAction</type>
          <arguments>
          </arguments>
          <code><![CDATA[	public function UpdateParentTicketLog()
	{
		$oLog = $this->Get('log');
		$sLog = $oLog->GetModifiedEntry('html');
		if ($sLog != '')
		{
			$oTicket = MetaModel::GetObject('Ticket', $this->Get('ticket_id'), false);
			if ($oTicket)
			{
				$oTicket->Set('private_log', $sLog);
				$oTicket->DBUpdate();
			}
		}
	}]]></code>
        </method>
        <method id="OnUpdate">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	protected function OnUpdate()
	{
		$this->UpdateParentTicketLog();
	}]]></code>
        </method>
      </methods>
      <presentation>
        <details>
          <items>
            <item id="name">
              <rank>10</rank>
            </item>
            <item id="status">
              <rank>20</rank>
            </item>
            <item id="ticket_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="description">
              <rank>60</rank>
            </item>
            <item id="start_date">
              <rank>70</rank>
            </item>
            <item id="end_date">
              <rank>80</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="name">
              <rank>10</rank>
            </item>
            <item id="status">
              <rank>20</rank>
            </item>
            <item id="ticket_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="start_date">
              <rank>60</rank>
            </item>
            <item id="end_date">
              <rank>70</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="status">
              <rank>10</rank>
            </item>
            <item id="ticket_id">
              <rank>20</rank>
            </item>
            <item id="start_date">
              <rank>30</rank>
            </item>
            <item id="end_date">
              <rank>40</rank>
            </item>
            <item id="team_id">
              <rank>50</rank>
            </item>
            <item id="agent_id">
              <rank>60</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
  </classes>
  <meta>
    <classes>
      <class id="cmdbAbstractObject" _delta="define">
        <methods>
          <method id="Set">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                    <type id="AttributeLinkedSetIndirect"/>
                    <type id="AttributeLinkedSet"/>
                    <type id="AttributeImage"/>
                    <type id="AttributeBlob"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="SetIfNull">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                    <type id="AttributeLinkedSetIndirect"/>
                    <type id="AttributeLinkedSet"/>
                    <type id="AttributeImage"/>
                    <type id="AttributeBlob"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentDate">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDate"/>
                    <type id="AttributeDateTime"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentUser">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeExternalKey"/>
                    <type id="AttributeInteger"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentPerson">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeExternalKey"/>
                    <type id="AttributeInteger"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetElapsedTime">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDuration"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDate"/>
                    <type id="AttributeDateTime"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="3">
                <type>string</type>
                <mandatory>false</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="Reset">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="ResetStopWatch">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="Copy">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>attcode</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="ApplyStimulus">
            <arguments>
              <argument id="1">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillCreationForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillTransitionForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillSearchForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
        </methods>
      </class>
      <class id="ResponseTicketTTO" _delta="define">
        <interfaces>
          <interface id="iMetricComputer"/>
        </interfaces>
      </class>
      <class id="ResponseTicketTTR" _delta="define">
        <interfaces>
          <interface id="iMetricComputer"/>
        </interfaces>
      </class>
    </classes>
  </meta>
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal" _delta="define">
      <properties>
        <name>portal:itop-portal</name>
        <!-- Can be either a fileref or a relative path to the file (To be tested). Takes over env-xxx/branding/portal-logo.png -->
        <!-- Priority order is <logo> from xml > env-xxx/branding/portal-logo.png > /images/logo-itop-dark-bg.svg -->
        <!--<fileref ref="brt_6a2be154b2a62659d3332c513bdad715"  />-->
        <!--<logo>../images/itop-logo.png</logo>-->
        <!-- Can be either a fileref or a relative path to the file from /env-xxx (eg. itop-portal-base/mystyle.css) -->
        <!-- Available themes must have a unique id. Some ids are loaded in a specific order : bootstrap/portal/custom. Other ids are loaded after them, but their order cannot be predicted -->
        <themes/>
        <!-- Can be either a fileref or a relative path to the file from /env-xxx (eg. itop-portal-base/mytemplate.html.twig) -->
        <!-- Available templates are id="layout|home" -->
        <templates/>
        <!-- Class used for generating objects view/edit urls (eg. in linked sets). -->
        <!-- Note: Notification placeholders are NOT using this but the "DBObject::RegisterURLMakerClass(<PORTAL_ID>, <CLASS_NAME>)" declarations. -->
        <urlmaker_class>iTopPortalViewUrlMaker</urlmaker_class>
        <!-- An OQL query to determine which TriggerOnPortalUpdate to use within THIS instance of the portal. This is mostly needed to enable different triggers on several portal instances -->
        <!-- Note : ":parent_classes" parameter is a reserved name that will be used for the current object class name (and its ancestors) -->
        <triggers_query><![CDATA[SELECT TriggerOnPortalUpdate AS t WHERE t.target_class IN (:parent_classes)]]></triggers_query>
        <attachments>
          <allow_delete>true</allow_delete>
        </attachments>
        <allowed_portals>
          <!-- Defines how other portals -allowed for the current user- will be opened. "tab" for a new tab, "self" for the current window -->
          <opening_mode>tab</opening_mode>
        </allowed_portals>
      </properties>
      <bricks>
        <brick id="user-profile" xsi:type="Combodo\iTop\Portal\Brick\UserProfileBrick">
          <rank>
            <!-- Can be either a <default> tag for both home page and navigation menu or distinct <home> or/and <navigation_menu> tags-->
            <default>1</default>
          </rank>
          <title>
            <!-- Can be either a <default> tag for both home page and navigation menu or distinct <home> or/and <navigation_menu> tags-->
            <default>Brick:Portal:UserProfile:Navigation:Dropdown:MyProfil</default>
          </title>
          <decoration_class>
            <default>fas fa-user fa-2x</default>
          </decoration_class>
          <!-- Show / hide some of the user profile forms by setting the tag value to true|false -->
          <!--<show_picture_form>true</show_picture_form>-->
          <!--<show_preferences_form>true</show_preferences_form>-->
          <!--<show_password_form>true</show_password_form>-->
          <form>
            <!-- Optional tag to list the fields. If empty only fields from <twig> tag will be displayed, if omitted fields from zlist details will. -->
            <fields/>
            <!-- Optional tag to specify the form layout. Fields that are not positioned in the layout will be placed at the end of the form -->
            <twig>
              <!-- data-field-id attribute must be an attribute code of the class -->
              <!-- data-field-flags attribute contains flags among read_only/hidden/mandatory/must_prompt/must_change -->
              <div class="form_field" data-field-id="first_name" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="name" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="org_id" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="email" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="phone">
              </div>
              <div class="form_field" data-field-id="location_id">
              </div>
              <div class="form_field" data-field-id="function">
              </div>
              <div class="form_field" data-field-id="manager_id" data-field-flags="read_only">
              </div>
            </twig>
          </form>
        </brick>
        <brick id="services" xsi:type="Combodo\iTop\Portal\Brick\BrowseBrick">
          <active>true</active>
          <width>6</width>
          <rank>
            <default>10</default>
          </rank>
          <title>
            <default>Brick:Portal:NewRequest:Title</default>
          </title>
          <description>Brick:Portal:NewRequest:Title+</description>
          <decoration_class>
            <default>fc fc-new-request fc-2x</default>
          </decoration_class>
          <!-- <fields  /> Optional tag to add attributes to the table by their code, can be specified for each level -->
          <levels>
            <level id="1">
              <class>ServiceFamily</class>
              <image_att>icon</image_att>
              <levels>
                <!-- Level IDs must be numeric -->
                <level id="1">
                  <!-- Can be either a class tag with the class name or an oql tag with the query -->
                  <class>Service</class>
                  <!-- Attribute code of the above class [from the OQL] that point to the upper level class -->
                  <parent_att>servicefamily_id</parent_att>
                  <!-- Attribute code of the above class [from the OQL] used to display the object name, default is 'name'. -->
                  <name_att/>
                  <!-- Attribute code of the above class [from the OQL] used to display in a tooltip when mouse is over the object -->
                  <tooltip_att>description</tooltip_att>
                  <!-- Attribute code of the above class [from the OQL] used to display a small text beside the object's name -->
                  <!-- Note: This is not used in "list" mode -->
                  <description_att>description</description_att>
                  <!-- Attribute code of the above class [from the OQL] used to display a image beside the object's name -->
                  <!-- Note: This is used in "mosaic" mode only for now -->
                  <image_att>icon</image_att>
                  <!-- Title of the level, will be display in lists and others browse modes -->
                  <title>Class:Service</title>
                  <!-- Optional tag to add attributes to the table by their code, can be specified for each level -->
                  <!-- Note: Fields will only be displayed in "list" mode but will still be used for filter in other modes -->
                  <!-- <fields  /> -->
                  <!-- Can be empty on intermediate levels, default is drilldown -->
                  <actions>
                    <action id="drilldown" xsi:type="drilldown"/>
                  </actions>
                  <levels>
                    <level id="1">
                      <!-- Note : We could have used just a class tag and put the OQL in the scope for everybody -->
                      <oql><![CDATA[SELECT ServiceSubcategory WHERE ServiceSubcategory.status != 'obsolete']]></oql>
                      <parent_att>service_id</parent_att>
                      <name_att/>
                      <tooltip_att>description</tooltip_att>
                      <description_att>description</description_att>
                      <title>Class:ServiceSubcategory</title>
                      <actions>
                        <action id="create_from_this" xsi:type="create_from_this">
                          <!-- Can be either a class tag containing the class of the object to create, or a static method taking the origin object as a parameter and that will return a object of the desired class -->
                          <!-- (eg. \Ticket::FromServiceSubcategory($oOrigin) that should return either a UserRequest or Incident regarding the request type) -->
                          <class>UserRequest</class>
                          <!-- Optional tag that can be used on any action type -->
                          <!--<title>Create a ticket</title>-->
                          <!-- Optional tag to define if the action should be done in a modal window ("modal"), a new window ("new") or the current window ("self") -->
                          <!--<opening_target>modal</opening_target>-->
                          <icon_class>fc fc-new-request fc-1-6x fc-flip-horizontal</icon_class>
                          <!-- Optional tag to order actions -->
                          <!--<rank>1</rank>-->
                          <rules>
                            <rule id="contact-to-userrequest"/>
                            <rule id="servicesubcategory-to-userrequest"/>
                            <rule id="go-to-open-request-on-submit"/>
                          </rules>
                        </action>
                        <action id="view" xsi:type="view"/>
                      </actions>
                      <levels/>
                    </level>
                  </levels>
                </level>
              </levels>
            </level>
          </levels>
          <browse_modes>
            <availables>
              <mode id="list"/>
              <mode id="tree"/>
              <mode id="mosaic"/>
            </availables>
            <default>list</default>
          </browse_modes>
          <!-- Optional. Set the default number of item lists will display. -->
          <!-- <default_list_length>20</default_list_length> -->
          <data_loading>auto</data_loading>
          <!-- lazy|full|auto. Let the consultant choose if the list/tree data are load progressively at each page/level or in one-shot or if it is up to the system regarding the "lazy_loading_threshold" parameter -->
        </brick>
        <brick id="ongoing-tickets-for-portal-user" xsi:type="Combodo\iTop\Portal\Brick\ManageBrick">
          <active>true</active>
          <rank>
            <default>20</default>
          </rank>
          <width>6</width>
          <title>
            <default>Brick:Portal:OngoingRequests:Title</default>
          </title>
          <!-- Optional tag to define which display modes can be used in the brick's page and the brick's tile -->
          <!--<display_modes>-->
          <!-- Optional tag that must contain at least 1 <mode> tag. -->
          <!--<availables>-->
          <!--<mode id="list"/>-->
          <!--<mode id="pie-chart"/>-->
          <!--<mode id="bar-chart"/>-->
          <!--</availables>-->
          <!-- Optional tag to define which display mode will be used by default when opening the brick -->
          <!--<default>list</default>-->
          <!-- Optional tag to define which display mode will be used to render the brick's tile -->
          <!--<tile>text</tile>-->
          <!--</display_modes>-->
          <description>Brick:Portal:OngoingRequests:Title+</description>
          <decoration_class>
            <default>fc fc-ongoing-request fc-2x</default>
          </decoration_class>
          <oql><![CDATA[SELECT Ticket]]></oql>
          <!-- Optional tag to define if the action should be done in a modal window ("modal"), a new window ("new") or the current window ("self") -->
          <!--<opening_target>modal</opening_target>-->
          <!-- Optional tag to define the how the objects should be opened. Values can be edit|view. Note that even if this is set to edit, objects not allowed in edition mode for the user (cf. scopes and security layers) will open in view mode -->
          <!-- <opening_mode>edit</opening_mode> -->
          <!-- Can be either a class tag with the class name or an oql tag with the query -->
          <!-- <class>Ticket</class> -->
          <fields>
            <field id="title"/>
            <field id="start_date"/>
            <field id="status"/>
            <field id="service_id"/>
            <field id="servicesubcategory_id"/>
            <field id="priority"/>
            <field id="caller_id"/>
          </fields>
          <!-- Optional tag to add attributes to the table by their code -->
          <grouping>
            <!-- Mandatory -->
            <tabs>
              <!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
              <show_tab_counts>true</show_tab_counts>
              <!-- Mandatory. Grouping by tabs -->
              <!--<attribute>operational_status</attribute>-->
              <!-- attribute xor groups tag -->
              <groups>
                <!-- Can be used only with ../oql tag, not ../class tag. Reason is that we can't know the class alias to apply to the condition's fields. We might have an exception saying that the field in ambiguous for the generated query. -->
                <group id="opened">
                  <rank>1</rank>
                  <title>Brick:Portal:OngoingRequests:Tab:OnGoing</title>
                  <!-- Optional. A string or dictionary entry to display under the page title for this tab -->
                  <!-- <description>Brick:Portal:OngoingRequests:Tab:OnGoing+</description> -->
                  <condition><![CDATA[SELECT Ticket AS T WHERE operational_status NOT IN ('closed', 'resolved')]]></condition>
                </group>
                <group id="resolved">
                  <rank>2</rank>
                  <title>Brick:Portal:OngoingRequests:Tab:Resolved</title>
                  <condition><![CDATA[SELECT Ticket AS T WHERE operational_status = 'resolved']]></condition>
                </group>
              </groups>
            </tabs>
            <!-- Implicit grouping on y axis by finalclass -->
          </grouping>
          <!-- Optional. Set the default number of item lists will display. -->
          <!-- <default_list_length>20</default_list_length> -->
          <data_loading>full</data_loading>
          <export>
            <export_default_fields>true</export_default_fields>
          </export>
        </brick>
        <brick id="closed-tickets-for-portal-user" xsi:type="Combodo\iTop\Portal\Brick\ManageBrick">
          <active>true</active>
          <rank>
            <navigation_menu>50</navigation_menu>
          </rank>
          <visible>
            <home>false</home>
          </visible>
          <width>12</width>
          <title>
            <default>Brick:Portal:ClosedRequests:Title</default>
          </title>
          <description></description>
          <decoration_class>
            <default>fc fc-closed-request fc-2x</default>
          </decoration_class>
          <oql><![CDATA[SELECT Ticket WHERE operational_status = 'closed']]></oql>
          <!-- Can be either a class tag with the class name or an oql tag with the query -->
          <!-- <class>Ticket</class> -->
          <fields>
            <field id="finalclass"/>
            <field id="title"/>
            <field id="start_date"/>
            <field id="status"/>
            <field id="servicesubcategory_id"/>
            <field id="priority"/>
            <field id="caller_id"/>
          </fields>
          <grouping>
            <tabs>
              <!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
              <!--<show_tab_counts>false</show_tab_counts>-->
              <groups>
                <group id="all">
                  <rank>1</rank>
                  <title>Brick:Portal:ClosedRequests:Title</title>
                  <condition><![CDATA[SELECT Ticket]]></condition>
                </group>
              </groups>
            </tabs>
            <!-- Implicit grouping on y axis by finalclass -->
          </grouping>
          <data_loading>auto</data_loading>
          <export>
            <export_default_fields>true</export_default_fields>
          </export>
        </brick>
      </bricks>
      <forms>
        <form id="service-view">
          <class>Service</class>
          <fields></fields>
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="name">
                </div>
                <div class="form_field" data-field-id="description">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="org_id">
                </div>
                <div class="form_field" data-field-id="servicefamily_id">
                </div>
                <div class="form_field" data-field-id="status">
                </div>
              </div>
            </div>
          </twig>
          <modes>
            <mode id="view"/>
          </modes>
        </form>
        <form id="servicesubcategory">
          <class>ServiceSubcategory</class>
          <!-- Optional tag to list the fields. If empty only fields from <twig> tag will be displayed, if omitted fields from zlist details will. -->
          <fields/>
          <!-- Optional tag to specify the form layout. Fields that are not positioned in the layout will be placed at the end of the form -->
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <!-- data-field-id attribute must be an attribute code of the class -->
                <div class="form_field" data-field-id="service_id">
                </div>
                <!-- data-field-flags attribute contains flags among read_only/hidden/mandatory/must_prompt/must_change -->
                <div class="form_field" data-field-id="name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="status" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="service_org_id">
                </div>
                <div class="form_field" data-field-id="request_type">
                </div>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="description">
              </div>
            </div>
          </twig>
        </form>
        <form id="ticket-create">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="service_id" data-field-flags="mandatory">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="servicesubcategory_id" data-field-flags="mandatory">
                </div>
              </div>
            </div>
            <div id="service_details_placeholder">
            </div>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="impact">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="urgency">
                </div>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="title">
              </div>
              <div class="form_field" data-field-id="description">
              </div>
              <div class="form_field" data-field-id="contacts_list">
              </div>
            </div>
          </twig>
          <modes>
            <!-- mode id can among create / edit / view -->
            <mode id="create"/>
          </modes>
        </form>
        <form id="ticket-edit">
          <class>Ticket</class>
          <properties>
            <!-- Optional, display mode of the form fields. "cosy" for a regular labels over values layout; "compact" for a side-by-side
            layout with input aligned; "dense" for a side-by-side layout with input filling all available space. You can also use a custom css class that will be used on the form as "form_xxx", as well as on the fields as "form_field_xxx".-->
            <!--<display_mode>cosy</display_mode>-->
            <!-- Optional, when set to false, submit button is hidden when transitions are available on the object (in creation and edit
            mode). Default is false. -->
            <!--<always_show_submit>false</always_show_submit>-->
            <!-- Optional, navigation rules to define where to go when clicking on the submit/cancel buttons of the form -->
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields></fields>
          <twig>
            <div class="row">
              <div class="col-sm-7">
                <fieldset>
                  <legend>{{'Ticket:baseinfo'|dict_s}}</legend>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="title" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="service_id" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="caller_id" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="servicesubcategory_id" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-12">
                    <div class="form_field" data-field-id="description" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="solution" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="user_satisfaction" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="user_comment" data-field-flags="read_only"></div>
                  </div>
                </fieldset>
              </div>
              <div class="col-sm-5">
                <fieldset>
                  <legend>{{'Ticket:Type'|dict_s}} &amp; {{'Ticket:date'|dict_s}}</legend>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="status" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="impact" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="urgency" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="priority" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="start_date" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="last_update" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="resolution_date" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="agent_id" data-field-flags="read_only"></div>
                  </div>
                </fieldset>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="contacts_list"></div>
              <div class="form_field" data-field-id="public_log"></div>
            </div>
          </twig>
          <modes>
            <mode id="edit"/>
            <mode id="view"/>
          </modes>
        </form>
        <form id="ticket-reopen">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig>
            <div>
              <div class="form_field" data-field-id="public_log" data-field-flags="must_change"></div>
              <div class="form_field" data-field-id="team_id" data-field-flags="hidden"></div>
              <div class="form_field" data-field-id="agent_id" data-field-flags="hidden"></div>
            </div>
          </twig>
          <modes>
            <mode id="apply_stimulus">
              <stimuli>
                <stimulus id="ev_reopen"/>
              </stimuli>
            </mode>
          </modes>
        </form>
        <form id="ticket-apply-stimulus">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig/>
          <modes>
            <mode id="apply_stimulus"/>
          </modes>
        </form>
        <form id="person-view">
          <class>Person</class>
          <fields/>
          <twig>
            <div class="row">
              <div class="col-sm-4">
                <div class="form_field" data-field-id="picture" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="first_name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="status" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="org_id" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="function" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="manager_id" data-field-flags="read_only">
                </div>
              </div>
            </div>
          </twig>
        </form>
      </forms>
      <classes>
        <!-- Note : A class (or one of its ancestors) MUST be declared here to be displayed in the portal -->
        <class id="User">
          <!-- Allow <allowed_profile>s to apply the <transition>s below. Flags on <field>s will be merged with those from datamodel -->
          <!-- See example in UserRequest class -->
          <!--<lifecycle/>-->
          <scopes>
            <!-- Note : Silos apply to those scope queries -->
            <scope id="all">
              <oql_view><![CDATA[SELECT User AS U JOIN Person AS P ON U.contactid=P.id WHERE P.id = :current_contact_id]]></oql_view>
              <!-- No object of this class can be edited -->
              <!--<oql_edit />-->
              <!-- Everybody -->
              <!--<allowed_profiles />-->
            </scope>
          </scopes>
        </class>
        <class id="Organization">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Organization WHERE id = :current_contact->org_id]]></oql_view>
            </scope>
          </scopes>
        </class>
        <class id="Location">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Location WHERE org_id = :current_contact->org_id]]></oql_view>
            </scope>
          </scopes>
        </class>
        <class id="Contact">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Contact WHERE org_id = :current_contact->org_id]]></oql_view>
            </scope>
            <scope id="admin">
              <oql_view><![CDATA[SELECT Contact]]></oql_view>
              <allowed_profiles>
                <allowed_profile id="Administrator"/>
              </allowed_profiles>
            </scope>
          </scopes>
          <lists>
            <list id="default">
              <items>
                <item id="status">
                  <rank>10</rank>
                </item>
                <item id="org_id">
                  <rank>20</rank>
                </item>
                <item id="function">
                  <rank>50</rank>
                </item>
              </items>
            </list>
          </lists>
        </class>
        <class id="ServiceFamily">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT ServiceFamily AS sf JOIN Service AS s ON s.servicefamily_id = sf.id JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id]]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="Service">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id AND s.status != 'obsolete']]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="ServiceSubcategory">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT ServiceSubcategory AS ssc JOIN Service AS s ON ssc.service_id=s.id JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id AND ssc.status != 'obsolete']]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="Ticket">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Ticket AS T WHERE T.caller_id = :current_contact_id AND T.finalclass IN ('UserRequest', 'Incident')]]></oql_view>
              <oql_edit><![CDATA[SELECT Ticket AS T]]></oql_edit>
            </scope>
            <scope id="portal-power-user">
              <oql_view><![CDATA[SELECT Ticket AS T WHERE T.org_id = :current_contact->org_id AND T.finalclass IN ('UserRequest', 'Incident')]]></oql_view>
              <oql_edit><![CDATA[SELECT Ticket AS T]]></oql_edit>
              <allowed_profiles>
                <allowed_profile id="Portal power user"/>
              </allowed_profiles>
            </scope>
          </scopes>
        </class>
      </classes>
      <action_rules>
        <action_rule id="contact-to-userrequest">
          <!-- source_oql|source_class is only necessary if there is some copy preset|retrofit -->
          <source_oql><![CDATA[SELECT Contact AS C WHERE C.id = :current_contact_id]]></source_oql>
          <presets>
            <!-- Only set() and copy() are supported for now -->
            <preset id="1">set(caller_id, $current_contact_id$)</preset>
            <preset id="2">copy(org_id, org_id)</preset>
            <preset id="3">set(origin, portal)</preset>
          </presets>
          <retrofits/>
        </action_rule>
        <action_rule id="service-to-userrequest">
          <source_class>Service</source_class>
          <presets>
            <preset id="1">copy(id, service_id)</preset>
          </presets>
        </action_rule>
        <action_rule id="servicesubcategory-to-userrequest">
          <source_class>ServiceSubcategory</source_class>
          <presets>
            <preset id="1">copy(id, servicesubcategory_id)</preset>
            <preset id="2">copy(service_id, service_id)</preset>
          </presets>
        </action_rule>
        <!-- Deprecated, will be removed in iTop 2.8 -->
        <action_rule id="go-to-open-request-on-submit">
          <submit xsi:type="goto">
            <brick>ongoing-tickets-for-portal-user</brick>
          </submit>
        </action_rule>
      </action_rules>
      <navigation_rules>
        <!-- Close form (either the modal or the whole page) -->
        <navigation_rule id="close-form" xsi:type="close"/>
        <!-- Go to the homepage -->
        <navigation_rule id="go-to-homepage" xsi:type="go-to-homepage"/>
        <!-- Open a manage brick (simple method) -->
        <navigation_rule id="go-to-open-requests" xsi:type="go-to-manage-brick">
          <!-- Mandatory, ID of the ManageBrick to go to -->
          <id>ongoing-tickets-for-portal-user</id>
          <!-- Optional, must be an ID of the available display modes of the brick (//brick/display_modes/availables/mode) -->
          <!-- <display_mode>list</mode> -->
          <!-- Optional, must be an ID of the grouping tab of the brick (//brick/grouping/tabs/groups/group)-->
          <!-- <grouping_tab>resolved</grouping_tab> -->
          <!-- Optional, a string to preset as filter in the brick. ":this->XXX" can be used for the current object -->
          <!-- <filter>:this->caller_id_friendlyname</filter> -->
        </navigation_rule>
        <!-- Open a browse brick -->
        <navigation_rule id="go-to-services" xsi:type="go-to-browse-brick">
          <!-- Mandatory, ID of the BrowseBrick to go to -->
          <id>services</id>
          <!-- Optional, must be an ID of the available browse modes of the brick (//brick/browse_modes/availables/mode) -->
          <!-- <browse_mode>tree</browse_mode> -->
          <!-- Optional, a string to preset as filter in the brick. ":this->XXX" can be used for the current object -->
          <!-- <filter>computer</filter> -->
        </navigation_rule>
        <!-- Open a brick, developer method -->
        <!-- <navigation_rule id="go-to-open-requests-alternate-way" xsi:type="go-to-brick"> -->
        <!-- <route> -->
        <!-- <id>p_manage_brick_display_as</id> -->
        <!-- <params> -->
        <!-- <param id="sBrickId">ongoing-tickets-for-portal-user</param> -->
        <!-- <param id="sDisplayMode">pie-chart</param> -->
        <!-- <param id="sGroupingTab">resolved</param> -->
        <!-- </params> -->
        <!-- </route> -->
        <!-- </navigation_rule> -->
      </navigation_rules>
    </module_design>
  </module_designs>
  <module_parameters>
    <parameters id="itop-portal" _delta="define">
      <lazy_loading_threshold>500</lazy_loading_threshold><!-- Will be placed in the conf/<env>/config-itop.php file under the itop-portal module's settings  -->
    </parameters>
  </module_parameters>
</itop_design>


Fixed version (ground truth):
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.7">
  <constants>
    <constant id="RESPONSE_TICKET_SLT_QUERY" xsi:type="string"
              _delta="define"><![CDATA[SELECT SLT AS slt JOIN lnkSLAToSLT AS l1 ON l1.slt_id=slt.id JOIN SLA AS sla ON l1.sla_id=sla.id JOIN lnkCustomerContractToService AS l2 ON l2.sla_id=sla.id JOIN CustomerContract AS sc ON l2.customercontract_id=sc.id WHERE slt.metric = :metric AND l2.service_id = :this->service_id AND sc.org_id = :this->org_id AND slt.request_type = :request_type AND slt.priority = :this->priority]]></constant>
  </constants>
  <classes>
    <class id="Ticket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <php_parent>
        <name>_Ticket</name>
      </php_parent>
      <properties>
        <comment><![CDATA[/**
 * Persistent classes for a CMDB
 *
 * @copyright   Copyright (C) 2010-2017 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */]]></comment>
        <category>bizmodel,searchable,structure</category>
        <abstract>true</abstract>
        <key_type>autoincrement</key_type>
        <db_table>ticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field>finalclass</db_final_class_field>
        <naming>
          <attributes>
            <attribute id="ref"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ref"/>
            <attribute id="finalclass"/>
          </attributes>
        </reconciliation>
        <indexes>
          <index id="ref">
            <attributes>
              <attribute id="ref"/>
            </attributes>
          </index>
        </indexes>
        <uniqueness_rules>
          <rule id="ref">
            <attributes>
              <attribute id="ref"/>
            </attributes>
            <is_blocking>false</is_blocking>
          </rule>
        </uniqueness_rules>
      </properties>
      <fields>
        <field id="operational_status" xsi:type="AttributeMetaEnum">
          <values>
            <value id="ongoing">ongoing</value>
            <value id="resolved">resolved</value>
            <value id="closed">closed</value>
          </values>
          <sql>operational_status</sql>
          <default_value>ongoing</default_value>
          <mappings>
            <mapping id="Ticket">
              <attcode>status</attcode>
              <metavalues>
                <metavalue id="resolved">
                  <values>
                    <value id="resolved"/>
                  </values>
                </metavalue>
                <metavalue id="closed">
                  <values>
                    <value id="closed"/>
                    <value id="rejected"/>
                  </values>
                </metavalue>
              </metavalues>
            </mapping>
          </mappings>
        </field>
        <field id="ref" xsi:type="AttributeString">
          <sql>ref</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="org_id" xsi:type="AttributeExternalKey">
          <sql>org_id</sql>
          <target_class>Organization</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="org_name" xsi:type="AttributeExternalField">
          <extkey_attcode>org_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="caller_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person WHERE org_id = :this->org_id]]></filter>
          <dependencies>
            <attribute id="org_id"/>
          </dependencies>
          <sql>caller_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="caller_name" xsi:type="AttributeExternalField">
          <extkey_attcode>caller_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="team_id" xsi:type="AttributeExternalKey">
          <sql>team_id</sql>
          <target_class>Team</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="team_name" xsi:type="AttributeExternalField">
          <extkey_attcode>team_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="agent_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person AS p JOIN lnkPersonToTeam AS l ON l.person_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->team_id]]></filter>
          <dependencies>
            <attribute id="team_id"/>
          </dependencies>
          <sql>agent_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
          <allow_target_creation>false</allow_target_creation>
        </field>
        <field id="agent_name" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="title" xsi:type="AttributeString">
          <sql>title</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="description" xsi:type="AttributeText">
          <sql>description</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
          <format>html</format>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <always_load_in_tables>true</always_load_in_tables>
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="end_date" xsi:type="AttributeDateTime">
          <sql>end_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="last_update" xsi:type="AttributeDateTime">
          <sql>last_update</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
          <tracking_level>none</tracking_level>
        </field>
        <field id="close_date" xsi:type="AttributeDateTime">
          <sql>close_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="private_log" xsi:type="AttributeCaseLog">
          <sql>private_log</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="contacts_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkContactToTicket</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
          <ext_key_to_remote>contact_id</ext_key_to_remote>
          <duplicates/>
        </field>
        <field id="functionalcis_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkFunctionalCIToTicket</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
          <ext_key_to_remote>functionalci_id</ext_key_to_remote>
          <duplicates/>
        </field>
        <field id="workorders_list" xsi:type="AttributeLinkedSet">
          <linked_class>WorkOrder</linked_class>
          <ext_key_to_me>ticket_id</ext_key_to_me>
          <count_min>0</count_min>
          <count_max>0</count_max>
        </field>
      </fields>
      <methods>
        <method id="DBInsertNoReload">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
    public function DBInsertNoReload()
    {
          $iNextId = ItopCounter::IncClass(get_class($this));
          $sRef = $this->MakeTicketRef($iNextId);
          $this->SetIfNull('ref', $sRef);
          $iKey = parent::DBInsertNoReload();
          return $iKey;
    }
        ]]></code>
        </method>
        <method id="MakeTicketRef">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
        protected function MakeTicketRef($iNextId)
        {
                return sprintf(static::GetTicketRefFormat(), $iNextId);
        }
        ]]></code>
        </method>
        <method id="GetTicketRefFormat">
          <static>true</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[
        public static function GetTicketRefFormat()
        {
                return 'T-%06d';
        }
        ]]></code>
        </method>
      </methods>
      <presentation>
        <details>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="caller_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="title">
              <rank>60</rank>
            </item>
            <item id="description">
              <rank>70</rank>
            </item>
            <item id="operational_status">
              <rank>75</rank>
            </item>
            <item id="start_date">
              <rank>80</rank>
            </item>
            <item id="end_date">
              <rank>90</rank>
            </item>
            <item id="last_update">
              <rank>100</rank>
            </item>
            <item id="close_date">
              <rank>110</rank>
            </item>
            <item id="private_log">
              <rank>120</rank>
            </item>
            <item id="contacts_list">
              <rank>130</rank>
            </item>
            <item id="functionalcis_list">
              <rank>140</rank>
            </item>
            <item id="workorders_list">
              <rank>150</rank>
            </item>
          </items>
        </details>
        <default_search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="caller_id">
              <rank>30</rank>
            </item>
            <item id="org_id">
              <rank>35</rank>
            </item>
          </items>
        </default_search>
        <search>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="description">
              <rank>30</rank>
            </item>
            <item id="operational_status">
              <rank>35</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="end_date">
              <rank>50</rank>
            </item>
            <item id="last_update">
              <rank>60</rank>
            </item>
            <item id="close_date">
              <rank>70</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="org_id">
              <rank>20</rank>
            </item>
            <item id="title">
              <rank>30</rank>
            </item>
            <item id="caller_id">
              <rank>40</rank>
            </item>
            <item id="team_id">
              <rank>50</rank>
            </item>
            <item id="agent_id">
              <rank>60</rank>
            </item>
            <item id="operational_status">
              <rank>65</rank>
            </item>
            <item id="start_date">
              <rank>70</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkContactToTicket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnkcontacttoticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="contact_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="contact_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="contact_id" xsi:type="AttributeExternalKey">
          <sql>contact_id</sql>
          <target_class>Contact</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="contact_email" xsi:type="AttributeExternalField">
          <extkey_attcode>contact_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="role" xsi:type="AttributeString">
          <sql>role</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="role_code" xsi:type="AttributeEnum">
          <values>
            <value id="manual">manual</value>
            <value id="computed">computed</value>
            <value id="do_not_notify">do_not_notify</value>
          </values>
          <sql>impact_code</sql>
          <default_value>manual</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="role_code">
              <rank>30</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkFunctionalCIToTicket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnkfunctionalcitoticket</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="functionalci_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="functionalci_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="ticket_title" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>title</target_attcode>
        </field>
        <field id="functionalci_id" xsi:type="AttributeExternalKey">
          <sql>functionalci_id</sql>
          <target_class>FunctionalCI</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="functionalci_name" xsi:type="AttributeExternalField">
          <extkey_attcode>functionalci_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="impact" xsi:type="AttributeString">
          <sql>impact</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="impact_code" xsi:type="AttributeEnum">
          <values>
            <value id="manual">manual</value>
            <value id="computed">computed</value>
            <value id="not_impacted">not_impacted</value>
          </values>
          <sql>impact_code</sql>
          <default_value>manual</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="functionalci_id">
              <rank>20</rank>
            </item>
            <item id="impact_code">
              <rank>30</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="WorkOrder" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <category>bizmodel,searchable,incidentmgmt,requestmgmt,changemgmt,m2prequest</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>workorder</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="name"/>
          </attributes>
        </naming>
        <display_template/>
        <icon>images/workorder.png</icon>
        <reconciliation>
          <attributes>
            <attribute id="name"/>
            <attribute id="ticket_id"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="name" xsi:type="AttributeString">
          <sql>name</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="status" xsi:type="AttributeEnum">
          <values>
            <value id="open">open</value>
            <value id="closed">closed</value>
          </values>
          <sql>status</sql>
          <default_value>open</default_value>
          <is_null_allowed>false</is_null_allowed>
          <display_style>list</display_style>
        </field>
        <field id="description" xsi:type="AttributeText">
          <sql>description</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="ticket_id" xsi:type="AttributeExternalKey">
          <sql>ticket_id</sql>
          <target_class>Ticket</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="team_id" xsi:type="AttributeExternalKey">
          <filter>SELECT Team</filter>
          <sql>team_id</sql>
          <target_class>Team</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
        </field>
        <field id="team_name" xsi:type="AttributeExternalField">
          <extkey_attcode>team_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="agent_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person AS p JOIN lnkPersonToTeam AS l ON l.person_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->team_id]]></filter>
          <dependencies>
            <attribute id="team_id"/>
          </dependencies>
          <sql>owner_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <allow_target_creation>false</allow_target_creation>
        </field>
        <field id="agent_email" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="end_date" xsi:type="AttributeDateTime">
          <sql>end_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="log" xsi:type="AttributeCaseLog">
          <sql>log</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
      </fields>
      <lifecycle>
        <attribute>status</attribute>
        <stimuli>
          <stimulus id="ev_close" xsi:type="StimulusUserAction"/>
        </stimuli>
        <states>
          <state id="open">
            <flags/>
            <transitions>
              <transition id="ev_close">
                <target>closed</target>
                <actions/>
              </transition>
            </transitions>
          </state>
          <state id="closed">
            <flags/>
            <transitions/>
          </state>
        </states>
      </lifecycle>
      <methods>
        <method id="UpdateParentTicketLog">
          <static>false</static>
          <access>public</access>
          <type>StimulusUserAction</type>
          <arguments>
          </arguments>
          <code><![CDATA[	public function UpdateParentTicketLog()
	{
		$oLog = $this->Get('log');
		$sLog = $oLog->GetModifiedEntry('html');
		if ($sLog != '')
		{
			$oTicket = MetaModel::GetObject('Ticket', $this->Get('ticket_id'), false);
			if ($oTicket)
			{
				$oTicket->Set('private_log', $sLog);
				$oTicket->DBUpdate();
			}
		}
	}]]></code>
        </method>
        <method id="OnUpdate">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	protected function OnUpdate()
	{
		$this->UpdateParentTicketLog();
	}]]></code>
        </method>
      </methods>
      <presentation>
        <details>
          <items>
            <item id="name">
              <rank>10</rank>
            </item>
            <item id="status">
              <rank>20</rank>
            </item>
            <item id="ticket_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="description">
              <rank>60</rank>
            </item>
            <item id="start_date">
              <rank>70</rank>
            </item>
            <item id="end_date">
              <rank>80</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="name">
              <rank>10</rank>
            </item>
            <item id="status">
              <rank>20</rank>
            </item>
            <item id="ticket_id">
              <rank>30</rank>
            </item>
            <item id="team_id">
              <rank>40</rank>
            </item>
            <item id="agent_id">
              <rank>50</rank>
            </item>
            <item id="start_date">
              <rank>60</rank>
            </item>
            <item id="end_date">
              <rank>70</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="status">
              <rank>10</rank>
            </item>
            <item id="ticket_id">
              <rank>20</rank>
            </item>
            <item id="start_date">
              <rank>30</rank>
            </item>
            <item id="end_date">
              <rank>40</rank>
            </item>
            <item id="team_id">
              <rank>50</rank>
            </item>
            <item id="agent_id">
              <rank>60</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
  </classes>
  <meta>
    <classes>
      <class id="cmdbAbstractObject" _delta="define">
        <methods>
          <method id="Set">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                    <type id="AttributeLinkedSetIndirect"/>
                    <type id="AttributeLinkedSet"/>
                    <type id="AttributeImage"/>
                    <type id="AttributeBlob"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="SetIfNull">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                    <type id="AttributeLinkedSetIndirect"/>
                    <type id="AttributeLinkedSet"/>
                    <type id="AttributeImage"/>
                    <type id="AttributeBlob"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentDate">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDate"/>
                    <type id="AttributeDateTime"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentUser">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeExternalKey"/>
                    <type id="AttributeInteger"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetCurrentPerson">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeExternalKey"/>
                    <type id="AttributeInteger"/>
                    <type id="AttributeString"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="SetElapsedTime">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDuration"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeDate"/>
                    <type id="AttributeDateTime"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="3">
                <type>string</type>
                <mandatory>false</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="Reset">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="ResetStopWatch">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>allow</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                  </types>
                </type_restrictions>
              </argument>
            </arguments>
          </method>
          <method id="Copy">
            <arguments>
              <argument id="1">
                <type>attcode</type>
                <mandatory>true</mandatory>
                <type_restrictions>
                  <operation>deny</operation>
                  <types>
                    <type id="AttributeStopWatch"/>
                    <type id="AttributeSubItem"/>
                    <type id="AttributeExternalField"/>
                  </types>
                </type_restrictions>
              </argument>
              <argument id="2">
                <type>attcode</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="ApplyStimulus">
            <arguments>
              <argument id="1">
                <type>string</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillCreationForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillTransitionForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
          <method id="PrefillSearchForm">
            <arguments>
              <argument id="1">
                <type>reference</type>
                <mandatory>true</mandatory>
              </argument>
            </arguments>
          </method>
        </methods>
      </class>
      <class id="ResponseTicketTTO" _delta="define">
        <interfaces>
          <interface id="iMetricComputer"/>
        </interfaces>
      </class>
      <class id="ResponseTicketTTR" _delta="define">
        <interfaces>
          <interface id="iMetricComputer"/>
        </interfaces>
      </class>
    </classes>
  </meta>
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal" _delta="define">
      <properties>
        <name>portal:itop-portal</name>
        <!-- Can be either a fileref or a relative path to the file (To be tested). Takes over env-xxx/branding/portal-logo.png -->
        <!-- Priority order is <logo> from xml > env-xxx/branding/portal-logo.png > /images/logo-itop-dark-bg.svg -->
        <!--<fileref ref="brt_6a2be154b2a62659d3332c513bdad715"  />-->
        <!--<logo>../images/itop-logo.png</logo>-->
        <!-- Can be either a fileref or a relative path to the file from /env-xxx (eg. itop-portal-base/mystyle.css) -->
        <!-- Available themes must have a unique id. Some ids are loaded in a specific order : bootstrap/portal/custom. Other ids are loaded after them, but their order cannot be predicted -->
        <themes/>
        <!-- Can be either a fileref or a relative path to the file from /env-xxx (eg. itop-portal-base/mytemplate.html.twig) -->
        <!-- Available templates are id="layout|home" -->
        <templates/>
        <!-- Class used for generating objects view/edit urls (eg. in linked sets). -->
        <!-- Note: Notification placeholders are NOT using this but the "DBObject::RegisterURLMakerClass(<PORTAL_ID>, <CLASS_NAME>)" declarations. -->
        <urlmaker_class>iTopPortalViewUrlMaker</urlmaker_class>
        <!-- An OQL query to determine which TriggerOnPortalUpdate to use within THIS instance of the portal. This is mostly needed to enable different triggers on several portal instances -->
        <!-- Note : ":parent_classes" parameter is a reserved name that will be used for the current object class name (and its ancestors) -->
        <triggers_query><![CDATA[SELECT TriggerOnPortalUpdate AS t WHERE t.target_class IN (:parent_classes)]]></triggers_query>
        <attachments>
          <allow_delete>true</allow_delete>
        </attachments>
        <allowed_portals>
          <!-- Defines how other portals -allowed for the current user- will be opened. "tab" for a new tab, "self" for the current window -->
          <opening_mode>tab</opening_mode>
        </allowed_portals>
      </properties>
      <bricks>
        <brick id="user-profile" xsi:type="Combodo\iTop\Portal\Brick\UserProfileBrick">
          <rank>
            <!-- Can be either a <default> tag for both home page and navigation menu or distinct <home> or/and <navigation_menu> tags-->
            <default>1</default>
          </rank>
          <title>
            <!-- Can be either a <default> tag for both home page and navigation menu or distinct <home> or/and <navigation_menu> tags-->
            <default>Brick:Portal:UserProfile:Navigation:Dropdown:MyProfil</default>
          </title>
          <decoration_class>
            <default>fas fa-user fa-2x</default>
          </decoration_class>
          <!-- Show / hide some of the user profile forms by setting the tag value to true|false -->
          <!--<show_picture_form>true</show_picture_form>-->
          <!--<show_preferences_form>true</show_preferences_form>-->
          <!--<show_password_form>true</show_password_form>-->
          <form>
            <!-- Optional tag to list the fields. If empty only fields from <twig> tag will be displayed, if omitted fields from zlist details will. -->
            <fields/>
            <!-- Optional tag to specify the form layout. Fields that are not positioned in the layout will be placed at the end of the form -->
            <twig>
              <!-- data-field-id attribute must be an attribute code of the class -->
              <!-- data-field-flags attribute contains flags among read_only/hidden/mandatory/must_prompt/must_change -->
              <div class="form_field" data-field-id="first_name" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="name" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="org_id" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="email" data-field-flags="read_only">
              </div>
              <div class="form_field" data-field-id="phone">
              </div>
              <div class="form_field" data-field-id="location_id">
              </div>
              <div class="form_field" data-field-id="function">
              </div>
              <div class="form_field" data-field-id="manager_id" data-field-flags="read_only">
              </div>
            </twig>
          </form>
        </brick>
        <brick id="services" xsi:type="Combodo\iTop\Portal\Brick\BrowseBrick">
          <active>true</active>
          <width>6</width>
          <rank>
            <default>10</default>
          </rank>
          <title>
            <default>Brick:Portal:NewRequest:Title</default>
          </title>
          <description>Brick:Portal:NewRequest:Title+</description>
          <decoration_class>
            <default>fc fc-new-request fc-2x</default>
          </decoration_class>
          <!-- <fields  /> Optional tag to add attributes to the table by their code, can be specified for each level -->
          <levels>
            <level id="1">
              <class>ServiceFamily</class>
              <image_att>icon</image_att>
              <levels>
                <!-- Level IDs must be numeric -->
                <level id="1">
                  <!-- Can be either a class tag with the class name or an oql tag with the query -->
                  <class>Service</class>
                  <!-- Attribute code of the above class [from the OQL] that point to the upper level class -->
                  <parent_att>servicefamily_id</parent_att>
                  <!-- Attribute code of the above class [from the OQL] used to display the object name, default is 'name'. -->
                  <name_att/>
                  <!-- Attribute code of the above class [from the OQL] used to display in a tooltip when mouse is over the object -->
                  <tooltip_att>description</tooltip_att>
                  <!-- Attribute code of the above class [from the OQL] used to display a small text beside the object's name -->
                  <!-- Note: This is not used in "list" mode -->
                  <description_att>description</description_att>
                  <!-- Attribute code of the above class [from the OQL] used to display a image beside the object's name -->
                  <!-- Note: This is used in "mosaic" mode only for now -->
                  <image_att>icon</image_att>
                  <!-- Title of the level, will be display in lists and others browse modes -->
                  <title>Class:Service</title>
                  <!-- Optional tag to add attributes to the table by their code, can be specified for each level -->
                  <!-- Note: Fields will only be displayed in "list" mode but will still be used for filter in other modes -->
                  <!-- <fields  /> -->
                  <!-- Can be empty on intermediate levels, default is drilldown -->
                  <actions>
                    <action id="drilldown" xsi:type="drilldown"/>
                  </actions>
                  <levels>
                    <level id="1">
                      <!-- Note : We could have used just a class tag and put the OQL in the scope for everybody -->
                      <oql><![CDATA[SELECT ServiceSubcategory WHERE ServiceSubcategory.status != 'obsolete']]></oql>
                      <parent_att>service_id</parent_att>
                      <name_att/>
                      <tooltip_att>description</tooltip_att>
                      <description_att>description</description_att>
                      <title>Class:ServiceSubcategory</title>
                      <actions>
                        <action id="create_from_this" xsi:type="create_from_this">
                          <!-- Can be either a class tag containing the class of the object to create, or a static method taking the origin object as a parameter and that will return a object of the desired class -->
                          <!-- (eg. \Ticket::FromServiceSubcategory($oOrigin) that should return either a UserRequest or Incident regarding the request type) -->
                          <class>UserRequest</class>
                          <!-- Optional tag that can be used on any action type -->
                          <!--<title>Create a ticket</title>-->
                          <!-- Optional tag to define if the action should be done in a modal window ("modal"), a new window ("new") or the current window ("self") -->
                          <!--<opening_target>modal</opening_target>-->
                          <icon_class>fc fc-new-request fc-1-6x fc-flip-horizontal</icon_class>
                          <!-- Optional tag to order actions -->
                          <!--<rank>1</rank>-->
                          <rules>
                            <rule id="contact-to-userrequest"/>
                            <rule id="servicesubcategory-to-userrequest"/>
                            <rule id="go-to-open-request-on-submit"/>
                          </rules>
                        </action>
                        <action id="view" xsi:type="view"/>
                      </actions>
                      <levels/>
                    </level>
                  </levels>
                </level>
              </levels>
            </level>
          </levels>
          <browse_modes>
            <availables>
              <mode id="list"/>
              <mode id="tree"/>
              <mode id="mosaic"/>
            </availables>
            <default>list</default>
          </browse_modes>
          <!-- Optional. Set the default number of item lists will display. -->
          <!-- <default_list_length>20</default_list_length> -->
          <data_loading>auto</data_loading>
          <!-- lazy|full|auto. Let the consultant choose if the list/tree data are load progressively at each page/level or in one-shot or if it is up to the system regarding the "lazy_loading_threshold" parameter -->
        </brick>
        <brick id="ongoing-tickets-for-portal-user" xsi:type="Combodo\iTop\Portal\Brick\ManageBrick">
          <active>true</active>
          <rank>
            <default>20</default>
          </rank>
          <width>6</width>
          <title>
            <default>Brick:Portal:OngoingRequests:Title</default>
          </title>
          <!-- Optional tag to define which display modes can be used in the brick's page and the brick's tile -->
          <!--<display_modes>-->
          <!-- Optional tag that must contain at least 1 <mode> tag. -->
          <!--<availables>-->
          <!--<mode id="list"/>-->
          <!--<mode id="pie-chart"/>-->
          <!--<mode id="bar-chart"/>-->
          <!--</availables>-->
          <!-- Optional tag to define which display mode will be used by default when opening the brick -->
          <!--<default>list</default>-->
          <!-- Optional tag to define which display mode will be used to render the brick's tile -->
          <!--<tile>text</tile>-->
          <!--</display_modes>-->
          <description>Brick:Portal:OngoingRequests:Title+</description>
          <decoration_class>
            <default>fc fc-ongoing-request fc-2x</default>
          </decoration_class>
          <oql><![CDATA[SELECT Ticket]]></oql>
          <!-- Optional tag to define if the action should be done in a modal window ("modal"), a new window ("new") or the current window ("self") -->
          <!--<opening_target>modal</opening_target>-->
          <!-- Optional tag to define the how the objects should be opened. Values can be edit|view. Note that even if this is set to edit, objects not allowed in edition mode for the user (cf. scopes and security layers) will open in view mode -->
          <!-- <opening_mode>edit</opening_mode> -->
          <!-- Can be either a class tag with the class name or an oql tag with the query -->
          <!-- <class>Ticket</class> -->
          <fields>
            <field id="title"/>
            <field id="start_date"/>
            <field id="status"/>
            <field id="service_id"/>
            <field id="servicesubcategory_id"/>
            <field id="priority"/>
            <field id="caller_id"/>
          </fields>
          <!-- Optional tag to add attributes to the table by their code -->
          <grouping>
            <!-- Mandatory -->
            <tabs>
              <!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
              <show_tab_counts>true</show_tab_counts>
              <!-- Mandatory. Grouping by tabs -->
              <!--<attribute>operational_status</attribute>-->
              <!-- attribute xor groups tag -->
              <groups>
                <!-- Can be used only with ../oql tag, not ../class tag. Reason is that we can't know the class alias to apply to the condition's fields. We might have an exception saying that the field in ambiguous for the generated query. -->
                <group id="opened">
                  <rank>1</rank>
                  <title>Brick:Portal:OngoingRequests:Tab:OnGoing</title>
                  <!-- Optional. A string or dictionary entry to display under the page title for this tab -->
                  <!-- <description>Brick:Portal:OngoingRequests:Tab:OnGoing+</description> -->
                  <condition><![CDATA[SELECT Ticket AS T WHERE operational_status NOT IN ('closed', 'resolved')]]></condition>
                </group>
                <group id="resolved">
                  <rank>2</rank>
                  <title>Brick:Portal:OngoingRequests:Tab:Resolved</title>
                  <condition><![CDATA[SELECT Ticket AS T WHERE operational_status = 'resolved']]></condition>
                </group>
              </groups>
            </tabs>
            <!-- Implicit grouping on y axis by finalclass -->
          </grouping>
          <!-- Optional. Set the default number of item lists will display. -->
          <!-- <default_list_length>20</default_list_length> -->
          <data_loading>full</data_loading>
          <export>
            <export_default_fields>true</export_default_fields>
          </export>
        </brick>
        <brick id="closed-tickets-for-portal-user" xsi:type="Combodo\iTop\Portal\Brick\ManageBrick">
          <active>true</active>
          <rank>
            <navigation_menu>50</navigation_menu>
          </rank>
          <visible>
            <home>false</home>
          </visible>
          <width>12</width>
          <title>
            <default>Brick:Portal:ClosedRequests:Title</default>
          </title>
          <description></description>
          <decoration_class>
            <default>fc fc-closed-request fc-2x</default>
          </decoration_class>
          <oql><![CDATA[SELECT Ticket WHERE operational_status = 'closed']]></oql>
          <!-- Can be either a class tag with the class name or an oql tag with the query -->
          <!-- <class>Ticket</class> -->
          <fields>
            <field id="finalclass"/>
            <field id="title"/>
            <field id="start_date"/>
            <field id="status"/>
            <field id="servicesubcategory_id"/>
            <field id="priority"/>
            <field id="caller_id"/>
          </fields>
          <grouping>
            <tabs>
              <!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
              <!--<show_tab_counts>false</show_tab_counts>-->
              <groups>
                <group id="all">
                  <rank>1</rank>
                  <title>Brick:Portal:ClosedRequests:Title</title>
                  <condition><![CDATA[SELECT Ticket]]></condition>
                </group>
              </groups>
            </tabs>
            <!-- Implicit grouping on y axis by finalclass -->
          </grouping>
          <data_loading>auto</data_loading>
          <export>
            <export_default_fields>true</export_default_fields>
          </export>
        </brick>
      </bricks>
      <forms>
        <form id="service-view">
          <class>Service</class>
          <fields></fields>
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="name">
                </div>
                <div class="form_field" data-field-id="description">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="org_id">
                </div>
                <div class="form_field" data-field-id="servicefamily_id">
                </div>
                <div class="form_field" data-field-id="status">
                </div>
              </div>
            </div>
          </twig>
          <modes>
            <mode id="view"/>
          </modes>
        </form>
        <form id="servicesubcategory">
          <class>ServiceSubcategory</class>
          <!-- Optional tag to list the fields. If empty only fields from <twig> tag will be displayed, if omitted fields from zlist details will. -->
          <fields/>
          <!-- Optional tag to specify the form layout. Fields that are not positioned in the layout will be placed at the end of the form -->
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <!-- data-field-id attribute must be an attribute code of the class -->
                <div class="form_field" data-field-id="service_id">
                </div>
                <!-- data-field-flags attribute contains flags among read_only/hidden/mandatory/must_prompt/must_change -->
                <div class="form_field" data-field-id="name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="status" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="service_org_id">
                </div>
                <div class="form_field" data-field-id="request_type">
                </div>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="description">
              </div>
            </div>
          </twig>
        </form>
        <form id="ticket-create">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="service_id" data-field-flags="mandatory">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="servicesubcategory_id" data-field-flags="mandatory">
                </div>
              </div>
            </div>
            <div id="service_details_placeholder">
            </div>
            <div class="row">
              <div class="col-sm-6">
                <div class="form_field" data-field-id="impact">
                </div>
              </div>
              <div class="col-sm-6">
                <div class="form_field" data-field-id="urgency">
                </div>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="title">
              </div>
              <div class="form_field" data-field-id="description">
              </div>
              <div class="form_field" data-field-id="contacts_list">
              </div>
            </div>
          </twig>
          <modes>
            <!-- mode id can among create / edit / view -->
            <mode id="create"/>
          </modes>
        </form>
        <form id="ticket-edit">
          <class>Ticket</class>
          <properties>
            <!-- Optional, display mode of the form fields. "cosy" for a regular labels over values layout; "compact" for a side-by-side
            layout with input aligned; "dense" for a side-by-side layout with input filling all available space. You can also use a custom css class that will be used on the form as "form_xxx", as well as on the fields as "form_field_xxx".-->
            <!--<display_mode>cosy</display_mode>-->
            <!-- Optional, when set to false, submit button is hidden when transitions are available on the object (in creation and edit
            mode). Default is false. -->
            <!--<always_show_submit>false</always_show_submit>-->
            <!-- Optional, navigation rules to define where to go when clicking on the submit/cancel buttons of the form -->
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields></fields>
          <twig>
            <div class="row">
              <div class="col-sm-7">
                <fieldset>
                  <legend>{{'Ticket:baseinfo'|dict_s}}</legend>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="title" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="service_id" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="caller_id" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="servicesubcategory_id" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-12">
                    <div class="form_field" data-field-id="description" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="solution" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="user_satisfaction" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="user_comment" data-field-flags="read_only"></div>
                  </div>
                </fieldset>
              </div>
              <div class="col-sm-5">
                <fieldset>
                  <legend>{{'Ticket:Type'|dict_s}} &amp; {{'Ticket:date'|dict_s}}</legend>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="status" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="impact" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="urgency" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="priority" data-field-flags="read_only"></div>
                  </div>
                  <div class="col-sm-6">
                    <div class="form_field" data-field-id="start_date" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="last_update" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="resolution_date" data-field-flags="read_only"></div>
                    <div class="form_field" data-field-id="agent_id" data-field-flags="read_only"></div>
                  </div>
                </fieldset>
              </div>
            </div>
            <div>
              <div class="form_field" data-field-id="contacts_list"></div>
              <div class="form_field" data-field-id="public_log"></div>
            </div>
          </twig>
          <modes>
            <mode id="edit"/>
            <mode id="view"/>
          </modes>
        </form>
        <form id="ticket-reopen">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig>
            <div>
              <div class="form_field" data-field-id="public_log" data-field-flags="must_change"></div>
              <div class="form_field" data-field-id="team_id" data-field-flags="hidden"></div>
              <div class="form_field" data-field-id="agent_id" data-field-flags="hidden"></div>
            </div>
          </twig>
          <modes>
            <mode id="apply_stimulus">
              <stimuli>
                <stimulus id="ev_reopen"/>
              </stimuli>
            </mode>
          </modes>
        </form>
        <form id="ticket-apply-stimulus">
          <class>Ticket</class>
          <properties>
            <navigation_rules>
              <submit>
                <default>go-to-open-requests</default>
              </submit>
            </navigation_rules>
          </properties>
          <fields/>
          <twig/>
          <modes>
            <mode id="apply_stimulus"/>
          </modes>
        </form>
        <form id="person-view">
          <class>Person</class>
          <fields/>
          <twig>
            <div class="row">
              <div class="col-sm-4">
                <div class="form_field" data-field-id="picture" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="first_name" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="status" data-field-flags="read_only">
                </div>
              </div>
              <div class="col-sm-4">
                <div class="form_field" data-field-id="org_id" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="function" data-field-flags="read_only">
                </div>
                <div class="form_field" data-field-id="manager_id" data-field-flags="read_only">
                </div>
              </div>
            </div>
          </twig>
        </form>
      </forms>
      <classes>
        <!-- Note : A class (or one of its ancestors) MUST be declared here to be displayed in the portal -->
        <class id="User">
          <!-- Allow <allowed_profile>s to apply the <transition>s below. Flags on <field>s will be merged with those from datamodel -->
          <!-- See example in UserRequest class -->
          <!--<lifecycle/>-->
          <scopes>
            <!-- Note : Silos apply to those scope queries -->
            <scope id="all">
              <oql_view><![CDATA[SELECT User AS U JOIN Person AS P ON U.contactid=P.id WHERE P.id = :current_contact_id]]></oql_view>
              <!-- No object of this class can be edited -->
              <!--<oql_edit />-->
              <!-- Everybody -->
              <!--<allowed_profiles />-->
            </scope>
          </scopes>
        </class>
        <class id="Organization">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Organization WHERE id = :current_contact->org_id]]></oql_view>
            </scope>
          </scopes>
        </class>
        <class id="Location">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Location WHERE org_id = :current_contact->org_id]]></oql_view>
            </scope>
          </scopes>
        </class>
        <class id="Contact">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Contact WHERE org_id = :current_contact->org_id]]></oql_view>
            </scope>
            <scope id="admin">
              <oql_view><![CDATA[SELECT Contact]]></oql_view>
              <allowed_profiles>
                <allowed_profile id="Administrator"/>
              </allowed_profiles>
            </scope>
          </scopes>
          <lists>
            <list id="default">
              <items>
                <item id="status">
                  <rank>10</rank>
                </item>
                <item id="org_id">
                  <rank>20</rank>
                </item>
                <item id="function">
                  <rank>50</rank>
                </item>
              </items>
            </list>
          </lists>
        </class>
        <class id="ServiceFamily">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT ServiceFamily AS sf JOIN Service AS s ON s.servicefamily_id = sf.id JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id]]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="Service">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Service AS s JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id AND s.status != 'obsolete']]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="ServiceSubcategory">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT ServiceSubcategory AS ssc JOIN Service AS s ON ssc.service_id=s.id JOIN lnkCustomerContractToService AS l1 ON l1.service_id=s.id JOIN CustomerContract AS cc ON l1.customercontract_id=cc.id WHERE cc.org_id = :current_contact->org_id AND ssc.status != 'obsolete']]></oql_view>
              <ignore_silos>true</ignore_silos>
            </scope>
          </scopes>
        </class>
        <class id="Ticket">
          <scopes>
            <scope id="all">
              <oql_view><![CDATA[SELECT Ticket AS T WHERE T.caller_id = :current_contact_id AND T.finalclass IN ('UserRequest', 'Incident')]]></oql_view>
              <oql_edit><![CDATA[SELECT Ticket AS T]]></oql_edit>
            </scope>
            <scope id="portal-power-user">
              <oql_view><![CDATA[SELECT Ticket AS T WHERE T.org_id = :current_contact->org_id AND T.finalclass IN ('UserRequest', 'Incident')]]></oql_view>
              <oql_edit><![CDATA[SELECT Ticket AS T]]></oql_edit>
              <allowed_profiles>
                <allowed_profile id="Portal power user"/>
              </allowed_profiles>
            </scope>
          </scopes>
        </class>
      </classes>
      <action_rules>
        <action_rule id="contact-to-userrequest">
          <!-- source_oql|source_class is only necessary if there is some copy preset|retrofit -->
          <source_oql><![CDATA[SELECT Contact AS C WHERE C.id = :current_contact_id]]></source_oql>
          <presets>
            <!-- Only set() and copy() are supported for now -->
            <preset id="1">set(caller_id, $current_contact_id$)</preset>
            <preset id="2">copy(org_id, org_id)</preset>
            <preset id="3">set(origin, portal)</preset>
          </presets>
          <retrofits/>
        </action_rule>
        <action_rule id="service-to-userrequest">
          <source_class>Service</source_class>
          <presets>
            <preset id="1">copy(id, service_id)</preset>
          </presets>
        </action_rule>
        <action_rule id="servicesubcategory-to-userrequest">
          <source_class>ServiceSubcategory</source_class>
          <presets>
            <preset id="1">copy(id, servicesubcategory_id)</preset>
            <preset id="2">copy(service_id, service_id)</preset>
          </presets>
        </action_rule>
        <!-- Deprecated, will be removed in iTop 2.8 -->
        <action_rule id="go-to-open-request-on-submit">
          <submit xsi:type="goto">
            <brick>ongoing-tickets-for-portal-user</brick>
          </submit>
        </action_rule>
      </action_rules>
      <navigation_rules>
        <!-- Close form (either the modal or the whole page) -->
        <navigation_rule id="close-form" xsi:type="close"/>
        <!-- Go to the homepage -->
        <navigation_rule id="go-to-homepage" xsi:type="go-to-homepage"/>
        <!-- Open a manage brick (simple method) -->
        <navigation_rule id="go-to-open-requests" xsi:type="go-to-manage-brick">
          <!-- Mandatory, ID of the ManageBrick to go to -->
          <id>ongoing-tickets-for-portal-user</id>
          <!-- Optional, must be an ID of the available display modes of the brick (//brick/display_modes/availables/mode) -->
          <!-- <display_mode>list</mode> -->
          <!-- Optional, must be an ID of the grouping tab of the brick (//brick/grouping/tabs/groups/group)-->
          <!-- <grouping_tab>resolved</grouping_tab> -->
          <!-- Optional, a string to preset as filter in the brick. ":this->XXX" can be used for the current object -->
          <!-- <filter>:this->caller_id_friendlyname</filter> -->
        </navigation_rule>
        <!-- Open a browse brick -->
        <navigation_rule id="go-to-services" xsi:type="go-to-browse-brick">
          <!-- Mandatory, ID of the BrowseBrick to go to -->
          <id>services</id>
          <!-- Optional, must be an ID of the available browse modes of the brick (//brick/browse_modes/availables/mode) -->
          <!-- <browse_mode>tree</browse_mode> -->
          <!-- Optional, a string to preset as filter in the brick. ":this->XXX" can be used for the current object -->
          <!-- <filter>computer</filter> -->
        </navigation_rule>
        <!-- Open a brick, developer method -->
        <!-- <navigation_rule id="go-to-open-requests-alternate-way" xsi:type="go-to-brick"> -->
        <!-- <route> -->
        <!-- <id>p_manage_brick_display_as</id> -->
        <!-- <params> -->
        <!-- <param id="sBrickId">ongoing-tickets-for-portal-user</param> -->
        <!-- <param id="sDisplayMode">pie-chart</param> -->
        <!-- <param id="sGroupingTab">resolved</param> -->
        <!-- </params> -->
        <!-- </route> -->
        <!-- </navigation_rule> -->
      </navigation_rules>
    </module_design>
  </module_designs>
  <module_parameters>
    <parameters id="itop-portal" _delta="define">
      <lazy_loading_threshold>500</lazy_loading_threshold><!-- Will be placed in the conf/<env>/config-itop.php file under the itop-portal module's settings  -->
      <enable_formmanager_content_check type="boolean">true</enable_formmanager_content_check>
    </parameters>
  </module_parameters>
</itop_design>