Ok I think I have fixed it.
Here is what I have done to fix up A2Billing and FreePBX to work together via the macro-dialout-trunk so that you can create custom trunks for a2billing pass-thru.
1: Goto FreePBX, Setup, Trunks, Create Custom Trunk.
2: In the Custom Trunk String enter without the quotes "A2B/$OUTNUM$"
3: Save it and you will see a new route called 2B/$OUTNUM$ it is fine just a glitch with FreePBX.
3: Goto Outbound Routes, Create or Modify your Long Distance route and point it to AMP:A2B/$OUTNUM$
4: Now Edit Extensions.conf and look for macro-dialout-trunk and find the line called
exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
Replace that line with the code below (which will preserve the original line so you know what you changed)
; Modified to support outbound calling for A2B
; original line: exten => s,n(skipoutnum),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
; added function
exten => s,n(skipoutnum),GotoIf($["${pre_num}" = "AMP:A2B/"]?a2bdial:skipoutnumnormal) ; Checks for A2B custom trunk and dials it.
exten => s,n(a2bdial),DeadAGI(a2billing.php|1) ; Dials out via the a2billing.php script.
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n(skipoutnumnormal),Dial(${pre_num:4}${the_num}${post_num},300,${DIAL_TRUNK_OPTIONS})
; end of modified additions
5: Save extensions.conf
6: We now need to edit a2billing.conf. Goto the agi-conf1 or which agi-conf# you will be using and find use_dnid=
add the following code below it.
; if YES then it will use the AGI_DNID instead of AGI_Extension for supporting dialout.
switch_extension_for_dnid=YES
7: save a2billing.conf
8: Goto your Asterisk CLI and issue a reload request.
9: Now we are done with FreePBX.
10: goto /var/lib/asterisk/agi-bin and edit a2billing.php
11: look for a line that says
$A2B->dnid = $agi->request['agi_extension'];
Replace that line with the following line (No worries, I placed that line into the code for preservation.
// Added check for agi_extension or agi_dnid for dialout number
// original line replaced was:
// $A2B->dnid = $agi->request['agi_extension'];
//
if ($A2B->agiconfig['switch_extension_for_dnid']==1)
$A2B->dnid = $agi->request['agi_dnid'];
else
$A2B->dnid = $agi->request['agi_extension'];
// End of modifications
11: Save a2billing.php
12: now pick up your phone and try dialing. It will now go though A2billing for accounting purposes.