X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FCGI.pm;h=c91c01fd080f8643cdf6f688ff99c9565138a5b4;hb=e81089e14bf8bd59c9dee9e70763df902962fb2b;hp=8c9b3260a71ec2fb86ea9985d053a3215839cb43;hpb=be4f8ca23c7d32350737887144796264b90c4e9d;p=freeside.git diff --git a/FS/FS/CGI.pm b/FS/FS/CGI.pm index 8c9b3260a..c91c01fd0 100644 --- a/FS/FS/CGI.pm +++ b/FS/FS/CGI.pm @@ -9,7 +9,7 @@ use URI::URL; use FS::UID; @ISA = qw(Exporter); -@EXPORT_OK = qw(header menubar idiot eidiot popurl table itable ntable +@EXPORT_OK = qw(header menubar idiot eidiot popurl rooturl table itable ntable small_custview myexit http_header); =head1 NAME @@ -61,10 +61,10 @@ sub header { - - $title + +
$title
-

+
END $x .= $menubar. "

" if $menubar; $x; @@ -115,6 +115,7 @@ sub menubar { #$menubar=menubar('Main Menu', '../', 'Item', 'url', ... ); my($item,$url,@html); while (@_) { ($item,$url)=splice(@_,0,2); + next if $item =~ /^\s*Main\s+Menu\s*$/i; push @html, qq!$item!; } join(' | ',@html); @@ -214,8 +215,9 @@ Returns current URL with LEVEL levels of path removed from the end (default 0). sub popurl { my($up)=@_; my $cgi = &FS::UID::cgi; - my $url = new URI::URL ( $cgi->isa('Apache') ? $cgi->uri : $cgi->url ); - $url->query(); + my $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + $url_string =~ s/\?.*//; + my $url = new URI::URL ( $url_string ); my(@path)=$url->path_components; splice @path, 0-$up; $url->path_components(@path); @@ -224,6 +226,36 @@ sub popurl { $x; } +=item rooturl + +=cut + +sub rooturl { + # better to start with the client-provided URL + my $cgi = &FS::UID::cgi; + my $url_string = $cgi->isa('Apache') ? $cgi->uri : $cgi->url; + $url_string =~ s/\?.*//; + + #even though this is kludgy + $url_string =~ s{ / index\.html /? $ } + {/}x; + $url_string =~ + s{ + / + (browse|config|docs|edit|graph|misc|search|view|pref|rt) + / + (process/)? + ([\w\-\.\/]+) + $ + } + {}x; + + $url_string .= '/' unless $url_string =~ /\/$/; + + $url_string; + +} + =item table Returns HTML tag for beginning a table. @@ -251,10 +283,11 @@ Returns HTML tag for beginning an (invisible) table. sub itable { my $col = shift; my $cellspacing = shift || 0; + my $width = ( scalar(@_) && shift ) ? '' : 'WIDTH="100%"'; #bah if ( $col ) { - qq!!; + qq!
!; } else { - qq!
!; + qq!
!; } } @@ -275,7 +308,7 @@ sub ntable { } -=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT +=item small_custview CUSTNUM || CUST_MAIN_OBJECT, COUNTRYDEFAULT, NOBALANCE_FLAG, URL Sheesh. I should just switch to Mason. @@ -287,13 +320,22 @@ sub small_custview { my $arg = shift; my $countrydefault = shift || 'US'; + my $nobalance = shift; + my $url = shift; my $cust_main = ref($arg) ? $arg : qsearchs('cust_main', { 'custnum' => $arg } ) or die "unknown custnum $arg"; - my $html = 'Customer #'. $cust_main->custnum. ''. - ntable('#e8e8e8'). '
'. ntable("#cccccc",2). + my $html; + + $html = qq!View ' + if $url; + + $html .= 'Customer #'. $cust_main->custnum. ''. + ' - '. + ucfirst($cust_main->status). ''. + ntable('#e8e8e8'). '
'. ntable("#cccccc",2). '
Billing
Address
'. $cust_main->getfield('last'). ', '. $cust_main->first. '
'; @@ -304,13 +346,27 @@ sub small_custview { $html .= $cust_main->country. '
' if $cust_main->country && $cust_main->country ne $countrydefault; + $html .= '
'; + if ( $cust_main->daytime && $cust_main->night ) { + use FS::Msgcat; + $html .= ( FS::Msgcat::_gettext('daytime') || 'Day' ). + ' '. $cust_main->daytime. + '
'. ( FS::Msgcat::_gettext('night') || 'Night' ). + ' '. $cust_main->night; + } elsif ( $cust_main->daytime || $cust_main->night ) { + $html .= $cust_main->daytime || $cust_main->night; + } + if ( $cust_main->fax ) { + $html .= '
Fax '. $cust_main->fax; + } + $html .= '
'; if ( defined $cust_main->dbdef_table->column('ship_last') ) { my $pre = $cust_main->ship_last ? 'ship_' : ''; - $html .= ''. ntable("#cccccc",2). + $html .= ''. ntable("#cccccc",2). 'Service
Address'. $cust_main->get("${pre}last"). ', '. $cust_main->get("${pre}first"). '
'; @@ -326,12 +382,30 @@ sub small_custview { if $cust_main->get("${pre}country") && $cust_main->get("${pre}country") ne $countrydefault; + $html .= ''; + + if ( $cust_main->get("${pre}daytime") && $cust_main->get("${pre}night") ) { + use FS::Msgcat; + $html .= ( FS::Msgcat::_gettext('daytime') || 'Day' ). + ' '. $cust_main->get("${pre}daytime"). + '
'. ( FS::Msgcat::_gettext('night') || 'Night' ). + ' '. $cust_main->get("${pre}night"); + } elsif ( $cust_main->get("${pre}daytime") + || $cust_main->get("${pre}night") ) { + $html .= $cust_main->get("${pre}daytime") + || $cust_main->get("${pre}night"); + } + if ( $cust_main->get("${pre}fax") ) { + $html .= '
Fax '. $cust_main->get("${pre}fax"); + } + $html .= ''; } $html .= ''; - $html .= '
Balance: $'. $cust_main->balance. '
'; + $html .= '
Balance: $'. $cust_main->balance. '
' + unless $nobalance; # last payment might be good here too?