From: ivan Date: Thu, 27 Dec 2001 09:26:14 +0000 (+0000) Subject: service and package disable! X-Git-Tag: freeside_1_4_0pre11~146 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=cf16b23820da69e3c8d0156ae27e21c635bf1ec5 service and package disable! --- diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 38f4390db..6c0f5f819 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -211,7 +211,7 @@ sub qsearch { $statement .= ' WHERE '. join(' AND ', map { if ( ! defined( $record->{$_} ) || $record->{$_} eq '' ) { if ( driver_name =~ /^Pg$/i ) { - "$_ IS NULL"; + qq-( $_ IS NULL OR $_ = '' )-; } else { qq-( $_ IS NULL OR $_ = "" )-; } diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index ceb2a0128..be2ad935f 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -60,6 +60,8 @@ inherits from FS::Record. The following fields are currently supported: =item plandata - Price plan data +=item disabled - Disabled flag, empty or `Y' + =back setup and recur are evaluated as Safe perl expressions. You can use numbers @@ -147,6 +149,9 @@ sub check { $self->recurtax =~ /^(Y?)$/ or return "Illegal recrutax: ". $self->recurtax; $self->recurtax($1); + $self->disabled =~ /^(Y?)$/ or return "Illegal disabled: ". $self->disabled; + $self->disabled($1); + ''; } @@ -185,7 +190,7 @@ sub svcpart { =head1 VERSION -$Id: part_pkg.pm,v 1.4 2001-10-20 12:17:59 ivan Exp $ +$Id: part_pkg.pm,v 1.5 2001-12-27 09:26:13 ivan Exp $ =head1 BUGS diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 2b3f3f309..18760c39a 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -40,6 +40,8 @@ FS::Record. The following fields are currently supported: =item svcdb - table used for this service. See L, L, and L, among others. +=item disabled - Disabled flag, empty or `Y' + =back =head1 METHODS @@ -235,6 +237,7 @@ sub check { my @fields = eval { fields( $recref->{svcdb} ) }; #might die return "Unknown svcdb!" unless @fields; +##REPLACED BY part_svc_column # my $svcdb; # foreach $svcdb ( qw( # svc_acct svc_acct_sm svc_domain @@ -259,6 +262,9 @@ sub check { # } # } + $self->disabled =~ /^(Y?)$/ or return "Illegal disabled: ". $self->disabled; + $self->disabled($1); + ''; #no error } @@ -295,7 +301,7 @@ sub all_part_svc_column { =head1 VERSION -$Id: part_svc.pm,v 1.6 2001-09-12 15:45:01 ivan Exp $ +$Id: part_svc.pm,v 1.7 2001-12-27 09:26:13 ivan Exp $ =head1 BUGS @@ -306,9 +312,9 @@ should be fixed. =head1 SEE ALSO -L, L, L, L, -L, L, L, schema.html from the -base documentation. +L, L, L, +L, L, L, L, +schema.html from the base documentation. =cut diff --git a/FS/bin/freeside-overdue b/FS/bin/freeside-overdue index 65941ce95..0c62b99c1 100755 --- a/FS/bin/freeside-overdue +++ b/FS/bin/freeside-overdue @@ -48,10 +48,10 @@ foreach $cust_main ( qsearch('cust_main',{} ) ) { $cust_main->balance_date(time-$opt{d} * 86400); } - if ( $opt{l} ) { - print "\n\tCharging late fee of \$$opt{l}" unless $opt{q}; - - } +# if ( $opt{l} ) { +# print "\n\tCharging late fee of \$$opt{l}" unless $opt{q}; +# +# } foreach $cust_pkg ( qsearch( 'cust_pkg', { 'custnum' => $cust_main->custnum } ) ) { @@ -83,7 +83,7 @@ foreach $cust_main ( qsearch('cust_main',{} ) ) { sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { - $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/\.]*)$/ || die "Illegal arguement \"$ARGV[$_]\""; $ARGV[$_]=$1; } } diff --git a/README.1.4.0pre4567-8 b/README.1.4.0pre4567-8 new file mode 100644 index 000000000..2e2138b37 --- /dev/null +++ b/README.1.4.0pre4567-8 @@ -0,0 +1,11 @@ +the following is necessary to upgrade from 1.4.0pre (4 thru 7) to 1.4.0pre8 + +install the perl modules and httemplate as per install.html or upgrade8.html + +ALTER TABLE part_pkg ADD disabled char(1) NULL; +ALTER TABLE part_svc ADD disabled char(1) NULL; + +Run bin/dbdef-create + +Restart Apache and freeside-queued + diff --git a/bin/fs-setup b/bin/fs-setup index da6c167e9..e7aa3b0d9 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.67 2001-11-06 17:48:17 ivan Exp $ +# $Id: fs-setup,v 1.68 2001-12-27 09:26:13 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -548,6 +548,7 @@ sub tables_hash_hack { 'recurtax', 'char', 'NULL', 1, 'plan', 'varchar', 'NULL', $char_d, 'plandata', 'text', 'NULL', '', + 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'pkgpart', 'unique' => [ [] ], @@ -590,6 +591,7 @@ sub tables_hash_hack { 'svcpart', 'int', '', '', 'svc', 'varchar', '', $char_d, 'svcdb', 'varchar', '', $char_d, + 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'svcpart', 'unique' => [ [] ], diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index 43683b01d..b0d28be8c 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -57,7 +57,7 @@ while (1) { warn "[fs_signup_server] Sending package definitions...\n" if $Debug; my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } - qsearch( 'part_pkg', {} ); + qsearch( 'part_pkg', { 'disabled' => '' } ); print $writer $data = join("\n", ( scalar(@part_pkg) || die "no usable package definitions, agent $agentnum" ), map { diff --git a/htetc/global.asa b/htetc/global.asa index dc75822ff..c22afc132 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -29,7 +29,7 @@ sub Script_OnFlush { $$ref =~ s/<\/BODY>[\s\n]*<\/HTML>[\s\n]*$//i or warn "can't remove"; - $$ref .= '
'. encode_entities(dbh->sprintProfile()). '
'; + $$ref .= '
'. ("\n"x96). encode_entities(dbh->sprintProfile()). '
'; $$ref .= ''; diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index e0d25f67d..d0b572aa4 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $p $part_pkg ); @@ -18,12 +18,33 @@ $cgi = new CGI; $p = popurl(2); +my %search; +if ( $cgi->param('showdisabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} + +my @part_pkg = qsearch('part_pkg', \%search ); +my $total = scalar(@part_pkg); + print header("Package Definition Listing",menubar( 'Main Menu' => $p, -)), "One or more services are grouped together into a package and given", - " pricing information. Customers purchase packages", - " rather than purchase services directly.

", - &table(), <
". + "$total packages "; + +if ( $cgi->param('showdisabled') ) { + $cgi->param('showdisabled', 0); + print qq!( hide disabled packages )!; +} else { + $cgi->param('showdisabled', 1); + print qq!( show disabled packages )!; +} + +my $colspan = $cgi->param('showdisabled') ? 2 : 3; +print &table(), < Package Comment @@ -37,7 +58,7 @@ END foreach $part_pkg ( sort { $a->getfield('pkgpart') <=> $b->getfield('pkgpart') -} qsearch('part_pkg',{}) ) { +} @part_pkg ) { my($hashref)=$part_pkg->hashref; my(@pkg_svc)=grep $_->getfield('quantity'), qsearch('pkg_svc',{'pkgpart'=> $hashref->{pkgpart} }); @@ -54,9 +75,16 @@ foreach $part_pkg ( sort { } print < - - $hashref->{pkgpart} - + $hashref->{pkgpart} +END + + unless ( $cgi->param('showdisabled') ) { + print ""; + print "DISABLED" if $hashref->{disabled}; + print ''; + } + + print <$hashref->{pkg} $hashref->{comment} $hashref->{freq} diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 8a564ba9a..da523ca51 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -1,10 +1,30 @@ - + +<% + +my %search; +if ( $cgi->param('showdisabled') ) { + %search = (); +} else { + %search = ( 'disabled' => '' ); +} + +my @part_svc = qsearch('part_svc', \%search ); +my $total = scalar(@part_svc); + +%> <%= header('Service Definition Listing', menubar( 'Main Menu' => $p) ) %> Services are items you offer to your customers.

+<%= $total %> services +<%= $cgi->param('showdisabled') + ? do { $cgi->param('showdisabled', 0); + '( hide disabled services )'; } + : do { $cgi->param('showdisabled', 1); + '( show disabled services )'; } +%> - + @@ -12,7 +32,7 @@ <% foreach my $part_svc ( sort { $a->getfield('svcpart') <=> $b->getfield('svcpart') - } qsearch('part_svc',{}) ) { + } @part_svc ) { my($hashref)=$part_svc->hashref; my($svcdb)=$hashref->{svcdb}; my @fields = @@ -26,6 +46,10 @@ +<% unless ( $cgi->param('showdisabled') ) { %> + +<% } %>
Serviceparam('showdisabled') ? 2 : 3 %>>Service Table Field Modifier
> <%= $hashref->{svcpart} %>> + <%= $hashref->{disabled} ? 'DISABLED' : '' %>> <%= $hashref->{svc} %> > diff --git a/httemplate/edit/agent_type.cgi b/httemplate/edit/agent_type.cgi index 849da8113..a2595bf41 100755 --- a/httemplate/edit/agent_type.cgi +++ b/httemplate/edit/agent_type.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $agent_type $action $hashref $p $part_pkg ); @@ -50,7 +50,7 @@ print <
Select which packages agents of this type may sell to customers
END -foreach $part_pkg ( qsearch('part_pkg',{}) ) { +foreach $part_pkg ( qsearch('part_pkg',{ 'disabled' => '' }) ) { print qq!
+# use vars qw( $cgi $custnum $action $cust_main $p1 @agents $agentnum $last $first $ss $company $address1 $address2 $city $zip @@ -412,7 +412,7 @@ unless ( $custnum ) { #eslaf my @part_pkg = grep { $_->svcpart('svc_acct') && $pkgpart->{ $_->pkgpart } } - qsearch( 'part_pkg', {} ); + qsearch( 'part_pkg', { 'disabled' => '' } ); if ( @part_pkg ) { diff --git a/httemplate/edit/cust_pkg.cgi b/httemplate/edit/cust_pkg.cgi index 7d5bb3fd3..73b190786 100755 --- a/httemplate/edit/cust_pkg.cgi +++ b/httemplate/edit/cust_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi %pkg %comment $custnum $p1 @cust_pkg @@ -17,7 +17,7 @@ $cgi = new CGI; %pkg = (); %comment = (); -foreach (qsearch('part_pkg', {})) { +foreach (qsearch('part_pkg', { 'disabled' => '' })) { $pkg{ $_ -> getfield('pkgpart') } = $_->getfield('pkg'); $comment{ $_ -> getfield('pkgpart') } = $_->getfield('comment'); } @@ -83,6 +83,7 @@ print qq!!; foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { $pkgparts++; my($pkgpart)=$type_pkgs->pkgpart; + next unless exists $pkg{$pkgpart}; #skip disabled ones print qq!! if ( $count == 0 ); my $value = $cgi->param("pkg$pkgpart") || 0; print < + <% @@ -76,7 +76,7 @@ print '
'; #print qq!!, print "Package Part #", $hashref->{pkgpart} ? $hashref->{pkgpart} : "(NEW)"; -print itable("#cccccc",2), <
@@ -96,6 +96,12 @@ print '{recurtax} eq "Y"; print '>'; +print ''; + +print '
Package (customer-visable)
Comment (customer-hidden)
Frequency (months) of recurring fee
Disable new orders'; +print '{disabled} eq "Y"; +print '>'; print '
'; my $thead = "\n\n". ntable('#cccccc', 2). < '' } ); foreach my $part_svc ( @part_svc ) { my $svcpart = $part_svc->svcpart; my $pkg_svc = qsearchs( 'pkg_svc', { @@ -232,7 +238,7 @@ function fixup(what) { <% foreach my $f ( qw( pkg comment freq ), @fixups ) { %> what.<%= $f %>.value = document.dummy.<%= $f %>.value; <% } %> -<% foreach my $f ( qw( setuptax recurtax ) ) { %> +<% foreach my $f ( qw( setuptax recurtax disabled ) ) { %> if (document.dummy.<%= $f %>.checked) what.<%= $f %>.value = 'Y'; else @@ -270,6 +276,7 @@ if (document.getElementById) { + <% foreach my $f ( @fixups ) { %> <% } %> @@ -284,7 +291,7 @@ if ( $cgi->param('pkgnum') ) { %> -<%= itable("#cccccc",2) %> +<%= ntable("#cccccc",2) %> <% my $href = $plans{$layer}->{'fields'}; foreach my $field ( keys %{ $href } ) { %> diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 29778567e..f2555a29f 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -1,4 +1,4 @@ - + <% my $part_svc; if ( $cgi->param('error') ) { #error @@ -45,8 +45,9 @@ function visualize(what) { Service Part #<%= $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %>

-Service -

+Service
+Disable new orders {disabled} eq 'Y' ? ' CHECKED' : '' %>>
+
Services are items you offer to your customers.
  • svc_acct - Shell accounts, POP mailboxes, SLIP/PPP and ISDN accounts
  • svc_domain - Domains @@ -167,12 +168,17 @@ if (document.getElementById) { function fixup(what) { what.svc.value = document.dummy.svc.value; - what.svcdb.value = document.dummy.svcdb.options[document.dummy.svcdb.selectedIndex].value + what.svcdb.value = document.dummy.svcdb.options[document.dummy.svcdb.selectedIndex].value; + if (document.dummy.disabled.checked) + what.disabled.value = 'Y'; + else + what.disabled.value = ''; } + <% print "$svcdb" unless $svcdb eq 'konq_kludge'; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index c64d49219..08bc9b723 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw( $cgi $pkgpart $old $new $part_svc $error $dbh ); @@ -26,8 +26,9 @@ $cgi->param('plandata', join('', map { "$_=". $cgi->param($_). "\n" } @plandata ) ); -$cgi->param('setuptax','') unless defined $cgi->param('setuptax'); -$cgi->param('recurtax','') unless defined $cgi->param('recurtax'); +foreach (qw( setuptax recurtax disabled )) { + $cgi->param($_, '') unless defined $cgi->param($_); +} $new = new FS::part_pkg ( { map { diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index e84fa0756..8710dd19d 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -1,5 +1,5 @@ <% -# +# use strict; use vars qw ( $cgi $query $custnum $cust_main $hashref $agent $referral @@ -268,8 +268,11 @@ print '
    '. foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) { my $pkgpart = $type_pkgs->pkgpart; - my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } ) - or do { warn "unknown type_pkgs.pkgpart $pkgpart"; next; }; +# my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } ) +# or do { warn "unknown type_pkgs.pkgpart $pkgpart"; next; }; + my $part_pkg = + qsearchs('part_pkg', { 'pkgpart' => $pkgpart, 'disabled' => '' } ) + or next; print qq!