Browse Source

User request (all-in-one): the end-user can leave the request type undefined, in such a case, she can select any type of services and the request type gets computed when the requests is written to the DB. Still, this is possible to select a request type and the list of services is filled with the corresponding services. This behavior was necessary for the new user portal to work fine.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4046 a333f486-631f-4898-b8df-5754b55c2be0
romainq 9 năm trước cách đây
mục cha
commit
3cdc918779

+ 14 - 3
datamodels/2.x/itop-request-mgmt/datamodel.itop-request-mgmt.xml

@@ -70,7 +70,7 @@
             <value id="service_request">service_request</value>
           </values>
           <sql>request_type</sql>
-          <default_value>incident</default_value>
+          <default_value></default_value>
           <is_null_allowed>true</is_null_allowed>
           <display_style>list</display_style>
         </field>
@@ -157,7 +157,7 @@
           <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 request_type = :this->request_type AND status != 'obsolete']]></filter>
+          <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"/>
@@ -1196,10 +1196,21 @@
           <type>Overload-DBObject</type>
           <code><![CDATA[	public function ComputeValues()
 	{
-
 		// 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)
+			{
+				$sType = $this->Get('servicesubcategory_id->request_type');
+				$this->Set('request_type', $sType);
+			}
+		}
+
 		return parent::ComputeValues();
 	}]]></code>
         </method>