From 98fc23b80dbc4935ff7a6efeb49fd3876b96f029 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Nov 2003 08:18:23 +0000 Subject: also set default latex template for late bill templates --- FS/FS/part_bill_event.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FS/FS/part_bill_event.pm b/FS/FS/part_bill_event.pm index 9e5d82161..86f929424 100644 --- a/FS/FS/part_bill_event.pm +++ b/FS/FS/part_bill_event.pm @@ -160,6 +160,12 @@ sub check { join("\n", $conf->config('invoice_template') ) ); } + unless ( $conf->exists("invoice_latex_$name") ) { + $conf->set( + "invoice_latex_$name" => + join("\n", $conf->config('invoice_latex') ) + ); + } } $self->SUPER::check; -- cgit v1.2.1 From 281d9b3d2f0f955c159275cafe405f73c88733ba Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Nov 2003 08:32:40 +0000 Subject: option to send statements when a payment or credit is applied --- FS/FS/Conf.pm | 7 +++++++ FS/FS/cust_bill_pay.pm | 19 +++++++++++++------ FS/FS/cust_credit_bill.pm | 33 +++++++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index b30beafaf..d911480df 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -491,6 +491,13 @@ httemplate/docs/config.html 'select_enum' => [ '', 'Payable upon receipt', 'Net 10', 'Net 15', 'Net 30', 'Net 45', 'Net 60' ], }, + { + 'key' => 'invoice_send_receipts', + 'section' => 'billing', + 'description' => 'Send receipts for payments and credits.', + 'type' => 'checkbox', + }, + { 'key' => 'lpr', 'section' => 'required', diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm index 5f4a49144..c8b5525ea 100644 --- a/FS/FS/cust_bill_pay.pm +++ b/FS/FS/cust_bill_pay.pm @@ -1,13 +1,18 @@ package FS::cust_bill_pay; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $conf ); use FS::Record qw( qsearch qsearchs dbh ); use FS::cust_bill; use FS::cust_pay; @ISA = qw( FS::Record ); +#ask FS::UID to run this stuff for us later +FS::UID->install_callback( sub { + $conf = new FS::Conf; +} ); + =head1 NAME FS::cust_bill_pay - Object methods for cust_bill_pay records @@ -101,7 +106,8 @@ sub insert { " greater than cust_pay.paid ". $cust_pay->paid; } - my $cust_bill = qsearchs('cust_bill', { 'invnum' => $self->invnum } ) or do { + my $cust_bill = $self->cust_bill; + unless ( $cust_bill ) { $dbh->rollback if $oldAutoCommit; return "unknown cust_bill.invnum: ". $self->invnum; }; @@ -120,6 +126,11 @@ sub insert { $dbh->commit or die $dbh->errstr if $oldAutoCommit; + if ( $conf->exists('invoice_send_receipts') ) { + my $send_error = $cust_bill->send; + warn "Error sending receipt: $send_error\n" if $send_error; + } + ''; } @@ -197,10 +208,6 @@ sub cust_bill { =back -=head1 VERSION - -$Id: cust_bill_pay.pm,v 1.13 2003-08-05 00:20:41 khoff Exp $ - =head1 BUGS Delete and replace methods. diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm index a54acb683..0bbc656ea 100644 --- a/FS/FS/cust_credit_bill.pm +++ b/FS/FS/cust_credit_bill.pm @@ -1,7 +1,7 @@ package FS::cust_credit_bill; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $conf ); use FS::UID qw( getotaker ); use FS::Record qw( qsearch qsearchs ); use FS::cust_main; @@ -11,6 +11,11 @@ use FS::cust_bill; @ISA = qw( FS::Record ); +#ask FS::UID to run this stuff for us later +FS::UID->install_callback( sub { + $conf = new FS::Conf; +} ); + =head1 NAME FS::cust_credit_bill - Object methods for cust_credit_bill records @@ -69,6 +74,19 @@ sub table { 'cust_credit_bill'; } Adds this cust_credit_bill to the database ("Posts" all or part of a credit). If there is an error, returns the error, otherwise returns false. +sub insert { + my $self = shift; + my $error = $self->SUPER::insert(@_); + return $error if $error; + + if ( $conf->exists('invoice_send_receipts') ) { + my $send_error = $self->cust_bill->send; + warn "Error sending receipt: $send_error\n" if $send_error; + } + + ''; +} + =item delete Currently unimplemented. @@ -141,11 +159,18 @@ sub cust_credit { qsearchs( 'cust_credit', { 'crednum' => $self->crednum } ); } -=back +=item cust_bill + +Returns the invoice (see L) -=head1 VERSION +=cut -$Id: cust_credit_bill.pm,v 1.8 2003-08-05 00:20:41 khoff Exp $ +sub cust_bill { + my $self = shift; + qsearchs( 'cust_bill', { 'invnum' => $self->invnum } ); +} + +=back =head1 BUGS -- cgit v1.2.1 From e294302d8bf2b12eec690d8c9f517fa81825c79a Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Nov 2003 10:39:58 +0000 Subject: adding sql_generic price plan --- httemplate/edit/part_pkg.cgi | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index 862e98ecf..b697a76b2 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -439,6 +439,41 @@ tie my %plans, 'Tie::IxHash', 'recur' => '\'my $last_bill = $cust_pkg->last_bill; my $hours = $cust_pkg->seconds_since_sqlradacct($last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; my $input = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctInputOctets\" ) / 1048576; my $output = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctOutputOctets\" ) / 1048576; my $total = $input + $output - \' + what.recur_included_total.value + \'; $total = 0 if $total < 0; my $input = $input - \' + what.recur_included_input.value + \'; $input = 0 if $input < 0; my $output = $output - \' + what.recur_included_output.value + \'; $output = 0 if $output < 0; my $totalcharge = sprintf(\"%.2f\", \' + what.recur_total_charge.value + \' * $total); my $hourscharge = sprintf(\"%.2f\", \' + what.recur_hourly_charge.value + \' * $hours); push @details, \"Last month\\\'s excess data \". sprintf(\"%.1f\", $total). \" megs: \\\$$totalcharge\", \"Last month\\\'s excess time \". sprintf(\"%.1f\", $hours). \" hours: \\\$$hourscharge\"; \' + what.recur_flat.value + \' + $hourscharge + \' + what.recur_input_charge.value + \' * $input + \' + what.recur_output_charge.value + \' * $output + $totalcharge ;\'', }, + 'sql_generic' => { + 'name' => 'Base charge plus a metered rate from a configurable SQL query', + 'fields' => { + 'setup_fee' => { 'name' => 'Setup fee for this package', + 'default' => 0, + }, + 'recur_flat' => { 'name' => 'Base monthly charge for this package', + 'default' => 0, + }, + 'recur_included' => { 'name' => 'Units included', + 'default' => 0, + }, + 'recur_unit_charge' => { 'name' => 'Additional charge per unit', + 'default' => 0, + }, + 'datasrc' => { 'name' => 'DBI data source', + 'default' => '', + }, + 'db_username' => { 'name' => 'Database username', + 'default' => '', + }, + 'db_password' => { 'name' => 'Database username', + 'default' => '', + }, + 'query' => { 'name' => 'SQL query', + 'default' => '', + }, + }, + 'fieldorder' => [qw( setup_fee recur_flat recur_included recur_unit_charge datasrc db_username db_password query )], + 'setup' => 'what.setup_fee.value', + # 'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\") or die $DBI::errstr; \'', + 'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\", \"\' + what.db_password.value + \'\" ) or die $DBI::errstr; my $sth = $dbh->prepare(\"\' + what.query.value + \'\") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq \"svc_domain\" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge.value + \';\'', + #'recur' => '\'my $dbh = DBI->connect("\' + what.datasrc.value + \'", "\' + what.db_username.value + \'", "\' what.db_password.value + \'" ) or die $DBI::errstr; my $sth = $dbh->prepare("\' + what.query.value + \'") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq "svc_domain" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_flat.value + \' + $units * \' + what.recur_unit_charge + \';\'', + }, + ; my %plandata = map { /^(\w+)=(.*)$/; ( $1 => $2 ); } -- cgit v1.2.1 From d6297be89acbef3cdf9fce4925f797063583b066 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Nov 2003 10:48:57 +0000 Subject: use the latex template for normal printing when available --- FS/FS/cust_bill.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 9409bc5f6..64759f9bf 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -343,6 +343,10 @@ sub send { } + if ( $conf->config('invoice_latex') ) { + @print_text = $self->print_ps('', $template); + } + if ( grep { $_ eq 'POST' } @invoicing_list ) { #postal my $lpr = $conf->config('lpr'); open(LPR, "|$lpr") -- cgit v1.2.1 From 9c6cd7a1ee5f65e3a608b3d3119005d90ecbf4a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 29 Nov 2003 10:50:47 +0000 Subject: missing cut --- FS/FS/cust_credit_bill.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FS/FS/cust_credit_bill.pm b/FS/FS/cust_credit_bill.pm index 0bbc656ea..88a732bc6 100644 --- a/FS/FS/cust_credit_bill.pm +++ b/FS/FS/cust_credit_bill.pm @@ -74,6 +74,8 @@ sub table { 'cust_credit_bill'; } Adds this cust_credit_bill to the database ("Posts" all or part of a credit). If there is an error, returns the error, otherwise returns false. +=cut + sub insert { my $self = shift; my $error = $self->SUPER::insert(@_); -- cgit v1.2.1 From 333281ca2d026e7b02bc53edbda15d88c0285dcb Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 30 Nov 2003 07:41:26 +0000 Subject: move to the left to line up with window envelopes --- conf/invoice_latex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/invoice_latex b/conf/invoice_latex index a89b9a33a..02d865626 100644 --- a/conf/invoice_latex +++ b/conf/invoice_latex @@ -23,7 +23,7 @@ \usepackage{graphicx} % required for logo graphic \addtolength{\voffset}{-0.0in} % top margin to top of header -\addtolength{\hoffset}{-0.25in} %left margin on page +\addtolength{\hoffset}{-0.55in} %left margin on page \addtolength{\topmargin}{-0.6in} % top margin to top of header \setlength{\headheight}{1in} % height of header \setlength{\headsep}{0.5in} % between header and text -- cgit v1.2.1 From 7f300c1a420b3a95bb7e99c0161059718fb21932 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 30 Nov 2003 07:52:17 +0000 Subject: add link to view typeset invoice --- httemplate/view/cust_bill.cgi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 53d7bc051..ddc92748d 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -22,6 +22,10 @@ print qq!Enter payments (check/cash) aga print qq!Reprint this invoice!. '

'; +print menubar( + 'View typeset invoice' => "${p}view/cust_bill-ps.cgi?$invnum", +), '

'; + #false laziness with search/cust_bill_event.cgi print table(). 'EventDateStatus'; -- cgit v1.2.1 From 9748a639549536ad0fc29445c8ea500ded22547d Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 30 Nov 2003 08:06:56 +0000 Subject: explicitly tell dvips to write output to a file --- FS/FS/cust_bill.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 64759f9bf..868771109 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1071,7 +1071,7 @@ sub print_ps { system('pslatex', "$file.tex"); system('pslatex', "$file.tex"); #system('dvips', '-t', 'letter', "$file.dvi", "$file.ps"); - system('dvips', '-t', 'letter', "$file.dvi" ); + system('dvips', '-t', 'letter', "$file.dvi", '-o', "$file.ps" ); open(POSTSCRIPT, "<$file.ps") or die "can't open $file.ps (probable error in LaTeX template): $!\n"; -- cgit v1.2.1 From 10632b11a7222299b19c5949acc983d7eeefbeee Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Dec 2003 22:50:44 +0000 Subject: add part_referral.disabled --- FS/FS/part_referral.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/FS/FS/part_referral.pm b/FS/FS/part_referral.pm index f30ddad01..c0858c0ed 100644 --- a/FS/FS/part_referral.pm +++ b/FS/FS/part_referral.pm @@ -38,6 +38,8 @@ The following fields are currently supported: =item referral - Text name of this advertising source +=item disabled - Disabled flag, empty or 'Y' + =back =head1 NOTE @@ -91,10 +93,17 @@ replace methods. sub check { my $self = shift; - $self->ut_numbern('refnum') + my $error = $self->ut_numbern('refnum') || $self->ut_text('referral') - || $self->SUPER::check ; + return $error if $error; + + if ( $self->dbdef_table->column('disabled') ) { + $error = $self->ut_enum('disabled', [ '', 'Y' ] ); + return $error if $error; + } + + $self->SUPER::check; } =back -- cgit v1.2.1 From a5bc5bcbadafe55b31d9e97fccb6122477e390fb Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Dec 2003 22:51:06 +0000 Subject: add part_referral.disabled, add disabled indices to agent and part_bill_event --- FS/bin/freeside-setup | 9 +++++---- httemplate/docs/upgrade10.html | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 80b74c1f1..4e3a09aad 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -342,7 +342,7 @@ sub tables_hash_hack { ], 'primary_key' => 'agentnum', 'unique' => [], - 'index' => [ ['typenum'] ], + 'index' => [ ['typenum'], ['diabled'] ], }, 'agent_type' => { @@ -408,7 +408,7 @@ sub tables_hash_hack { ], 'primary_key' => 'eventpart', 'unique' => [], - 'index' => [ ['payby'] ], + 'index' => [ ['payby'], ['disabled'], ], }, 'cust_bill_pkg' => { @@ -567,7 +567,7 @@ sub tables_hash_hack { ], 'primary_key' => 'paynum', 'unique' => [], - 'index' => [ [ 'custnum' ], [ 'paybatch' ] ], + 'index' => [ [ 'custnum' ], [ 'paybatch' ], [ 'payby' ], [ '_date' ] ], }, 'cust_bill_pay' => { @@ -718,10 +718,11 @@ sub tables_hash_hack { 'columns' => [ 'refnum', 'serial', '', '', 'referral', 'varchar', '', $char_d, + 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'refnum', 'unique' => [], - 'index' => [], + 'index' => [ ['disabled'] ], }, 'part_svc' => { diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 080528bac..3c6519a61 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -144,6 +144,9 @@ ALTER TABLE agent ADD _password varchar(80) NULL; ALTER TABLE h_agent ADD _password varchar(80) NULL; ALTER TABLE cust_main ADD paycvv varchar(4) NULL; ALTER TABLE h_cust_main ADD paycvv varchar(4) NULL; +ALTER TABLE part_referral ADD disabled char(1) NULL; +ALTER TABLE h_part_referral ADD disabled char(1) NULL; +CREATE INDEX part_referral1 ON part_referral ( disabled ); dump database, edit: - cust_main: increase otaker from 8 to 32 @@ -164,6 +167,8 @@ optionally: CREATE INDEX cust_main9 ON cust_main ( ship_daytime ); CREATE INDEX cust_main10 ON cust_main ( ship_night ); CREATE INDEX cust_main11 ON cust_main ( ship_fax ); + CREATE INDEX agent2 ON agent ( disabled ); + CREATE INDEX part_bill_event2 ON part_bill_event ( disabled ); serial columns -- cgit v1.2.1 From e58b9fa1cdf0693f29d0d3db9c861cf4ecd7a77c Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Dec 2003 23:53:34 +0000 Subject: signup page w/advertising source dropdown --- FS/FS/ClientAPI/Signup.pm | 12 ++++++++++++ fs_signup/FS-SignupClient/cgi/signup.cgi | 7 +++++-- fs_signup/FS-SignupClient/cgi/signup.html | 10 ++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/FS/FS/ClientAPI/Signup.pm b/FS/FS/ClientAPI/Signup.pm index 60639b132..375958b9c 100644 --- a/FS/FS/ClientAPI/Signup.pm +++ b/FS/FS/ClientAPI/Signup.pm @@ -40,6 +40,16 @@ sub signup_info { ) ], + 'part_referral' => + [ + map { $_->hashref } + qsearch('part_referral', + dbdef->table('part_referral')->column('disabled') + ? { 'disabled' => '' } + : {} + ) + ], + 'agentnum2part_pkg' => { map { @@ -72,6 +82,8 @@ sub signup_info { 'countrydefault' => $conf->config('countrydefault') || 'US', + 'refnum' => $conf->config('signup_server-default_refnum'), + }; if ( diff --git a/fs_signup/FS-SignupClient/cgi/signup.cgi b/fs_signup/FS-SignupClient/cgi/signup.cgi index 5ca93d289..8dae9dd12 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.cgi +++ b/fs_signup/FS-SignupClient/cgi/signup.cgi @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: signup.cgi,v 1.48 2003-10-25 02:05:44 ivan Exp $ +# $Id: signup.cgi,v 1.49 2003-12-10 23:53:34 ivan Exp $ use strict; use vars qw( @payby $cgi $locales $packages @@ -10,7 +10,7 @@ use vars qw( @payby $cgi $locales $packages $country $zip $daytime $night $fax $invoicing_list $payby $payinfo $paycvv $paydate $payname $referral_custnum $init_popstate $pkgpart $username $password $password2 $sec_phrase $popnum - $agentnum + $agentnum $refnum $ieak_file $ieak_template $cck_file $cck_template $signup_html $signup_template $success_html $success_template @@ -218,6 +218,7 @@ if ( defined $cgi->param('magic') ) { #$agentnum, # = $cgi->param('agentnum'), $agentnum ||= $cgi->param('agentnum'); $init_popstate = $cgi->param('init_popstate'); + $refnum = $cgi->param('refnum'); if ( $cgi->param('_password') ne $cgi->param('_password2') ) { $error = $init_data->{msgcat}{passwords_dont_match}; #msgcat @@ -266,6 +267,7 @@ if ( defined $cgi->param('magic') ) { '_password' => $password, 'popnum' => $popnum, 'agentnum' => $agentnum, + 'refnum' => $refnum, map { $_ => $cgi->param($_) } grep { /^snarf_/ } $cgi->param } ); @@ -314,6 +316,7 @@ if ( defined $cgi->param('magic') ) { $popnum = ''; $referral_custnum = $cgi->param('ref') || ''; $init_popstate = $cgi->param('init_popstate') || ''; + $refnum = $init_data->{'refnum'}; print_form; } diff --git a/fs_signup/FS-SignupClient/cgi/signup.html b/fs_signup/FS-SignupClient/cgi/signup.html index dc4252c73..96bdac666 100755 --- a/fs_signup/FS-SignupClient/cgi/signup.html +++ b/fs_signup/FS-SignupClient/cgi/signup.html @@ -18,6 +18,16 @@ +Where did you hear about our service?

Contact Information -- cgit v1.2.1 From cc19608aa931a3f57e3f4a899e0ef49b2590877e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 14 Dec 2003 17:53:28 +0000 Subject: non-breaking spaces in custoemr view field names --- httemplate/view/cust_main.cgi | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 83f114ef9..fb015671f 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -76,7 +76,7 @@ print '', + '', ''; @@ -105,8 +105,8 @@ print '', $cust_main->country, '', ; - my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; - my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; + my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; + my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; print '', @@ -166,7 +166,7 @@ print ''; print '', ; @@ -184,13 +184,13 @@ print ''; } print ''; - print '', - '', - '', - '', '', '', + print 'Phone bill billing', '', ; @@ -276,7 +276,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { ; } elsif ( $cust_main->payby eq 'COMP' ) { print 'Complimentary', - '', '', -- cgit v1.2.1 From 4a46507233cdd366306562f97730eadaa09ae400 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Dec 2003 03:41:10 +0000 Subject: add _latex_escape sub --- FS/FS/cust_bill.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 868771109..353ab49ea 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1090,6 +1090,21 @@ sub print_ps { } +# quick subroutine for print_ps +# +# There are ten characters that LaTeX treats as special characters, which +# means that they do not simply typeset themselves: +# # $ % & ~ _ ^ \ { } +# +# TeX ignores blanks following an escaped character; if you want a blank (as +# in "10% of ..."), you have to "escape" the blank as well ("10\%\ of ..."). + +sub _latex_escape { + my $value = shift; + $value =~ s/([#\$%&~_\^{}])( )?/"\\$1". ( length($2) ? "\\$2" : '' )/ge; + $value; +} + #utility methods for print_* sub balance_due_msg { -- cgit v1.2.1 From 60d630b2052d208f9f8adb8a28706c731f366bc2 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Dec 2003 06:42:32 +0000 Subject: fix bug that charged full amounts of all open invoices as soon as balance went positive (only manifests when any cust_bill->owed somehow got to be negative) --- FS/FS/cust_bill.pm | 5 ++++- FS/FS/cust_main.pm | 20 ++++++-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 353ab49ea..88f40da3c 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -594,7 +594,10 @@ sub realtime_bop { my( $self, $method ) = @_; my $cust_main = $self->cust_main; - my $amount = $self->owed; + my $balance = $cust_main->balance; + my $amount = ( $balance < $self->owed ) ? $balance : $self->owed; + $amount = sprintf("%.2f", $amount); + return "not run (balance $balance)" unless $amount > 0; my $description = 'Internet Services'; if ( $conf->exists('business-onlinepayment-description') ) { diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index df7bf1abb..41bfa5818 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1481,24 +1481,15 @@ sub collect { } } - foreach my $cust_bill ( $self->cust_bill ) { - - #this has to be before next's - my $amount = sprintf( "%.2f", $balance < $cust_bill->owed - ? $balance - : $cust_bill->owed - ); - $balance = sprintf( "%.2f", $balance - $amount ); - - next unless $cust_bill->owed > 0; + foreach my $cust_bill ( $self->open_cust_bill ) { # don't try to charge for the same invoice if it's already in a batch #next if qsearchs( 'cust_pay_batch', { 'invnum' => $cust_bill->invnum } ); - warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ", amount $amount, balance $balance)" if $Debug; - - next unless $amount > 0; + last if $self->balance <= 0; + warn "invnum ". $cust_bill->invnum. " (owed ". $cust_bill->owed. ")" + if $Debug; foreach my $part_bill_event ( sort { $a->seconds <=> $b->seconds @@ -1515,7 +1506,8 @@ sub collect { 'disabled' => '', } ) ) { - last unless $cust_bill->owed > 0; #don't run subsequent events if owed=0 + last if $cust_bill->owed <= 0 # don't run subsequent events if owed<=0 + || $self->balance <= 0; # or if balance<=0 warn "calling invoice event (". $part_bill_event->eventcode. ")\n" if $Debug; -- cgit v1.2.1 From b3808f960c0351710f7005e7a2729925f57c7f4a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Dec 2003 08:07:06 +0000 Subject: print_ps returns ths invoice now, do not count on latex printing it, oops --- httemplate/misc/print-invoice.cgi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/httemplate/misc/print-invoice.cgi b/httemplate/misc/print-invoice.cgi index 8c1240c05..0dda68a4e 100755 --- a/httemplate/misc/print-invoice.cgi +++ b/httemplate/misc/print-invoice.cgi @@ -13,8 +13,7 @@ die "Can't find invoice!\n" unless $cust_bill; open(LPR,"|$lpr") or die "Can't open $lpr: $!"; if ( $conf->exists('invoice_latex') ) { - $cust_bill->print_ps; - #print LPR $cust_bill->print_ps; #( date ) + print LPR $cust_bill->print_ps; #( date ) } else { print LPR $cust_bill->print_text; #( date ) } -- cgit v1.2.1 From 50a3c53a35c705795cea89a2af17c5197351fce4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Dec 2003 08:08:38 +0000 Subject: line up w/window envelopes --- conf/invoice_latex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/invoice_latex b/conf/invoice_latex index 02d865626..b28679344 100644 --- a/conf/invoice_latex +++ b/conf/invoice_latex @@ -23,7 +23,7 @@ \usepackage{graphicx} % required for logo graphic \addtolength{\voffset}{-0.0in} % top margin to top of header -\addtolength{\hoffset}{-0.55in} %left margin on page +\addtolength{\hoffset}{-0.60in} %left margin on page \addtolength{\topmargin}{-0.6in} % top margin to top of header \setlength{\headheight}{1in} % height of header \setlength{\headsep}{0.5in} % between header and text -- cgit v1.2.1 From 7c67ed5982f05a562c30e45938a9fa164cbeb7cb Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 20 Dec 2003 03:47:09 +0000 Subject: fix inflated advertising source numbers --- httemplate/browse/part_referral.cgi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/httemplate/browse/part_referral.cgi b/httemplate/browse/part_referral.cgi index 69bb95aa5..3f59abcf5 100755 --- a/httemplate/browse/part_referral.cgi +++ b/httemplate/browse/part_referral.cgi @@ -23,7 +23,8 @@ Where a customer heard about your service. Tracked for informational purposes. ; my $sth = dbh->prepare("SELECT COUNT(*) FROM h_cust_main - WHERE refnum = ? + WHERE history_action = 'insert' + AND refnum = ? AND history_date > ? ") or die dbh->errstr; %> -- cgit v1.2.1 From cfebba4f8a73501b86d7a14037de88c0c87c758e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Dec 2003 21:12:43 +0000 Subject: add outsourced databases with both addresses by default --- FS/bin/freeside-addoutsourceuser | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FS/bin/freeside-addoutsourceuser b/FS/bin/freeside-addoutsourceuser index 180cd9399..abb515b6f 100644 --- a/FS/bin/freeside-addoutsourceuser +++ b/FS/bin/freeside-addoutsourceuser @@ -10,6 +10,6 @@ freeside-adduser -h /usr/local/etc/freeside/htpasswd \ $username $password 2>/dev/null [ -e /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain ] \ - || ( freeside-setup $username 2>/dev/null; \ - /home/ivan/freeside/bin/populate-msgcat $username ) + || ( freeside-setup -s $username 2>/dev/null; \ + /home/ivan/freeside/bin/populate-msgcat $username 2>/dev/null ) -- cgit v1.2.1 From 3dc9375300fa2b9706e2b5707694022962f65b4d Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Dec 2003 23:13:41 +0000 Subject: cache virtual_fields method results to help performance --- FS/FS/Record.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 14dfca2cb..2517d1841 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2,7 +2,7 @@ package FS::Record; use strict; use vars qw( $dbdef_file $dbdef $setup_hack $AUTOLOAD @ISA @EXPORT_OK $DEBUG - $me %dbdef_cache ); + $me %dbdef_cache %virtual_fields_cache ); use subs qw(reload_dbdef); use Exporter; use Carp qw(carp cluck croak confess); @@ -1379,14 +1379,17 @@ sub virtual_fields { return () unless $self->dbdef->table('part_virtual_field'); - # This should be smart enough to cache results. + unless ( $virtual_fields_cache{$table} ) { + my $query = 'SELECT name from part_virtual_field ' . + "WHERE dbtable = '$table'"; + my $dbh = dbh; + my $result = $dbh->selectcol_arrayref($query); + confess $dbh->errstr if $dbh->err; + $virtual_fields_cache{$table} = $result; + } + + @{$virtual_fields_cache{$table}}; - my $query = 'SELECT name from part_virtual_field ' . - "WHERE dbtable = '$table'"; - my $dbh = dbh; - my $result = $dbh->selectcol_arrayref($query); - confess $dbh->errstr if $dbh->err; - return @$result; } -- cgit v1.2.1 From 6a751696054face897088706d222d5c9383d40fe Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 21 Dec 2003 23:16:45 +0000 Subject: work even if there are stray type_pkgs records around --- httemplate/browse/agent_type.cgi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index c61208c83..5473804e8 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -19,7 +19,7 @@ foreach my $agent_type ( sort { } qsearch('agent_type',{}) ) { my $hashref = $agent_type->hashref; #more efficient to do this with SQL... - my @type_pkgs = grep { ! $_->part_pkg->disabled } + my @type_pkgs = grep { $_->part_pkg and ! $_->part_pkg->disabled } qsearch('type_pkgs',{'typenum'=> $hashref->{typenum} }); my $rowspan = scalar(@type_pkgs); $rowspan = int($rowspan/2+0.5) ; -- cgit v1.2.1 From 0cfa5f6462513d0bf3ed5f2d3a5efc008f180ebc Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Dec 2003 17:50:20 +0000 Subject: add cust_credit, cust_pay and cust_refund subs --- FS/FS/cust_main.pm | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 41bfa5818..0046f0287 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -22,6 +22,7 @@ use FS::cust_bill; use FS::cust_bill_pkg; use FS::cust_pay; use FS::cust_credit; +use FS::cust_refund; use FS::part_referral; use FS::cust_main_county; use FS::agent; @@ -467,19 +468,19 @@ sub delete { local $FS::UID::AutoCommit = 0; my $dbh = dbh; - if ( qsearch( 'cust_bill', { 'custnum' => $self->custnum } ) ) { + if ( $self->cust_bill ) { $dbh->rollback if $oldAutoCommit; return "Can't delete a customer with invoices"; } - if ( qsearch( 'cust_credit', { 'custnum' => $self->custnum } ) ) { + if ( $self->cust_credit ) { $dbh->rollback if $oldAutoCommit; return "Can't delete a customer with credits"; } - if ( qsearch( 'cust_pay', { 'custnum' => $self->custnum } ) ) { + if ( $self->cust_pay ) { $dbh->rollback if $oldAutoCommit; return "Can't delete a customer with payments"; } - if ( qsearch( 'cust_refund', { 'custnum' => $self->custnum } ) ) { + if ( $self->cust_refund ) { $dbh->rollback if $oldAutoCommit; return "Can't delete a customer with refunds"; } @@ -2378,6 +2379,42 @@ sub open_cust_bill { grep { $_->owed > 0 } $self->cust_bill; } +=item cust_credit + +Returns all the credits (see L) for this customer. + +=cut + +sub cust_credit { + my $self = shift; + sort { $a->_date <=> $b->_date } + qsearch( 'cust_credit', { 'custnum' => $self->custnum } ) +} + +=item cust_pay + +Returns all the payments (see L) for this customer. + +=cut + +sub cust_pay { + my $self = shift; + sort { $a->_date <=> $b->_date } + qsearch( 'cust_pay', { 'custnum' => $self->custnum } ) +} + +=item cust_refund + +Returns all the refunds (see L) for this customer. + +=cut + +sub cust_refund { + my $self = shift; + sort { $a->_date <=> $b->_date } + qsearch( 'cust_refund', { 'custnum' => $self->custnum } ) +} + =back =head1 SUBROUTINES -- cgit v1.2.1 From 6092bc23dc3e17a45d75c8cac30cb8ad9efba89f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Dec 2003 21:01:10 +0000 Subject: allow credits to be modified at API level --- FS/FS/cust_credit.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index e668abd73..18ab1c361 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -141,7 +141,10 @@ posted. =cut sub replace { - return "Can't modify credit!" + #return "Can't modify credit!" + my $self = shift; + return "Can't modify closed credit" if $self->closed =~ /^Y/i; + $self->SUPER::replace(@_); } =item check @@ -240,13 +243,9 @@ sub credited { =back -=head1 VERSION - -$Id: cust_credit.pm,v 1.17 2003-08-05 00:20:41 khoff Exp $ - =head1 BUGS -The delete method. +The delete method. The replace method. =head1 SEE ALSO -- cgit v1.2.1 From 1f044cfca0e3573db5dae7d7d6dc92933ffd2f8e Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Dec 2003 21:18:16 +0000 Subject: quiet warning --- FS/FS/cust_bill.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 88f40da3c..e5c19668d 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -1113,6 +1113,7 @@ sub _latex_escape { sub balance_due_msg { my $self = shift; my $msg = 'Balance Due'; + return $msg unless $conf->exists('invoice_default_terms'); if ( $conf->config('invoice_default_terms') =~ /^\s*Net\s*(\d+)\s*$/ ) { $msg .= ' - Please pay by '. time2str("%x", $self->_date + ($1*86400) ); } elsif ( $conf->config('invoice_default_terms') ) { -- cgit v1.2.1 From c2671089005c4f4f1fb886b9936aa8d5eea5eb59 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Dec 2003 21:22:19 +0000 Subject: default to the whole-country tax rate if states aren't defined --- FS/FS/cust_main.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 0046f0287..8695ae09c 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1239,6 +1239,16 @@ sub bill { } ); } + #one more try at a whole-country tax rate + unless ( @taxes ) { + @taxes = qsearch( 'cust_main_county', { + 'state' => '', + 'county' => '', + 'country' => $self->country, + 'taxclass' => '', + } ); + } + # maybe eliminate this entirely, along with all the 0% records unless ( @taxes ) { $dbh->rollback if $oldAutoCommit; -- cgit v1.2.1 From 2c0d7675caacd5891b7f699c92260d321b4d03b5 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 22 Dec 2003 21:37:04 +0000 Subject: add total cards & amount to pending batch screen --- httemplate/browse/cust_pay_batch.cgi | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/httemplate/browse/cust_pay_batch.cgi b/httemplate/browse/cust_pay_batch.cgi index d90a03313..3420e97b6 100755 --- a/httemplate/browse/cust_pay_batch.cgi +++ b/httemplate/browse/cust_pay_batch.cgi @@ -14,8 +14,24 @@ Format
-

+
+ +<% + my $statement = "SELECT SUM(amount) from cust_pay_batch"; + my $sth = dbh->prepare($statement) or die dbh->errstr. "doing $statement"; + $sth->execute or die "Error executing \"$statement\": ". $sth->errstr; + my $total = $sth->fetchrow_arrayref->[0]; + + my $c_statement = "SELECT COUNT(*) from cust_pay_batch"; + my $c_sth = dbh->prepare($c_statement) + or die dbh->errstr. "doing $c_statement"; + $c_sth->execute or die "Error executing \"$c_statement\": ". $c_sth->errstr; + my $cards = $c_sth->fetchrow_arrayref->[0]; +%> +<%= $cards %> credit card payments batched
+$<%= sprintf("%.2f", $total) %> total in pending batch
+
<%= &table() %>
-- cgit v1.2.1 From 3c0d5d77527f46e59c68fb6f92de2391e779f07b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 00:41:15 +0000 Subject: allow_negative_charges config option --- FS/FS/Conf.pm | 7 +++++++ FS/FS/cust_main.pm | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index d911480df..b391fe44b 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1144,6 +1144,13 @@ httemplate/docs/config.html ], }, + { + 'key' => 'allow_negative_charges', + 'section' => 'billing', + 'description' => 'Allow negative charges. Normally not used unless importing data from a legacy system that requires this.', + 'type' => 'checkbox', + }, + ); 1; diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 8695ae09c..3e40cc127 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -1201,15 +1201,15 @@ sub bill { } $setup = sprintf( "%.2f", $setup ); $recur = sprintf( "%.2f", $recur ); - if ( $setup < 0 ) { + if ( $setup < 0 && ! $conf->exists('allow_negative_charges') ) { $dbh->rollback if $oldAutoCommit; return "negative setup $setup for pkgnum ". $cust_pkg->pkgnum; } - if ( $recur < 0 ) { + if ( $recur < 0 && ! $conf->exists('allow_negative_charges') ) { $dbh->rollback if $oldAutoCommit; return "negative recur $recur for pkgnum ". $cust_pkg->pkgnum; } - if ( $setup > 0 || $recur > 0 ) { + if ( $setup != 0 || $recur != 0 ) { my $cust_bill_pkg = new FS::cust_bill_pkg ({ 'pkgnum' => $cust_pkg->pkgnum, 'setup' => $setup, @@ -1327,7 +1327,7 @@ sub bill { } #unless $self->tax =~ /Y/i || $self->payby eq 'COMP' - } #if $setup > 0 || $recur > 0 + } #if $setup != 0 || $recur != 0 } #if $cust_pkg_mod_flag -- cgit v1.2.1 From 38d7ed9d33840a59bbbf6895e3c7a6d191094c03 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 00:51:37 +0000 Subject: add edit_info to selfservice API --- FS/FS/ClientAPI/MyAccount.pm | 34 ++++++++++++++++++++++++++++ fs_selfservice/FS-SelfService/SelfService.pm | 18 ++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm index c9a749424..290022148 100644 --- a/FS/FS/ClientAPI/MyAccount.pm +++ b/FS/FS/ClientAPI/MyAccount.pm @@ -20,6 +20,7 @@ use FS::ClientAPI; #hmm FS::ClientAPI->register_handlers( 'MyAccount/login' => \&login, 'MyAccount/customer_info' => \&customer_info, + 'MyAccount/edit_info' => \&edit_info, 'MyAccount/invoice' => \&invoice, 'MyAccount/cancel' => \&cancel, 'MyAccount/payment_info' => \&payment_info, @@ -29,6 +30,14 @@ FS::ClientAPI->register_handlers( 'MyAccount/cancel_pkg' => \&cancel_pkg, ); +use vars qw( @cust_main_editable_fields ); +@cust_main_editable_fields = qw( + first last company address1 address2 city + county state zip country daytime night fax + ship_first ship_last ship_company ship_address1 ship_address2 ship_city + ship_state ship_zip ship_country ship_daytime ship_night ship_fax +); + #store in db? my $cache = new Cache::SharedMemoryCache(); @@ -104,6 +113,10 @@ sub customer_info { $return{name} = $cust_main->first. ' '. $cust_main->get('last'); + for (@cust_main_editable_fields) { + $return{$_} = $cust_main->get($_); + } + } else { #no customer record my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $session->{'svcnum'} } ) @@ -119,6 +132,27 @@ sub customer_info { } +sub edit_info { + my $p = shift; + my $session = $cache->get($p->{'session_id'}) + or return { 'error' => "Can't resume session" }; #better error message + + my $custnum = $session->{'custnum'} + or return { 'error' => "no customer record" }; + + my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ) + or return { 'error' => "unknown custnum $custnum" }; + + my $new = new FS::cust_main { $cust_main->hash }; + $new->set( $_ => $p->{$_} ) + foreach grep { exists $p->{$_} } @cust_main_editable_fields; + my $error = $new->replace($cust_main); + return { 'error' => $error } if $error; + #$cust_main = $new; + + return { 'error' => '' }; +} + sub payment_info { my $p = shift; my $session = $cache->get($p->{'session_id'}) diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm index be6dd3a8a..715f935f3 100644 --- a/fs_selfservice/FS-SelfService/SelfService.pm +++ b/fs_selfservice/FS-SelfService/SelfService.pm @@ -23,6 +23,7 @@ $socket .= '.'.$tag if defined $tag && length($tag); 'chsh' => 'passwd/passwd', 'login' => 'MyAccount/login', 'customer_info' => 'MyAccount/customer_info', + 'edit_info' => 'MyAccount/edit_info', 'invoice' => 'MyAccount/invoice', 'cancel' => 'MyAccount/cancel', 'payment_info' => 'MyAccount/payment_info', @@ -113,7 +114,7 @@ FS::SelfService - Freeside self-service API my $customer_info = customer_info( { 'session_id' => $session_id } ); #payment_info and process_payment are available in 1.5+ only - my $payment_info = payment_info) { 'session_id' => $session_id } ); + my $payment_info = payment_info( { 'session_id' => $session_id } ); #!!! process_payment example @@ -244,8 +245,23 @@ the following keys: invnum, date, owed An HTML fragment containing shipping and billing addresses. +=item The following fields are also returned: first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax + =back +=item edit_info HASHREF + +Takes a hash reference as parameter with any of the following keys: + +first last company address1 address2 city county state zip country daytime night fax ship_first ship_last ship_company ship_address1 ship_address2 ship_city ship_state ship_zip ship_country ship_daytime ship_night ship_fax + +If a field exists, the customer record is updated with the new value of that +field. If a field does not exist, that field is not changed on the customer +record. + +Returns a hash reference with a single key, B, empty on success, or an +error message on errors + =item invoice HASHREF Returns an invoice. Takes a hash reference as parameter with two keys: -- cgit v1.2.1 From 8db0e6f5d34786bfd93ce21f43126a5fab441ade Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 01:06:10 +0000 Subject: fix path to svc_Common in example table --- eg/table_template-svc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eg/table_template-svc.pm b/eg/table_template-svc.pm index ebf7299d2..66d17e34a 100644 --- a/eg/table_template-svc.pm +++ b/eg/table_template-svc.pm @@ -6,7 +6,7 @@ use vars qw(@ISA); use FS::svc_Common; use FS::cust_svc; -@ISA = qw(svc_Common); +@ISA = qw(FS::svc_Common); =head1 NAME -- cgit v1.2.1 From 869a43742a9bcba4d2dd117b76e759ff6c81d371 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 01:10:50 +0000 Subject: update svc template for 1.5 --- eg/table_template-svc.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eg/table_template-svc.pm b/eg/table_template-svc.pm index 66d17e34a..7f7ef4b68 100644 --- a/eg/table_template-svc.pm +++ b/eg/table_template-svc.pm @@ -141,7 +141,7 @@ sub check { my $part_svc = $x; - ''; #no error + $self->SUPER::check; } =back -- cgit v1.2.1 From d20581bcbf2809d5c2969d773b16a0c8714a6dec Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 01:49:32 +0000 Subject: add svc_external --- FS/FS.pm | 4 + FS/FS/cust_svc.pm | 2 + FS/FS/svc_external.pm | 174 +++++++++++++++++++++++++++++++++++++++++ FS/bin/freeside-setup | 11 +++ httemplate/docs/upgrade10.html | 9 ++- 5 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 FS/FS/svc_external.pm diff --git a/FS/FS.pm b/FS/FS.pm index a299e659d..36c3a1777 100644 --- a/FS/FS.pm +++ b/FS/FS.pm @@ -66,6 +66,10 @@ L - Mail forwarding class L - Web virtual host class. +L - DSL, wireless and other broadband class. + +L - Externally tracked service class. + L - Service definition class L - Column constraint class diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index af0abf7f1..ce2b969f9 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -296,6 +296,8 @@ sub label { $tag = $domain->zone; } elsif ( $svcdb eq 'svc_broadband' ) { $tag = $svc_x->ip_addr; + } elsif ( $svcdb eq 'svc_external' ) { + $tag = $svc_x->id. ': '. $svc_x->title; } else { cluck "warning: asked for label of unsupported svcdb; using svcnum"; $tag = $svc_x->getfield('svcnum'); diff --git a/FS/FS/svc_external.pm b/FS/FS/svc_external.pm new file mode 100644 index 000000000..fe4ea1d67 --- /dev/null +++ b/FS/FS/svc_external.pm @@ -0,0 +1,174 @@ +package FS::svc_external; + +use strict; +use vars qw(@ISA); # $conf +use FS::UID; +#use FS::Record qw( qsearch qsearchs dbh); +use FS::svc_Common; + +@ISA = qw( FS::svc_Common ); + +#FS::UID::install_callback( sub { +# $conf = new FS::Conf; +#}; + +=head1 NAME + +FS::svc_external - Object methods for svc_external records + +=head1 SYNOPSIS + + use FS::svc_external; + + $record = new FS::svc_external \%hash; + $record = new FS::svc_external { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + + $error = $record->suspend; + + $error = $record->unsuspend; + + $error = $record->cancel; + +=head1 DESCRIPTION + +An FS::svc_external object represents a externally tracked service. +FS::svc_external inherits from FS::svc_Common. The following fields are +currently supported: + +=over 4 + +=item svcnum - primary key + +=item id - unique number of external record + +=item title - for invoice line items + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new external service. To add the external service to the database, +see L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I method. + +=cut + +sub table { 'svc_external'; } + +=item insert + +Adds this external service to the database. If there is an error, returns the +error, otherwise returns false. + +The additional fields pkgnum and svcpart (see L) should be +defined. An FS::cust_svc record will be created and inserted. + +=cut + +sub insert { + my $self = shift; + my $error; + + $error = $self->SUPER::insert; + return $error if $error; + + ''; +} + +=item delete + +Delete this record from the database. + +=cut + +sub delete { + my $self = shift; + my $error; + + $error = $self->SUPER::delete; + return $error if $error; + + ''; +} + + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +sub replace { + my ( $new, $old ) = ( shift, shift ); + my $error; + + $error = $new->SUPER::replace($old); + return $error if $error; + + ''; +} + +=item suspend + +Called by the suspend method of FS::cust_pkg (see L). + +=item unsuspend + +Called by the unsuspend method of FS::cust_pkg (see L). + +=item cancel + +Called by the cancel method of FS::cust_pkg (see L). + +=item check + +Checks all fields to make sure this is a valid external service. If there is +an error, returns the error, otherwise returns false. Called by the insert +and repalce methods. + +=cut + +sub check { + my $self = shift; + + my $x = $self->setfixed; + return $x unless ref($x); + my $part_svc = $x; + + my $error = + $self->ut_numbern('svcnum') + || $self->ut_number('id') + || $self->ut_textn('title') + ; + + $self->SUPER::check; +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L, L, L, L, +L, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 4e3a09aad..fce8bc750 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -1120,6 +1120,17 @@ sub tables_hash_hack { 'index' => [ [ 'svcnum' ] ], }, + 'svc_external' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'id', 'int', '', '', + 'title', 'varchar', 'NULL', $char_d, + ], + 'primary_key' => 'svcnum', + 'unique' => [], + 'index' => [], + }, + ); %tables; diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html index 3c6519a61..275b821a3 100644 --- a/httemplate/docs/upgrade10.html +++ b/httemplate/docs/upgrade10.html @@ -73,6 +73,13 @@ CREATE TABLE acct_snarf ( ); CREATE INDEX acct_snarf1 ON acct_snarf ( svcnum ); +CREATE TABLE svc_external ( + svcnum int NOT NULL, + id int NOT NULL, + title varchar(80), + PRIMARY KEY (svcnum) +); + CREATE TABLE part_pkg_temp ( pkgpart serial NOT NULL, pkg varchar(80) NOT NULL, @@ -175,7 +182,7 @@ optionally: mandatory again: dbdef-create username -create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband acct_snarf +create-history-tables username cust_bill_pkg_detail router part_svc_router addr_block svc_broadband acct_snarf svc_external dbdef-create username apache - fix sections to include .html also -- cgit v1.2.1 From 31d6d0e8d0d624cd051440acf322cd8893c1026e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Dec 2003 02:36:38 +0000 Subject: add svc_external --- FS/FS/part_export.pm | 4 ++ FS/MANIFEST | 3 + FS/t/svc_broadband.t | 5 ++ FS/t/svc_external.t | 5 ++ htetc/global.asa | 1 + htetc/handler.pl | 1 + httemplate/edit/part_svc.cgi | 7 ++- httemplate/edit/process/svc_external.cgi | 29 +++++++++ httemplate/edit/svc_external.cgi | 105 +++++++++++++++++++++++++++++++ httemplate/view/svc_external.cgi | 52 +++++++++++++++ 10 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 FS/t/svc_broadband.t create mode 100644 FS/t/svc_external.t create mode 100755 httemplate/edit/process/svc_external.cgi create mode 100644 httemplate/edit/svc_external.cgi create mode 100644 httemplate/view/svc_external.cgi diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index 17e5cf908..1b46841ec 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -1076,6 +1076,10 @@ tie my %forward_shellcommands_options, 'Tie::IxHash', 'notes' => '', }, }, + + 'svc_external' => { + }, + ); =back diff --git a/FS/MANIFEST b/FS/MANIFEST index 877f3ce0d..3cbf0e91f 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -102,6 +102,7 @@ FS/svc_acct.pm FS/svc_acct_pop.pm FS/svc_broadband.pm FS/svc_domain.pm +FS/svc_external.pm FS/router.pm FS/type_pkgs.pm FS/nas.pm @@ -184,8 +185,10 @@ t/radius_usergroup.t t/session.t t/svc_acct.t t/svc_acct_pop.t +t/svc_broadband.t t/svc_Common.t t/svc_domain.t +t/svc_external.t t/svc_forward.t t/svc_www.t t/type_pkgs.t diff --git a/FS/t/svc_broadband.t b/FS/t/svc_broadband.t new file mode 100644 index 000000000..02dc1124a --- /dev/null +++ b/FS/t/svc_broadband.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::svc_broadband; +$loaded=1; +print "ok 1\n"; diff --git a/FS/t/svc_external.t b/FS/t/svc_external.t new file mode 100644 index 000000000..20a676784 --- /dev/null +++ b/FS/t/svc_external.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::svc_external; +$loaded=1; +print "ok 1\n"; diff --git a/htetc/global.asa b/htetc/global.asa index 2e31be394..f550560ee 100644 --- a/htetc/global.asa +++ b/htetc/global.asa @@ -56,6 +56,7 @@ use FS::svc_www; use FS::router; use FS::addr_block; use FS::svc_broadband; +use FS::svc_external; use FS::type_pkgs; use FS::part_export; use FS::part_export_option; diff --git a/htetc/handler.pl b/htetc/handler.pl index ba73bcfaf..c5f685f85 100644 --- a/htetc/handler.pl +++ b/htetc/handler.pl @@ -114,6 +114,7 @@ sub handler use FS::router; use FS::addr_block; use FS::svc_broadband; + use FS::svc_external; use FS::type_pkgs; use FS::part_export; use FS::part_export_option; diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 18319b341..10e89288f 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -53,6 +53,7 @@ Services are items you offer to your customers.
  • svc_forward - mail forwarding
  • svc_www - Virtual domain website
  • svc_broadband - Broadband/High-speed Internet service +
  • svc_external - Externally-tracked service @@ -129,6 +130,10 @@ my %defs = ( 'ip_addr' => 'IP address. Leave blank for automatic assignment.', 'blocknum' => 'Address block.', }, + 'svc_external' => { + #'id' => '', + #'title' => '', + }, ); foreach my $svcdb (grep dbdef->table($_), keys %defs ) { @@ -151,7 +156,7 @@ my %defs = ( my @dbs = $hashref->{svcdb} ? ( $hashref->{svcdb} ) - : qw( svc_acct svc_domain svc_forward svc_www svc_broadband ); + : qw( svc_acct svc_domain svc_forward svc_www svc_broadband svc_external ); tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs; my $widget = new HTML::Widgets::SelectLayers( diff --git a/httemplate/edit/process/svc_external.cgi b/httemplate/edit/process/svc_external.cgi new file mode 100755 index 000000000..728cd2189 --- /dev/null +++ b/httemplate/edit/process/svc_external.cgi @@ -0,0 +1,29 @@ +<% + +$cgi->param('svcnum') =~ /^(\d*)$/ or die "Illegal svcnum!"; +my $svcnum =$1; + +my $old = qsearchs('svc_external',{'svcnum'=>$svcnum}) if $svcnum; + +my $new = new FS::svc_external ( { + map { + ($_, scalar($cgi->param($_))); + } ( fields('svc_external'), qw( pkgnum svcpart ) ) +} ); + +my $error = ''; +if ( $svcnum ) { + $error = $new->replace($old); +} else { + $error = $new->insert; + $svcnum = $new->getfield('svcnum'); +} + +if ($error) { + $cgi->param('error', $error); + print $cgi->redirect(popurl(2). "svc_external.cgi?". $cgi->query_string ); +} else { + print $cgi->redirect(popurl(3). "view/svc_external.cgi?$svcnum"); +} + +%> diff --git a/httemplate/edit/svc_external.cgi b/httemplate/edit/svc_external.cgi new file mode 100644 index 000000000..bcfc85e3f --- /dev/null +++ b/httemplate/edit/svc_external.cgi @@ -0,0 +1,105 @@ + +<% + +my( $svcnum, $pkgnum, $svcpart, $part_svc, $svc_external ); +if ( $cgi->param('error') ) { + $svc_external = new FS::svc_external ( { + map { $_, scalar($cgi->param($_)) } fields('svc_external') + } ); + $svcnum = $svc_external->svcnum; + $pkgnum = $cgi->param('pkgnum'); + $svcpart = $cgi->param('svcpart'); + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; +} else { + my($query) = $cgi->keywords; + if ( $query =~ /^(\d+)$/ ) { #editing + $svcnum=$1; + $svc_external=qsearchs('svc_external',{'svcnum'=>$svcnum}) + or die "Unknown (svc_external) svcnum!"; + + my($cust_svc)=qsearchs('cust_svc',{'svcnum'=>$svcnum}) + or die "Unknown (cust_svc) svcnum!"; + + $pkgnum=$cust_svc->pkgnum; + $svcpart=$cust_svc->svcpart; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + + } else { #adding + + foreach $_ (split(/-/,$query)) { #get & untaint pkgnum & svcpart + $pkgnum=$1 if /^pkgnum(\d+)$/; + $svcpart=$1 if /^svcpart(\d+)$/; + } + $svc_external = new FS::svc_external { svcpart => $svcpart }; + + $part_svc=qsearchs('part_svc',{'svcpart'=>$svcpart}); + die "No part_svc entry!" unless $part_svc; + + $svcnum=''; + + #set fixed and default fields from part_svc + foreach my $part_svc_column ( + grep { $_->columnflag } $part_svc->all_part_svc_column + ) { + $svc_external->setfield( $part_svc_column->columnname, + $part_svc_column->columnvalue, + ); + } + + } +} +my $action = $svc_external->svcnum ? 'Edit' : 'Add'; + +my $p1 = popurl(1); +print header("External service $action", ''); + +print qq!Error: !, $cgi->param('error'), + "" + if $cgi->param('error'); + +print qq!
    !; + +#display + + +#svcnum +print qq!!; +print qq!Service #!, $svcnum ? $svcnum : "(NEW)", "

    "; + +#pkgnum +print qq!!; + +#svcpart +print qq!!; + +my($id,$title)=( + $svc_external->id, + $svc_external->title, +); + +print &ntable("#cccccc",2), + '
  • '. + ''; + +foreach my $field ($svc_external->virtual_fields) { + if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) { + # If the flag is X, it won't even show up in $svc_acct->virtual_fields. + print $svc_external->pvf($field)->widget('HTML', 'edit', + $svc_external->getfield($field)); + } +} + +%> + +
    '; print "Billing address", &ntable("#cccccc"), "
    ", &ntable("#cccccc",2), - '
    Contact name
    Contact name', $cust_main->last, ', ', $cust_main->first, '
    '. $daytime_label. '', $cust_main->daytime || ' ', '
    '; print &ntable("#cccccc"), "
    ", &ntable("#cccccc",2), - '
    Customer number', + '
    Customer number', $custnum, '
    '; my $referral = qsearchs('part_referral', { 'refnum' => $cust_main->refnum } ); - print '
    Advertising source', + print '
    Advertising source', $referral->refnum, ": ", $referral->referral, '
    Order taker', $cust_main->otaker, '
    Referring Customer'; + print '
    Referring Customer'; my $referring_cust_main = ''; if ( $cust_main->referral_custnum && ( $referring_cust_main = @@ -220,22 +220,22 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { print "Billing information (", qq!!, "Bill now)", &ntable("#cccccc"), "
    ", &ntable("#cccccc",2), - '
    Tax exempt', + '
    Tax exempt', $cust_main->tax ? 'yes' : 'no', '
    Postal invoices', + '
    Postal invoices', ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no', '
    Email invoices', + '
    Email invoices', join(', ', grep { $_ ne 'POST' } @invoicing_list ) || 'no', '
    Billing type', + '
    Billing type', ; if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { my $payinfo = $cust_main->payinfo; $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); - print 'Credit card ', + print 'Credit card ', ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ), '
    Card number', @@ -247,7 +247,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { ; } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') { my( $account, $aba ) = split('@', $cust_main->payinfo ); - print 'Electronic check', + print 'Electronic check ', ( $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' ), '
    Account number', @@ -260,7 +260,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { } elsif ( $cust_main->payby eq 'LECB' ) { $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/; my $payinfo = "$1-$2-$3"; - print 'Phone bill billing
    Phone number', $payinfo, '
    Authorized by', + '
    Authorized by', $cust_main->payinfo, '
    Expiration', $cust_main->paydate, '
    #
    External ID'. + qq!!. + '
    Title'. + qq!!. + '

    + + + + diff --git a/httemplate/view/svc_external.cgi b/httemplate/view/svc_external.cgi new file mode 100644 index 000000000..e5c977f13 --- /dev/null +++ b/httemplate/view/svc_external.cgi @@ -0,0 +1,52 @@ + +<% + +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/; +my $svcnum = $1; +my $svc_external = qsearchs( 'svc_external', { 'svcnum' => $svcnum } ) + or die "svc_external: Unknown svcnum $svcnum"; + +#false laziness w/all svc_*.cgi +my $cust_svc = qsearchs( 'cust_svc', { 'svcnum' => $svcnum } ); +my $pkgnum = $cust_svc->getfield('pkgnum'); +my($cust_pkg, $custnum); +if ($pkgnum) { + $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); + $custnum = $cust_pkg->custnum; +} else { + $cust_pkg = ''; + $custnum = ''; +} +#eofalse + +%> + +<%= header('External Service View', menubar( + ( ( $custnum ) + ? ( "View this package (#$pkgnum)" => "${p}view/cust_pkg.cgi?$pkgnum", + "View this customer (#$custnum)" => "${p}view/cust_main.cgi?$custnum", + ) + : ( "Cancel this (unaudited) external service" => + "${p}misc/cancel-unaudited.cgi?$svcnum" ) + ), + "Main menu" => $p, +)) %> + +Edit this information
    +<%= ntable("#cccccc") %><%= ntable("#cccccc",2) %> + +Service number + <%= $svcnum %> +External ID + <%= $svc_external->id %> +Title + <%= $svc_external->title %> + +<% foreach (sort { $a cmp $b } $svc_external->virtual_fields) { %> + <%= $svc_external->pvf($_)->widget('HTML', 'view', $svc_external->getfield($_)) %> +<% } %> + + +
    <%= joblisting({'svcnum'=>$svcnum}, 1) %> + -- cgit v1.2.1 From 9617ce4b230c7dc56b4fa4a50d805ddaef87d090 Mon Sep 17 00:00:00 2001 From: khoff Date: Wed, 24 Dec 2003 18:18:21 +0000 Subject: tyop --- FS/bin/freeside-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index fce8bc750..b7a414ae2 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -342,7 +342,7 @@ sub tables_hash_hack { ], 'primary_key' => 'agentnum', 'unique' => [], - 'index' => [ ['typenum'], ['diabled'] ], + 'index' => [ ['typenum'], ['disabled'] ], }, 'agent_type' => { -- cgit v1.2.1 From abc64a997eeacdc95988296889754d708aa97cad Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 27 Dec 2003 08:23:38 +0000 Subject: package reports by agent --- httemplate/index.html | 2 +- httemplate/search/cust_pkg.cgi | 6 ++++ httemplate/search/cust_pkg.html | 46 ------------------------- httemplate/search/cust_pkg_report.cgi | 63 +++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 47 deletions(-) delete mode 100755 httemplate/search/cust_pkg.html create mode 100755 httemplate/search/cust_pkg_report.cgi diff --git a/httemplate/index.html b/httemplate/index.html index d863f3f3e..d024de0bf 100644 --- a/httemplate/index.html +++ b/httemplate/index.html @@ -56,7 +56,7 @@
    Credit card #
    Invoice #
    Check #
    -
    View pending credit card batch

    Packages (by next bill date range) +
    View pending credit card batch

    Packages (by next bill date range)

    Invoice reports
    • Invoice event errors (failed credit cards) diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 3c3e17864..c2f6272c4 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -35,6 +35,12 @@ if ( $cgi->param('magic') && $cgi->param('magic') eq 'bill' ) { $range .= ( $range ? 'AND ' : ' WHERE ' ). '( cancel IS NULL OR cancel = 0 )'; + if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + $range .= ( $range ? 'AND ' : ' WHERE ' ). + "$1 = ( SELECT agentnum FROM cust_main". + " WHERE cust_main.custnum = cust_pkg.custnum )"; + } + #false laziness with below my $statement = "SELECT COUNT(*) FROM cust_pkg $range"; warn $statement; diff --git a/httemplate/search/cust_pkg.html b/httemplate/search/cust_pkg.html deleted file mode 100755 index 0dad83a2a..000000000 --- a/httemplate/search/cust_pkg.html +++ /dev/null @@ -1,46 +0,0 @@ - - - Packages - - - - - - -

      Packages

      -
      - - Return packages with next bill date:

      - - - - - - - - - - - -
      From:
      m/d/y
      To:
      m/d/y
      -
      - -
      - - - - diff --git a/httemplate/search/cust_pkg_report.cgi b/httemplate/search/cust_pkg_report.cgi new file mode 100755 index 000000000..b31674540 --- /dev/null +++ b/httemplate/search/cust_pkg_report.cgi @@ -0,0 +1,63 @@ + + + Packages + + + + + + +

      Packages

      +
      + + Return packages with next bill date:

      + + + + + + + + + + + +<% my %agent_search = dbdef->table('agent')->column('disabled') + ? ( 'disabled' => '' ) : (); + my @agents = qsearch( 'agent', \%agent_search ); + if ( scalar(@agents) == 1 ) { +%> + +<% } else { %> + + + + + +<% } %> +
      From:
      m/d/y
      To:
      m/d/y
      Agent:
      +
      + +
      + + + + -- cgit v1.2.1