Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Tue, 18 Nov 2014 19:41:35 +0000 (11:41 -0800)
committerIvan Kohler <ivan@freeside.biz>
Tue, 18 Nov 2014 19:41:35 +0000 (11:41 -0800)
12 files changed:
FS/FS/ClientAPI/MyAccount.pm
FS/FS/Template_Mixin.pm
FS/FS/cdr/cx3.pm
FS/FS/cust_main/Billing.pm
FS/FS/part_export/phone_shellcommands.pm
FS/FS/part_pkg/discount_Mixin.pm
conf/invoice_html
conf/invoice_latex
debian/rules
fs_selfservice/FS-SelfService/cgi/login.html
fs_selfservice/FS-SelfService/cgi/selfservice.cgi
fs_selfservice/FS-SelfService/cgi/view_usage.html

index ec114ff..61082bd 100644 (file)
@@ -1716,6 +1716,9 @@ sub list_svcs {
   my($context, $session, $custnum) = _custoragent_session_custnum($p);
   return { 'error' => $session } if $context eq 'error';
 
+  my $conf = new FS::Conf;
+
+  my $hide_usage = $conf->exists('selfservice_hide-usage') ? 1 : 0;
   my $search = { 'custnum' => $custnum };
   $search->{'agentnum'} = $session->{'agentnum'} if $context eq 'agent';
   my $cust_main = qsearchs('cust_main', $search )
@@ -1729,7 +1732,6 @@ sub list_svcs {
 
   my @cust_svc = ();
   my @cust_pkg_usage = ();
-  #foreach my $cust_pkg ( $cust_main->ncancelled_pkgs ) {
   foreach my $cust_pkg ( $p->{'ncancelled'} 
                          ? $cust_main->ncancelled_pkgs
                          : $cust_main->unsuspended_pkgs ) {
@@ -1740,14 +1742,16 @@ sub list_svcs {
 
   @cust_svc = grep { $_->part_svc->selfservice_access ne 'hidden' } @cust_svc;
   my %usage_pools;
-  foreach (@cust_pkg_usage) {
-    my $part = $_->part_pkg_usage;
-    my $tag = $part->description . ($part->shared ? 1 : 0);
-    my $row = $usage_pools{$tag} 
-          ||= [ $part->description, 0, 0, $part->shared ? 1 : 0 ];
-    $row->[1] += sprintf('%.1f', $_->minutes); # minutes remaining
-    $row->[2] += $part->minutes; # minutes total
-  }
+  if (!$hide_usage) {
+    foreach (@cust_pkg_usage) {
+      my $part = $_->part_pkg_usage;
+      my $tag = $part->description . ($part->shared ? 1 : 0);
+      my $row = $usage_pools{$tag} 
+            ||= [ $part->description, 0, 0, $part->shared ? 1 : 0 ];
+      $row->[1] += sprintf('%.1f', $_->minutes); # minutes remaining
+      $row->[2] += $part->minutes; # minutes total
+    }
+  } # otherwise just leave them empty
 
   if ( $p->{'svcdb'} ) {
     my $svcdb = ref($p->{'svcdb'}) eq 'HASH'
@@ -1761,108 +1765,110 @@ sub list_svcs {
   #@svc_x = sort { $a->domain cmp $b->domain || $a->username cmp $b->username }
   #              @svc_x;
 
-    my $conf = new FS::Conf;
+  my @svcs; # stuff to return to the client
+  foreach my $cust_svc (@cust_svc) {
+    my $svc_x = $cust_svc->svc_x;
+    my($label, $value) = $cust_svc->label;
+    my $part_svc = $cust_svc->part_svc;
+    my $svcdb = $part_svc->svcdb;
+    my $cust_pkg = $cust_svc->cust_pkg;
+    my $part_pkg = $cust_pkg->part_pkg;
 
-  { 
+    my %hash = (
+      'svcnum'         => $cust_svc->svcnum,
+      'display_svcnum' => $cust_svc->display_svcnum,
+      'svcdb'          => $svcdb,
+      'label'          => $label,
+      'value'          => $value,
+      'pkg_label'      => $cust_pkg->pkg_locale,
+      'pkg_status'     => $cust_pkg->status,
+      'readonly'       => ($part_svc->selfservice_access eq 'readonly'),
+    );
+
+    # would it make sense to put this in a svc_* method?
+
+    if ( $svcdb eq 'svc_acct' ) {
+      foreach (qw(username email finger seconds)) {
+        $hash{$_} = $svc_x->$_;
+      }
+
+      if (!$hide_usage) {
+        %hash = (
+          %hash,
+          'upbytes'    => display_bytecount($svc_x->upbytes),
+          'downbytes'  => display_bytecount($svc_x->downbytes),
+          'totalbytes' => display_bytecount($svc_x->totalbytes),
+
+          'recharge_amount'  => $part_pkg->option('recharge_amount',1),
+          'recharge_seconds' => $part_pkg->option('recharge_seconds',1),
+          'recharge_upbytes'    =>
+            display_bytecount($part_pkg->option('recharge_upbytes',1)),
+          'recharge_downbytes'  =>
+            display_bytecount($part_pkg->option('recharge_downbytes',1)),
+          'recharge_totalbytes' =>
+            display_bytecount($part_pkg->option('recharge_totalbytes',1)),
+          # more...
+        );
+      }
+
+    } elsif ( $svcdb eq 'svc_dsl' ) {
+
+      $hash{'phonenum'} = $svc_x->phonenum;
+      if ( $svc_x->first || $svc_x->get('last') || $svc_x->company ) {
+        $hash{'name'} = $svc_x->first. ' '. $svc_x->get('last');
+        $hash{'name'} = $svc_x->company. ' ('. $hash{'name'}. ')'
+          if $svc_x->company;
+      } else {
+        $hash{'name'} = $cust_main->name;
+      }
+      # no usage to hide here
+
+    } elsif ( $svcdb eq 'svc_phone' ) {
+      if (!$hide_usage) {
+        # could potentially show lots of things...
+        $hash{'outbound'} = 1;
+        $hash{'inbound'}  = 0;
+        if ( $part_pkg->plan eq 'voip_inbound' ) {
+          $hash{'outbound'} = 0;
+          $hash{'inbound'}  = 1;
+        } elsif ( $part_pkg->option('selfservice_inbound_format')
+              or  $conf->config('selfservice-default_inbound_cdr_format')
+        ) {
+          $hash{'inbound'}  = 1;
+        }
+        foreach (qw(inbound outbound)) {
+          # hmm...we can't filter by status here, because there might
+          # not be cdr_terminations at all.  have to go by date.
+          # find all since the last bill date.
+          # XXX cdr types?  we are going to need them.
+          if ( $hash{$_} ) {
+            my $sum_cdr = $svc_x->sum_cdrs(
+              'inbound' => ( $_ eq 'inbound' ? 1 : 0 ),
+              'begin'   => ($cust_pkg->last_bill || 0),
+              'nonzero' => 1,
+              'disable_charged_party' => 1,
+            );
+            $hash{$_} = $sum_cdr->hashref;
+          }
+        }
+      } # not hiding usage
+    } # svcdb
+
+    push @svcs, \%hash;
+  } # foreach $cust_svc
+
+  return { 
     'svcnum'   => $session->{'svcnum'},
     'custnum'  => $custnum,
     'date_format' => $conf->config('date_format') || '%m/%d/%Y',
     'view_usage_nodomain' => $conf->exists('selfservice-view_usage_nodomain'),
-    'svcs'     => [
-      map { 
-            my $svc_x = $_->svc_x;
-            my($label, $value) = $_->label;
-            my $part_svc = $_->part_svc;
-            my $svcdb = $part_svc->svcdb;
-            my $cust_pkg = $_->cust_pkg;
-            my $part_pkg = $cust_pkg->part_pkg;
-
-            my %hash = (
-              'svcnum'         => $_->svcnum,
-              'display_svcnum' => $_->display_svcnum,
-              'svcdb'          => $svcdb,
-              'label'          => $label,
-              'value'          => $value,
-              'pkg_label'      => $cust_pkg->pkg_locale,
-              'pkg_status'     => $cust_pkg->status,
-              'readonly'       => ($part_svc->selfservice_access eq 'readonly'),
-            );
-
-            if ( $svcdb eq 'svc_acct' ) {
-              %hash = (
-                %hash,
-                'username'   => $svc_x->username,
-                'email'      => $svc_x->email,
-                'finger'     => $svc_x->finger,
-                'seconds'    => $svc_x->seconds,
-                'upbytes'    => display_bytecount($svc_x->upbytes),
-                'downbytes'  => display_bytecount($svc_x->downbytes),
-                'totalbytes' => display_bytecount($svc_x->totalbytes),
-
-                'recharge_amount'  => $part_pkg->option('recharge_amount',1),
-                'recharge_seconds' => $part_pkg->option('recharge_seconds',1),
-                'recharge_upbytes'    =>
-                  display_bytecount($part_pkg->option('recharge_upbytes',1)),
-                'recharge_downbytes'  =>
-                  display_bytecount($part_pkg->option('recharge_downbytes',1)),
-                'recharge_totalbytes' =>
-                  display_bytecount($part_pkg->option('recharge_totalbytes',1)),
-                # more...
-              );
-
-            } elsif ( $svcdb eq 'svc_dsl' ) {
-              $hash{'phonenum'} = $svc_x->phonenum;
-              if ( $svc_x->first || $svc_x->get('last') || $svc_x->company ) {
-                $hash{'name'} = $svc_x->first. ' '. $svc_x->get('last');
-                $hash{'name'} = $svc_x->company. ' ('. $hash{'name'}. ')'
-                  if $svc_x->company;
-              } else {
-                $hash{'name'} = $cust_main->name;
-              }
-            } elsif ( $svcdb eq 'svc_phone' ) {
-              # could potentially show lots of things...
-              $hash{'outbound'} = 1;
-              $hash{'inbound'}  = 0;
-              if ( $part_pkg->plan eq 'voip_inbound' ) {
-                $hash{'outbound'} = 0;
-                $hash{'inbound'}  = 1;
-              } elsif ( $part_pkg->option('selfservice_inbound_format')
-                    or  $conf->config('selfservice-default_inbound_cdr_format')
-              ) {
-                $hash{'inbound'}  = 1;
-              }
-              foreach (qw(inbound outbound)) {
-                # hmm...we can't filter by status here, because there might
-                # not be cdr_terminations at all.  have to go by date.
-                # find all since the last bill date.
-                # XXX cdr types?  we are going to need them.
-                if ( $hash{$_} ) {
-                  my $sum_cdr = $svc_x->sum_cdrs(
-                    'inbound' => ( $_ eq 'inbound' ? 1 : 0 ),
-                    'begin'   => ($cust_pkg->last_bill || 0),
-                    'nonzero' => 1,
-                    'disable_charged_party' => 1,
-                  );
-                  $hash{$_} = $sum_cdr->hashref;
-                }
-              }
-            }
-
-            # elsif ( $svcdb eq 'svc_phone' || $svcdb eq 'svc_port' ) {
-            #  %hash = (
-            #    %hash,
-            #  );
-            #}
-
-            \%hash;
-          }
-          @cust_svc
-    ],
+    'svcs'     => \@svcs,
     'usage_pools' => [
       map { $usage_pools{$_} }
       sort { $a cmp $b }
       keys %usage_pools
     ],
+    'hide_usage' => $hide_usage,
   };
 
 }
@@ -2144,6 +2150,10 @@ sub _usage_details {
   my($callback, $p, %opt) = @_;
   my $conf = FS::Conf->new;
 
+  if ( $conf->exists('selfservice_hide-usage') ) {
+    return { 'error' => 'Viewing usage is not allowed.' };
+  }
+
   my($context, $session, $custnum) = _custoragent_session_custnum($p);
   return { 'error' => $session } if $context eq 'error';
 
index f70ac3c..0928ee5 100644 (file)
@@ -344,13 +344,13 @@ sub print_generic {
   my @invoice_template = map "$_\n", $conf->config($templatefile)
     or die "cannot load config data $templatefile";
 
-  my $old_latex = '';
   if ( $format eq 'latex' && grep { /^%%Detail/ } @invoice_template ) {
     #change this to a die when the old code is removed
-    warn "old-style invoice template $templatefile; ".
+    # it's been almost ten years, changing it to a die.
+    die "old-style invoice template $templatefile; ".
          "patch with conf/invoice_latex.diff or use new conf/invoice_latex*\n";
-    $old_latex = 'true';
-    @invoice_template = _translate_old_latex_format(@invoice_template);
+         #$old_latex = 'true';
+         #@invoice_template = _translate_old_latex_format(@invoice_template);
   } 
 
   warn "$me print_generic creating T:T object\n"
@@ -880,6 +880,7 @@ sub print_generic {
                     );
   my $money_char = $money_chars{$format};
 
+  # extremely dubious
   my %other_money_chars = ( 'latex'    => '\dollar ',#XXX should be a config too
                             'html'     => $conf->config('money_char') || '$',
                             'template' => '',
@@ -1091,8 +1092,7 @@ sub print_generic {
         ext_description => [ map { &$escape_function($_) } 
                              @{ $line_item->{'ext_description'} || [] }
                            ],
-        amount          => ( $old_latex ? '' : $money_char).
-                            $line_item->{'amount'},
+        amount          => $money_char . $line_item->{'amount'},
         product_code    => $line_item->{'pkgpart'} || 'N/A',
       };
 
@@ -1178,8 +1178,9 @@ sub print_generic {
       $line_item->{'product_code'} = $line_item->{'pkgpart'} || 'N/A'; # mt()?
       $line_item->{'section'} = $section;
       $line_item->{'description'} = &$escape_function($line_item->{'description'});
-      if (!$old_latex) { # dubious; templates should provide this
-        $line_item->{'amount'} = $money_char.$line_item->{'amount'};
+      $line_item->{'amount'} = $money_char.$line_item->{'amount'};
+
+      if ( length($line_item->{'unit_amount'}) ) {
         $line_item->{'unit_amount'} = $money_char.$line_item->{'unit_amount'};
       }
       $line_item->{'ext_description'} ||= [];
@@ -1226,13 +1227,12 @@ sub print_generic {
 
     if ( $multisection ) {
 
-      my $money = $old_latex ? '' : $money_char;
       push @detail_items, {
         ext_description => [],
         ref          => '',
         quantity     => '',
         description  => $description,
-        amount       => $money. $amount,
+        amount       => $money_char. $amount,
         product_code => '',
         section      => $tax_section,
       };
@@ -1360,13 +1360,12 @@ sub print_generic {
         $total->{'total_amount'} = $minus.$other_money_char.$credit->{'amount'};
         $adjusttotal += $credit->{'amount'};
         if ( $multisection ) {
-          my $money = $old_latex ? '' : $money_char;
           push @detail_items, {
             ext_description => [],
             ref          => '',
             quantity     => '',
             description  => &$escape_function($credit->{'description'}),
-            amount       => $money. $credit->{'amount'},
+            amount       => $money_char . $credit->{'amount'},
             product_code => '',
             section      => $adjust_section,
           };
@@ -1395,13 +1394,12 @@ sub print_generic {
         $total->{'total_amount'} = $minus.$other_money_char.$payment->{'amount'};
         $adjusttotal += $payment->{'amount'};
         if ( $multisection ) {
-          my $money = $old_latex ? '' : $money_char;
           push @detail_items, {
             ext_description => [],
             ref          => '',
             quantity     => '',
             description  => &$escape_function($payment->{'description'}),
-            amount       => $money. $payment->{'amount'},
+            amount       => $money_char . $payment->{'amount'},
             product_code => '',
             section      => $adjust_section,
           };
@@ -2635,16 +2633,21 @@ sub _items_cust_bill_pkg {
   my $cust_main = $self->cust_main;#for per-agent cust_bill-line_item-ate_style
                                    # and location labels
 
-  my @b = ();
-  my ($s, $r, $u) = ( undef, undef, undef );
+  my @b = (); # accumulator for the line item hashes that we'll return
+  my ($s, $r, $u, $d) = ( undef, undef, undef );
+            # the 'current' line item hashes for setup, recur, usage, discount
   foreach my $cust_bill_pkg ( @$cust_bill_pkgs )
   {
-
-    foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
+    # if the current line item is waiting to go out, and the one we're about
+    # to start is not bundled, then push out the current one and start a new
+    # one.
+    foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) , $d ) {
       if ( $_ && !$cust_bill_pkg->hidden ) {
-        $_->{amount}      = sprintf( "%.2f", $_->{amount} ),
+        $_->{amount}      = sprintf( "%.2f", $_->{amount} );
         $_->{amount}      =~ s/^\-0\.00$/0.00/;
-        $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} ),
+        if (exists($_->{unit_amount})) {
+          $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );
+        }
         push @b, { %$_ }
           if $_->{amount} != 0
           || $discount_show_always
@@ -2715,6 +2718,7 @@ sub _items_cust_bill_pkg {
         # quotation_pkgs are never fees, so don't worry about the case where
         # part_pkg is undefined
 
+        # and I guess they're never bundled either?
         if ( $cust_bill_pkg->setup != 0 ) {
           my $description = $desc;
           $description .= ' Setup'
@@ -2739,7 +2743,8 @@ sub _items_cust_bill_pkg {
           };
         }
 
-      } elsif ( $cust_bill_pkg->pkgnum > 0 ) { # and it's not a quotation_pkg
+      } elsif ( $cust_bill_pkg->pkgnum > 0 ) {
+        # a "normal" package line item (not a quotation, not a fee, not a tax)
 
         warn "$me _items_cust_bill_pkg cust_bill_pkg is non-tax\n"
           if $DEBUG > 1;
@@ -3018,6 +3023,66 @@ sub _items_cust_bill_pkg {
 
         } # recurring or usage with recurring charge
 
+        # decide whether to show active discounts here
+        if (
+            # case 1: we are showing a single line for the package
+            ( !$type )
+            # case 2: we are showing a setup line for a package that has
+            # no base recurring fee
+            or ( $type eq 'S' and $cust_bill_pkg->unitrecur == 0 )
+            # case 3: we are showing a recur line for a package that has 
+            # a base recurring fee
+            or ( $type eq 'R' and $cust_bill_pkg->unitrecur > 0 )
+        ) {
+
+          my @discounts = $cust_bill_pkg->cust_bill_pkg_discount;
+          # special case: if there are old "discount details" on this line 
+          # item, don't show discount line items
+          if ( FS::cust_bill_pkg_detail->count(
+              "detail LIKE 'Includes discount%' AND billpkgnum = " .
+              $cust_bill_pkg->billpkgnum
+             ) > 0 ) {
+             @discounts = ();
+          }
+          if( @discounts ) {
+            warn "$me _items_cust_bill_pkg including discounts for ".
+              $cust_bill_pkg->billpkgnum."\n"
+              if $DEBUG;
+            my $discount_amount = sum( map {$_->amount} @discounts );
+            my $orig_amount = $cust_bill_pkg->setup + $cust_bill_pkg->recur
+                              + $discount_amount;
+            # if multiple discounts apply to the same package, how to display
+            # them? ext_description lines, apparently
+            if ( $d and $cust_bill_pkg->hidden ) {
+              $d->{amount}      += $discount_amount;
+              $d->{orig_amount} += $orig_amount;
+            } else {
+              my @ext;
+              # make a placeholder for the original price, if necessary
+              # (if unit prices are enabled, it won't be necessary)
+              push @ext, '' if !$conf->exists('invoice-unitprice');
+              $d = {
+                _is_discount    => 1,
+                description     => $self->mt('Discount included'),
+                amount          => $discount_amount,
+                orig_amount     => $orig_amount,
+                ext_description => \@ext,
+              };
+              foreach my $cust_bill_pkg_discount (@discounts) {
+                my $def = $cust_bill_pkg_discount->cust_pkg_discount->discount;
+                push @ext, &{$escape_function}( $def->description );
+              }
+            }
+
+            # update the placeholder to show the original price in the 
+            # first ext_description line
+            if ( !$conf->exists('invoice-unitprice') ) {
+              $d->{ext_description}->[0] =
+                sprintf('Original price: %.2f', $d->{orig_amount});
+            }
+          } # if there are any discounts
+        } # if this is an appropriate place to show discounts
+
       } else { # taxes and fees
 
         warn "$me _items_cust_bill_pkg cust_bill_pkg is tax\n"
@@ -3039,13 +3104,14 @@ sub _items_cust_bill_pkg {
 
   }
 
-  foreach ( $s, $r, ($opt{skip_usage} ? () : $u ) ) {
+  foreach ( $s, $r, ($opt{skip_usage} ? () : $u, $d ) ) {
     if ( $_  ) {
       $_->{amount}      = sprintf( "%.2f", $_->{amount} ),
         if exists($_->{amount});
       $_->{amount}      =~ s/^\-0\.00$/0.00/;
-      $_->{unit_amount} = sprintf('%.2f', $_->{unit_amount})
-        if exists($_->{unit_amount});
+      if (exists($_->{unit_amount})) {
+        $_->{unit_amount} = sprintf( "%.2f", $_->{unit_amount} );
+      }
 
       push @b, { %$_ }
         if $_->{amount} != 0
index bc511d9..e5b5f03 100644 (file)
@@ -16,18 +16,17 @@ use Date::Parse;
 
 sub {                 
        my ($cdr, $data, $conf, $param) = @_;
-               $param->{skiprow} = 1 if $data ne 'CallDetail 0'; # skip non-detail records
+               $param->{skiprow} = 1 unless $data =~ 'CallDetail'; # skip non-detail records
        },              # record type
-       'uniqueid',     # unique id  
-       skip(1),        # unknown
+       skip(2),        # unknown, callid ( not unique )
        'src',          # source
        'dst',          # destination
 sub { my ($cdr, $calldate, $param) = @_;
 
-       if ($calldate =~ /^(\d{4})-(\d{2})-(\d{2})\s*(\d{2}):(\d{2}):(\d{2})$/){
+       if ($calldate =~ /^(\d{2})\/(\d{2})\/(\d{4})\s*(\d{2}):(\d{2}):(\d{2})$/){
 
                $cdr->set('calldate', $calldate);
-                my $tmp_date = "$2/$3/$1 $4:$5:$6";
+                my $tmp_date = "$2/$1/$3 $4:$5:$6";
 
                 $tmp_date = str2time($tmp_date);
                 $cdr->set('startdate', $tmp_date);
index f65d495..9e2082f 100644 (file)
@@ -946,7 +946,9 @@ sub _make_lines {
   my $setup = 0;
   my $unitsetup = 0;
   my @setup_discounts = ();
-  my %setup_param = ( 'discounts' => \@setup_discounts );
+  my %setup_param = ( 'discounts'     => \@setup_discounts,
+                      'real_pkgpart'  => $params{real_pkgpart}
+                    );
   my $setup_billed_currency = '';
   my $setup_billed_amount = 0;
   # Conditions for setting setup date and charging the setup fee:
index 593b14e..71445bf 100644 (file)
@@ -53,6 +53,7 @@ old_ for replace operations):
   <LI><code>$cust_name</code> - Customer name (quoted for the shell)
   <LI><code>$pkgnum</code> - Internal package number
   <LI><code>$custnum</code> - Internal customer number
+  <LI><code>$phone_name</code> - Phone name (quoted for the shell)
   <LI><code>$mac_addr</code> - MAC address (Device MAC address insert and delete commands only)
   <LI><code>$devicename</code> - Device type (Device type insert and delete commands only)
 </UL>
@@ -115,6 +116,7 @@ sub _export_command {
   my $cust_name = $cust_pkg ? $cust_pkg->cust_main->name : '';
   $cust_name = shell_quote $cust_name;
   my $sip_password = shell_quote $svc_phone->sip_password;
+  my $phone_name = shell_quote $svc_phone->phone_name;
   #done setting variables for the command
 
   $self->shellcommands_queue( $svc_phone->svcnum,
index be0200c..3180275 100644 (file)
@@ -32,7 +32,7 @@ sub calc_recur {
 
 Takes all the arguments of calc_recur.  Calculates and returns  the amount 
 by which to reduce the recurring fee; also increments months used on the 
-discount and generates an invoice detail describing it.
+discount.
 
 =cut
 
@@ -162,31 +162,34 @@ sub calc_discount {
       'months'         => $months,
     };
     push @{ $param->{'discounts'} }, $cust_bill_pkg_discount;
+    $tot_discount += $amount;
 
     #add details on discount to invoice
-    my $money_char = $conf->config('money_char') || '$';
-    $months = sprintf('%.2f', $months) if $months =~ /\./;
-
-    my $d = 'Includes ';
-    my $format;
-
-    if ( $months eq '1' ) {
-      $d .= "discount of $money_char$amount";
-      $d .= " each" if $cust_pkg->quantity > 1;
-      $format = 'Undiscounted amount: %s%.2f';
-    } else {
-      $d .= 'setup ' if defined $param->{'setup_charge'};
-      $d .= 'discount of '. $discount->description_short;
-      $d .= " for $months months"
-       unless defined $param->{'setup_charge'};
-      $d .= ": $money_char$amount" if $discount->percent;
-      $format = 'Undiscounted monthly amount: %s%.2f';
-    }
+    # no longer! this is now done during rendering based on the existence
+    # of the cust_bill_pkg_discount record
+    #
+    #my $money_char = $conf->config('money_char') || '$';
+    #$months = sprintf('%.2f', $months) if $months =~ /\./;
+
+    #my $d = 'Includes ';
+    #my $format;
+
+    #if ( $months eq '1' ) {
+    #  $d .= "discount of $money_char$amount";
+    #  $d .= " each" if $cust_pkg->quantity > 1;
+    #  $format = 'Undiscounted amount: %s%.2f';
+    #} else {
+    #  $d .= 'setup ' if defined $param->{'setup_charge'};
+    #  $d .= 'discount of '. $discount->description_short;
+    #  $d .= " for $months months"
+    #    unless defined $param->{'setup_charge'};
+    #  $d .= ": $money_char$amount" if $discount->percent;
+    #  $format = 'Undiscounted monthly amount: %s%.2f';
+    #}
+
+    #push @$details, $d;
+    #push @$details, sprintf( $format, $money_char, $br );
 
-    push @$details, $d;
-    push @$details, sprintf( $format, $money_char, $br );
-
-    $tot_discount += $amount;
   }
 
   sprintf('%.2f', $tot_discount);
index 509bf95..bd99899 100644 (file)
                  ) }
             @detail_items )
           {
-            $OUT .=
-              '<tr class="invoice_desc';
             if ( $section->{description_generator} ) {
-              $OUT .= &{$section->{description_generator}}($line);
+              $OUT .= '<tr class="invoice_desc' .
+                      &{$section->{description_generator}}($line);
             } else {
-              $OUT .=  ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
-                       '">'.
-                       '<td align="center">'. 
-                       ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
-                       '<td align="left">'. $line->{'description'}. '</td>'.
-                       ( $unitprices 
-                           ? '<td align="right">'. $line->{'unit_amount'}. '</td>'.
-                             '<td align="right">'. $line->{'quantity'}. '</td>'
-                           : ''
-                       ).
-
-                       '<td align="right">'. $line->{'amount'}. '</td>';
+              my $class = 'invoice_desc_more';
+              if ( $line->{'ref'} and $line->{'ref'} ne $lastref ) {
+                # then it's a new package (not a continuation)
+                $class = 'invoice_desc';
+              }
+              $OUT .= '<tr class="'.$class.'">
+                       <td align="center">';
+              if ( $line->{'ref'} ne $lastref ) {
+                $OUT .= $line->{'ref'};
+              }
+              $OUT .= '</td>
+                       <td align="left">'. $line->{'description'}. '</td>';
+              if ( $unitprices ) {
+                $OUT .= 
+                  '<td align="right">'. $line->{'unit_amount'}. '</td>'.
+                  '<td align="right">'. $line->{'quantity'}. '</td>';
+              }
+              $OUT .= '<td align="right">'. $line->{'amount'}. '</td>';
             }
             $OUT .= '</tr>';
             $lastref = $line->{'ref'};
index 6a5b53d..99d12d5 100644 (file)
 \newcommand{\FSdesc}[5]{\r
   \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} &\r
   \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} &\r
-[@-- $unitprices ? '  \multicolumn{1}{r}{\textbf{\dollar #3}} &'."\n".\r
+[@-- $unitprices ? '  \multicolumn{1}{r}{\textbf{#3}} &'."\n".\r
                    '  \multicolumn{1}{r}{\textbf{#4}} &'."\n"\r
                  : ''\r
 --@]\r
-  \multicolumn{1}{r}{\textbf{\dollar #5}}\\\r
+  \multicolumn{1}{r}{\textbf{#5}}\\\r
 }\r
 % ...extended description...\r
 \newcommand{\FSextdesc}[1]{\r
         } else {\r
           $OUT .= '\FSdesc'.\r
                   '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'.\r
-                  '{' . $line->{'description'} . '}' .\r
-                  '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'.\r
-                  '{' . ( $unitprices ? $line->{'quantity'} : ''  ) . '}' .\r
-                  '{' . $line->{'amount'} . "}${rowbreak}\n";\r
+                  '{' . $line->{'description'} . '}' ;\r
+          if ( $unitprices and length($line->{'unit_amount'}) ) {\r
+            # then show the unit amount and quantity\r
+            $OUT .= \r
+                '{\\dollar' . $line->{'unit_amount'} . '}'.\r
+                '{'         . $line->{'quantity'}    . '}';\r
+          } else {\r
+            # leave those columns blank\r
+            $OUT .= '{}{}';\r
+          }\r
+          $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n";\r
         }\r
         $lastref = $line->{'ref'};\r
 \r
index be6ce51..d82978c 100755 (executable)
@@ -17,6 +17,9 @@ TMP     = $(CURDIR)/debian/$(PACKAGE)
 ##this is gotten from dbconfig-common
 #DB_TYPE = db_type_is_configured_during_pkg_install_by_dbconfig-common_not_at_build_time
 
+#Data source
+DATASOURCE = DBI:${DB_TYPE}:dbname=freeside
+
 #no chance, it doesn't get backslash-interpolted now...
 ##DEBVERSION                    = `head -1 debian/changelog | cut -d')' -f1 | cut -c11-`
 #DEBVERSION                    = 1.7.3~rc2-1
@@ -36,7 +39,8 @@ export FREESIDE_LOG = $(TMP)/usr/local/etc/freeside
 export FREESIDE_LOCK = $(TMP)/usr/local/etc/freeside
 export FREESIDE_CACHE = $(TMP)/usr/local/etc/freeside
 export FREESIDE_EXPORT = $(TMP)/usr/local/etc/freeside
-expory FREESIDE_SS = $(TMP)/usr/share/docs/freeside
+export FREESIDE_SS = $(TMP)/usr/share/docs/freeside
+export DIST_CONF = ${FREESIDE_CONF}/default_conf
 
 #XXX own subdir?
 #export MASON_HANDLER          = /usr/share/freeside/handler.pl
@@ -89,9 +93,11 @@ build-stamp:
        dh_testdir
        # Add commands to compile the package here
        
-       ( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor )
-
-       $(MAKE) -e DESTDIR=${TMP}-lib perl-modules
+       ( cd FS/ && $(PERL) Makefile.PL INSTALLDIRS=vendor && [ -e Makefile ] || perl Makefile.PL && make )
+       
+       #install this for freeside-setup
+       install -d $(DIST_CONF)
+       install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
 
        #TEST#
 
@@ -118,15 +124,39 @@ install-stamp: build-stamp
        # Add here commands to install package into
        # debian/<package>-whatever.
 
-       ( cd FS/ && $(MAKE) -e DESTDIR=$(TMP)-lib install )
-
        install -d $(FREESIDE_DOCUMENT_ROOT)
+       install -d $(TMP)-lib/usr/bin/
        install -d $(TMP)-webui/usr/local/etc/freeside/
        install -d $(TMP)/usr/local/etc/freeside/
        install -d $(FREESIDE_CACHE)/masondata #MASONDATA
 
-        # Install configuration files, hack what to do???
-       $(MAKE) -e DESTDIR=$(TMP) create-config
+       ( cd FS/ && $(MAKE) -e DESTDIR=${TMP}-lib install)
+
+        # Install configuration files
+       install -d -o freeside ${FREESIDE_CONF}
+
+       touch ${FREESIDE_CONF}/secrets
+       chown freeside ${FREESIDE_CONF}/secrets
+       chmod 600 ${FREESIDE_CONF}/secrets
+
+       /bin/echo -e "${DATASOURCE}\n${DB_USER}\n${DB_PASSWORD}" >${FREESIDE_CONF}/secrets
+       chmod 600 ${FREESIDE_CONF}/secrets
+       chown freeside ${FREESIDE_CONF}/secrets
+
+       mkdir "${FREESIDE_CACHE}/counters.${DATASOURCE}"
+       chown freeside "${FREESIDE_CACHE}/counters.${DATASOURCE}"
+
+       mkdir "${FREESIDE_CACHE}/cache.${DATASOURCE}"
+       chown freeside "${FREESIDE_CACHE}/cache.${DATASOURCE}"
+
+       mkdir "${FREESIDE_EXPORT}/export.${DATASOURCE}"
+       chown freeside "${FREESIDE_EXPORT}/export.${DATASOURCE}"
+
+       #install this for freeside-setup
+       install -d $(DIST_CONF)
+       #install conf/[a-z]* $(DEFAULT_CONF)
+       #CVS is not [a-z]
+       install `ls -d conf/[a-z]* | grep -v CVS | grep -v '^conf/registries'` $(DIST_CONF)
 
        # Install interfaces
        $(MAKE) -e DESTDIR=$(TMP)-webui install-docs
@@ -187,9 +217,11 @@ install-stamp: build-stamp
                --with-web-handler=modperl2 )
 
         ##(create-rt)
-        #$(MAKE) -e create-rt
+       #$(MAKE) -e DESTDIR=${TMP}-lib create-rt
        install -d $(RT_PATH)
-       ( cd rt; make install )
+       install -d $(RT_PATH)/share
+
+       ( cd rt; $(MAKE) install )
        
        ##hack the build dir out of RT.  yeah, sucky.
 
@@ -212,7 +244,7 @@ install-stamp: build-stamp
 
        dh_install
 
-       touch $@
+       #touch $@
 
 binary-arch:
 # We have nothing to do here for an architecture-independent package
@@ -234,7 +266,6 @@ binary-indep: build install
        dh_link
        dh_compress 
        dh_fixperms
-       dh_installdeb
        dh_gencontrol
        dh_md5sums
        dh_builddeb
index 9cee01d..abf1770 100644 (file)
@@ -47,7 +47,7 @@ if ( $single_domain ) {
 <TR>
   <TH ALIGN="right">Password </TH>
   <TD>
-    <INPUT TYPE="password" NAME="password"> <A HREF="<%= $selfurl %>?action=forgot_password">Forgot your password?</A>
+   <INPUT TYPE="password" NAME="password"> <A HREF="<%= $selfurl %>?<%= "agentnum=$agentnum&" if $agentnum; %>action=forgot_password">Forgot your password?</A>
   </TD>
 </TR>
 <TR>
index 4e21ad8..b008fbf 100755 (executable)
@@ -936,11 +936,17 @@ sub delete_svc {
 }
 
 sub view_usage {
-  list_svcs(
+  my $res = list_svcs(
     'session_id'  => $session_id,
     'svcdb'       => [ 'svc_acct', 'svc_phone', 'svc_port', ],
     'ncancelled'  => 1,
   );
+  if ($res->{hide_usage}) {
+    $action = 'myaccount';
+    return myaccount();
+  } else {
+    return $res;
+  }
 }
 
 sub real_port_graph {
index c43f7d3..2aa7c1e 100644 (file)
@@ -18,8 +18,6 @@
     '';
 %>
 <%= include('header', 'Account usage') %>
-<%= if( $hide_usage ){ $OUT .= '<' . '!--' } %>
-
 
 <%= if ( $error ) {
   $OUT .= qq!<FONT SIZE="+1" COLOR="#ff0000">$error</FONT><BR><BR>!;
@@ -218,6 +216,5 @@ foreach my $svc_port ( @svc_port ) {
 
 
 </TD></TR></TABLE>
-<%= if( $hide_usage ){ $OUT .= '--'. '>' } %>
 <%= include('footer') %>