<dtml-comment>
title:
connection_id:MySQL
max_rows:100000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>uid</params>
SELECT DISTINCT delivery.relative_url, delivery.path, delivery.portal_type, movement.start_date, movement.quantity, movement.inventory, movement.stop_date, source_node.title as source_title, destination_node.title as destination_title
FROM catalog, catalog as piece_tissu, catalog as delivery, category, movement
LEFT JOIN catalog as source_node ON source_node.uid = movement.source_uid
LEFT JOIN catalog as destination_node ON destination_node.uid = movement.destination_uid
WHERE catalog.uid=category.uid
AND piece_tissu.uid = category.category_uid
AND piece_tissu.portal_type = "Piece Tissu"
AND category.base_category_uid = <dtml-var "portal_categories.aggregate.uid">
AND movement.uid = catalog.uid
AND delivery.uid = movement.delivery_uid
<dtml-if uid>
AND piece_tissu.uid = <dtml-sqlvar uid type="int">
</dtml-if>
ORDER BY movement.stop_date DESC, movement.start_date DESC