<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>resource_relative_url
variation_relative_url</params>
SELECT inventory_cell.relative_url, inventory_cell.path, movement.start_date, movement.stop_date
FROM movement, catalog as inventory_cell, catalog as resource, catalog as variation, category as cat1, category as cat2, catalog as delivery, catalog as inventory_line

WHERE inventory_cell.portal_type = "Inventory Cell"
AND inventory_cell.uid = movement.uid
AND movement.resource_uid = resource.uid
AND resource.relative_url = "<dtml-var resource_relative_url>"
AND variation.relative_url = "<dtml-var variation_relative_url>"
AND delivery.portal_type = "Inventory MP"
AND delivery.uid = movement.delivery_uid
AND inventory_cell.parent_uid = inventory_line.uid

AND cat2.uid = inventory_cell.uid
AND cat2.base_category_uid = <dtml-var "portal_categories.coloris.uid">
AND cat2.category_uid = variation.uid

AND cat1.uid = inventory_line.uid
AND cat1.base_category_uid = <dtml-var "portal_categories.resource.uid">
AND cat1.category_uid = resource.uid

ORDER BY movement.stop_date DESC, movement.start_date DESC