SELECT
cscart_banners.banner_id,
cscart_banners.type,
cscart_banners.target,
cscart_banners.status,
cscart_banners.position,
cscart_banner_descriptions.banner,
cscart_banner_descriptions.description,
cscart_banner_descriptions.url,
cscart_banner_images.banner_image_id,
cscart_banners.company_id
FROM
cscart_banners
LEFT JOIN cscart_banner_descriptions ON cscart_banner_descriptions.banner_id = cscart_banners.banner_id
AND cscart_banner_descriptions.lang_code = 'nl'
LEFT JOIN cscart_banner_images ON cscart_banner_images.banner_id = cscart_banners.banner_id
AND cscart_banner_images.lang_code = 'nl'
INNER JOIN cscart_ult_objects_sharing ON (
cscart_ult_objects_sharing.share_object_id = cscart_banners.banner_id
AND cscart_ult_objects_sharing.share_company_id = 1
AND cscart_ult_objects_sharing.share_object_type = 'banners'
)
WHERE
1
AND (
cscart_banners.type != 'G'
OR cscart_banner_images.banner_image_id IS NOT NULL
)
AND cscart_banners.banner_id IN (32)
AND cscart_banners.status = 'A'
AND IF (
cscart_banners.type not like 'abt__ut2',
'available',
IF (
cscart_banners.type like 'abt__ut2'
AND (
cscart_banners.abt__ut2_use_avail_period = 'N'
OR (
cscart_banners.abt__ut2_use_avail_period = 'Y'
AND (
cscart_banners.abt__ut2_avail_from = 0
OR cscart_banners.abt__ut2_avail_from <= 1732291040
)
AND (
cscart_banners.abt__ut2_avail_till = 0
OR cscart_banners.abt__ut2_avail_till >= 1732291040
)
)
),
'available',
'not available'
)
) = 'available'
ORDER BY
cscart_banners.position asc