2008-11-26 22:50:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* AgileBill - Open Billing Software
|
|
|
|
*
|
|
|
|
* This body of work is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the Open AgileBill License
|
|
|
|
* License as published at http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
*
|
|
|
|
* Originally authored by Tony Landis, AgileBill LLC
|
|
|
|
*
|
|
|
|
* Recent modifications by Deon George
|
|
|
|
*
|
|
|
|
* @author Deon George <deonATleenooksDOTnet>
|
|
|
|
* @copyright 2009 Deon George
|
|
|
|
* @link http://osb.leenooks.net
|
2008-11-26 22:50:40 +00:00
|
|
|
*
|
|
|
|
* @link http://www.agileco.com/
|
|
|
|
* @copyright 2004-2008 Agileco, LLC.
|
|
|
|
* @license http://www.agileco.com/agilebill/license1-4.txt
|
2009-08-03 04:10:16 +00:00
|
|
|
* @author Tony Landis <tony@agileco.com>
|
2008-11-26 22:50:40 +00:00
|
|
|
* @package AgileBill
|
2009-08-03 04:10:16 +00:00
|
|
|
* @subpackage Module:EmailQueue
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-03 04:10:16 +00:00
|
|
|
/**
|
|
|
|
* The main AgileBill Email Queue Class
|
|
|
|
*
|
|
|
|
* @package AgileBill
|
|
|
|
* @subpackage Module:EmailQueue
|
|
|
|
*/
|
|
|
|
class email_queue extends OSB_module {
|
|
|
|
/**
|
|
|
|
* Send mails in the queue
|
|
|
|
*/
|
|
|
|
public function send($VAR) {
|
|
|
|
$db = &DB();
|
|
|
|
$rs = $db->Execute(sqlSelect($db,'email_queue','*',array('status'=>0)));
|
|
|
|
|
|
|
|
if ($rs && $rs->RecordCount()) {
|
|
|
|
require_once(PATH_MODULES.'email_template/email_template.inc.php');
|
|
|
|
|
|
|
|
while (! $rs->EOF) {
|
|
|
|
# Get values
|
|
|
|
$sql = array();
|
|
|
|
$sql[1] = $rs->fields['sql1'];
|
|
|
|
$sql[2] = $rs->fields['sql2'];
|
|
|
|
$sql[3] = $rs->fields['sql3'];
|
|
|
|
|
|
|
|
# Unserialize the SQL data if required.
|
|
|
|
foreach ($sql as $i)
|
|
|
|
if (preg_match('/^a:/',$sql[$i]) && is_array($a = unserialize($sql[$a])))
|
|
|
|
$sql[$i] = $a;
|
2008-11-26 22:50:40 +00:00
|
|
|
|
|
|
|
# Send email
|
|
|
|
$mail = new email_template;
|
2009-08-03 04:10:16 +00:00
|
|
|
$result = $mail->send($rs->fields['email_template'],$rs->fields['account_id'],$sql[1],$sql[2],$sql[3],false);
|
2008-11-26 22:50:40 +00:00
|
|
|
|
|
|
|
# Update to sent status
|
2009-08-03 04:10:16 +00:00
|
|
|
if ($result)
|
|
|
|
$db->Execute(sqlUpdate($db,'email_queue',array('status'=>1),array('id'=>$rs->fields['id'])));
|
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
$rs->MoveNext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
?>
|