im_customer_select

one of the documented procedures in this installation of the ACS
Usage:
im_customer_select   db   select_name   { default "" }   { status "" }   { exclude_status "" }
What it does:
Returns an html select box named $select_name and defaulted to $default with a list of all the customers in the system. If status is specified, we limit the select box to customers that match that status. If exclude status is provided, we limit to states that do not match exclude_status (list of statuses to exclude).
Defined in: /web/philip/tcl/intranet-defs.tcl

Source code:


    set sql "select ug.group_name, ug.group_id
             from user_groups ug, im_customers c
             where ug.parent_group_id=[im_customer_group_id $db]
               and ug.group_id = c.group_id(+)"
    if { ![empty_string_p $status] } {
	append sql " and customer_status_id=(select customer_status_id from im_customer_status where customer_status='[DoubleApos $status]')"
    }
    if { ![empty_string_p $exclude_status] } {
	set exclude_string ""
	foreach type $exclude_status {
	    if { ![empty_string_p $exclude_string] } {
		append exclude_string ", "
	    } 
	    append exclude_string "'[DoubleApos $type]'"
	    
	}
	append sql " and customer_status_id in (select customer_status_id 
                                                  from im_customer_status 
                                                 where customer_status not in ($exclude_string)) "
    }
    append sql " order by lower(group_name)"
    return [im_selection_to_select_box $db $sql $select_name $default]


philg@mit.edu