<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

blib::lib::FS::UI::Web

get_page_pref NAME, TABLENUM

Returns the user's page preference named NAME for the current page. If the page is a view or edit page or otherwise shows a single record at a time, it should use TABLENUM to link the preference to that record.

set_page_pref NAME, TABLENUM, VALUE

Sets the user's page preference named NAME for the current page. Use TABLENUM as for get_page_pref.

If VALUE is an empty string, the preference will be deleted (and get_page_pref will return an empty string).

  my $mypref = set_page_pref('mypref', '', 100);
parse_beginning_ending CGI [, PREFIX ]

Parses a beginning/ending date range, as used on many reports. This function recognizes two sets of CGI params: "begin" and "end", the integer timestamp values, and "beginning" and "ending", the user-readable date fields.

If "begin" contains an integer, that's passed through as the beginning date. Otherwise, "beginning" is passed to DateTime::Format::Natural and turned into an integer. If this fails or it doesn't have a value, zero is used as the beginning date.

The same happens for "end" and "ending", except that if "ending" contains a date without a time, it gets moved to the end of that day, and if there's no value, the value returned is the highest unsigned 32-bit time value (some time in 2037).

PREFIX is optionally a string to prepend (with '_' as a delimiter) to the form field names.

svc_url

Returns a service URL, first checking to see if there is a service-specific page to link to, otherwise to a generic service handling page. Options are passed as a list of name-value pairs, and include:

  • m - Mason request object ($m)
  • action - The action for which to construct "edit", "view", or "search"
  • ** part_svc - Service definition (see FS::part_svc)
  • ** svcdb - Service table
  • *** query - Query string
  • *** svc - FS::cust_svc or FS::svc_* object
  • ahref - Optional flag, if set true returns <A HREF="$url"> instead of just the URL.

* Required fields

** part_svc OR svcdb is required

*** query OR svc is required

cust_header [ CUST_FIELDS_VALUE ]

Returns an array of customer information headers according to the supplied customer fields value, or if no value is supplied, the cust-fields configuration value.

cust_sql_fields [ CUST_FIELDS_VALUE ]

Returns a list of fields for the SELECT portion of an SQL query.

As with the cust_header subroutine, the fields returned are defined by the supplied customer fields setting, or if no customer fields setting is supplied, the <B>cust-fields</B> configuration value.

join_cust_main [ TABLE[.CUSTNUM] ] [ LOCATION_TABLE[.LOCATIONNUM] ]

Returns an SQL join phrase for the FROM clause so that the fields listed in "cust_sql_fields" will be available. Currently joins to cust_main itself, as well as cust_location (under the aliases 'bill_location' and 'ship_location') if address fields are needed. "cust_header" should have been called already.

All of these will be left joins; if you want to exclude rows with no linked cust_main record (or bill_location/ship_location), you can do so in the WHERE clause.

TABLE is the table containing the custnum field. If CUSTNUM (a field name in that table) is specified, that field will be joined to cust_main.custnum. Otherwise, this function will assume the field is named "custnum". If the argument isn't present at all, the join will just say "USING (custnum)", which might work.

As a special case, if TABLE is 'cust_main', only the joins to cust_location will be returned.

LOCATION_TABLE is an optional table name to use for joining ship_location, in case your query also includes package information and you want the "service address" columns to reflect package addresses.

cust_fields OBJECT [ CUST_FIELDS_VALUE ]

Given an object that contains fields from cust_main (say, from a JOINed search. See httemplate/search/svc_* for examples), returns an array of customer information, or "(unlinked)" if this service is not linked to a customer.

As with the cust_header subroutine, the fields returned are defined by the supplied customer fields setting, or if no customer fields setting is supplied, the <B>cust-fields</B> configuration value.

cust_fields_subs

Returns an array of subroutine references for returning customer field values. This is similar to cust_fields, but returns each field's sub as a distinct element.

cust_colors

Returns an array of subroutine references (or empty strings) for returning customer information colors.

As with the cust_header subroutine, the fields returned are defined by the supplied customer fields setting, or if no customer fields setting is supplied, the <B>cust-fields</B> configuration value.

cust_styles

Returns an array of customer information styles.

As with the cust_header subroutine, the fields returned are defined by the supplied customer fields setting, or if no customer fields setting is supplied, the <B>cust-fields</B> configuration value.

cust_aligns

Returns an array or scalar (depending on context) of customer information alignments.

As with the cust_header subroutine, the fields returned are defined by the supplied customer fields setting, or if no customer fields setting is supplied, the <B>cust-fields</B> configuration value.

cust_links

Returns an array of links to view/cust_main.cgi, for use with cust_fields.

is_mobile

Utility function to determine if the client is a mobile browser.

random_id [ DIGITS ]

Returns a random number of length DIGITS, or if unspecified, a long random identifier consisting of the timestamp, process ID, and a random number. Anything in the UI that needs a random identifier should use this.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 29:

'=item' outside of any '=over'

=over without closing =back

Around line 134:

Expected '=item *'

Around line 136:

Expected '=item *'

Around line 138:

Expected '=item *'

Around line 140:

Expected '=item *'

Around line 142:

Expected '=item *'

<% include ('/elements/footer.html' ) %>