sergiocesar wrote:
It looks like it is triggered by the customer balance relative to ZERO. shouldn't it be triggered by relative to balance plus the credit limit?
so the customer is only notified if his phone is about to be cut off?
You can do that in asterisk ext or dialplan before sending the call to a2billing. Here is an dialplan i wrote which plays a voice prompt and connects the client to my office when His or hers balance is 35 cents or less. If greater than 0.35 it sends the call on to a2billing.
Its very simple to instead have it play the clients balance + credit limit and send the call directly to a2billing. You could even put a extra field into the cc_card table so the balance would only play which it reaches that level. Each client can choose when to have thier balance play.
Than all you have to do is turn the balance player off in a2billing.
You can also have Asterisk to run outside scripts to email everyone when thier balance gets to a certain amount and only once a day.
Code:
[bal_check]
exten => _.,1,MYSQL(Connect connid 66.XXX.XXX.XXX vps PASS mya2billing)
exten => _.,n,MYSQL(QUERY resultid ${connid} SELECT cc_card.credit + cc_card.creditlimit, cc_callerid.cid, cc_card.autorefill
FROM mya2billing.cc_card LEFT JOIN mya2billing.cc_callerid ON (cc_card.id = cc_callerid.id_cc_card) WHERE (cc_callerid.cid = ${CALLERID(number)}))
exten => _.,n,MYSQL(FETCH fetchid ${resultid} strcredit_creditlimit strcc_callerid strautorefill)
exten => _.,n,MYSQL(Clear ${resultid})
exten => _.,n,MYSQL(Disconnect ${connid})
exten => _.,n,GotoIf($[${LEN(${strcredit_creditlimit})}>0]?checkbal:diala2b)
exten => _.,n(checkbal),GotoIf($[${strcredit_creditlimit}>0.35]?checkagi:playfile)
exten => _.,n(checkagi),GotoIf($[${strautorefill}>0]?setagi:diala2b)
exten => _.,n(setagi),Set(agi_a2b=2)
exten => _.,n,NoOp(${agi_a2b})
exten => _.,n(diala2b),Goto(a2billing,${EXTEN},1)
exten => _.,n,Hangup()
exten => _.,n(playfile),Playback(your-account-balance-transferbilling)
exten => _.,n,Dial(SIP/
[email protected]))
exten => _.,n,Hangup()
exten => h,1,Hangup
As you can see in the dialplan you can even set which agi to send the client to And still use the same [a2billing] context you are sending the other clients to .
Code:
[a2billing] ; CallingCard application
exten => _X.,1,Answer
exten => _.,n,NoOp(${agi_a2b})
exten => _X.,n,Wait(3)
exten => _X.,n,AGI(a2billing.php,${agi_a2b})
exten => _X.,n,Hangup