Email Scheduled Tasks

Settings

List: Courses Instructed (this is also joined to enrolled students.

Condition:

$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);

// loop through the data array, which is split into groups
foreach ($data as $group) {
// loop through each group, which is split into rows
foreach ($group as $row) {
// for each row, grab the expiration date and calculate the difference in days between it and "now"

$complete= 'enrolled_studcourses_instructed___statusents___completed';
$status = ''courses_instructed___status';

if($complete == 0 || $status == 0){
return 'You have courses that need completed';
}
}
}


I am trying to evaluate if the enrolled_student has completed the course and if not send a email advising the student has a course that is incomplete. If the courses_status is 0 or Open.

When I run the above code I get no errors however no updates or email and I should return 1 row or email.
 
As per the wiki:

http://fabrikar.com/forums/index.php?wiki/email-scheduled-task/

... the condition is run on every row. You can use placeholders, or access the $row array. So ...

return '{courses_instructed___status}' == '0' || '{enrolled_studcourses_instructed___statusents___completed}' == '0';

... should work. However, that element name 'enrolled_studcourses_instructed___statusents___completed' doesn't look right. You should only have one ___ in a placeholder, the seperator between table and field name. is that on a different table to courses_instructed___status? Like maybe a repeat group?

-- hugh
 
$status -- Comes from the course which is the parent table.

$completed -- Comes from the enrolled_students table which is a repeat group to courses. I would assume the element name would be enrolled_students___completed

I think i may have messed up on the copy and paste.
 
OK, this isn't entirely trivial.

Your list is set to "merge and reduce rows" for the repeated data, which means all your repeated data is merged, so (say) your 'enrolled_strudents___completed_raw' element is like this:

Code:
["enrolled_students___completed_raw"]=> string(85) "["1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1"]"

So you'll need to start by copying that list (just select it in the Lists tab and hit Copy), give the copied list/form/groups some differenty name (I usually append " (email)" or something) so you can tell the difference in the various menus. Then edit that copy of the list, and set that "Merge" in the join settings to "individual rows" (or whatever the non-merged option is call).

Then use that copy for the email cron.

Let me know once you've copied it.
 
OK.

I just added a new feature to the cron email plugin, a "test mode". When run on the backend (with the Run button), if test mode is enabled, it won't actually send mail, it'll just output useful info about what it would have done.

I did that because trying to work on stuff like your form, I worry about trying to test without sending mail to your clients. I don't know if that's live data or not.

Anyway ... if it is, you might want to do a an update of Fabrik. I folded those changes into the 3.8 release.

Then I'll feel happier working on this.

-- hugh
 
OK, I'll try and get to it today, but I have a very busy day ahead of me, it might be tomorrow or the weekend. Bump this thread if I haven't gotten back to you by Saturday.

-- hugh
 
Sorry, I've been on the road for much of the last week. I'm at the airport waiting to board a flight home on the last leg, I'll be catching up on a lot of stuff this week.

-- hugh
 
Ya I had to create another copy to be able to view the course and save info with out the join because I had to many joins to save the record.
 
Yeah, that'll happen if you are trying to send a lot of emails.

Try editing ...

./plugins/fabrik_cron/email/email.php

... and at line 50, as the first line of the process() method, put ...

Code:
ini_set('max_execution_time', 300);

That may or not may not work, depending how your web server is configured. Usually on shared sites you won't be able to override things like execution time. But if you have your own VM, it should work.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top