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 'svc_cable' => 'Cable',
46 'phone_device' => 'Phone device',
47 'cust_pkg_discount' => 'Discount',
48 #? it gets provisioned anyway 'phone_avail' => 'Phone',
51 my $pkg_join = "JOIN cust_pkg USING ( pkgnum )";
52 my $svc_join = "JOIN cust_svc USING ( svcnum ) $pkg_join";
55 'svc_acct' => $svc_join,
56 'radius_usergroup' => $svc_join,
57 'svc_domain' => $svc_join,
58 'svc_www' => $svc_join,
59 'svc_forward' => $svc_join,
60 'svc_broadband' => $svc_join,
61 'svc_external' => $svc_join,
62 'svc_phone' => $svc_join,
63 'svc_cable' => $svc_join,
64 'phone_device' => $svc_join,
65 'cust_pkg_discount'=> $pkg_join,
82 # acct_snarf? is this even used? it is now, for communigate RPOP
89 # (virtual fields? eh... maybe when they're real)
97 # inventory_item (from services)
98 # pkg_referral? (changed?)
103 # cust_main-exemption?? (295.ca named tax exemptions)
106 my( $cust_main ) = @_;
108 my $conf = new FS::Conf;
110 my $curuser = $FS::CurrentUser::CurrentUser;
113 unless $curuser->access_right('View customer history');
115 # find out the beginning of this customer history, if possible
116 my $h_insert = qsearchs({
117 'table' => 'h_cust_main',
118 'hashref' => { 'custnum' => $cust_main->custnum,
119 'history_action' => 'insert',
121 'extra_sql' => 'ORDER BY historynum LIMIT 1',
123 my $start = $h_insert ? $h_insert->history_date : 0;
125 # retreive the history
129 my $years = $conf->config('change_history-years') || .5;
130 if ( $cgi->param('change_history-years') =~ /^([\d\.]+)$/ ) {
133 my $newer_than = int( time - $years * 31556736 ); #60*60*24*365.24
135 local($FS::Record::nowarn_classload) = 1;
137 foreach my $table ( keys %tables ) {
138 my @items = qsearch({
139 'table' => "h_$table",
140 'addl_from' => $table_join{$table},
141 'hashref' => { 'history_date' => { op=>'>=', value=>$newer_than }, },
142 'extra_sql' => ' AND custnum = '. $cust_main->custnum,
144 push @history, @items;
147 my @legacy_items = qsearch({
148 'table' => 'legacy_cust_history',
149 'hashref' => { 'history_date' => { op=>'>=', value=>$newer_than }, },
150 'extra_sql' => ' AND custnum = '. $cust_main->custnum,
152 push @history, @legacy_items;