/** * Subscription renewal mail function * * @return void */ public function subscription_renewal_mail() { $db = $db = JFactory::getDbo(); $redshopMail = new redshopMail(); $query = "SELECT ps.* FROM #__" . TABLE_PREFIX . "_product_subscribe_detail AS ps" . " ,#__" . TABLE_PREFIX . "_subscription_renewal AS r" . " WHERE r.product_id = ps.product_id AND r.before_no_days >= DATEDIFF(FROM_UNIXTIME( ps.end_date ),curdate())" . " AND ps.renewal_reminder = 1"; $db->setQuery($query); $data = $db->loadObjectList(); for ($i = 0; $i < count($data); $i++) { // Subscription renewal mail $redshopMail->sendSubscriptionRenewalMail($data[$i]); // Update mail sent field to 0 $update_query = "UPDATE #__" . TABLE_PREFIX . "_product_subscribe_detail " . "SET renewal_reminder = 0 " . "WHERE product_subscribe_id=" . (int) $data[$i]->product_subscribe_id; $db->setQuery($update_query); $db->Query(); } }