From: Ivan Kohler Date: Tue, 18 Nov 2014 19:41:35 +0000 (-0800) Subject: Merge branch 'master' of git.freeside.biz:/home/git/freeside X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=707368aa7db1cecdd05b74c8531249a1e1370823;hp=6bead8d6f196872b9863aa902341697b43a5b067 Merge branch 'master' of git.freeside.biz:/home/git/freeside --- diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index ec114ff09..61082bd9e 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -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'; diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index f70ac3ce2..0928ee52f 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -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 diff --git a/FS/FS/cdr/cx3.pm b/FS/FS/cdr/cx3.pm index bc511d966..e5b5f0350 100644 --- a/FS/FS/cdr/cx3.pm +++ b/FS/FS/cdr/cx3.pm @@ -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); diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index f65d495cf..9e2082fc3 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -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: diff --git a/FS/FS/part_export/phone_shellcommands.pm b/FS/FS/part_export/phone_shellcommands.pm index 593b14e47..71445bf27 100644 --- a/FS/FS/part_export/phone_shellcommands.pm +++ b/FS/FS/part_export/phone_shellcommands.pm @@ -53,6 +53,7 @@ old_ for replace operations):
  • $cust_name - Customer name (quoted for the shell)
  • $pkgnum - Internal package number
  • $custnum - Internal customer number +
  • $phone_name - Phone name (quoted for the shell)
  • $mac_addr - MAC address (Device MAC address insert and delete commands only)
  • $devicename - Device type (Device type insert and delete commands only) @@ -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, diff --git a/FS/FS/part_pkg/discount_Mixin.pm b/FS/FS/part_pkg/discount_Mixin.pm index be0200c77..31802758c 100644 --- a/FS/FS/part_pkg/discount_Mixin.pm +++ b/FS/FS/part_pkg/discount_Mixin.pm @@ -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); diff --git a/conf/invoice_html b/conf/invoice_html index 509bf950d..bd99899e0 100644 --- a/conf/invoice_html +++ b/conf/invoice_html @@ -161,23 +161,28 @@ ) } @detail_items ) { - $OUT .= - '{description_generator}}($line); } else { - $OUT .= ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ). - '">'. - ''. - ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). ''. - ''. $line->{'description'}. ''. - ( $unitprices - ? ''. $line->{'unit_amount'}. ''. - ''. $line->{'quantity'}. '' - : '' - ). - - ''. $line->{'amount'}. ''; + 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 .= ' + '; + if ( $line->{'ref'} ne $lastref ) { + $OUT .= $line->{'ref'}; + } + $OUT .= ' + '. $line->{'description'}. ''; + if ( $unitprices ) { + $OUT .= + ''. $line->{'unit_amount'}. ''. + ''. $line->{'quantity'}. ''; + } + $OUT .= ''. $line->{'amount'}. ''; } $OUT .= ''; $lastref = $line->{'ref'}; diff --git a/conf/invoice_latex b/conf/invoice_latex index 6a5b53dd5..99d12d5c7 100644 --- a/conf/invoice_latex +++ b/conf/invoice_latex @@ -187,11 +187,11 @@ \newcommand{\FSdesc}[5]{ \multicolumn{1}{c}{\rule{0pt}{2.5ex}\textbf{#1}} & \multicolumn{[@-- $unitprices ? '4' : '6' --@]}{l}{\textbf{#2}} & -[@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{\dollar #3}} &'."\n". +[@-- $unitprices ? ' \multicolumn{1}{r}{\textbf{#3}} &'."\n". ' \multicolumn{1}{r}{\textbf{#4}} &'."\n" : '' --@] - \multicolumn{1}{r}{\textbf{\dollar #5}}\\ + \multicolumn{1}{r}{\textbf{#5}}\\ } % ...extended description... \newcommand{\FSextdesc}[1]{ @@ -333,10 +333,17 @@ } else { $OUT .= '\FSdesc'. '{' . ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ) . '}'. - '{' . $line->{'description'} . '}' . - '{' . ( $unitprices ? $line->{'unit_amount'} : '' ) . '}'. - '{' . ( $unitprices ? $line->{'quantity'} : '' ) . '}' . - '{' . $line->{'amount'} . "}${rowbreak}\n"; + '{' . $line->{'description'} . '}' ; + if ( $unitprices and length($line->{'unit_amount'}) ) { + # then show the unit amount and quantity + $OUT .= + '{\\dollar' . $line->{'unit_amount'} . '}'. + '{' . $line->{'quantity'} . '}'; + } else { + # leave those columns blank + $OUT .= '{}{}'; + } + $OUT .= '{\\dollar' . $line->{'amount'} . "}${rowbreak}\n"; } $lastref = $line->{'ref'}; diff --git a/debian/rules b/debian/rules index be6ce5111..d82978cfd 100755 --- a/debian/rules +++ b/debian/rules @@ -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/-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 diff --git a/fs_selfservice/FS-SelfService/cgi/login.html b/fs_selfservice/FS-SelfService/cgi/login.html index 9cee01d14..abf177080 100644 --- a/fs_selfservice/FS-SelfService/cgi/login.html +++ b/fs_selfservice/FS-SelfService/cgi/login.html @@ -47,7 +47,7 @@ if ( $single_domain ) { Password - Forgot your password? + action=forgot_password">Forgot your password? diff --git a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi index 4e21ad8df..b008fbf8b 100755 --- a/fs_selfservice/FS-SelfService/cgi/selfservice.cgi +++ b/fs_selfservice/FS-SelfService/cgi/selfservice.cgi @@ -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 { diff --git a/fs_selfservice/FS-SelfService/cgi/view_usage.html b/fs_selfservice/FS-SelfService/cgi/view_usage.html index c43f7d3da..2aa7c1efb 100644 --- a/fs_selfservice/FS-SelfService/cgi/view_usage.html +++ b/fs_selfservice/FS-SelfService/cgi/view_usage.html @@ -18,8 +18,6 @@ ''; %> <%= include('header', 'Account usage') %> -<%= if( $hide_usage ){ $OUT .= '<' . '!--' } %> - <%= if ( $error ) { $OUT .= qq!$error

    !; @@ -218,6 +216,5 @@ foreach my $svc_port ( @svc_port ) { -<%= if( $hide_usage ){ $OUT .= '--'. '>' } %> <%= include('footer') %>