MatBOy, as far as I remember macros go before the context definitions. I really depends on your setup.
Turning on and off the voicemail should be easy with this PHP script. To turn voicemail on call it from the diaplan with the parameter 1, to turn off use the parameter 0. Also don't forget to record the files "voicemail_turned_on" and "voicemail_turned_off".
Code:
#!/usr/bin/php -q
<?php
declare(ticks = 1);
if (function_exists('pcntl_signal')) {
pcntl_signal(SIGHUP, SIG_IGN);
}
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
include (dirname(__FILE__)."/libs_a2billing/db_php_lib/Class.Table.php");
include (dirname(__FILE__)."/libs_a2billing/Class.A2Billing.php");
include (dirname(__FILE__)."/libs_a2billing/Class.RateEngine.php");
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi.php");
include (dirname(__FILE__)."/libs_a2billing/phpagi_2_14/phpagi-asmanager.php");
$charge_callback=0;
$G_startime = time();
$agi_date = "Release : 13 August 2006";
$agi_version = "1.2.3 (BrainCoral)";
/********** CREATE THE AGI INSTANCE + ANSWER THE CALL **********/
$agi = new AGI();
$idconfig = 1;
$agi->verbose('line:'.__LINE__.' - '."IDCONFIG : $idconfig \n");
if ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'did') $mode = 'did';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'callback') $mode = 'callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'cid-callback') $mode = 'cid-callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'all-callback') $mode = 'all-callback';
elseif ($argc > 2 && strlen($argv[2]) > 0 && $argv[2] == 'predictivedialer') $mode = 'predictivedialer';
else $mode = 'standard';
$agi->verbose('line:'.__LINE__.' - '."MODE : $mode \n");
// get the area code for the cid-callback & all-callback
if ($argc > 3 && strlen($argv[3]) > 0) $caller_areacode = $argv[3];
$A2B = new A2Billing();
$A2B -> load_conf($agi, NULL, 0, $idconfig);
$A2B -> CC_TESTING = isset($A2B->agiconfig['debugshell']) && $A2B->agiconfig['debugshell'];
// TEST DID
// if ($A2B -> CC_TESTING) $mode = 'did';
//-- Print header
if ($A2B->agiconfig['debug']>=1) $agi->verbose ('AGI Request:');
if ($A2B->agiconfig['debug']>=1) $agi->verbose (print_r($agi->request, true));
/* GET THE AGI PARAMETER */
$A2B -> get_agi_request_parameter ($agi);
//$A2B -> accountcode = '2222222222';
if (!$A2B -> DbConnect()){
$agi-> stream_file('prepaid-final', '#');
exit;
}
$instance_table = new Table();
$A2B -> set_instance_table ($instance_table);
// Ask the caller to enter his password
$ok = false;
$errorCount = 0;
while (!$ok)
{
$errorCount++;
$resDTMF = $agi->get_data ("a2billing/voicemail/enter_password", 5000, 5);
$password = $resDTMF ["result"];
if ($password . ";" != ";")
{
$query = "SELECT id,voicemail FROM cc_card WHERE (userpass='" . $password . "')";
$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $query);
$ok = (is_array($result));
}
if ($ok)
$cardID = $result[0][0];
else
{
$agi->stream_file ("a2billing/voicemail/wrong_password");
if ($errorCount < 3)
$agi->stream_file ("a2billing/voicemail/try_again");
else
{
$agi->stream_file ("a2billing/voicemail/too_many_errors");
exit ();
}
}
}
// Turn voicemail feature on/off
$query = "UPDATE cc_card SET voicemail=" . argv[1] . " WHERE (id=${cardID})";
$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $query);
if (argv[1] == "1")
$agi->stream_file ("a2billing/voicemail/voicemail_turned_on");
else
$agi->stream_file ("a2billing/voicemail/voicemail_turned_off");
?>