Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Custom phone number format

Hi,

I want to customize the phone format number, just before it is sent to the database. Indeed, I want to add international prefixes (+49, etc…) to telephone numbers, each time they are inputted.

For example, 015417543010 > 4915417543010.

After reading some piece of code, I understand that ./include/class.format.php is the file to modify. Am I wrong?

So I tried to put some logic in function phone, between lines 90-99, but it does not work at all. It is as if the function was never called. I can even remove function phone completely, and yet, osTicket works as if nothing has been changed

Here a simple example that does do nothing:
function phone($phone) {
$phone= preg_replace('/^0/', "49", $phone);
return $phone;
}

Thanks for any help.

Comments

  • Can you go to:
    Admin panel -> Manage -> Forms -> Contact Information
    Locate Phone Number,  Click Config.
    Change Display Format.
  • You mean after the modification of class.format.php file?
  • Well, here what I have already tried :
    • remove the class.format.php file to check if the file is used, and yes it is…
    • restart the server, just in case, after each change…
    • remove the function phone(), but osTicket still works very well;
    • change Display Format in Admin panel after any change;
    • wipe out the content of the class.format.php file, to check if the file is used, and yes it is…
    • try to return anything else that the phone number, in function phone() but the phone number is always returned;
  • I'm saying that instead of modifying any files etc just change the Display Format.
  • FSvFSv
    edited April 27
    How?

    I can only change for Unformatted, and it is already the case.

    And how it will modify automatically the phone number each time it is inputted by users? By what magic it will replace the first 0 of phone numbers by 49?

    I specify, I want to store the phone numbers after the change, in this modified format.

    :s
  • And how it will modify automatically the phone number each time it is inputted by users? By what magic it will replace the first 0 of phone numbers by 49?

    It won't.  It will let your users/agents enter the phone number correctly in the first place.
  • But it is not what I want… if not, I would not have opened this thread… and this "manual way" is not very smart… above all when we can get this by coding…

    And I do not want to frustrate the agent for nothing, deservedly, they will think that it could be automated…But that's not all, I will need it for the "planned" plugins.

    That is why I want to modify the phone numbers, just before they are sent in the database. But I do not understand why my piece of code does not work.

    I would appreciate someone helping me.
  • Okay... I guess you never want to use a different country code.

    So why not just 

    function phone($phone) {
    $phone= "49". $phone;
    return $phone;
    }

    or 

    function phone($phone) {
    if (isset($phone)) $phone = "49". $phone;
    return $phone;
    }


  • Thanks, but as I said, it does not work :s

    Here what I wrote previously:
    • try to return anything else that the phone number, in function phone() but the phone number is always returned;
    I even, hopelessly, tried your code, but it does not work.
Sign In or Register to comment.