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>
|
|
|
|
* @package AgileBill
|
|
|
|
* @subpackage Modules:EmailLog
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main AgileBill Email Log Class
|
|
|
|
*
|
2008-11-26 22:50:40 +00:00
|
|
|
* @package AgileBill
|
2009-08-03 04:10:16 +00:00
|
|
|
* @subpackage Modules:EmailLog
|
2008-11-26 22:50:40 +00:00
|
|
|
*/
|
2009-08-03 04:10:16 +00:00
|
|
|
class email_log extends OSB_module {
|
2008-11-26 22:50:40 +00:00
|
|
|
var $user_view_count = 25; /* show last X email logs for user */
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
public function user_list($VAR) {
|
|
|
|
if (! SESS_LOGGED)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$db = &DB();
|
|
|
|
|
|
|
|
$email = $db->GetOne(sqlSelect($db,'account','email',array('id'=>SESS_ACCOUNT)));
|
|
|
|
$rs = $db->Execute(
|
|
|
|
sqlSelect($db,'email_log','id,email,date_orig,subject,urgent,userread',array('email'=>$email,'account_id'=>SESS_ACCOUNT),'date_orig',$this->user_view_count));
|
|
|
|
|
|
|
|
if ($rs && $rs->RecordCount()) {
|
|
|
|
$smart = array();
|
|
|
|
while (! $rs->EOF) {
|
|
|
|
array_push($smart,$rs->fields);
|
|
|
|
$rs->MoveNext();
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
global $smarty;
|
2009-08-03 04:10:16 +00:00
|
|
|
$smarty->assign('email_log',$smart);
|
|
|
|
}
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
public function user_view($VAR) {
|
|
|
|
if (! SESS_LOGGED || empty($VAR['id']))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
$db = &DB();
|
|
|
|
|
|
|
|
$rs = $db->Execute(sqlSelect($db,'email_log','*',array('id'=>$VAR['id'],'account_id'=>SESS_ACCOUNT)));
|
|
|
|
if ($rs && $rs->RecordCount()) {
|
2008-11-26 22:50:40 +00:00
|
|
|
global $smarty;
|
2009-08-03 04:10:16 +00:00
|
|
|
|
|
|
|
$smarty->assign('email_log',$rs->fields);
|
|
|
|
# Update to read
|
|
|
|
if ($rs->fields['userread'] != 1)
|
|
|
|
$db->Execute(sqlUpdate($db,'email_log',array('userread'=>1),array('id'=>$rs->fields['id'])));
|
2008-11-26 22:50:40 +00:00
|
|
|
}
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
|
2008-11-26 22:50:40 +00:00
|
|
|
function add($account_id, $subject, $message, $email, $html=0, $urgent=0) {
|
|
|
|
$db=&DB();
|
|
|
|
$fields=Array('date_orig'=>time(), 'account_id'=>$account_id, 'subject'=>$subject, 'message'=>$message, 'email'=>$email, 'html'=>$html, 'urgent'=>$urgent, 'userread'=>0);
|
|
|
|
$id = & $db->Execute(sqlInsert($db,"email_log",$fields));
|
|
|
|
}
|
|
|
|
}
|
2009-08-03 04:10:16 +00:00
|
|
|
?>
|