+=item 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.
+
+=cut
+
+sub cust_fields_subs {
+ my $unlinked_warn = 0;
+
+ return map {
+ my $f = $_;
+ if ( $unlinked_warn++ ) {
+
+ sub {
+ my $record = shift;
+ if ( $record->custnum ) {
+ encode_entities( $record->$f(@_) );
+ } else {
+ '(unlinked)'
+ };
+ };
+
+ } else {
+
+ sub {
+ my $record = shift;
+ $record->custnum ? encode_entities( $record->$f(@_) ) : '';
+ };
+
+ }
+
+ } @cust_fields;
+}
+
+=item cust_colors
+
+Returns an array of subroutine references (or empty strings) for returning
+customer information colors.
+
+As with L<the cust_header subroutine|/cust_header>, 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.
+
+=cut
+
+sub cust_colors {
+ map {
+ my $method = $_;
+ if ( $method ) {
+ sub { shift->$method(@_) };
+ } else {
+ '';
+ }
+ } @cust_colors;
+}
+
+=item cust_styles
+
+Returns an array of customer information styles.
+
+As with L<the cust_header subroutine|/cust_header>, 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.
+
+=cut
+
+sub cust_styles {
+ map {
+ if ( $_ ) {
+ $_;
+ } else {
+ '';
+ }
+ } @cust_styles;
+}
+
+=item cust_aligns
+
+Returns an array or scalar (depending on context) of customer information
+alignments.
+
+As with L<the cust_header subroutine|/cust_header>, 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.
+
+=cut
+
+sub cust_aligns {
+ if ( wantarray ) {
+ @cust_aligns;
+ } else {
+ join('', @cust_aligns);
+ }
+}
+
+=item cust_links
+
+Returns an array of links to view/cust_main.cgi, for use with cust_fields.
+
+=cut
+
+sub cust_links {
+ my $link = [ FS::CGI::rooturl().'view/cust_main.cgi?', 'custnum' ];
+
+ return map { $_ eq 'cust_status_label' ? '' : $link }
+ @cust_fields;
+}
+
+=item is_mobile
+
+Utility function to determine if the client is a mobile browser.
+
+=cut
+
+sub is_mobile {
+ my $ua = $ENV{'HTTP_USER_AGENT'} || '';
+ if ( $ua =~ /(?:hiptop|Blazer|Novarra|Vagabond|SonyEricsson|Symbian|NetFront|UP.Browser|UP.Link|Windows CE|MIDP|J2ME|DoCoMo|J-PHONE|PalmOS|PalmSource|iPhone|iPod|AvantGo|Nokia|Android|WebOS|S60|Opera Mini|Opera Mobi)/io ) {
+ return 1;
+ }
+ return 0;
+}
+
+=item 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.
+
+=cut
+
+sub random_id {
+ my $digits = shift;
+ if (!defined $NO_RANDOM_IDS) {
+ my $conf = FS::Conf->new;
+ $NO_RANDOM_IDS = $conf->exists('no_random_ids') ? 1 : 0;
+ warn "TEST MODE--RANDOM ID NUMBERS DISABLED\n" if $NO_RANDOM_IDS;
+ }
+ if ( $NO_RANDOM_IDS ) {
+ if ( $digits > 0 ) {
+ return 0;
+ } else {
+ return '0000000000-0000-000000000.000000';
+ }
+ } else {
+ if ($digits > 0) {
+ return int(rand(10 ** $digits));
+ } else {
+ return time . "-$$-" . rand() * 2**32;
+ }
+ }
+}
+
+=back
+
+=cut
+