OSB enhancements to date

This commit is contained in:
Deon George
2010-11-30 09:41:08 +11:00
parent 8715a2059b
commit ec6a542bc3
478 changed files with 23423 additions and 9309 deletions

View File

@@ -92,8 +92,30 @@ class account extends OSB_module {
/** SMARTY METHODS **/
/**
* Get authorized groups
* Get a list of groups to which an account is a member of
*
* Accounts are always a member of group 0/2 (All Un & Registered Users)
*/
public function sAccountGroups($account_id) {
static $CACHE = array();
if (! isset($CACHE[$account_id])) {
$db = &DB();
$rs = $db->Execute(sqlSelect($db,'account_group','group_id',sprintf('group_id>2 AND active=1 AND account_id=%s',$account_id)));
$CACHE[$account_id] = array(0,2);
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
array_push($CACHE[$account_id],$rs->fields['group_id']);
$rs->MoveNext();
}
}
}
return $CACHE[$account_id];
}
// @todo Use sAccountGroups() in this method
public function user_get_auth_groups($VAR) {
global $smarty,$C_auth;
@@ -103,16 +125,17 @@ class account extends OSB_module {
# Get groups for this account
$authgrp = array();
if (! empty($VAR['id'])) {
$grs = $db->Execute(sqlSelect($db,'account_group','group_id',sprintf('group_id>2 AND active=1 AND account_id=%s',$VAR['id'])));
if ($grs && $grs->RecordCount()) {
while (! $grs->EOF) {
$authgrp[$grs->fields['group_id']] = true;
$grs->MoveNext();
$rs = $db->Execute(sqlSelect($db,'account_group','group_id',sprintf('group_id>2 AND active=1 AND account_id=%s',$VAR['id'])));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$authgrp[$rs->fields['group_id']] = true;
$rs->MoveNext();
}
}
}
$rs = $db->Execute(sqlSelect($db,'group','id,name',sprintf('id IN (%s) AND id > 2',implode(',',$C_auth->group))));
if ($rs && $rs->RecordCount()) {
while (! $rs->EOF) {
$gid = $rs->fields['id'];
@@ -609,9 +632,7 @@ class account extends OSB_module {
$limit = $result->fields['date_orig']+$LIMIT_SECONDS;
if ($limit>time()) {
$error1 = $C_translate->translate('password_reset_spam_limit',$this->module,'');
$error = str_replace('%limit%',$LIMIT_SECONDS,$error1);
$C_debug->alert($error);
$C_debug->alert(sprintf(_('You have already submitted the password reset request for this account within the past %s seconds, please wait to try again'),$LIMIT_SECONDS));
return;
@@ -640,7 +661,7 @@ class account extends OSB_module {
$my->send('account_reset_password',$account,'','',$now,false);
# ALERT: we have sent an email to you....
$C_debug->alert($C_translate->translate('password_reset_sent',$this->module,''));
$C_debug->alert(_('Thank you, we have sent an email to your email address on file with a link for changing your password. The link is valid for 15 minutes only, so be sure to check your email right away.'));
}
/**
@@ -914,9 +935,9 @@ class account extends OSB_module {
}
}
public function __construct() {
public function __construct($id=null) {
if (! defined('AJAX'))
parent::__construct();
parent::__construct($id);
}
/**
@@ -1084,6 +1105,8 @@ class account extends OSB_module {
$where = sprintf('(username LIKE "%s%%" OR first_name LIKE "%s%%" OR last_name LIKE "%s%%" OR company LIKE "%s%%")',
$VAR[$field],$VAR[$field],$VAR[$field],$VAR[$field]);
$where .= 'AND status=1';
if (! preg_match("/{$return}/",$fieldlist))
$fieldlist .= ','.$return;
@@ -1095,8 +1118,8 @@ class account extends OSB_module {
if ($result->RecordCount() > 0) {
while (! $result->EOF) {
printf('<li><div class="name"><b>%s %s</b></div><div class="email"><span class="informal">%s</span></div><div class="index" style="display:none">%s</div></li>',
$result->fields['first_name'],$result->fields['last_name'],$result->fields['email'],$result->fields[$return]);
printf('<li><div class="name"><b>%s %s (%s)</b></div><div class="email"><span class="informal">%s</span></div><div class="index" style="display:none">%s</div></li>',
$result->fields['first_name'],$result->fields['last_name'],$result->fields['username'],$result->fields['email'],$result->fields[$return]);
$result->MoveNext();
}
@@ -1774,13 +1797,13 @@ class account extends OSB_module {
}
# Get invoice details for this account
$view = $db->SelectLimit(sqlSelect($db,'invoice','id,date_orig,total_amt,billed_amt,process_status',array('account_id'=>$VAR['id']),'id DESC'),10);
$view = $db->SelectLimit(sqlSelect($db,'invoice','id,date_orig,total_amt,IFNULL(credit_amt,0) as credit_amt,status,billed_amt,process_status',array('account_id'=>$VAR['id']),'id DESC'),10);
if ($view && $view->RecordCount() > 0) {
$smart['invoice'] = array();
while (! $view->EOF) {
if ($view->fields['total_amt'] > $view->fields['billed_amt'] && $view->fields['suspend_billing'] != 1)
$view->fields['due'] = $view->fields['total_amt']-$view->fields['billed_amt'];
$view->fields['due'] = round($view->fields['total_amt']-$view->fields['billed_amt']-$view->fields['credit_amt'],2);
array_push($smart['invoice'],$view->fields);
$view->MoveNext();
@@ -1798,6 +1821,18 @@ class account extends OSB_module {
}
}
# Get payment details for this account
$rs = $db->SelectLimit(sqlSelect($db,array('payment','payment_item'),'A.id,A.date_payment,A.total_amt,SUM(B.alloc_amt) AS alloc_amt',
sprintf('A.account_id=%s AND B.payment_id=A.id',$VAR['id']),'A.date_payment DESC','','','B.payment_id'),10);
if ($rs && $rs->RecordCount() > 0) {
$smart['payment'] = array();
while (! $rs->EOF) {
array_push($smart['payment'],$rs->fields);
$rs->MoveNext();
}
}
# Get invoices to be generated for this account
include_once(PATH_MODULES.'invoice/invoice.inc.php');
$invoice = new invoice;