asterisk2billing.org
http://forum.asterisk2billing.org/

Need to playback() a file as soon as the call is ANSWERED.
http://forum.asterisk2billing.org/viewtopic.php?f=18&t=3137
Page 2 of 2

Author:  cygar [ Sun Feb 08, 2009 9:51 pm ]
Post subject: 

Hola !

I just want to show how this "patch" was finally done in case somebody has something similar to do.

Class.A2Billing.php file:

In the A2Billing Class the public var $conTonoA was added in order to be read from ClassRateEngine.php.

Code:

$Q = "SELECT ani FROM Anis where ani='".$ani."' AND tipo='TonoA'";

if ($this->agiconfig['debug']>=1) $agi->verbose($Q);
$resultadoa = $this->instance_table -> SQLExec ($this->DBHandle, $Q);

if ($this->agiconfig['debug']>=1) $agi->verbose($result);
$this->write_log("Debug info:  TonoA query {$Q}:  $resultadoa");

if($resultadoa != 0){
  $this->write_log("DTMF A has to be sended");
  // The following var is going to be read in  Clase RateEngine
  $this->esTonoA='si';                               
}



In ClassRateEngine.php:

Code:

$prefix                 = $this -> ratecard_obj[$k][$usetrunk+1];
$tech                   = $this -> ratecard_obj[$k][$usetrunk+2];
$ipaddress              = $this -> ratecard_obj[$k][$usetrunk+3];
$removeprefix   = $this -> ratecard_obj[$k][$usetrunk+4];
$timeout                = $this -> ratecard_obj[$k]['timeout'];
$musiconhold    = $this -> ratecard_obj[$k][39];
$failover_trunk = $this -> ratecard_obj[$k][40+$usetrunk_failover];
$addparameter   = $this -> ratecard_obj[$k][42+$usetrunk_failover];

if (strncmp($destination, $removeprefix, strlen($removeprefix)) == 0)
  $destination= substr($destination, strlen($removeprefix));

$dialparams = str_replace("%timeout%", $timeout *1000, $A2B->agiconfig['dialcommand_param']);

// Dial() Modification either for Jail originated calls or Calls where DTMF A // has to be played. Matias Rollan Patch

$paracarcel = $A2B->escarcel;
if($paracarcel == 'pacific'){ // Jail msg
$stringdial = "A($paracarcel)";
$A2B -> write_log("Debug: StringDial $stringdial");
$dialparams = str_replace("%carcel%", $paracarcel, $dialparams);
$A2B->write_log("Debug: Parameter: $dialparams");
}else{
  // DTMF A to be played
   $mitonoA = $A2B->esTonoA;
   if($mitonoA == 'si'){
      $A2B -> write_log("Debug: DTMF A is going to be added to Dial()");
      $tono = "D(wAA:wAA)";   // DTMF As
      $dialparams = str_replace("%carcel%", $tono, $dialparams);
      $A2B->write_log("Debug: Dialparams $dialparams");
    }else{
        $dialparams = str_replace("%carcel%", '', $dialparams);
        $A2B->write_log("Debug: Regular Dial() : $dialparams");
    }

}


And as in my first post regarding the Jail message I change the /etc/asterisk/a2billing.conf the Dial() line:

Code:
dialcommand_param="|45|rHL(%timeout%:61000:00000)%carcel%"


So everytime a call is originated from the CallerIDs listed in Anis table with tipo field equal to:

- 'carcel' the A(audio_file_for_jail) is replaced in the Dial
- 'TonoA' the D(wAA:wAA) is concatenated in the Dial

The coding is ugly but is working perfectly well in my platform I just wanted to share it.

--
Matias Rollan
<[email protected]> || <[email protected]>[/code][/quote]

Author:  jacknab [ Thu Mar 26, 2009 6:59 am ]
Post subject:  Question about the A(audio_file)

Is there a simple way to assign a:
dialcommand_param = "|60|HRrgL(%timeout%:61000:30000)A(audio_file)"

To a specific Rate card or even trunk? (would work best prob by rate card)

Author:  stavros [ Thu Mar 26, 2009 1:32 pm ]
Post subject: 

Yes, but it involves writing some PHP.

Page 2 of 2 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/