|
306 | 306 | <is_null_allowed>true</is_null_allowed> |
307 | 307 | </field> |
308 | 308 | <field id="servicesubcategory_id" xsi:type="AttributeExternalKey"> |
309 | | - <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> |
310 | | - <dependencies> |
311 | | - <attribute id="service_id"/> |
312 | | - <attribute id="request_type"/> |
313 | | - </dependencies> |
| 309 | + <filter><![CDATA[SELECT ServiceSubcategory WHERE service_id = :this->service_id AND status != 'obsolete']]></filter> |
| 310 | + <dependencies/> |
314 | 311 | <sql>servicesubcategory_id</sql> |
315 | 312 | <target_class>ServiceSubcategory</target_class> |
316 | 313 | <is_null_allowed>true</is_null_allowed> |
|
1334 | 1331 | // Compute the priority of the ticket |
1335 | 1332 | $this->Set('priority', $this->ComputePriority()); |
1336 | 1333 |
|
1337 | | - // Compute the request_type if not already defined (by the user) |
1338 | | - $sType = $this->Get('request_type'); |
1339 | | - if (is_null($sType) || ($sType === '')) |
| 1334 | + return parent::ComputeValues(); |
| 1335 | + }]]></code> |
| 1336 | + </method> |
| 1337 | + <method id="EvtComputeRequestType"> |
| 1338 | + <static>false</static> |
| 1339 | + <access>public</access> |
| 1340 | + <type>EventListener</type> |
| 1341 | + <code><![CDATA[ public function EvtComputeRequestType(?Combodo\iTop\Service\Events\EventData $oEventData = null) |
| 1342 | + { |
| 1343 | + $iSvcSubcat = $this->Get('servicesubcategory_id'); |
| 1344 | + if ($iSvcSubcat != 0) |
1340 | 1345 | { |
1341 | | - $iSvcSubcat = $this->Get('servicesubcategory_id'); |
1342 | | - if ($iSvcSubcat != 0) |
1343 | | - { |
1344 | | - $oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true); |
1345 | | - $this->Set('request_type', $oSvcSubcat->Get('request_type')); |
1346 | | - } |
| 1346 | + $oSvcSubcat = MetaModel::GetObject(ServiceSubcategory::class, $iSvcSubcat, true, true); |
| 1347 | + $this->Set('request_type', $oSvcSubcat->Get('request_type')); |
1347 | 1348 | } |
1348 | | -
|
1349 | | - return parent::ComputeValues(); |
1350 | 1349 | }]]></code> |
1351 | 1350 | </method> |
1352 | 1351 | <method id="DisplayBareRelations"> |
|
1528 | 1527 | }]]></code> |
1529 | 1528 | </method> |
1530 | 1529 | </methods> |
| 1530 | + <event_listeners> |
| 1531 | + <event_listener id="EVENT_DB_BEFORE_WRITE"> |
| 1532 | + <event>EVENT_DB_BEFORE_WRITE</event> |
| 1533 | + <callback>EvtComputeRequestType</callback> |
| 1534 | + <rank>0</rank> |
| 1535 | + </event_listener> |
| 1536 | + </event_listeners> |
1531 | 1537 | <presentation> |
1532 | 1538 | <details> |
1533 | 1539 | <items> |
|
0 commit comments