1 <% include("/elements/table-grid.html") %>
2 % my $bgcolor1 = '#eeeeee';
3 % my $bgcolor2 = '#ffffff';
7 <TH CLASS="grid" BGCOLOR="#cccccc">User</TH>
8 <TH CLASS="grid" BGCOLOR="#cccccc">Date</TH>
9 <TH CLASS="grid" BGCOLOR="#cccccc">Time</TH>
10 <% $single_cust ? '' :
11 '<TH CLASS="grid" BGCOLOR="#cccccc">Customer</TH>'
13 <TH CLASS="grid" BGCOLOR="#cccccc">Item</TH>
14 <TH CLASS="grid" BGCOLOR="#cccccc">Action</TH>
15 <TH CLASS="grid" BGCOLOR="#cccccc">Description</TH>
18 % foreach my $item ( sort { $a->history_date <=> $b->history_date
20 % || $a->historynum <=> $b->historynum
25 % my $history_other = '';
26 % my $act = $item->history_action;
27 % if ( $act =~ /^replace/ ) {
28 % my $pkey = $item->primary_key;
29 % my $date = $item->history_date;
30 % $history_other = qsearchs({
31 % 'table' => $item->table,
32 % 'hashref' => { $pkey => $item->$pkey(),
33 % 'history_action' => $replace_other{$act},
34 % 'historynum' => { 'op' => $replace_dir{$act},
35 % 'value' => $item->historynum
39 % AND history_date $replace_direq{$act} $date
40 % AND ($date $replace_op{$act} $fuzz) $replace_direq{$act} history_date
41 % ORDER BY historynum $replace_ord{$act} LIMIT 1
46 % if ( $bgcolor eq $bgcolor1 ) {
47 % $bgcolor = $bgcolor2;
49 % $bgcolor = $bgcolor1;
53 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
54 % my $otaker = $item->history_user;
55 % $otaker = '<i>auto billing</i>' if $otaker eq 'fs_daily';
56 % $otaker = '<i>customer self-service</i>' if $otaker eq 'fs_selfservice';
57 % $otaker = '<i>job queue</i>' if $otaker eq 'fs_queue';
60 <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
61 % my $d = time2str('%b %o, %Y', $item->history_date );
65 <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
66 % my $t = time2str('%r', $item->history_date );
71 % unless ( $single_cust ) {
72 <TD ALIGN="center" CLASS="grid" BGCOLOR="<% $bgcolor %>">
73 % my $cust_main = qsearchs('cust_main', { custnum => $item->custnum });
74 <% $cust_main ? "<A HREF='${p}view/cust_main.cgi?"
75 .$cust_main->custnum."'>".$cust_main->name.'</A>' : '' %>
79 <TD ALIGN="center" CLASS="grid" BGCOLOR="<% $bgcolor %>">
81 % $label = $item->table;
83 % $label = $tables{$label};
84 % if ( $single_cust ) {
85 % $label = &{ $h_table_labelsub{$item->table} }( $item, $label )
86 % if $h_table_labelsub{$item->table};
90 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
91 <% $action{$item->history_action} %>
93 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
95 map { my $value = ( $_ =~ /(^pay(info|cvv)|^ss|_password)$/ )
98 $value = time2str($cust_pkg_date_format, $value)
99 if $item->table eq 'h_cust_pkg'
100 && $cust_pkg_date_fields{$_}
103 $value = substr($value, 0, 77).'...' if length($value) > 80;
104 $value = encode_entities($value);
105 "<I>$_</I>:<B>$value</B>";
107 grep { $history_other
108 ? ( $item->get($_) ne $history_other->get($_) )
109 : ( $item->get($_) =~ /\S/ )
111 grep { ! /^(history|custnum$)/i }
123 my @history = @{$opt{'history'}};
124 my %tables = %{$opt{'tables'}};
125 my $single_cust = $opt{'single_cust'};
126 my $conf = new FS::Conf;
127 my $curuser = $FS::CurrentUser::CurrentUser;
130 unless $curuser->access_right('View customer history');
133 'insert' => 'Insert', #'Create',
134 'replace_old' => 'Change from',
135 'replace_new' => 'Change to',
136 'delete' => 'Remove',
139 my %cust_pkg_date_fields = map { $_=>1 } qw(
140 start_date setup bill last_bill susp adjourn cancel expire contract_end
144 # finding the other replace row
146 my %replace_other = (
147 'replace_new' => 'replace_old',
148 'replace_old' => 'replace_new',
151 'replace_new' => '<',
152 'replace_old' => '>',
154 my %replace_direq = (
155 'replace_new' => '<=',
156 'replace_old' => '>=',
159 'replace_new' => '-',
160 'replace_old' => '+',
163 'replace_new' => 'DESC',
164 'replace_old' => 'ASC',
167 my $fuzz = 5; #seems like a lot
170 my $pkg_labelsub = sub {
171 my($item, $label) = @_;
172 $pkgpart{$item->pkgpart} ||= $item->part_pkg->pkg;
173 $label. ': <b>'. encode_entities($pkgpart{$item->pkgpart}). '</b>';
176 my $svc_labelsub = sub {
177 my($item, $label) = @_;
178 $label. ': <b>'. encode_entities($item->label($item->history_date)). '</b>';
181 my %h_table_labelsub = (
182 'h_cust_pkg' => $pkg_labelsub,
183 'h_svc_acct' => $svc_labelsub,
184 #'h_radius_usergroup' =>
185 'h_svc_domain' => $svc_labelsub,
186 'h_svc_www' => $svc_labelsub,
187 'h_svc_forward' => $svc_labelsub,
188 'h_svc_broadband' => $svc_labelsub,
189 'h_svc_external' => $svc_labelsub,
190 'h_svc_phone' => $svc_labelsub,
194 my $cust_pkg_date_format = '%b %o, %Y';
195 $cust_pkg_date_format .= ' %l:%M:%S%P'
196 if $conf->exists('cust_pkg-display_times')
197 || $curuser->option('cust_pkg-display_times');