From d295494489c9f429d1b77106642a7180ca7f1c1e Mon Sep 17 00:00:00 2001 From: abacab Date: Mon, 29 Dec 2008 21:45:00 -0500 Subject: [PATCH] If lowBalance is not set, then do not run the void_prepaid:task function. --- modules/voip_prepaid/voip_prepaid.inc.php | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/modules/voip_prepaid/voip_prepaid.inc.php b/modules/voip_prepaid/voip_prepaid.inc.php index 029e8bd2..1c074dbf 100644 --- a/modules/voip_prepaid/voip_prepaid.inc.php +++ b/modules/voip_prepaid/voip_prepaid.inc.php @@ -78,23 +78,26 @@ class voip_prepaid { include_once(PATH_MODULES.'email_template/email_template.inc.php'); - // delete expired pins? - // $delrs = & $db->Execute(sqlDelete($db,"voip_prepaid"," date_expire <> 0 and date_expire is not null and date_expire > ".time())); - - // get low balances and notify - $db=&DB(); - $rs = & $db->Execute($sql = sqlSelect($db,"voip_prepaid","*", "balance <= $this->lowBalance and (bulk is null or bulk=0) and (date_email is null or date_email = 0) ")); - if($rs && $rs->RecordCount() > 0) + if ($this->lowBalance) { - while(!$rs->EOF) - { - # send the user the details - $email = new email_template; - $email->send('voip_balance_prepaid', $rs->fields['account_id'], $rs->fields['id'], '', number_format($rs->fields['balance'],4)); + // delete expired pins? + // $delrs = & $db->Execute(sqlDelete($db,"voip_prepaid"," date_expire <> 0 and date_expire is not null and date_expire > ".time())); - # update the record - $db->Execute( sqlUpdate($db, "voip_prepaid", array('date_email'=>time()),"id={$rs->fields['id']}")); - $rs->MoveNext(); + // get low balances and notify + $db=&DB(); + $rs = & $db->Execute($sql = sqlSelect($db,"voip_prepaid","*", "balance <= $this->lowBalance and (bulk is null or bulk=0) and (date_email is null or date_email = 0) ")); + if($rs && $rs->RecordCount() > 0) + { + while(!$rs->EOF) + { + # send the user the details + $email = new email_template; + $email->send('voip_balance_prepaid', $rs->fields['account_id'], $rs->fields['id'], '', number_format($rs->fields['balance'],4)); + + # update the record + $db->Execute( sqlUpdate($db, "voip_prepaid", array('date_email'=>time()),"id={$rs->fields['id']}")); + $rs->MoveNext(); + } } } }