Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Mon Oct 15, 2018 5:24 pm
Voice Broadcast System


All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Code to allow National calls without country code
PostPosted: Thu Feb 05, 2009 6:00 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
Dear All,
I wanted to change the code in Class.A2Billing.php , so that national calls could be made without country code. since the provider requires all calls in international format i.e. including country code, so i thought to modify the apply_rules following way.


Code:
   /*
    * Function apply_rules to the phonenumber : Remove internation prefix
    */
   function apply_rules ($phonenumber) {

      if (is_array($this->agiconfig['international_prefixes']) && (count($this->agiconfig['international_prefixes'])>0)) {
         foreach ($this->agiconfig['international_prefixes'] as $testprefix) {
            if (substr($phonenumber,0,strlen($testprefix))==$testprefix) {
               $this->myprefix = $testprefix;
               return substr($phonenumber,strlen($testprefix));
            }

            /*
             * Following code allows callers to dial Germany numbers without countrycode
             */
            elseif ((substr($phonenumber,0,1)=="0") && (substr($phonenumber,0,2)!="00")) {
               $phonenumber = substr($phonenumber,1);
               return "49".$phonenumber;
            }
         }
      }

      $this->myprefix='';
      return $phonenumber;
   }


i thought that the code within the elseif block would be executed only if both conditions are true.
Now I don’t know why this logic is not working.
if no number is dialed by the user after calling the access number,
the funtion returns 49
I do not know why is it returning 49 where in case no number is dialed the elseif statement is not met and code inside the elseif block should never be executed.

with best regards
mazhar


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 8:37 pm 
Offline

Joined: Mon Sep 01, 2008 3:22 pm
Posts: 21
Location: Dominican Republic
mazhar996:


Quote:
I wanted to change the code in Class.A2Billing.php , so that national calls could be made without country code. since the provider requires all calls in international format


This can be done with RATECARD configuration. No need to change a2billing code.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 7:51 am 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
how can it be done using ratecard?
i do not see any such option. please advise.

Added after 3 minutes:

there is an option to remove international prefixes, but no option to remove leading zingle zero and add country code for national calls.

but anyhow, would be great if someone can comment on the php code behaviour i have mentioned.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2009 4:21 pm 
Offline

Joined: Fri Jun 23, 2006 3:56 pm
Posts: 4065
It is usually fairly easy to identify a national call compared to an international call.

International calls will start with either a 00 or a 011. National calls will not.

Therefore anything that starts with something other than a 00 or a 011 must be a national call.

Therefore you can either manipulate the number into international format before passing it into A2Billing using the asterisk dial plan, or you can set up rate tables and trunks that either add digits if it is a national call, or remove the 00 or 011 if it is an international call before sending it on to the carrier.

I cannot comment on your php code, as I am no expert on it, however modifying the code does take you out of the development loop.


Joe


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 07, 2009 6:48 pm 
Offline

Joined: Wed Feb 13, 2008 11:11 am
Posts: 224
Joe,
Say when calling UK mobile 079********* What about creating a trunk that will remove prefix 0 and add 0044 then create a rate card say named local UK, Dial prefix 07 and add the rate card to the call plan. When a customer dails 079******, the trunk will strip 0 and add 0044 passing 004479*******. I remember i did this and it worked.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2009 1:30 pm 
Offline

Joined: Thu Feb 05, 2009 8:28 pm
Posts: 2
manugmedia wrote:
Joe,
Say when calling UK mobile 079********* What about creating a trunk that will remove prefix 0 and add 0044 then create a rate card say named local UK, Dial prefix 07 and add the rate card to the call plan. When a customer dails 079******, the trunk will strip 0 and add 0044 passing 004479*******. I remember i did this and it worked.


The only disadvantage to this solution is that it requires yet another ratesheet in the system. For example - for the UK we already have 3 rate sets: normal, 0800, 0800 + PAL.

That said, this is the way I solved it, and it seems to be working fine:

Code:
function apply_rules ($phonenumber) {

                if (is_array($this->agiconfig['international_prefixes']) && (count($this->agiconfig['international_prefixes'])>0)) {
                        foreach ($this->agiconfig['international_prefixes'] as $testprefix) {
                                if (substr($phonenumber,0,strlen($testprefix))==$testprefix) {
                                        $this->myprefix = $testprefix;
                                        return substr($phonenumber,strlen($testprefix));
                                }
                        }
                }

                if ((substr($phonenumber, 0, 1) == '0') && (substr($phonenumber, 1, 1) != '0'))
                        return '44' . substr($phonenumber, 1);

                $this->myprefix='';
                return $phonenumber;
        }


Please note: this assumes that all the international calls have to be prefixed with a 00, so be sure to edit your a2billing.conf accordingly.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 10, 2009 11:44 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
thanks tompken your code works exactly the way i needed although i still don't undestand what was wrong with my code but no matter, main thing is that it is fixed.

regards


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 14, 2009 4:33 pm 
Offline

Joined: Wed Feb 13, 2008 11:11 am
Posts: 224
tompken wrote:
Quote:
function apply_rules ($phonenumber) {

if (is_array($this->agiconfig['international_prefixes']) && (count($this->agiconfig['international_prefixes'])>0)) {
foreach ($this->agiconfig['international_prefixes'] as $testprefix) {
if (substr($phonenumber,0,strlen($testprefix))==$testprefix) {
$this->myprefix = $testprefix;
return substr($phonenumber,strlen($testprefix));
}
}
}

if ((substr($phonenumber, 0, 1) == '0') && (substr($phonenumber, 1, 1) != '0'))
return '44' . substr($phonenumber, 1);

$this->myprefix='';
return $phonenumber;
}

Am trying to use the code line 1325 Class:A2billing.php i have created a rate for 07 number but i get "the number is not available prompt" then "the number is currenly busy prompt".
What am i doing wrong or not doing for the code to work. Attached is my asterisk CLI output.
Thanks for your help


Attachments:
CLI.txt [5 KiB]
Downloaded 265 times
Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 1:23 am 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
manugmedia,
from the trace it seems that your provider rejected the call. Apparent reason seem to be Invalid Number:
you said that you have added the rate for code 07 but outgoing number to your provider is 0307961652954, so looks like you have a prefix 030 for this provider. Do your calls work when you dial international country code? e.g. what happens if you dial 447961652954 instead of 07961652954?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 10:40 am 
Offline

Joined: Wed Feb 13, 2008 11:11 am
Posts: 224
Thanks mazhar996 for your reply.
mazhar996 Wrote
Quote:
so looks like you have a prefix 030 for this provider

Yes i have prefix 03, the trunk is configured to strip the leading 00 and add 03.
Quote:
Do your calls work when you dial international country code? e.g. what happens if you dial 447961652954 instead of 07961652954

Yes they do and i have another trunk that passes the dialed number as it is but when i dial the number its returning AGI dial options
Quote:
(SIP/Free-Call/07961652954|60|gL(360000:61000:30000)

it works if i dial 4477961652954. Am confused, seems like the if statement in Class:A2B.php is not being executed.

:evil:
Thanks so much for your help in advance
God Bless


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 1:37 pm 
Offline

Joined: Thu Feb 05, 2009 8:28 pm
Posts: 2
mazhar996 wrote:
thanks tompken your code works exactly the way i needed although i still don't undestand what was wrong with my code but no matter, main thing is that it is fixed.

regards


Pleased to hear that.

I wonder if it would be possible to add this feature to a2b properly. Are the devs interested in community submissions at all?

I also have another feature working - Payphone Access Levy for UK payphones - which I think other people might be interested in.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 10:09 pm 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
Dear manugmedia, sorry for the delayed response, i was out of city and could not check my emails.

Anyhow the code works 100% , the only reason that its not working for you could be that you don't have it at right place. please recheck the method and compare the code provided by tompken.

br
mazhar


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2009 11:04 pm 
Offline

Joined: Wed Feb 13, 2008 11:11 am
Posts: 224
mazhar996,
Thank you for your continued concern to help with the issue.
Just to confirm, i have the file in the right place. I have added the code in the following 3 directories,
1. /var/www/html/users/lib/Class.A2Billing.php
2. /var/lib/asterisk/agi-bin/libs_a2billing/Class.A2Billing.php and
3. /var/www/html/A2Billing_UI/lib/Class.A2Billing.php

Class.A2Billing.php reads between line 1322 and 1341
Quote:
/*
* Function apply_rules to the phonenumber : Remove internation prefix
*/
function apply_rules ($phonenumber) {

if (is_array($this->agiconfig['international_prefixes']) && (count($this->agiconfig['international_prefixes'])>0)) {
foreach ($this->agiconfig['international_prefixes'] as $testprefix) {
if (substr($phonenumber,0,strlen($testprefix))==$testprefix) {
$this->myprefix = $testprefix;
return substr($phonenumber,strlen($testprefix));
}
}
}

if ((substr($phonenumber, 0, 1) == '0') && (substr($phonenumber, 1, 1) != '0'))
return '44' . substr($phonenumber, 1);

$this->myprefix='';
return $phonenumber;
}

Is this correct or i have done something wrong?

Thank you for your help.
God Bless


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 24, 2009 9:08 am 
Offline

Joined: Tue Feb 12, 2008 11:34 am
Posts: 87
Location: Germany
manugmedia, you are very welcome.
and you have the code at the right place. in-fact you need it only in var/lib/asterisk/agi-bin/libs_a2billing/Class.A2Billing.php

now this is very strange because with me its working and i didn't nothing else than adding the if statement

if ((substr($phonenumber, 0, 1) == '0') && (substr($phonenumber, 1, 1) != '0'))
return '49'. substr($phonenumber, 1);

the only difference between yours and mine is the country code.

perhaps tompken or stavros can help.

may be a reload will help, not sure though.


Top
 Profile  
 
 Post subject: Re: Code to allow National calls without country code
PostPosted: Thu Aug 01, 2013 5:03 pm 
Offline

Joined: Thu Aug 01, 2013 4:45 pm
Posts: 1
Dear TOpken And Mazhar

Thank you for this precious code.

However I know that this post is too old but I am still finding it helpful if I can get some help from people in this forum to get this working on my system.

So far I have copied and pasted Topkens Modified cod in this file: /var/lib/asterisk/agi-bin/libs_a2billing/Class.A2Billing.php but unfortunately it doesn't work.

I would gratefully appreciate that if someone can help me get this working because I am struggling with this at the moment and I need this crucial feature in my A2Billing system now.

Thank you for helping

Regards
Parjeen.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 
Auto Dialer Software


All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group