X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_pkg.cgi;h=12179eacaea28179f8161afa90159bd791979765;hp=7dfacf1895859694f74cfed7e27b8bb73c55c72a;hb=4bf86e5f7f44e77159564804d09e0938a8edc905;hpb=7fc18b419e3cec20eb7c898017673b40a7424cde diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 7dfacf189..12179eaca 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -43,10 +43,16 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } else { - my $unconf = ''; + my $qual = ''; if ( $query eq 'pkgnum' ) { $sortby=\*pkgnum_sort; + } elsif ( $query eq 'SUSP_pkgnum' ) { + + $sortby=\*pkgnum_sort; + + $qual = 'WHERE susp IS NOT NULL AND susp != 0'; + } elsif ( $query eq 'APKG_pkgnum' ) { $sortby=\*pkgnum_sort; @@ -86,8 +92,8 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { WHERE cust_pkg.pkgnum = cust_svc.pkgnum AND cust_svc.svcpart = pkg_svc.svcpart AND cust_pkg.pkgpart = pkg_svc.pkgpart - GROUP BY cust_svc.pkgnum,cust_svc.svcnum"; - $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; + GROUP BY cust_svc.pkgnum,cust_svc.svcpart"; + my $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; $sth->execute or die "Error executing \"$query\": ". $sth->errstr; @@ -101,12 +107,12 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { AND pkg_svc.quantity != 0;"; $sth = dbh->prepare($query) or die dbh->errstr. " preparing $query"; $sth->execute or die "Error executing \"$query\": ". $sth->errstr; - $unconf = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum - WHERE temp2_$$.pkgnum IS NOT NULL"; + $qual = " LEFT JOIN temp2_$$ ON cust_pkg.pkgnum = temp2_$$.pkgnum + WHERE temp2_$$.pkgnum IS NOT NULL"; } else { - $unconf = " + $qual = " WHERE 0 < ( SELECT count(*) FROM pkg_svc WHERE pkg_svc.pkgpart = cust_pkg.pkgpart @@ -120,21 +126,18 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { } } else { - die "Empty QUERY_STRING!"; + die "Empty or unknown QUERY_STRING!"; } - my $statement = "SELECT COUNT(*) FROM cust_pkg $unconf"; + my $statement = "SELECT COUNT(*) FROM cust_pkg $qual"; my $sth = dbh->prepare($statement) or die dbh->errstr." preparing $statement"; $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; $total = $sth->fetchrow_arrayref->[0]; - #if ( driver_name eq 'mysql' ) { #remove ORDER BY for mysql? hua? - # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf $limit" ); - #} else { - # @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); - #} - @cust_pkg = qsearch('cust_pkg',{}, '', "$unconf ORDER BY pkgnum $limit" ); + my $tblname = driver_name eq 'mysql' ? 'cust_pkg.' : ''; + @cust_pkg = + qsearch('cust_pkg',{}, '', "$qual ORDER BY ${tblname}pkgnum $limit" ); if ( driver_name eq 'mysql' ) { $query = "DROP TABLE temp1_$$,temp2_$$;"; @@ -191,6 +194,12 @@ if ( scalar(@cust_pkg) == 1 ) { Package Setup +END + + print 'Last
bill
' + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <Next
bill
Susp. Expire @@ -200,17 +209,10 @@ if ( scalar(@cust_pkg) == 1 ) { company END -if ( defined dbdef->table('cust_main')->column('ship_last') ) { - print <(service) name - company -END -} + print '(service) namecompany' + if defined dbdef->table('cust_main')->column('ship_last'); -print <Services - -END + print 'Services'; my $n1 = ''; my(%saw,$cust_pkg); @@ -241,6 +243,12 @@ END $cust_main ? $cust_main->first : '', $cust_main ? $cust_main->company : '', ); + + my $last_bill = $cust_pkg->getfield('last_bill') + ? time2str("%D", $cust_pkg->getfield('last_bill') ) + : '' + if defined dbdef->table('cust_pkg')->column('last_bill'); + my($ship_last, $ship_first, $ship_company); if ( defined dbdef->table('cust_main')->column('ship_last') ) { ($ship_last, $ship_first, $ship_company) = ( @@ -266,11 +274,17 @@ END my $p = popurl(2); print $n1, <$pkgnum - $pkg - $setup - $bill - $susp - $expire - $cancel + $setup +END + + print "$last_bill" + if defined dbdef->table('cust_pkg')->column('last_bill'); + + print <$bill + $susp + $expire + $cancel END if ( $cust_main ) { print <