Hello
I use the following code to calculate the remainig budget of a supplier on the fly:
The template leads.php holds the shipped items and its prize.
Unfortunately when listing all the suppliers (hundreds) and adding the hundreds of item prizes couch gets slow.
Does anyone know how to add up the prizes (editable 'preis') just within the sql statement?
The corresponding sql statement is:
Regards,
Olliwalli
I use the following code to calculate the remainig budget of a supplier on the fly:
- Code: Select all
<cms:php>
echo number_format (
<cms:show restbudget /> - (
<cms:reverse_related_pages masterpage='app/data/leads.php' custom_field="status=Aktiv,Verrechnet|testlead!=Ja|datum_verteilt=<cms:show monat />" field='anbieter_relation'>
<cms:show preis /> +
</cms:reverse_related_pages>
0), 2, ".", "'");
</cms:php>
The template leads.php holds the shipped items and its prize.
Unfortunately when listing all the suppliers (hundreds) and adding the hundreds of item prizes couch gets slow.
Does anyone know how to add up the prizes (editable 'preis') just within the sql statement?
The corresponding sql statement is:
- Code: Select all
SELECT p.id,
p.template_id
FROM couch_pages p
INNER JOIN couch_relations rel
ON rel.pid = p.id
INNER JOIN couch_data_text t0
ON t0.page_id = p.id
INNER JOIN couch_data_text t1
ON t1.page_id = p.id
INNER JOIN couch_data_text t2
ON t2.page_id = p.id
WHERE rel.cid = 13751
AND rel.fid = 308
AND p.template_id = '54'
AND p.publish_date < '2018-01-13 09:28:13'
AND NOT p.publish_date = '0000-00-00 00:00:00'
AND p.parent_id = 0
AND ( t0.field_id = 343
AND t1.field_id = 341
AND t2.field_id = 345 )
AND ( ( t0.search_value LIKE '%Aktiv%'
OR t0.search_value LIKE '%Verrechnet%' )
AND t1.search_value NOT LIKE '%Ja%'
AND t2.search_value LIKE '%2018-01%' )
ORDER BY rel.weight DESC
Regards,
Olliwalli