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

Rate initial issue
http://forum.asterisk2billing.org/viewtopic.php?f=33&t=7509
Page 1 of 1

Author:  james [ Sat Apr 17, 2010 5:37 pm ]
Post subject:  Rate initial issue

Verison .133
* Function to play the rate in cents
* format : "7 point 5 cents per minute"
*
* @param object $agi
* @param float $rate
* @return nothing
**/
function fct_say_rate ($agi, $rate){

$this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[SAY RATE ::> ".$rate."]");

global $currencies_list;

if (isset($this->agiconfig['agi_force_currency']) && strlen($this->agiconfig['agi_force_currency'])==3)
{
$this->currency = $this->agiconfig['agi_force_currency'];
}

if (!isset($currencies_list[strtoupper($this->currency)][2]) || !is_numeric($currencies_list[strtoupper($this->currency)][2])) $mycur = 1;
else $mycur = $currencies_list[strtoupper($this->currency)][2];
$rate_cur = $rate / $mycur;
$cents = intval($rate_cur);
$units = round(($rate_cur - $cents) * 1E4);
while ($units != 0 && $units % 10 == 0) $units /= 10;

// say 'the rate is'
//$agi->stream_file('the-rate-is');

$agi->say_number($cents);
if ($units > 0) {
$agi->stream_file('point');
$agi->say_digits($units);
}
$agi->stream_file('cents-per-minute');
}
-----------------------------------------------------------------------------------------------------------
Version 1.6

* Function to play the initial rate
* format : "the cost of the call is 7 dollars and 50 cents per minutes"
*
* @param object $agi
* @param float $rate
* @return nothing
**/
function fct_say_rate ($agi, $rate)
{
global $currencies_list;

if (isset($this->agiconfig['agi_force_currency']) && strlen($this->agiconfig['agi_force_currency'])==3) {
$this->currency = $this->agiconfig['agi_force_currency'];
}

$this -> debug( DEBUG, $agi, __FILE__, __LINE__, "[CURRENCY : $this->currency]");
if (!isset($currencies_list[strtoupper($this->currency)][2]) || !is_numeric($currencies_list[strtoupper($this->currency)][2])) $mycur = 1;
else $mycur = $currencies_list[strtoupper($this->currency)][2];
$credit_cur = $rate / $mycur;

list($units,$cents)=split('[.]', $credit_cur);
if (strlen($cents)>2) $cents=substr($cents,0,2);
if ($units=='') $units=0;
if ($cents=='') $cents=0;
elseif (strlen($cents)==1) $cents.= '0';

if (isset($this->agiconfig['currency_association_internal'][strtolower($this->currency)])) {
$units_audio = $this->agiconfig['currency_association_internal'][strtolower($this->currency)];
// leave the last character ex: dollars -> dollar
$unit_audio = substr($units_audio,0,-1);
} else {
$units_audio = $this->agiconfig['currency_association_internal']['all'];
$unit_audio = $units_audio;
}
$cent_audio = 'prepaid-cent';
$cents_audio = 'prepaid-cents';

// say 'the cost of the call is '
$agi-> stream_file('prepaid-cost-call', '#');

if ($units==0 && $cents==0) {
$agi -> say_number(0);
$agi -> stream_file($unit_audio, '#');
} else {
if ($units > 1) {
$agi -> say_number($units);

if (($this ->current_language=='ru')&&(strtolower($this->currency)=='usd')&& ( ( $units%10==2) || ($units%10==3 )|| ($units%10==4)) ) {
// test for the specific grammatical rules in RUssian
$agi-> stream_file('dollar2', '#');
} elseif (($this ->current_language=='ru')&&(strtolower($this->currency)=='usd')&& ( $units%10==1)) {
// test for the specific grammatical rules in RUssian
$agi-> stream_file($unit_audio, '#');
} else {
$agi-> stream_file($units_audio, '#');
}

} else {
$agi -> say_number($units);
$agi -> stream_file($unit_audio, '#');
}

if ($units > 0 && $cents > 0) {
$agi -> stream_file('vm-and', '#');
}
if ($cents>0) {
$agi -> say_number($cents);

if ($cents>1) {
if ((strtolower($this->currency)=='usd')&&($this ->current_language=='ru')&& ( ( $cents%10==2) || ($cents%10==3 )|| ($cents%10==4)) ) {
// test for the specific grammatical rules in RUssian
$agi-> stream_file('prepaid-cent2', '#');
} elseif ((strtolower($this->currency)=='usd')&&($this ->current_language=='ru')&& ( $cents%10==1) ) {
// test for the specific grammatical rules in RUssian
$agi-> stream_file($cent_audio, '#');
} else {
$agi-> stream_file($cents_audio, '#');
}
} else {
$agi-> stream_file($cent_audio, '#');
}
}
}
// say 'per minutes'
$agi-> stream_file('prepaid-per-minutes', '#');
}
------------------------------



Can we use 1.6 version?
In such a way that if rate call cost is less than 1 euro is should play
Only cents

For example if rate is 0.075 (7 point 5 cents per minutes)

If call cost more than 1 euro then it should play euro and cent


above are thow fuction to say rate intial ,can we

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