<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0">
	<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-2021 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>
				<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">
							<code>ongoing</code>
						</value>
						<value id="resolved">
							<code>resolved</code>
							<style>
								<main_color>#689F38</main_color>
								<complementary_color>#FFFFFF</complementary_color>
								<decoration_classes>fas fa-check</decoration_classes>
							</style>
						</value>
						<value id="closed">
							<code>closed</code>
							<style>
								<main_color>#E1E7EC</main_color>
								<complementary_color>#6E7A8A</complementary_color>
								<decoration_classes/>
							</style>
						</value>
					</values>
					<default_style>
						<main_color>#2B6CB0</main_color>
						<complementary_color>#FFFFFF</complementary_color>
						<decoration_classes/>
					</default_style>
					<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="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>
				<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">
							<code>manual</code>
						</value>
						<value id="computed">
							<code>computed</code>
						</value>
						<value id="do_not_notify">
							<code>do_not_notify</code>
						</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="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>
				<fields_semantic>
					<state_attribute>status</state_attribute>
				</fields_semantic>
				<style>
					<icon>../../images/icons/icons8-tasklist.svg</icon>
				</style>
				<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">
							<code>open</code>
						</value>
						<value id="closed">
							<code>closed</code>
						</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>true</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>true</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>
				<stimuli>
					<stimulus id="ev_close" xsi:type="StimulusUserAction"/>
				</stimuli>
				<states>
					<state id="open">
						<flags/>
						<transitions>
							<transition id="ev_close">
								<target>closed</target>
                <actions>
                  <action>
                    <verb>SetCurrentDateIfNull</verb>
                    <params>
                      <param xsi:type="attcode">end_date</param>
                    </params>
                  </action>
                </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>
		<class id="Document" _delta="must_exist">
			<fields>
				<field id="contracts_list" xsi:type="AttributeLinkedSetIndirect" _delta="define">
					<linked_class>lnkContractToDocument</linked_class>
					<ext_key_to_me>document_id</ext_key_to_me>
					<count_min>0</count_min>
					<count_max>0</count_max>
					<ext_key_to_remote>contract_id</ext_key_to_remote>
					<duplicates/>
				</field>
				<field id="services_list" xsi:type="AttributeLinkedSetIndirect" _delta="define">
					<linked_class>lnkDocumentToService</linked_class>
					<ext_key_to_me>document_id</ext_key_to_me>
					<count_min>0</count_min>
					<count_max>0</count_max>
					<ext_key_to_remote>service_id</ext_key_to_remote>
					<duplicates/>
				</field>
			</fields>
			<methods/>
			<presentation>
				<details>
					<items>
						<item id="contracts_list" _delta="define">
							<rank>70</rank>
						</item>
						<item id="services_list" _delta="define">
							<rank>80</rank>
						</item>
					</items>
				</details>
			</presentation>
		</class>
    <class id="Person" _delta="must_exist">
      <fields>
        <field id="tickets_list" xsi:type="AttributeLinkedSet" _delta="define">
          <linked_class>Ticket</linked_class>
          <ext_key_to_me>caller_id</ext_key_to_me>
          <edit_mode>add_only</edit_mode>
          <count_min>0</count_min>
          <count_max>0</count_max>
        </field>
      </fields>
      <presentation>
        <details>
          <items>
            <item id="tickets_list" _delta="define">
              <rank>20</rank>
            </item>
          </items>
        </details>
      </presentation>
    </class>
    <class id="Team" _delta="must_exist">
      <fields>
        <field id="tickets_list" xsi:type="AttributeLinkedSet" _delta="define">
          <linked_class>Ticket</linked_class>
          <ext_key_to_me>team_id</ext_key_to_me>
          <edit_mode>none</edit_mode>
          <count_min>0</count_min>
          <count_max>0</count_max>
        </field>
      </fields>
      <presentation>
        <details>
          <items>
            <item id="tickets_list" _delta="define">
              <rank>90</rank>
            </item>
          </items>
        </details>
      </presentation>
    </class>
	</classes>
	<meta>
		<classes>
			<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" >
			<bricks>
				<brick id="services" xsi:type="Combodo\iTop\Portal\Brick\BrowseBrick" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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="ServiceFamily" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<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" _delta="define">
					<!-- 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" _delta="define">
					<source_class>Service</source_class>
					<presets>
						<preset id="1">copy(id, service_id)</preset>
					</presets>
				</action_rule>
				<action_rule id="servicesubcategory-to-userrequest" _delta="define">
					<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" _delta="define">
					<submit xsi:type="goto">
						<brick>ongoing-tickets-for-portal-user</brick>
					</submit>
				</action_rule>
			</action_rules>
			<navigation_rules>
				<!-- Open a manage brick (simple method) -->
				<navigation_rule id="go-to-open-requests" xsi:type="go-to-manage-brick" _delta="define">
					<!-- 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" _delta="define">
					<!-- 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>
</itop_design>
