Display Order of Button Groups on Panel

Currently groups are ordered by the lowest extension in the group. The SQL to simulate it is:

select `group` from fop2buttons group by `group` order by min(exten);

Is it possible to sort the groups alphabetically (with the exception of having the first group be the logged-in user's group as it is now)?

Tx,
Ted

Comments

  • It will be difficult to have the logged group shown first, it will require a source code change in the client. I will take a look when I get back from vacations.
  • It could be done with a single SQL statement. If you assume a variable EXTEN has the extension of the FOP2 user:
    (select * from fop2buttons
    where `group` in (select `group` from fop2buttons where exten="148") and type="extension"
    order by exten)
    union
    (select * from fop2buttons
    where `group` not in (select `group` from fop2buttons where exten="148") and type="extension"
    order by `group`,exten)
    

    The first select gets the users in the same group and as there is only one group, it only has to sort by exten. The second selection gets all the extensions not in the same group as the current FOP2 and sorts them by the group name then the exten.

    Ted
  • Hi,

    Thanks for the clarification. The problem is that the fop2 client does not perform any sql queries at the moment you login, it generates a static config that is stored in memory. And at the moment of rendering the buttons, it just swaps positions IN the group with the 1st button. So you cannot change the group display based on the extension you are logged as unless I hack deep into the code...

    Best regards,
  • As I don't see your internals, I can only guess how you get the underlying data. My previous post (which I just corrected; there were a couple of syntax errors) was an attempt to help, clarify, and collaborate not tell you how to write your software. I hope it didn't come across that way. While I mostly develop in Java, wild SQL statements have always appealed to me.

    Regards,
    Ted
  • Hi Ted,

    I really appreciate your post and help, and I also like this kind of SQL challenges.

    Although your solution does not apply because of the way fop2 is coded, it was an insightful post and I thank you for that, it adds richness to the forums. Proposing solutions is always a good thing in a forum.

    Now that I am back from vacations I will see if I can make the group sorting query and modification on the client to see if it is possible to change the group order on the display based on the logged extension.

    Best regards,
Sign In or Register to comment.