thellie
Member
Hi, me again...
I would like to set a scheduled task, in order to check and change the user group of volunteers based on comparing their startdate and the current date. I have the MySQL query written and raring to go, but I'm not sure how to write the PHP code it gets wrapped in for this... Is there an example code that can be posted for me please?
I normally grab an existing piece of code from the forum, or wiki, or online somewhere, but can't find anything for the new J!4/F4 version.
Thanks in anticipation
My query is:
I would like to set a scheduled task, in order to check and change the user group of volunteers based on comparing their startdate and the current date. I have the MySQL query written and raring to go, but I'm not sure how to write the PHP code it gets wrapped in for this... Is there an example code that can be posted for me please?
I normally grab an existing piece of code from the forum, or wiki, or online somewhere, but can't find anything for the new J!4/F4 version.
Thanks in anticipation
My query is:
Code:
UPDATE nm7t_user_usergroup_map AS t
LEFT JOIN vol_appform AS e
ON e.user_id = t.user_id
SET t.group_id = CASE
WHEN (t.group_id =22) && (curdate() >= e.startdate && curdate()<=IF(e.actual_enddate,e.actual_enddate,e.enddate))
&& e.programme =22
THEN 19
WHEN (t.group_id =22) && (curdate() >= e.startdate && curdate()<=IF(e.actual_enddate,e.actual_enddate,e.enddate))
&& (e.programme =19 OR e.programme = 20)
THEN 20
WHEN (t.group_id =22) && (curdate() >= e.startdate && curdate()<=IF(e.actual_enddate,e.actual_enddate,e.enddate))
&& e.programme =23
THEN 18
WHEN (t.group_id =20 OR t.group_id =19) && (IF(e.actual_enddate,e.actual_enddate,e.enddate) < curdate())
THEN 25
WHEN (e.startdate >= curdate() && t.group_id != 21)
THEN 22
ELSE t.group_id
END;