<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>destination_section_uid=""
source_uid=""
destination_uid=""</params>
SELECT DISTINCT condition.id, condition.Description, condition.path, condition.uid, condition.portal_type
FROM catalog AS condition
<dtml-if expr="destination_section_uid<>''">
, category as cat1
</dtml-if>
<dtml-if expr="source_uid<>''">
, category as cat2
</dtml-if>
<dtml-if expr="destination_uid<>''">
, category as cat3
</dtml-if>
WHERE condition.portal_type="Condition Achat"

<dtml-if expr="destination_section_uid<>''">
AND condition.uid = cat1.uid
AND cat1.category_uid = "<dtml-var destination_section_uid>"
AND cat1.base_category_uid = <dtml-var "portal_categories.destination_section.uid">
</dtml-if>

<dtml-if expr="source_uid<>''">
AND condition.uid = cat2.uid
AND cat2.category_uid = "<dtml-var source_uid>"
AND cat2.base_category_uid = <dtml-var "portal_categories.source.uid">
AND cat2.category_strict_membership = 1
</dtml-if>

<dtml-if expr="destination_uid<>''">
AND condition.uid = cat3.uid
AND cat3.category_uid = "<dtml-var destination_uid>"
AND cat3.base_category_uid = <dtml-var "portal_categories.destination.uid">
</dtml-if>