mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°4032 - On UserRequest, change proposed service subcategories (#786)
* N°4032 - On UserRequest, service subcategory no more limited by request_type
This commit is contained in:
@@ -306,11 +306,8 @@
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
</field>
|
||||
<field id="servicesubcategory_id" xsi:type="AttributeExternalKey">
|
||||
<filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND (ISNULL(:this->request_type) OR request_type = :this->request_type) AND status != 'obsolete']]></filter>
|
||||
<dependencies>
|
||||
<attribute id="service_id"/>
|
||||
<attribute id="request_type"/>
|
||||
</dependencies>
|
||||
<filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND status != 'obsolete']]></filter>
|
||||
<dependencies/>
|
||||
<sql>servicesubcategory_id</sql>
|
||||
<target_class>ServiceSubcategory</target_class>
|
||||
<is_null_allowed>true</is_null_allowed>
|
||||
@@ -1334,21 +1331,23 @@
|
||||
// Compute the priority of the ticket
|
||||
$this->Set('priority', $this->ComputePriority());
|
||||
|
||||
// Compute the request_type if not already defined (by the user)
|
||||
$sType = $this->Get('request_type');
|
||||
if (is_null($sType) || ($sType === ''))
|
||||
{
|
||||
$iSvcSubcat = $this->Get('servicesubcategory_id');
|
||||
if ($iSvcSubcat != 0)
|
||||
{
|
||||
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
|
||||
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
|
||||
}
|
||||
}
|
||||
|
||||
return parent::ComputeValues();
|
||||
}]]></code>
|
||||
</method>
|
||||
<method id="EvtComputeRequestType">
|
||||
<static>false</static>
|
||||
<access>public</access>
|
||||
<type>EventListener</type>
|
||||
<code><![CDATA[ public function EvtComputeRequestType(?Combodo\iTop\Service\Events\EventData $oEventData = null)
|
||||
{
|
||||
$iSvcSubcat = $this->Get('servicesubcategory_id');
|
||||
if ($iSvcSubcat != 0)
|
||||
{
|
||||
$oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true);
|
||||
$this->Set('request_type', $oSvcSubcat->Get('request_type'));
|
||||
}
|
||||
}]]></code>
|
||||
</method>
|
||||
<method id="DisplayBareRelations">
|
||||
<static>false</static>
|
||||
<access>public</access>
|
||||
@@ -1528,6 +1527,13 @@
|
||||
}]]></code>
|
||||
</method>
|
||||
</methods>
|
||||
<event_listeners>
|
||||
<event_listener id="EVENT_DB_BEFORE_WRITE">
|
||||
<event>EVENT_DB_BEFORE_WRITE</event>
|
||||
<callback>EvtComputeRequestType</callback>
|
||||
<rank>0</rank>
|
||||
</event_listener>
|
||||
</event_listeners>
|
||||
<presentation>
|
||||
<details>
|
||||
<items>
|
||||
|
||||
Reference in New Issue
Block a user