Phonebook extensions mismatch
Hi,
first, thank you for this amazing product. We have bought the full license for unlimited buttons/extensions, and we love FOP2.
FOP2 works great, but we have a weird behavior with phonebook entries in the web frontend.
I've integrated FOP2 phonebook with the CID Superfecta module in Freepbx 12.0.54, and it works.
Extensions display the correct CID.
The FOP web frontend display also correct CID when external calls incoming, but when internal extensions call another extension, the web frontend displays the first entry in the phonebook that match the last 2 numbers of extensions.
I.E. John Smith with ext 52 is visualized as Marc Brown mobile +39 123 457852
All the phones are in the local LAN net.
The Chrome plugin works well.
Thank you for your help.
Regards
Marco
first, thank you for this amazing product. We have bought the full license for unlimited buttons/extensions, and we love FOP2.
FOP2 works great, but we have a weird behavior with phonebook entries in the web frontend.
I've integrated FOP2 phonebook with the CID Superfecta module in Freepbx 12.0.54, and it works.
Extensions display the correct CID.
The FOP web frontend display also correct CID when external calls incoming, but when internal extensions call another extension, the web frontend displays the first entry in the phonebook that match the last 2 numbers of extensions.
I.E. John Smith with ext 52 is visualized as Marc Brown mobile +39 123 457852
All the phones are in the local LAN net.
The Chrome plugin works well.
Thank you for your help.
Regards
Marco
Comments
Before that you can add another if condition, assuming your extensions are 2 digits, you can set it like this
And then put the closing curly bracket just before the Header line:
That should prevent callerid numbers less than 3 digits long from looking up for matches in the DB.
Best regards,
I found this thread because I am experiencing similar issues.
This does not appear to be the case. My extensions are 3 digits long. When there is an address book entry for that extension, say, 215, and there is another address book entry for someone else , say 55334215, the second (longer) entry is matched, not the shorter (more precisely matching) entry.
Running FOP2 version 2.31.05 on FreePBX 13.0.191.11. Any thoughts?
SELECT concat(firstname,' ',lastname) AS name,company,picture FROM visual_phonebook WHERE (phone1 LIKE '%215' OR phone2 LIKE '%215') AND context='' ORDER BY LENGTH(CONCAT(phone1,phone2)) LIMIT 1
And see what record you get.. perhaps you have a phone2 field set on your extension (short) but not on your customer, and that makes the order by clause show the customer instead of extension entry? play a bit with it and see, then you can alter checkdir.php to use the correct query.
THE PROBLEM
When a user dialled from an extension (3 digits) the lookup would often incorrectly return a name and picture associated with a different address book entry. This happened when the 3 digit extension number appeared anywhere within the longer phone number. For example, calling extension 650, would select entry for user with phone number 12346501
The issue is that the logic of this select statement did not work: The problem is that the LIKE statement was finding all records containing the callerid phone number ANYWHERE within it. So, when the calling extension is 650, it matched on ALL of 1236504, 1234650, 650, 16501245. The ORDER BY statement was then supposed to select the shortest match (which should have been the extension). However, because there are two phone fields, an attempt was made to identify the record with the shortest match by concatenating both numbers in the record, and comparing that length with the concatenated numbers of the other matching records.
The LIMIT 1 statement then picked the first record.
This does not work because there is no certainty that the total length of both phone number fields will be shorter for the correct entry.
Consider this mini-database:
Calling Extension is 650.
User A Phone1: 650 Phone2: 12345678
User B Phone1: 12650348 Phone2: nul
Both of these records are selected by the above statement. They are then compared by adding the two phone fields, and picking the shortest COMBINED length:
User A: 3+8=11
User B: 8+0=8
User B record is shorter, so it is selected. The correct record is User A.
MY WORKAROUND
In Australia, all phone numbers are 10 digits (including area code) – even mobile numbers.
So, I have set the comparison to EQUALS (rather than LIKE) so that I only get one valid match. I have removed the LENGTH comparison altogether.
This works, except that if the visual phone book entry does not include the area code, or includes spaces, the record is not found.
FIX REQUIRED
• We need to be able to strip the spaces out of the visual phonebook phone number entries when comparing;
• We need to be able to perform a routine on the visual phonebook phone number entries to only compare the significant digits – in the same way that the script does with the caller id number:
When comparing the CLID with the visual phone book entries after stripping spaces and looking at the same significant digits, the EQUALS comparison operator will then work as desired.
I am not sufficiently expert to figure out how to do this bit. Hopefully what I have said helps, and the proper fix will be simple for you
My above workaround still works, but it would be nice to see a fix coded into the program itself.
Hi,
Part of your analysis is not correct. The query does not find the number anywhere but just the final bit. The like search has the % (wildcard) at the begining only, then the significant digits as retrieved in the callerid.
I made a quick test with the same data you posted as an example:
Then I run the query to match based on callerid '650':
As you see, the User A record is retrieved. Not sure why you were getting the incorrect contact, only the LAST part of the number is matched.
Regarding normalization of entered numbers in the phonebook, what can I say, people might type spaces, parenthesis, dashes, dots, words, whatever... Its a bit complicated to do that kind of normalization. In general, whenever phone number lists are involved, users should use 'computer friendly' numbers to get consistent results.
So, a quick way to compare numbers would be to strip any non digit character from it, but MySQL lacks that function, however there are some examples posted on StackOverflow, like this one:
With that function created on MySQL asterisk database, then you can modify the query in vphonebook.php a bit:
The thing is that I am not much comfortable having users needing to add a Function in MySQL/MariaDB by default... maybe I am just picky and its not a problem at all. What do you think?