summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authormark <mark>2010-02-24 23:32:47 +0000
committermark <mark>2010-02-24 23:32:47 +0000
commit2419a740ea77d7c1fd2151dbf8822fc40fd94053 (patch)
treec4c0183db77d346e90abe7ccd2e508211bfd9507 /httemplate
parente281c64b7dc78502cda21b4f4a9b22cfcf848801 (diff)
RT#7132: bulk increment package bill dates
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/misc/bulk_pkg_increment_bill.cgi50
-rwxr-xr-xhttemplate/misc/process/bulk_pkg_increment_bill.cgi76
-rwxr-xr-xhttemplate/search/cust_pkg.cgi35
3 files changed, 149 insertions, 12 deletions
diff --git a/httemplate/misc/bulk_pkg_increment_bill.cgi b/httemplate/misc/bulk_pkg_increment_bill.cgi
new file mode 100755
index 000000000..79bc0cd3e
--- /dev/null
+++ b/httemplate/misc/bulk_pkg_increment_bill.cgi
@@ -0,0 +1,50 @@
+<% include('/elements/header-popup.html', "Increment Bill Date") %>
+
+% if ( $cgi->param('error') ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
+ <BR><BR>
+% }
+
+<FORM ACTION="<% $p %>misc/process/bulk_pkg_increment_bill.cgi" METHOD=POST>
+
+%# some false laziness w/search/cust_pkg.cgi
+
+<INPUT TYPE="hidden" NAME="query" VALUE="<% $cgi->keywords |h %>">
+% for my $param (qw(agentnum custnum magic status classnum custom censustract)) {
+<INPUT TYPE="hidden" NAME="<% $param %>" VALUE="<% $cgi->param($param) |h %>">
+% }
+%
+% foreach my $pkgpart ($cgi->param('pkgpart')) {
+<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $pkgpart |h %>">
+% }
+%
+% foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
+%
+ <INPUT TYPE="hidden" NAME="<% $field %>begin" VALUE="<% $cgi->param("${field}.begin") |h %>">
+ <INPUT TYPE="hidden" NAME="<% $field %>beginning" VALUE="<% $cgi->param("${field}beginning") |h %>">
+ <INPUT TYPE="hidden" NAME="<% $field %>end" VALUE="<% $cgi->param("${field}.end") |h %>">
+ <INPUT TYPE="hidden" NAME="<% $field %>ending" VALUE="<% $cgi->param("${field}.ending") |h %>">
+% }
+
+<% ntable('#cccccc') %>
+
+ <TR>
+ <TD>Days to increment: </TD>
+ <TD><INPUT type="text" name="days"></TD>
+ </TR>
+
+</TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="Increment bill date">
+
+</FORM>
+</BODY>
+</HTML>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
+
+</%init>
diff --git a/httemplate/misc/process/bulk_pkg_increment_bill.cgi b/httemplate/misc/process/bulk_pkg_increment_bill.cgi
new file mode 100755
index 000000000..0d8417b26
--- /dev/null
+++ b/httemplate/misc/process/bulk_pkg_increment_bill.cgi
@@ -0,0 +1,76 @@
+%if ($error) {
+% $cgi->param('error', $error);
+<% $cgi->redirect(popurl(2). 'bulk_pkg_increment_bill.cgi?'. $cgi->query_string ) %>
+%} else {
+<% header('Packages Adjusted') %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY></HTML>
+% }
+<%init>
+
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
+my $error;
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages')
+ and $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
+
+my $days = $cgi->param('days') or die "missing parameter: days";
+$days > 0 or $error = "Number of days must be > 0";
+
+my %search_hash = ();
+
+$search_hash{'query'} = $cgi->param('query');
+
+for my $param (qw(agentnum magic status classnum pkgpart)) {
+ $search_hash{$param} = $cgi->param($param)
+ if $cgi->param($param);
+}
+
+###
+# parse dates
+###
+
+#false laziness w/report_cust_pkg.html
+# and, now, w/bulk_change_pkg.cgi
+my %disable = (
+ 'all' => {},
+ 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, },
+ 'active' => { 'susp'=>1, 'cancel'=>1 },
+ 'suspended' => { 'cancel' => 1 },
+ 'cancelled' => {},
+ '' => {},
+);
+
+foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) {
+
+ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field);
+
+ next if $beginning == 0 && $ending == 4294967295
+ or $disable{$cgi->param('status')}->{$field};
+
+ $search_hash{$field} = [ $beginning, $ending ];
+
+}
+
+if(!$error) {
+ foreach my $cust_pkg (qsearch(FS::cust_pkg->search(\%search_hash))) {
+ next if ! $cust_pkg->bill;
+ my $new_cust_pkg = FS::cust_pkg->new({ $cust_pkg->hash });
+ $new_cust_pkg->bill($new_cust_pkg->bill + $days*86400);
+ $error = $new_cust_pkg->replace($cust_pkg);
+
+ if($error) {
+ $cgi->param("error",substr($error, 0, 512));
+ $dbh->rollback;
+ return;
+ }
+ }
+
+ $dbh->commit;
+}
+
+</%init>
diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi
index ee4c82d8e..2a4366ae4 100755
--- a/httemplate/search/cust_pkg.cgi
+++ b/httemplate/search/cust_pkg.cgi
@@ -257,18 +257,29 @@ my $html_init = include('/elements/init_overlib.html');
my $extra_choices = sub {
my $query = shift;
-
- return '' unless
- $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages');
-
- '<BR><BR>'.
- include( '/elements/popup_link.html',
- 'label' => 'Change these packages',
- 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
- 'actionlabel' => 'Change Packages',
- 'width' => 763,
- 'height' => 336,
- );
+ my $text = '';
+
+ if( $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages') ) {
+ $text .= '<BR><BR>'.
+ include( '/elements/popup_link.html',
+ 'label' => 'Change these packages',
+ 'action' => "${p}misc/bulk_change_pkg.cgi?$query",
+ 'actionlabel' => 'Change Packages',
+ 'width' => 569,
+ 'height' => 210,
+ );
+ if( $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates') ) {
+ $text .= '<BR>'.
+ include( '/elements/popup_link.html',
+ 'label' => 'Increment next bill date',
+ 'action' => "${p}misc/bulk_pkg_increment_bill.cgi?$query",
+ 'actionlabel' => 'Increment Bill Date',
+ 'width' => 569,
+ 'height' => 210,
+ );
+ }
+ }
+ return $text;
};
</%init>