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 .= '
| '; @@ -752,7 +788,7 @@ sub www_listSubscriptionCodeBatches { $output .= ' |