Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prettier Grouped Dropdown Options?
12-07-2018, 08:30 AM, (This post was last modified: 12-07-2018, 09:11 AM by VortecCPI.)
#1
Prettier Grouped Dropdown Options?
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,
                            chartmaster.accountname,
                            chartmaster.group_
                        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"
;

    
$ResultSelection=DB_query($SQLAccountSelect);
    echo 
'<td><select name="GLCode">';    
    echo 
'<option value="">' _('Select an Account Code') . '</option>';
    while (
$MyRowSelection=DB_fetch_array($ResultSelection)){
        if (
$OptGroup != $MyRowSelection['group_']) {
            echo 
'<optgroup label="' $MyRowSelection['group_'] . '">';
            
$OptGroup $MyRowSelection['group_'];
        }
        if (isset(
$_POST['GLCode']) and $_POST['GLCode']==$MyRowSelection['accountcode']){
            echo 
'<option selected="selected" value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false) . '</option>';
        } else {
            echo 
'<option value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false)  . '</option>';
        }
    }
    echo 
'</select></td>'
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-07-2018, 08:56 PM,
#2
RE: Prettier Grouped Dropdown Options?
Great idea Paul!

This would be useful in many scripts
Reply
12-07-2018, 10:55 PM,
#3
RE: Prettier Grouped Dropdown Options?
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.
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-08-2018, 01:59 PM, (This post was last modified: 12-09-2018, 03:38 AM by TurboPT.)
#4
RE: Prettier Grouped Dropdown Options?
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.
Reply
12-08-2018, 11:03 PM,
#5
RE: Prettier Grouped Dropdown Options?
Agreed. Simple but functional.
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-09-2018, 04:29 AM,
#6
RE: Prettier Grouped Dropdown Options?
Change committed.
Reply
12-09-2018, 07:49 AM,
#7
RE: Prettier Grouped Dropdown Options?
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...
https://www.linkedin.com/in/eclipsepaulbecker
Reply
12-10-2018, 01:33 PM,
#8
RE: Prettier Grouped Dropdown Options?
Yeah nice :-)
Be good when you are on the same version Paul B so we can pull in your changes without re-doing!!
Phil Daintree
webERP Admin
Logic Works Ltd
http://www.logicworks.co.nz
Reply
12-10-2018, 08:43 PM,
#9
RE: Prettier Grouped Dropdown Options?
I have been working away steadily testing the current GIT version so will let my scripts loose as I go...
https://www.linkedin.com/in/eclipsepaulbecker
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)