RT#28246: Add more details to Change History for Discounts [actually fixed the bug]
[freeside.git] / httemplate / elements / change_history_common.html
index 34ce70b..2d2c4c0 100644 (file)
                 $item->fields
          )
       %>
+% if ( $single_cust && $h_table_descripsub{$item->table} ) {
+      <% &{ $h_table_descripsub{$item->table} }( $item ) %>
+% }
     </TD>
   </TR>
 
@@ -185,6 +188,27 @@ my %h_table_labelsub = (
   #'h_phone_device'
 );
 
+my $discounts = {};
+my $discount_descripsub = sub {
+  my($item) = @_;
+  $pkgpart{$item->pkgpart} ||= qsearchs({
+    'table' => 'part_pkg',
+    'hashref' => {'pkgpart' => $item->pkgpart}
+  })->pkg;
+  my $dnum = $item->discountnum;
+  $discounts->{$dnum} ||= qsearchs({
+    'table'=>'discount',
+    'hashref'=>{'discountnum'=>$dnum}
+  });
+  my $d = $discounts->{$dnum};
+  '(<b>' . encode_entities($d->description_short) . '</b>'
+  . ' on <b>' . encode_entities($pkgpart{$item->pkgpart}) . '</b>)';
+};
+
+my %h_table_descripsub = (
+  'h_cust_pkg_discount' => $discount_descripsub,
+);
+
 my $cust_pkg_date_format = '%b %o, %Y';
 $cust_pkg_date_format .= ' %l:%M:%S%P'
   if $conf->exists('cust_pkg-display_times')