I just started learning php and mysql, so the perl is greek to me. Here is how i got the agent info to the asterisk dialplan before making the call.
I picked up that every call gets passed to the manager and uses the vicidial_list table to log info regarding the call and the status thereoff.
For testing i loaded the asterisk-addons to get the asteriks MYSQL app going.
Now before every call in asterisk i do a mysql query, to get the agents information, i then in turn use this to cross reference a custom database to see if the agent has call_credit available to make the call.
This i think will be a nice feature to add, you can then limit the call_credit per agent or per campaign.
I know this is not pretty but it's a start.
Here goes I added this to my asterisk dialplan
exten => _91011XXXXXXX,1,MYSQL(Connect connid localhost usertest userpass asterisk) ;connect to database
exten => _91011XXXXXXX,2,MYSQL(Query resultid ${connid} SELECT\ 'user'\ FROM\ 'vicidial_list'\ WHERE\ 'phone_number'=\'${EXTEN:2}\'\ AND\ 'status'=\'INCALL\')
exten => _91011XXXXXXX,3,MYSQL(Fetch fetchid ${resultid} agentinfo)
exten => _91011XXXXXXX,4,NoOp(THE AGENT NAME IS *****${agentinfo}******)
exten => _91011XXXXXXX,5,MYSQL(Clear ${resultid})
exten => _91011XXXXXXX,6,MYSQL(Disconnect ${connid})
exten => _91011XXXXXXX,7,NoOp(CALLEDID ====******************${CALLERID(all)})
exten => _91011XXXXXXX,8,AGI(
agi://127.0.0.1:4577/call_log)
exten => _91011XXXXXXX,9,Dial(SIP/cc101,55,To) ;testing to extension cc101
exten => _91011XXXXXXX,10,Hangup
I tested it with manual dial and autodial works like a charm