1 % if ( int( time - (keys %years)[0] * 31556736 ) > $start ) {
3 % my $chy = $cgi->param('change_history-years');
4 % foreach my $y (keys %years) {
5 % if ( $y == $years ) {
6 <FONT SIZE="+1"><% $years{$y} %></FONT>
8 % $cgi->param('change_history-years', $y);
9 <A HREF="<% $cgi->self_url %>"><% $years{$y} %></A>
11 % last if int( time - $y * 31556736 ) < $start;
13 % $cgi->param('change_history-years', $chy);
16 <% include("/elements/change_history_common.html",
17 'history' => \@history,
24 tie my %years, 'Tie::IxHash',
32 tie my %tables, 'Tie::IxHash',
33 'cust_main' => 'Customer',
34 'cust_main_invoice' => 'Invoice destination',
35 'cust_pkg' => 'Package',
36 #? or just svc_* ? 'cust_svc' =>
37 'svc_acct' => 'Account',
38 'radius_usergroup' => 'RADIUS group',
39 'svc_domain' => 'Domain',
40 'svc_www' => 'Hosting',
41 'svc_forward' => 'Mail forward',
42 'svc_broadband' => 'Broadband',
43 'svc_external' => 'External service',
44 'svc_phone' => 'Phone',
45 'phone_device' => 'Phone device',
46 'cust_pkg_discount' => 'Discount',
47 #? it gets provisioned anyway 'phone_avail' => 'Phone',
50 my $pkg_join = "JOIN cust_pkg USING ( pkgnum )";
51 my $svc_join = "JOIN cust_svc USING ( svcnum ) $pkg_join";
54 'svc_acct' => $svc_join,
55 'radius_usergroup' => $svc_join,
56 'svc_domain' => $svc_join,
57 'svc_www' => $svc_join,
58 'svc_forward' => $svc_join,
59 'svc_broadband' => $svc_join,
60 'svc_external' => $svc_join,
61 'svc_phone' => $svc_join,
62 'phone_device' => $svc_join,
63 'cust_pkg_discount'=> $pkg_join,
80 # acct_snarf? is this even used? it is now, for communigate RPOP
87 # (virtual fields? eh... maybe when they're real)
95 # inventory_item (from services)
96 # pkg_referral? (changed?)
101 # cust_main-exemption?? (295.ca named tax exemptions)
104 my( $cust_main ) = @_;
106 my $conf = new FS::Conf;
108 my $curuser = $FS::CurrentUser::CurrentUser;
111 unless $curuser->access_right('View customer history');
113 # find out the beginning of this customer history, if possible
114 my $h_insert = qsearchs({
115 'table' => 'h_cust_main',
116 'hashref' => { 'custnum' => $cust_main->custnum,
117 'history_action' => 'insert',
119 'extra_sql' => 'ORDER BY historynum LIMIT 1',
121 my $start = $h_insert ? $h_insert->history_date : 0;
123 # retreive the history
127 my $years = $conf->config('change_history-years') || .5;
128 if ( $cgi->param('change_history-years') =~ /^([\d\.]+)$/ ) {
131 my $newer_than = int( time - $years * 31556736 ); #60*60*24*365.24
133 local($FS::Record::nowarn_classload) = 1;
135 foreach my $table ( keys %tables ) {
136 my @items = qsearch({
137 'table' => "h_$table",
138 'addl_from' => $table_join{$table},
139 'hashref' => { 'history_date' => { op=>'>=', value=>$newer_than }, },
140 'extra_sql' => ' AND custnum = '. $cust_main->custnum,
142 push @history, @items;