diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 5615296d6..1546a7f69 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -14,6 +14,7 @@ method, getValueFromForm is still the deprecated method. - fixed: Image Collateral Uploader in Rich Editor now works correctly - fixed: problem with Calendar in EMS "Ticket" tab, "Start" field + - fixed: Manage Subscription Codes: Search on wrong screen? 7.5.17 - fixed: Payment Methods Hover Help Incomplete diff --git a/lib/WebGUI/Asset/Sku/Subscription.pm b/lib/WebGUI/Asset/Sku/Subscription.pm index 15081961e..8b63ccbe2 100644 --- a/lib/WebGUI/Asset/Sku/Subscription.pm +++ b/lib/WebGUI/Asset/Sku/Subscription.pm @@ -723,17 +723,53 @@ sub www_listSubscriptionCodeBatches { # Check privs return $session->privilege->insufficient unless $self->canEdit; - + + my $dcStart = $session->form->date('dcStart'); + my $dcStop = $session->datetime->addToTime($session->form->date('dcStop'), 23, 59); + my $selection = $session->form->process('selection'); + + my $f = WebGUI::HTMLForm->new( $session ); + $f->hidden( + name => 'func', + value => 'listSubscriptionCodeBatches', + ); + + $f->readOnly( + label => + WebGUI::Form::radio( $session, { name => 'selection', value => 'dc', checked => ($selection eq 'dc') } ) + . $i18n->get('selection created'), + value => + WebGUI::Form::date( $session, { name => 'dcStart', value=> $dcStart } ) + . ' ' . $i18n->get( 'and' ) . ' ' + . WebGUI::Form::date( $session, { name => 'dcStop', value=> $dcStop } ), + ); + $f->readOnly( + label => + WebGUI::Form::radio( $session, { name => 'selection', value => 'all', checked => ($selection ne 'dc') } ) + . $i18n->get('display all'), + value => '', + ); + $f->submit( + value => $i18n->get('select'), + ); + + ##Configure the SQL query based on what the user has selected. + my $sqlQuery = 'select * from Subscription_codeBatch where subscriptionId=?'; + my $sqlParams = [ $self->getId ]; + if ($selection eq 'dc') { + $sqlQuery .= ' and dateCreated >= ? and dateCreated <= ?'; + push @{ $sqlParams }, $dcStart, $dcStop; + } + # Set up a paginator to paginate the list of batches my $p = WebGUI::Paginator->new( $session, $self->getUrl('func=listSubscriptionCodeBatches') ); - $p->setDataByQuery( 'select * from Subscription_codeBatch where subscriptionId=?', undef, 1, [ - $self->getId, - ]); + $p->setDataByQuery( $sqlQuery, undef, 1, $sqlParams); # Fetch the list of batches at the current paginition index my $batches = $p->getPageData; - my $output = $p->getBarTraditional($session->form->process("pn")); + my $output = $f->print; + $output .= $p->getBarTraditional($session->form->process("pn")); $output .= ''; foreach my $batch ( @{$batches} ) { $output .= '
'; @@ -752,7 +788,7 @@ sub www_listSubscriptionCodeBatches { $output .= '
'; $output .= $p->getBarTraditional($session->form->process("pn")); - $output = $i18n->get('no subscription code batches') unless ( @{$batches} ); + $output = $i18n->get('no subscription code batches') unless $session->db->quickScalar('select count(*) from Subscription_codeBatch'); return $self->getAdminConsoleWithSubmenu->render( $output, $i18n->get('manage batches') ); } @@ -855,7 +891,7 @@ sub www_listSubscriptionCodes { $output = $i18n->get('selection message'); $output .= $f->print; - $output .= '
'.$delete.'
' if ($delete); + $output .= '
'.$delete.'
' if ($delete) and $p->getRowCount; $output .= $p->getBarTraditional($session->form->process("pn")); $output .= '
'; $output .= ''; diff --git a/lib/WebGUI/i18n/English/Asset_Subscription.pm b/lib/WebGUI/i18n/English/Asset_Subscription.pm index 38f4d2cc3..5a0c97fe5 100755 --- a/lib/WebGUI/i18n/English/Asset_Subscription.pm +++ b/lib/WebGUI/i18n/English/Asset_Subscription.pm @@ -220,6 +220,12 @@ our $I18N = { context => q|Shows up in the selection part of listSubscriptionCodes.| }, + 'display all' => { + message => q|display all|, + lastUpdated => 1216612381, + context => q|Shows up in the selection part of listSubscriptionCodes.| + }, + 'manage batches' => { message => q|Manage subscription code batches|, lastUpdated => 1101228391,