+% #XXX enable me# if ( $curuser->access_right('View customer packages') {
+<& cust_main/packages.html, $cust_main &>
+% #}
+
+% }
+
+
+% ###
+% # Payment History
+% ###
+
+% if ( $view eq 'jumbo' ) {
+ <BR><BR>
+ <A NAME="history"><FONT SIZE="+2"><% mt('Payment History') |h %></FONT></A>
+ <BR>
+% }
+
+% if ( $view eq 'payment_history' || $view eq 'jumbo' ) {
+
+<& cust_main/payment_history.html, $cust_main &>
+
+% }
+
+
+% ###
+% # Change History
+% ###
+
+% if ( $view eq 'change_history' ) { # || $view eq 'jumbo'
+<& cust_main/change_history.html, $cust_main &>
+% }
+
+% if ( $view eq 'custom' ) {
+% if ( $conf->config('cust_main-custom_link') ) {
+<& cust_main/custom.html, $cust_main &>
+% } elsif ( $conf->config('cust_main-custom_content') ) {
+ <& cust_main/custom_content.html, $cust_main &>
+% #} else {
+% # warn "custom view without cust_main-custom_link or -custom_content?";
+% }
+% }
+
+</DIV>
+<& /elements/footer.html &>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied"
+ unless $curuser->access_right('View customer');
+
+my $conf = new FS::Conf;
+
+my $custnum;
+if ( $cgi->param('custnum') =~ /^(\d+)$/ ) {
+ $custnum = $1;
+} else {
+ die "No customer specified (bad URL)!" unless $cgi->keywords;
+ my($query) = $cgi->keywords; # needs parens with my, ->keywords returns array
+ $query =~ /^(\d+)$/;
+ $custnum = $1;
+ $cgi->param('custnum', $1);
+}
+
+my $cust_main = qsearchs( {
+ 'table' => 'cust_main',
+ 'hashref' => { 'custnum' => $custnum },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql,
+});
+die "Customer not found!" unless $cust_main;
+
+my $title = encode_entities($cust_main->name);
+$title = '#'. $cust_main->display_custnum. " $title";
+# if $conf->exists('cust_main-title-display_custnum');
+$title = mt("Customer")." ".$title;
+
+my @agentnums = $curuser->agentnums;
+if (scalar(@agentnums) > 1 ) {
+ $title = encode_entities($cust_main->agent->agent). " $title";
+}
+
+my $status = $cust_main->status_label;
+$status .= ' (Cancelled)' if $cust_main->is_status_delay_cancel;
+my $title_noescape = $title. ' (<B><FONT COLOR="#'. $cust_main->statuscolor. '">'. $status. '</FONT></B>)';
+$title .= " ($status)";
+
+#false laziness w/pref/pref.html and Conf.pm (cust_main-default_view)
+tie my %views, 'Tie::IxHash',
+ emt('Basics') => 'basics',
+ emt('Notes') => 'notes', #notes and files?
+;
+if ( $conf->config('ticket_system') ) {
+ $views{emt('Tickets')} = 'tickets';
+ $views{emt('Appointments')} = 'appointments'
+ if $curuser->access_right('View appointments');
+}
+$views{emt('Quotations')} = 'quotations';
+$views{emt('Packages')} = 'packages';
+$views{emt('Payment History')} = 'payment_history';
+$views{emt('Change History')} = 'change_history'
+ if $curuser->access_right('View customer history');
+$views{$conf->config('cust_main-custom_title') || emt('Custom')} = 'custom'
+ if $conf->config('cust_main-custom_link')
+ || $conf->config('cust_main-custom_content');
+$views{emt('Jumbo')} = 'jumbo';
+
+my %viewname = reverse %views;
+
+my $view = $cgi->param('show') || $curuser->default_customer_view;
+
+my $ie_compat = $conf->config('ie-compatibility_mode');
+my $head = '';
+if ( $ie_compat ) {
+ $head = qq(<meta http-equiv="X-UA-Compatible" content="IE=$ie_compat" />);
+}