webERP Forum

Full Version: Prettier Grouped Dropdown Options?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was going to ask how we can do what I saw in FrontAccounting last night but now I know so I am going to share because it was really simple:


Note <optgroup label="LABEL">
PHP Code:
    $SQLAccountSelect="SELECT chartmaster.accountcode,
                        FROM chartmaster
                        INNER JOIN glaccountusers ON glaccountusers.accountcode=chartmaster.accountcode AND glaccountusers.userid='" 
.  $_SESSION['UserID'] . "' AND glaccountusers.canview=1
                        INNER JOIN accountgroups ON chartmaster.group_=accountgroups.groupname
                        ORDER BY accountgroups.sequenceintb, accountgroups.groupname, chartmaster.accountcode"

'<td><select name="GLCode">';    
'<option value="">' _('Select an Account Code') . '</option>';
    while (
        if (
$OptGroup != $MyRowSelection['group_']) {
'<optgroup label="' $MyRowSelection['group_'] . '">';
$OptGroup $MyRowSelection['group_'];
        if (isset(
$_POST['GLCode']) and $_POST['GLCode']==$MyRowSelection['accountcode']){
'<option selected="selected" value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false) . '</option>';
        } else {
'<option value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false)  . '</option>';
Great idea Paul!

This would be useful in many scripts
Thank you Tim.

You know... It is really so simple but it sure looks great.

In my opinion it really helps me more quickly find a GL Account.
Back at a prior company, I did a similar sort of thing for customized part# association and BOM dating.

The company's part reference might be something such as 123456, but their reference referred to 1 or more other parts that were designated alternatives (by various manufacturer part#'s, of which any could be used) to supply that reference.

I also did a similar thing for BOMs, because we wanted to keep a date reference to a BOM so that they could be compared as to what parts were added/removed, part quantity changes, as well as motherboard reference changes. The differently-dated parent BOM#'s were suffixed with a date, but the optgroup used the parent BOM# to ease reference.

In both instances, the optgroup was sorted to ease the reference as well.

I'm surprised the optgroup feature is not used more often. (not just in webERP, but with other apps as well)


I'll add that tomorrow as well.
Agreed. Simple but functional.
Change committed.
I have done this in every script that has a GL Account dropdown. I also standardized each option to be "#### - GL Account Name" as in some scripts we do not have a hyphen between the number and the account name.

Yes... Very bad OCD over here on this side...
Yeah nice :-)
Be good when you are on the same version Paul B so we can pull in your changes without re-doing!!
I have been working away steadily testing the current GIT version so will let my scripts loose as I go...
Reference URL's