<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
  <classes>
    <class id="Ticket" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <comment><![CDATA[/**
 * Persistent classes for a CMDB
 *
 * @copyright   Copyright (C) 2010-2012 Combodo SARL
 * @license     http://opensource.org/licenses/AGPL-3.0
 */]]></comment>
        <category>bizmodel,searchable</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"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="ref" xsi:type="AttributeString">
          <sql>ref</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </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>
        </field>
        <field id="ticket_log" xsi:type="AttributeCaseLog">
          <sql>ticket_log</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="start_date" xsi:type="AttributeDateTime">
          <sql>start_date</sql>
          <default_value/>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="document_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkTicketToDoc</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>document_id</ext_key_to_remote>
        </field>
        <field id="ci_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkTicketToCI</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>ci_id</ext_key_to_remote>
        </field>
        <field id="contact_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkTicketToContact</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>
        </field>
        <field id="incident_list" xsi:type="AttributeLinkedSetIndirect">
          <linked_class>lnkTicketToIncident</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>incident_id</ext_key_to_remote>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="description">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="document_list">
              <rank>50</rank>
            </item>
            <item id="ci_list">
              <rank>60</rank>
            </item>
            <item id="contact_list">
              <rank>70</rank>
            </item>
            <item id="incident_list">
              <rank>80</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="finalclass">
              <rank>10</rank>
            </item>
            <item id="ref">
              <rank>20</rank>
            </item>
            <item id="title">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="finalclass">
              <rank>10</rank>
            </item>
            <item id="ref">
              <rank>20</rank>
            </item>
            <item id="title">
              <rank>30</rank>
            </item>
            <item id="ticket_log">
              <rank>40</rank>
            </item>
            <item id="start_date">
              <rank>50</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="ResponseTicket" _delta="define">
      <parent>Ticket</parent>
      <properties>
        <category>bizmodel</category>
        <abstract>true</abstract>
        <key_type>autoincrement</key_type>
        <db_table>ticket_response</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ref"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ref"/>
          </attributes>
        </reconciliation>
      </properties>
      <fields>
        <field id="status" xsi:type="AttributeEnum">
          <values>
            <value>new</value>
            <value>assigned</value>
            <value>frozen</value>
            <value>escalated_tto</value>
            <value>escalated_ttr</value>
            <value>resolved</value>
            <value>closed</value>
          </values>
          <sql>status</sql>
          <default_value>new</default_value>
          <is_null_allowed>false</is_null_allowed>
        </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_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="caller_email" xsi:type="AttributeExternalField">
          <extkey_attcode>caller_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </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>
          <jointype/>
        </field>
        <field id="org_name" xsi:type="AttributeExternalField">
          <extkey_attcode>org_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="service_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Service AS s JOIN SLA AS sla ON sla.service_id=s.id JOIN lnkContractToSLA AS ln ON ln.sla_id=sla.id JOIN CustomerContract AS cc ON ln.contract_id=cc.id WHERE cc.org_id =:this->org_id]]></filter>
          <dependencies>
            <attribute id="org_id"/>
          </dependencies>
          <sql>service_id</sql>
          <target_class>Service</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="service_name" xsi:type="AttributeExternalField">
          <extkey_attcode>service_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="servicesubcategory_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id]]></filter>
          <dependencies>
            <attribute id="service_id"/>
          </dependencies>
          <sql>servicesubcategory_id</sql>
          <target_class>ServiceSubcategory</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="servicesubcategory_name" xsi:type="AttributeExternalField">
          <extkey_attcode>servicesubcategory_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="product" xsi:type="AttributeString">
          <sql>product</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="impact" xsi:type="AttributeEnum">
          <values>
            <value>1</value>
            <value>2</value>
            <value>3</value>
          </values>
          <sql>impact</sql>
          <default_value>1</default_value>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="urgency" xsi:type="AttributeEnum">
          <values>
            <value>1</value>
            <value>2</value>
            <value>3</value>
          </values>
          <sql>urgency</sql>
          <default_value>1</default_value>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="priority" xsi:type="AttributeEnum">
          <values>
            <value>1</value>
            <value>2</value>
            <value>3</value>
          </values>
          <sql>priority</sql>
          <default_value>1</default_value>
          <is_null_allowed>false</is_null_allowed>
        </field>
        <field id="workgroup_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Team AS t JOIN CustomerContract AS cc ON cc.support_team_id=t.id JOIN lnkContractToSLA AS ln ON ln.contract_id=cc.id JOIN SLA AS sla ON ln.sla_id=sla.id WHERE sla.service_id = :this->service_id AND cc.org_id = :this->org_id]]></filter>
          <dependencies>
            <attribute id="org_id"/>
            <attribute id="service_id"/>
          </dependencies>
          <sql>workgroup_id</sql>
          <target_class>Team</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="workgroup_name" xsi:type="AttributeExternalField">
          <extkey_attcode>workgroup_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="agent_id" xsi:type="AttributeExternalKey">
          <filter><![CDATA[SELECT Person AS p JOIN lnkTeamToContact AS l ON l.contact_id=p.id JOIN Team AS t ON l.team_id=t.id WHERE t.id = :this->workgroup_id]]></filter>
          <dependencies>
            <attribute id="workgroup_id"/>
          </dependencies>
          <sql>agent_id</sql>
          <target_class>Person</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="agent_name" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="agent_email" xsi:type="AttributeExternalField">
          <extkey_attcode>agent_id</extkey_attcode>
          <target_attcode>email</target_attcode>
        </field>
        <field id="related_problem_id" xsi:type="AttributeExternalKey">
          <sql>related_problem_id</sql>
          <target_class>Problem</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="related_problem_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>related_problem_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="related_change_id" xsi:type="AttributeExternalKey">
          <sql>related_change_id</sql>
          <target_class>Change</target_class>
          <is_null_allowed>true</is_null_allowed>
          <on_target_delete>DEL_MANUAL</on_target_delete>
          <jointype/>
        </field>
        <field id="related_change_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>related_change_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="close_date" xsi:type="AttributeDateTime">
          <sql>close_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>
        </field>
        <field id="assignment_date" xsi:type="AttributeDateTime">
          <sql>assignment_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="resolution_date" xsi:type="AttributeDateTime">
          <sql>resolution_date</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="tto_escalation_deadline" xsi:type="AttributeDeadline">
          <sql>tto_escalation_deadline</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="ttr_escalation_deadline" xsi:type="AttributeDeadline">
          <sql>ttr_escalation_deadline</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="closure_deadline" xsi:type="AttributeDeadline">
          <sql>closure_deadline</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="resolution_code" xsi:type="AttributeEnum">
          <values>
            <value>fixed</value>
            <value>duplicate</value>
            <value>couldnotreproduce</value>
            <value>irrelevant</value>
          </values>
          <sql>resolution_code</sql>
          <default_value>fixed</default_value>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="solution" xsi:type="AttributeText">
          <sql>solution</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="user_satisfaction" xsi:type="AttributeEnum">
          <values>
            <value>1</value>
            <value>2</value>
            <value>3</value>
            <value>4</value>
          </values>
          <sql>user_satisfaction</sql>
          <default_value>1</default_value>
          <is_null_allowed>true</is_null_allowed>
        </field>
        <field id="user_commment" xsi:type="AttributeText">
          <sql>user_commment</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
      </fields>
      <lifecycle>
        <attribute>status</attribute>
        <stimuli>
          <stimulus id="ev_assign" xsi:type="StimulusUserAction"/>
          <stimulus id="ev_reassign" xsi:type="StimulusUserAction"/>
          <stimulus id="ev_timeout" xsi:type="StimulusInternal"/>
          <stimulus id="ev_resolve" xsi:type="StimulusUserAction"/>
          <stimulus id="ev_close" xsi:type="StimulusUserAction"/>
        </stimuli>
        <states>
          <state id="new">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="description">
                <must_prompt/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <mandatory/>
              </attribute>
              <attribute id="org_id">
                <must_prompt/>
              </attribute>
              <attribute id="service_id">
                <must_prompt/>
              </attribute>
              <attribute id="servicesubcategory_id">
                <must_prompt/>
              </attribute>
              <attribute id="product">
                <must_prompt/>
              </attribute>
              <attribute id="impact">
                <must_prompt/>
              </attribute>
              <attribute id="urgency">
                <must_prompt/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <must_prompt/>
              </attribute>
              <attribute id="agent_email">
                <hidden/>
              </attribute>
              <attribute id="related_problem_id">
                <hidden/>
              </attribute>
              <attribute id="related_change_id">
                <hidden/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <read_only/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <hidden/>
              </attribute>
              <attribute id="solution">
                <hidden/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_assign">
                <stimulus>ev_assign</stimulus>
                <target>assigned</target>
                <actions>
                  <action>
                    <verb>SetAssignedDate</verb>
                  </action>
                </actions>
              </transition>
              <transition id="ev_timeout">
                <stimulus>ev_timeout</stimulus>
                <target>escalated_tto</target>
                <actions/>
              </transition>
            </transitions>
          </state>
          <state id="escalated_tto">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <mandatory/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="agent_email">
                <hidden/>
              </attribute>
              <attribute id="related_problem_id">
                <hidden/>
              </attribute>
              <attribute id="related_change_id">
                <hidden/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <read_only/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <hidden/>
              </attribute>
              <attribute id="solution">
                <hidden/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_assign">
                <stimulus>ev_assign</stimulus>
                <target>assigned</target>
                <actions>
                  <action>
                    <verb>SetAssignedDate</verb>
                  </action>
                </actions>
              </transition>
            </transitions>
          </state>
          <state id="assigned">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="title">
                <read_only/>
              </attribute>
              <attribute id="description">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <mandatory/>
                <must_prompt/>
              </attribute>
              <attribute id="agent_id">
                <mandatory/>
                <must_prompt/>
              </attribute>
              <attribute id="agent_email">
                <read_only/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <read_only/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <hidden/>
              </attribute>
              <attribute id="solution">
                <hidden/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_reassign">
                <stimulus>ev_reassign</stimulus>
                <target>assigned</target>
                <actions/>
              </transition>
              <transition id="ev_timeout">
                <stimulus>ev_timeout</stimulus>
                <target>escalated_ttr</target>
                <actions/>
              </transition>
              <transition id="ev_resolve">
                <stimulus>ev_resolve</stimulus>
                <target>resolved</target>
                <actions>
                  <action>
                    <verb>SetResolveDate</verb>
                  </action>
                  <action>
                    <verb>SetClosureDeadline</verb>
                  </action>
                </actions>
              </transition>
            </transitions>
          </state>
          <state id="escalated_ttr">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="title">
                <read_only/>
              </attribute>
              <attribute id="description">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <mandatory/>
                <must_prompt/>
              </attribute>
              <attribute id="agent_id">
                <mandatory/>
                <must_prompt/>
              </attribute>
              <attribute id="agent_email">
                <read_only/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <read_only/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <hidden/>
              </attribute>
              <attribute id="solution">
                <hidden/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_reassign">
                <stimulus>ev_reassign</stimulus>
                <target>escalated_ttr</target>
                <actions/>
              </transition>
              <transition id="ev_resolve">
                <stimulus>ev_resolve</stimulus>
                <target>resolved</target>
                <actions>
                  <action>
                    <verb>SetResolveDate</verb>
                  </action>
                  <action>
                    <verb>SetClosureDeadline</verb>
                  </action>
                </actions>
              </transition>
            </transitions>
          </state>
          <state id="frozen">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="title">
                <read_only/>
              </attribute>
              <attribute id="description">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <mandatory/>
              </attribute>
              <attribute id="agent_id">
                <mandatory/>
              </attribute>
              <attribute id="agent_email">
                <read_only/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <read_only/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <hidden/>
              </attribute>
              <attribute id="solution">
                <hidden/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions/>
          </state>
          <state id="resolved">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="title">
                <read_only/>
              </attribute>
              <attribute id="description">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="service_id">
                <read_only/>
              </attribute>
              <attribute id="servicesubcategory_id">
                <read_only/>
              </attribute>
              <attribute id="product">
                <read_only/>
              </attribute>
              <attribute id="impact">
                <read_only/>
              </attribute>
              <attribute id="urgency">
                <read_only/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <read_only/>
              </attribute>
              <attribute id="agent_id">
                <read_only/>
              </attribute>
              <attribute id="agent_email">
                <read_only/>
              </attribute>
              <attribute id="close_date">
                <hidden/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="closure_deadline">
                <read_only/>
              </attribute>
              <attribute id="resolution_code">
                <must_prompt/>
              </attribute>
              <attribute id="solution">
                <must_prompt/>
              </attribute>
              <attribute id="user_satisfaction">
                <hidden/>
              </attribute>
              <attribute id="user_commment">
                <hidden/>
              </attribute>
            </flags>
            <transitions>
              <transition id="ev_reassign">
                <stimulus>ev_reassign</stimulus>
                <target>assigned</target>
                <actions/>
              </transition>
              <transition id="ev_close">
                <stimulus>ev_close</stimulus>
                <target>closed</target>
                <actions>
                  <action>
                    <verb>SetClosureDate</verb>
                  </action>
                </actions>
              </transition>
            </transitions>
          </state>
          <state id="closed">
            <flags>
              <attribute id="ref">
                <read_only/>
              </attribute>
              <attribute id="title">
                <read_only/>
              </attribute>
              <attribute id="description">
                <read_only/>
              </attribute>
              <attribute id="ticket_log">
                <read_only/>
              </attribute>
              <attribute id="start_date">
                <read_only/>
              </attribute>
              <attribute id="caller_id">
                <read_only/>
              </attribute>
              <attribute id="org_id">
                <read_only/>
              </attribute>
              <attribute id="service_id">
                <read_only/>
              </attribute>
              <attribute id="servicesubcategory_id">
                <read_only/>
              </attribute>
              <attribute id="product">
                <read_only/>
              </attribute>
              <attribute id="impact">
                <read_only/>
              </attribute>
              <attribute id="urgency">
                <read_only/>
              </attribute>
              <attribute id="priority">
                <read_only/>
              </attribute>
              <attribute id="workgroup_id">
                <read_only/>
              </attribute>
              <attribute id="agent_id">
                <read_only/>
              </attribute>
              <attribute id="agent_email">
                <read_only/>
              </attribute>
              <attribute id="close_date">
                <read_only/>
              </attribute>
              <attribute id="last_update">
                <read_only/>
              </attribute>
              <attribute id="assignment_date">
                <hidden/>
              </attribute>
              <attribute id="resolution_date">
                <hidden/>
              </attribute>
              <attribute id="tto_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="ttr_escalation_deadline">
                <hidden/>
              </attribute>
              <attribute id="closure_deadline">
                <hidden/>
              </attribute>
              <attribute id="resolution_code">
                <read_only/>
              </attribute>
              <attribute id="solution">
                <read_only/>
              </attribute>
              <attribute id="user_satisfaction">
                <must_prompt/>
              </attribute>
              <attribute id="user_commment">
                <must_prompt/>
              </attribute>
            </flags>
            <transitions/>
          </state>
        </states>
      </lifecycle>
      <methods>
        <method id="SetClosureDeadline">
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function SetClosureDeadline($sStimulusCode)
	{
		$iMaxWaitHours = 24;
		$this->Set('closure_deadline', time() + $iMaxWaitHours * 3600);
		return true;
	}]]></code>
        </method>
        <method id="SetAssignedDate">
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function SetAssignedDate($sStimulusCode)
	{
		$this->Set('assignment_date', time());
		return true;
	}]]></code>
        </method>
        <method id="SetResolveDate">
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function SetResolveDate($sStimulusCode)
	{
		$this->Set('resolution_date', time());
		return true;
	}]]></code>
        </method>
        <method id="SetClosureDate">
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function SetClosureDate($sStimulusCode)
	{
		$this->Set('close_date', time());
		return true;
	}]]></code>
        </method>
        <method id="ComputeSLT">
          <comment><![CDATA[/**
	 * Determines the shortest SLT, for this ticket, for the given metric. Returns null is no SLT was found
	 * @param string $sMetric Type of metric 'TTO', 'TTR', etc as defined in the SLT class
	 * @return hash Array with 'SLT' => name of the SLT selected, 'value' => duration in seconds of the SLT metric, null if no SLT applies to this ticket
	 */]]></comment>
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function ComputeSLT($sMetric = 'TTO')
	{
		$aResult = null;
		if (MetaModel::IsValidClass('SLT'))
		{
			$sOQL = "SELECT SLT JOIN lnkSLTToSLA AS L1 ON L1.slt_id=SLT.id JOIN SLA ON L1.sla_id = SLA.id JOIN lnkContractToSLA AS L2 ON L2.sla_id = SLA.id JOIN CustomerContract ON L2.contract_id = CustomerContract.id 
					WHERE SLT.ticket_priority = :priority AND SLA.service_id = :service_id AND SLT.metric = :metric AND CustomerContract.org_id = :org_id";
			
			$oSLTSet = new DBObjectSet(DBObjectSearch::FromOQL($sOQL),
							array(),
							array(
								'priority' => $this->Get('priority'),
								'service_id' => $this->Get('service_id'),
								'metric' => $sMetric,
								'org_id' => $this->Get('org_id'),
							)
							);
							
			$iMinDuration = PHP_INT_MAX;
			$sSLTName = '';
	
			while($oSLT = $oSLTSet->Fetch())
			{
				$iDuration = (int)$oSLT->Get('value');
				$sUnit = $oSLT->Get('value_unit');
				//echo "<p>Found SLT: ".$oSLT->GetName()." - $iDuration ($sUnit)</p>\n";
				switch($sUnit)
				{
					case 'days':
					$iDuration = $iDuration * 24; // 24 hours in 1 days
					// Fall though
					
					case 'hours':
					$iDuration = $iDuration * 60; // 60 minutes in 1 hour
					// Fall though
					
					case 'minutes':
					$iDuration = $iDuration * 60;
				}
				if ($iDuration < $iMinDuration)
				{
					$iMinDuration = $iDuration;
					$sSLTName = $oSLT->GetName();
				}
			}
			if ($iMinDuration == PHP_INT_MAX)
			{
				$aResult = null;
			}
			else
			{
				$aResult = array('SLT' => $sSLTName, 'value' => $iMinDuration);
			}
		}
		return $aResult;
	}]]></code>
        </method>
        <method id="ComputePriority">
          <comment>/**
	 * Compute the priority of the ticket based on its impact and urgency
	 * @return integer The priority of the ticket 1(high) .. 3(low)
	 */</comment>
          <static>false</static>
          <access>public</access>
          <type>LifecycleAction</type>
          <code><![CDATA[	public function ComputePriority()
	{
		// priority[impact][urgency]
		$aPriorities = array(
			// single person
			1 => array(
					1 => 1,
					2 => 1,
					3 => 2,
			),
			// a group
			2 => array(
				1 => 1,
				2 => 2,
				3 => 3,
			),
			// a departement!
			3 => array(
					1 => 2,
					2 => 3,
					3 => 3,
			),
		);
		$iPriority = 1;
		if (isset($aPriorities[(int)$this->Get('impact')][(int)$this->Get('urgency')]))
		{
			$iPriority = $aPriorities[(int)$this->Get('impact')][(int)$this->Get('urgency')];
		}
		return $iPriority;		
	}]]></code>
        </method>
        <method id="ComputeValues">
          <static>false</static>
          <access>public</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	public function ComputeValues()
	{
		// Compute the priority of the ticket
		$this->Set('priority', $this->ComputePriority());
		
		// Compute the SLA deadlines, if any is applicable to this ticket
		$aSLT = $this->ComputeSLT('TTO');
		if ($aSLT != null)
		{
			$oStartDate = new DateTime($this->Get('start_date'));
			$oDeadline = SLAComputation::GetDeadline($this, $aSLT['value'], $oStartDate);		
			$this->Set('tto_escalation_deadline', $oDeadline->format('U'));
		}
		else
		{
			$this->Set('tto_escalation_deadline', null);
		}
		$aSLT = $this->ComputeSLT('TTR');
		if ($aSLT != null)
		{
			$oStartDate = new DateTime($this->Get('start_date'));
			$oDeadline = SLAComputation::GetDeadline($this, $aSLT['value'], $oStartDate);		
			$this->Set('ttr_escalation_deadline', $oDeadline->format('U'));
		}
		else
		{
			$this->Set('ttr_escalation_deadline', null);
		}
	}]]></code>
        </method>
        <method id="GetHilightClass">
          <comment><![CDATA[/**
	 * Determines if the ticket must be hilighted in the list, if we're about to miss a SLA for instance
	 */]]></comment>
          <static>false</static>
          <access>public</access>
          <type>Overload-iDisplay</type>
          <code><![CDATA[	public function GetHilightClass()
	{
		$sHilightClass = '';
		switch($this->GetState())
		{
			case 'new':
			$oEscalationDeadline = $this->Get('tto_escalation_deadline');
			if ($oEscalationDeadline != null)
			{
				// A SLA is running
				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
				$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
				if ($ratio <= 0)
				{
					$sHilightClass = HILIGHT_CLASS_CRITICAL;
				}
				else if ($ratio <= 0.25)
				{
					$sHilightClass = HILIGHT_CLASS_WARNING;
				}
			}
			break;
			
			case 'assigned':
			$oEscalationDeadline = $this->Get('ttr_escalation_deadline');
			if ($oEscalationDeadline != null)
			{
				// A SLA is running
				$iStartDate = AttributeDateTime::GetAsUnixSeconds($this->Get('start_date'));
				$iEscalationDeadline = AttributeDateTime::GetAsUnixSeconds($oEscalationDeadline);
				$ratio = ($iEscalationDeadline - time())/($iEscalationDeadline - $iStartDate);
				if ($ratio <= 0)
				{
					$sHilightClass = HILIGHT_CLASS_CRITICAL;
				}
				else if ($ratio <= 0.25)
				{
					$sHilightClass = HILIGHT_CLASS_WARNING;
				}
			}
			break;
			
			case 'escalated_tto':
			case 'escalated_ttr':
			$sHilightClass = HILIGHT_CLASS_CRITICAL;
			break;
		}
		return $sHilightClass;
	}]]></code>
        </method>
        <method id="OnInsert">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	protected function OnInsert()
	{
		$this->Set('last_update', time());
	}]]></code>
        </method>
        <method id="OnUpdate">
          <static>false</static>
          <access>protected</access>
          <type>Overload-DBObject</type>
          <code><![CDATA[	protected function OnUpdate()
	{
		$this->Set('last_update', time());
	}]]></code>
        </method>
      </methods>
      <presentation>
        <details>
          <items>
            <item id="ref">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="org_id">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="tto_escalation_deadline">
              <rank>50</rank>
            </item>
            <item id="ttr_escalation_deadline">
              <rank>60</rank>
            </item>
            <item id="closure_deadline">
              <rank>70</rank>
            </item>
            <item id="document_list">
              <rank>80</rank>
            </item>
            <item id="ci_list">
              <rank>90</rank>
            </item>
            <item id="contact_list">
              <rank>100</rank>
            </item>
            <item id="status">
              <rank>110</rank>
            </item>
            <item id="caller_id">
              <rank>120</rank>
            </item>
            <item id="service_id">
              <rank>130</rank>
            </item>
            <item id="servicesubcategory_id">
              <rank>140</rank>
            </item>
            <item id="product">
              <rank>150</rank>
            </item>
            <item id="impact">
              <rank>160</rank>
            </item>
            <item id="urgency">
              <rank>170</rank>
            </item>
            <item id="priority">
              <rank>180</rank>
            </item>
            <item id="workgroup_id">
              <rank>190</rank>
            </item>
            <item id="agent_id">
              <rank>200</rank>
            </item>
            <item id="agent_email">
              <rank>210</rank>
            </item>
            <item id="related_problem_id">
              <rank>220</rank>
            </item>
            <item id="related_change_id">
              <rank>230</rank>
            </item>
            <item id="close_date">
              <rank>240</rank>
            </item>
            <item id="last_update">
              <rank>250</rank>
            </item>
            <item id="assignment_date">
              <rank>260</rank>
            </item>
            <item id="resolution_code">
              <rank>270</rank>
            </item>
            <item id="solution">
              <rank>280</rank>
            </item>
            <item id="user_satisfaction">
              <rank>290</rank>
            </item>
            <item id="user_commment">
              <rank>300</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="finalclass">
              <rank>10</rank>
            </item>
            <item id="ref">
              <rank>20</rank>
            </item>
            <item id="title">
              <rank>30</rank>
            </item>
            <item id="org_id">
              <rank>40</rank>
            </item>
            <item id="start_date">
              <rank>50</rank>
            </item>
            <item id="status">
              <rank>60</rank>
            </item>
            <item id="caller_id">
              <rank>70</rank>
            </item>
            <item id="service_id">
              <rank>80</rank>
            </item>
            <item id="servicesubcategory_id">
              <rank>90</rank>
            </item>
            <item id="product">
              <rank>100</rank>
            </item>
            <item id="impact">
              <rank>110</rank>
            </item>
            <item id="urgency">
              <rank>120</rank>
            </item>
            <item id="priority">
              <rank>130</rank>
            </item>
            <item id="workgroup_id">
              <rank>140</rank>
            </item>
            <item id="agent_id">
              <rank>150</rank>
            </item>
            <item id="agent_email">
              <rank>160</rank>
            </item>
            <item id="close_date">
              <rank>170</rank>
            </item>
            <item id="resolution_code">
              <rank>180</rank>
            </item>
            <item id="solution">
              <rank>190</rank>
            </item>
            <item id="user_satisfaction">
              <rank>200</rank>
            </item>
            <item id="user_commment">
              <rank>210</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="finalclass">
              <rank>10</rank>
            </item>
            <item id="title">
              <rank>20</rank>
            </item>
            <item id="org_id">
              <rank>30</rank>
            </item>
            <item id="start_date">
              <rank>40</rank>
            </item>
            <item id="status">
              <rank>50</rank>
            </item>
            <item id="caller_id">
              <rank>60</rank>
            </item>
            <item id="service_id">
              <rank>70</rank>
            </item>
            <item id="priority">
              <rank>80</rank>
            </item>
            <item id="workgroup_id">
              <rank>90</rank>
            </item>
            <item id="agent_id">
              <rank>100</rank>
            </item>
            <item id="last_update">
              <rank>110</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkTicketToDoc" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel,searchable,incidentmgmt,requestmgmt,changemgmt,problemmgmt,lnkticket</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnktickettodoc</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="document_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>
          <jointype/>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="document_id" xsi:type="AttributeExternalKey">
          <sql>document_id</sql>
          <target_class>Document</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
          <jointype/>
        </field>
        <field id="document_name" xsi:type="AttributeExternalField">
          <extkey_attcode>document_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="document_id">
              <rank>20</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="document_id">
              <rank>20</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="document_id">
              <rank>20</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkTicketToContact" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel,searchable,incidentmgmt,requestmgmt,changemgmt,problemmgmt,lnkticket</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnktickettocontact</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_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>
          <jointype/>
        </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>
          <jointype/>
        </field>
        <field id="contact_name" xsi:type="AttributeExternalField">
          <extkey_attcode>contact_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </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>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="contact_email">
              <rank>30</rank>
            </item>
            <item id="role">
              <rank>40</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="contact_email">
              <rank>30</rank>
            </item>
            <item id="role">
              <rank>40</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="contact_id">
              <rank>20</rank>
            </item>
            <item id="contact_email">
              <rank>30</rank>
            </item>
            <item id="role">
              <rank>40</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
    <class id="lnkTicketToCI" _delta="define">
      <parent>cmdbAbstractObject</parent>
      <properties>
        <is_link>1</is_link>
        <category>bizmodel,searchable,incidentmgmt,requestmgmt,changemgmt,problemmgmt,lnkticket</category>
        <abstract>false</abstract>
        <key_type>autoincrement</key_type>
        <db_table>lnktickettoci</db_table>
        <db_key_field>id</db_key_field>
        <db_final_class_field/>
        <naming>
          <attributes>
            <attribute id="ticket_id"/>
          </attributes>
        </naming>
        <display_template/>
        <icon/>
        <reconciliation>
          <attributes>
            <attribute id="ticket_id"/>
            <attribute id="ci_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>
          <jointype/>
        </field>
        <field id="ticket_ref" xsi:type="AttributeExternalField">
          <extkey_attcode>ticket_id</extkey_attcode>
          <target_attcode>ref</target_attcode>
        </field>
        <field id="ci_id" xsi:type="AttributeExternalKey">
          <sql>ci_id</sql>
          <target_class>FunctionalCI</target_class>
          <is_null_allowed>false</is_null_allowed>
          <on_target_delete>DEL_AUTO</on_target_delete>
          <jointype/>
        </field>
        <field id="ci_name" xsi:type="AttributeExternalField">
          <extkey_attcode>ci_id</extkey_attcode>
          <target_attcode>name</target_attcode>
        </field>
        <field id="ci_status" xsi:type="AttributeExternalField">
          <extkey_attcode>ci_id</extkey_attcode>
          <target_attcode>status</target_attcode>
        </field>
        <field id="impact" xsi:type="AttributeString">
          <sql>impact</sql>
          <default_value/>
          <is_null_allowed>true</is_null_allowed>
        </field>
      </fields>
      <methods/>
      <presentation>
        <details>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="ci_id">
              <rank>20</rank>
            </item>
            <item id="impact">
              <rank>30</rank>
            </item>
            <item id="ci_status">
              <rank>40</rank>
            </item>
          </items>
        </details>
        <search>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="ci_id">
              <rank>20</rank>
            </item>
            <item id="ci_status">
              <rank>30</rank>
            </item>
          </items>
        </search>
        <list>
          <items>
            <item id="ticket_id">
              <rank>10</rank>
            </item>
            <item id="ci_id">
              <rank>20</rank>
            </item>
            <item id="impact">
              <rank>30</rank>
            </item>
            <item id="ci_status">
              <rank>40</rank>
            </item>
          </items>
        </list>
      </presentation>
    </class>
  </classes>
</itop_design>
