ontarget
Active Member
Hi I have the following php list plugin code called "Mark Paid"
When selected it sends an email out and changes paid == 1.
It works for individual rows (no errors - paid becomes 1 and email is sent)
but not for multiselect rows > DD option at top of list > Mark paid.
The error i get on multiselect is:
I dont know how to fix it as the forloop should go through each record selected and update / send accordingly.
I'm using Fabrik Epsilon and j4.3.4
When selected it sends an email out and changes paid == 1.
It works for individual rows (no errors - paid becomes 1 and email is sent)
but not for multiselect rows > DD option at top of list > Mark paid.
The error i get on multiselect is:
1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com, `course_title` FROM `aaa_participant_claim` WHERE `id` = 19427' at line 1
PHP:
$item = $model->getTable();
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');
//$db = FabrikWorker::getDbo();
$db = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$tr_table = $db->quoteName('aaa_participant_claim');
$c_id = $db->quoteName('id');
$paid = $db->quoteName('paid');
$paid_date = $db->quoteName('paid_date');
$email = $db->quoteName('email');
$coursetitle = $db->quoteName('course_title');
$centre = $db->quoteName('claim_process');
$date = new DateTime(); //this returns the current date time
$time = $date->format('Y-m-d H:i:s'); //"2017-12-12 12:36:34"
$cnt = 0;
foreach ($ids AS $myid) {
if ($cnt == 0) {
$row1 = $model->getRow($myid);
}
$cnt++;
//Added send email to Paid
$query = "SELECT $email, $coursetitle, $centre
FROM $tr_table
WHERE $c_id = $myid";
$db->setQuery($query);
$result = $db->loadObject();
$headers = "From: noreply@xxxxxx.ie";
$email = $result->email;
$course = $result->course_title;
$centre = $result->claim_process;
$subject = "Claim Approved (DO NOT REPLY)";
$msg = "Dear Participant,\nYour claim has been marked APPROVED for payment by your Education Support Centre for the course:\n" . $course . "\nYou should expect to receive payment by bank transfer in due course.\nDO NOT REPLY TO THIS EMAIL.\nFor all queries, please email " . $centre . "\n----------END------------\n";
mail($email,$subject,$msg,$headers);
//End of Email sending
$q = "UPDATE $tr_table SET $paid = 1, $paid_date = \"$time\" WHERE $c_id = $myid";
$db->setQuery($q);
$db->execute();
}
I dont know how to fix it as the forloop should go through each record selected and update / send accordingly.
I'm using Fabrik Epsilon and j4.3.4