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 ( @history ) {
19 % my $history_other = '';
20 % my $act = $item->history_action;
21 % if ( $act =~ /^replace/ ) {
22 % my $pkey = $item->primary_key;
23 % my $date = $item->history_date;
24 % $history_other = qsearchs({
25 % 'table' => $item->table,
26 % 'hashref' => { $pkey => $item->$pkey(),
27 % 'history_action' => $replace_other{$act},
28 % 'historynum' => { 'op' => $replace_dir{$act},
29 % 'value' => $item->historynum
33 % AND history_date $replace_direq{$act} $date
34 % AND ($date $replace_op{$act} $fuzz) $replace_direq{$act} history_date
35 % ORDER BY historynum $replace_ord{$act} LIMIT 1
40 % if ( $bgcolor eq $bgcolor1 ) {
41 % $bgcolor = $bgcolor2;
43 % $bgcolor = $bgcolor1;
47 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
48 % my $otaker = $item->history_user;
49 % $otaker = '<i>auto billing</i>' if $otaker eq 'fs_daily';
50 % $otaker = '<i>customer self-service</i>' if $otaker eq 'fs_selfservice';
51 % $otaker = '<i>job queue</i>' if $otaker eq 'fs_queue';
54 <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
55 % my $d = time2str('%b %o, %Y', $item->history_date );
59 <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
60 % my $t = time2str('%r', $item->history_date );
65 % unless ( $single_cust ) {
66 <TD ALIGN="center" CLASS="grid" BGCOLOR="<% $bgcolor %>">
67 % my $cust_main = qsearchs('cust_main', { custnum => $item->custnum });
68 <% $cust_main ? "<A HREF='${p}view/cust_main.cgi?"
69 .$cust_main->custnum."'>".$cust_main->name.'</A>' : '' %>
73 <TD ALIGN="center" CLASS="grid" BGCOLOR="<% $bgcolor %>">
75 % $label = $item->table;
77 % $label = $tables{$label};
78 % if ( $single_cust ) {
79 % $label = &{ $h_table_labelsub{$item->table} }( $item, $label )
80 % if $h_table_labelsub{$item->table};
84 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
85 <% $action{$item->history_action} %>
87 <TD ALIGN="left" CLASS="grid" BGCOLOR="<% $bgcolor %>">
89 map { my $value = ( $_ =~ /(^pay(info|cvv)|^ss|_password)$/ )
92 $value = time2str($cust_pkg_date_format, $value)
93 if $item->table eq 'h_cust_pkg'
94 && $cust_pkg_date_fields{$_}
97 $value = substr($value, 0, 77).'...' if length($value) > 80;
98 $value = encode_entities($value);
99 "<I>$_</I>:<B>$value</B>";
101 grep { $history_other
102 ? ( $item->get($_) ne $history_other->get($_) )
103 : ( $item->get($_) =~ /\S/ )
105 grep { ! /^(history|custnum$)/i }
117 my @history = @{$opt{'history'}};
118 my %tables = %{$opt{'tables'}};
119 my $single_cust = $opt{'single_cust'};
120 my $conf = new FS::Conf;
121 my $curuser = $FS::CurrentUser::CurrentUser;
124 unless $curuser->access_right('View customer history');
127 'insert' => 'Insert', #'Create',
128 'replace_old' => 'Change from',
129 'replace_new' => 'Change to',
130 'delete' => 'Remove',
133 my %cust_pkg_date_fields = map { $_=>1 } qw(
134 start_date setup bill last_bill susp adjourn cancel expire contract_end
138 # finding the other replace row
140 my %replace_other = (
141 'replace_new' => 'replace_old',
142 'replace_old' => 'replace_new',
145 'replace_new' => '<',
146 'replace_old' => '>',
148 my %replace_direq = (
149 'replace_new' => '<=',
150 'replace_old' => '>=',
153 'replace_new' => '-',
154 'replace_old' => '+',
157 'replace_new' => 'DESC',
158 'replace_old' => 'ASC',
161 my $fuzz = 5; #seems like a lot
164 my $pkg_labelsub = sub {
165 my($item, $label) = @_;
166 $pkgpart{$item->pkgpart} ||= $item->part_pkg->pkg;
167 $label. ': <b>'. encode_entities($pkgpart{$item->pkgpart}). '</b>';
170 my $svc_labelsub = sub {
171 my($item, $label) = @_;
172 $label. ': <b>'. encode_entities($item->label($item->history_date)). '</b>';
175 my %h_table_labelsub = (
176 'h_cust_pkg' => $pkg_labelsub,
177 'h_svc_acct' => $svc_labelsub,
178 #'h_radius_usergroup' =>
179 'h_svc_domain' => $svc_labelsub,
180 'h_svc_www' => $svc_labelsub,
181 'h_svc_forward' => $svc_labelsub,
182 'h_svc_broadband' => $svc_labelsub,
183 'h_svc_external' => $svc_labelsub,
184 'h_svc_phone' => $svc_labelsub,
188 my $cust_pkg_date_format = '%b %o, %Y';
189 $cust_pkg_date_format .= ' %l:%M:%S%P'
190 if $conf->exists('cust_pkg-display_times')
191 || $curuser->option('cust_pkg-display_times');
193 @history = sort { $a->history_date <=> $b->history_date
194 || $a->historynum <=> $b->historynum } @history;
196 if ( $curuser->option('history_order') eq 'newest' ) {
197 @history = reverse @history;