<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>modele_id_list=""
forme_id_list=""
gamme_id_list=""
collection_list=""
eip_list=""
marque_list=""
modele_origine_list=""</params>
SELECT DISTINCT modele.id, modele.relative_url, modele.path, modele.Description, modele.modele_state, modele.default_destination_title
FROM catalog AS modele
<dtml-if expr="_.len(collection_list)>0">
, category AS cat1
</dtml-if>
<dtml-if expr="_.len(eip_list)>0">
, category AS cat2
</dtml-if>
<dtml-if expr="_.len(marque_list)>0">
, category AS cat3
</dtml-if>
<dtml-if expr="_.len(modele_origine_list)>0">
<dtml-if expr="not (_.len(modele_origine_list)==1 and modele_origine_list[0]=='')">
, category AS cat4
</dtml-if>
</dtml-if>
WHERE modele.portal_type = "Modele"

<dtml-if expr="_.len(modele_id_list)>0">
AND ( modele.id LIKE "<dtml-var expr="modele_id_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(modele_id_list)-1)">
OR modele.id LIKE "<dtml-var expr="modele_id_list[loop_item+1]">"
</dtml-in>
)
</dtml-if>

<dtml-if expr="_.len(forme_id_list)>0">
AND ( modele.forme_id LIKE "<dtml-var expr="forme_id_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(forme_id_list)-1)">
OR modele.forme_id LIKE "<dtml-var expr="forme_id_list[loop_item+1]">"
</dtml-in>
)
</dtml-if>

<dtml-if expr="_.len(gamme_id_list)>0">
AND ( modele.gamme_id LIKE "<dtml-var expr="gamme_id_list[0]">"
<dtml-in prefix="loop" expr="_.range(_.len(gamme_id_list)-1)">
OR modele.gamme_id LIKE "<dtml-var expr="gamme_id_list[loop_item+1]">"
</dtml-in>
)
</dtml-if>

<dtml-if expr="_.len(collection_list)>0">
AND cat1.uid=modele.uid
AND ( cat1.category_uid=<dtml-var expr="identify_category(base_category='collection',category=collection_list[0])">
<dtml-in prefix="loop" expr="_.range(_.len(collection_list)-1)">
OR cat1.category_uid=<dtml-var expr="identify_category(base_category='collection',category=collection_list[loop_item+1])">
</dtml-in>
)
AND cat1.base_category_uid=<dtml-var "portal_categories.collection.uid">
</dtml-if>


<dtml-if expr="_.len(eip_list)>0">
AND cat2.uid=modele.uid
AND ( cat2.category_uid=<dtml-var expr="identify_category(base_category='eip',category=eip_list[0])">
<dtml-in prefix="loop" expr="_.range(_.len(eip_list)-1)">
OR cat2.category_uid=<dtml-var expr="identify_category(base_category='eip',category=eip_list[loop_item+1])">
</dtml-in>
)
AND cat2.base_category_uid=<dtml-var "portal_categories.eip.uid">
</dtml-if>

<dtml-if expr="_.len(marque_list)>0">
AND cat3.uid=modele.uid
AND ( cat3.category_uid=<dtml-var expr="identify_category(base_category='marque',category=marque_list[0])">
<dtml-in prefix="loop" expr="_.range(_.len(marque_list)-1)">
OR cat3.category_uid=<dtml-var expr="identify_category(base_category='marque',category=marque_list[loop_item+1])">
</dtml-in>
)
AND cat3.base_category_uid=<dtml-var "portal_categories.marque.uid">
</dtml-if>

<dtml-if expr="_.len(modele_origine_list)>0">
<dtml-if expr="not (_.len(modele_origine_list)==1 and modele_origine_list[0]=='')">
AND cat4.uid=modele.uid
<dtml-if expr="modele_origine_list[0]<>''">
AND ( cat4.category_uid=<dtml-var expr="identify_category(base_category='modele_origine',category=modele_origine_list[0])">
<dtml-else>
AND ( cat4.category_uid <> 0
</dtml-if>
<dtml-in prefix="loop" expr="_.range(_.len(modele_origine_list)-1)">
<dtml-if expr="modele_origine_list[loop_item+1]<>''">
OR cat4.category_uid=<dtml-var expr="identify_category(base_category='modele_origine',category=modele_origine_list[loop_item+1])">
</dtml-if>
</dtml-in>
)
AND cat4.base_category_uid=<dtml-var "portal_categories.modele_origine.uid">
</dtml-if>
</dtml-if>

