Jump to content

For any one thats AU


Scott1234

Recommended Posts

Sharing is caring, This is a far better Yealink dial now pattern for dialplans.xml, 3 digits extensions 2-9 xx for AU.

"^(+?61[0-9]{9})|^([2-9]{1}[0-9]{7})|^(0[2|3|7|8]{1}[0-9]{8})|^([04|05]{1}[0-9]{9})|^((1300|1800)[0-9]{6})|^(13[0-9]{4})|^(?:000|106|112)|^[2-9]\d{2}"

Summary,

<?xml version="1.0" encoding="UTF-8"?>
<dialnow>
    <!-- Matches Australian + or 61 numbers with or without country code -->
    <Data DialNowRule="^(+?61[0-9]{9})" LineID="0"/>
    
    <!-- Matches Australian local area numbers without area code -->
    <Data DialNowRule="^([2-9]{1}[0-9]{7})" LineID="0"/>

    <!-- Matches Australian numbers with area code 02, 03, 07, or 08 -->
    <Data DialNowRule="^(0[2|3|7|8]{1}[0-9]{8})" LineID="0"/>

    <!-- Matches Australian mobile numbers starting with 04 or 05 (05 proposed) -->
    <Data DialNowRule="^([04|05]{1}[0-9]{9})" LineID="0"/>

    <!-- Matches Australian 1300 or 1800 numbers -->
    <Data DialNowRule="^((1300|1800)[0-9]{6})" LineID="0"/>

    <!-- Matches Australian 13 numbers -->
    <Data DialNowRule="^(13[0-9]{4})" LineID="0"/>

    <!-- Matches Australian special numbers emergency 000, 106, or 112 -->
    <Data DialNowRule="^(?:000|106|112)" LineID="0"/>

    <!-- Matches Australian special access numbers (dial before you dig etc. 11 or 12) -->
    <Data DialNowRule="^((11|12)[0-9]{2})" LineID="0"/>

    <!-- Matches 3 digits extensions 2 to 9 xx -->
    <Data DialNowRule="^[2-9]\d{2}" LineID="0"/>
</dialnow>


 

 

 

Link to comment
Share on other sites

  • 4 months later...

@Vodia PBX

Do we have any control over how the PBX interprets numbers for its auto-rewriting? Based on country code and area code? Australia is not set up right; when the domains are set with country code 61 most are auto-formatted correctly except a few. 

The presentation for these numbers, which is how they are dialled, should be,

1800 XXX XXX or (1800) XXX XXX

1300 XXX XXX or (1300) XXX XXX

13 XX XX or (13) XX XX 

The problem is it thinks it needs an area code; these are the only numbers here that don't need that.

To get the PBX to format it correctly, it has to be inputted as 01800 XXX XXX

Once you set the domain area code to get the nice local number presentation, it will break the 1800/1300/13 dialling as it uses +61 1800 XXX XXX. 

Numbers can go out as +61 1800 XXX XXX, just no area code for them.

Even with the dial plan set to 'Don't rewrite', it still changes when processing. Luckily, it does not match how people dial them, so it only causes a problem once you set the domain area code.

The PBX also like to format it like, 1800 XXXXXX

Ideally, I would like to set the area code because the local number presentation and the app look much nicer.

Thanks 

Link to comment
Share on other sites

Can I run a custom js in pbxwebai for this? I might play on a test box.

It might be to do with, 

} else if (country == "61") {
    if (number.substr(0, 3) == "+61") {
        return "0" + number.substr(3)
    } else {
        return "0011" + number.substr(1)
    }
}

Needing to be something like this, but not 100% sure without testing.

} else if (country == "61") {
    if (number.substr(0, 3) == "+61") {
        return "0" + number.substr(3)
    } else if (number.substr(0, 4) == "1300" || number.substr(0, 4) == "1800") {
        return "+" + number;
    } else {
        return "0011" + number.substr(1)
    }
}

And or maybe this section, with my mod.

function localNumber(number, country, area) {
    if (number.length < 6) {
        return number;
    }

    if (number.substr(0, 1) == "+") {
        if (country === undefined)
            country = sessionStorage.getItem("country");
        if (area === undefined)
            area = sessionStorage.getItem("area");

        if (country == "1") {
            if (number.substr(0, 2) == "+1" && number.length == 12) {
                return number.substr(2);
            } else {
                return "011" + number.substr(1);
            }
        } else if (country == "61") {
            if (number.substr(0, 4) == "+6113" || number.substr(0, 4) == "+6118") {
                return "+" + number.substr(2);
            } else if (number.substr(0, 3) == "+61") {
                return "0" + number.substr(3);
            } else if (number.substr(0, 3) == "130") {
                return "13" + number.substr(3);
            } else {
                return "0011" + number.substr(1);
            }
        } else if (country == "81") {
            if (number.substr(0, 3) == "+81") {
                return "0" + number.substr(3);
            } else {
                return "010" + number.substr(1);
            }
        } else if (country != "") {
            if (number.substr(0, 1) == "+" && number.substr(1, country.length) == country) {
                if (area.substr(0, 1) == "0")
                    area = area.substr(1);
                var local = number.substr(1 + country.length);
                if (local.substr(0, 1) == "0")
                    local = local.substr(1);
                if ((area && local.substr(0, area.length) == area) || area == "-") {
                    return local.substr(area.length);
                } else {
                    return local;
                }
            } else {
                return "00" + number.substr(1);
            }
        }
    }

    return number;
}

// Test cases
function testNumber(number) {
    console.log(`Input: "${number}" => Output: "${localNumber(number)}"`);
}

testNumber("1800444444");            // Output: "1800 444 444"
testNumber("1300444444");            // Output: "1300 444 444"
testNumber("611800444444");          // Output: "+61 1800 444 444"
testNumber("611300444444");          // Output: "+61 1300 444 444"
testNumber("+611800444444");         // Output: "+61 1800 444 444"
testNumber("+611300444444");         // Output: "+61 1300 444 444"

testNumber("131313");                // Output: "13 13 13"
testNumber("61131313");              // Output: "+61 13 13 13"
testNumber("+61131313");             // Output: "+61 13 13 13"

testNumber("0443388777");            // Output: "0443 388 777"
testNumber("61443388777");           // Output: "+61 443 388 777"
testNumber("+61443388777");          // Output: "+61 443 388 777"

testNumber("0295618006");            // Output: "02 9561 8006"
testNumber("61295618006");           // Output: "+61 2 9561 8006"
testNumber("+61295618006");          // Output: "+61 2 9561 8006"

testNumber("0395618006");            // Output: "03 9561 8006"
testNumber("61395618006");           // Output: "+61 3 9561 8006"
testNumber("+61395618006");          // Output: "+61 3 9561 8006"

testNumber("0795618006");            // Output: "07 9561 8006"
testNumber("61795618006");           // Output: "+61 7 9561 8006"
testNumber("+61795618006");          // Output: "+61 7 9561 8006"

testNumber("0895618006");            // Output: "08 9561 8006"
testNumber("61895618006");           // Output: "+61 8 9561 8006"
testNumber("+61895618006");          // Output: "+61 8 9561 8006"

testNumber("000");                   // Output: "000"
testNumber("+61000");                // Output: "+61 000"

¯\_(ツ)_/¯

edit, also I think have gone down too many rabbit holes, I have analysed the script in more details and can see it would pass it to showNanpaNumber and format things a little differently.  So i will review more of the script before offering suggestions to adjustments.

Either way currently as it stands it does not handle the 1800 1300 correctly as first mentioned. 

Link to comment
Share on other sites

I have arrived at this for theglobalNumber() function , untested on the system, next question can I run a custom format.js ? in webwebai this should correct the dial out from having the area code for these numbers. 

I think this is all that needs to change until I see the results of it tested.

  
    } else if (country == "61") {
//Start of insert
      	if (number.substr(0, 4) == '1800' ||
     		number.substr(0, 4) == '1300' ||  
      		number.substr(0, 2) == '13') {
    		return '+61' + number;
//End of insert
        if (number.substr(0, 4) == "0011")
            return "+" + number.substr(4);
        if (number.substr(0, 1) == "0")
            return "+61" + number.substr(1);
        if (area != "" && area != "-")
            return "+61" + area + number

 

Link to comment
Share on other sites

2 hours ago, Vodia PBX said:

Looking at https://en.wikipedia.org/wiki/Telephone_numbers_in_Australia would it be safe to say that the PBX should return '+61' + number for anything that starts with "1" as long as the number is more than 5 digits?

That would only resolve 1800 XXX XXX or 1300 XXX XXX and 13 XX XX , but not 11 XX or 12 XX (network and community services) I did not include them in my example as they are less frequently used, but if doing it properly it should accommodate them, the yealink dial now examples from above show you the variables for these numbers. 

Example dial before you dig (1100) is a popular number that people ring to check if there are dangerous services buried under where they are going to dig.

    <!-- Matches Australian 1300 or 1800 numbers -->
    <Data DialNowRule="^((1300|1800)[0-9]{6})" LineID="0"/>

    <!-- Matches Australian 13 numbers -->
    <Data DialNowRule="^(13[0-9]{4})" LineID="0"/>
  
  <!-- Matches Australian special numbers emergency 000, 106, or 112 -->
    <Data DialNowRule="^(?:000|106|112)" LineID="0"/>

    <!-- Matches Australian special access numbers (dial before you dig etc. 11 or 12) -->
    <Data DialNowRule="^((11|12)[0-9]{2})" LineID="0"/>
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
10 hours ago, Scott1234 said:

Is there any way I can experiment with my own JS script fix's? for the above as I really want to resolve the dial issue when defining area code for AU with regards to 13/1300/1800.

Did you try the "local override" (at least that is how it's called in Safari) in the browser? It's a very convenient way to change anything in your web page and it's great for tinkering with such things. E.g. if you are not happy with the numbers in your online banking account, try this method — does not require any changes on the backend and might impress people looking at it! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...