Fix Notify About Low Stock email to be more user friendly. Fixes bug #11364.

This commit is contained in:
Colin Kuskie 2010-01-21 11:56:01 -08:00
parent 38dedef368
commit ba91560a96
3 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,6 @@
7.8.11
- fixed #11362: Unable to checkout with ITransact plugin
- fixed #11364: Notify About Low Stock workflow activity email is not user friendly
7.8.10
- fixed #11332: Pagination in webgui.org forum urls

View file

@ -92,7 +92,11 @@ See WebGUI::Workflow::Activity::execute() for details.
sub execute {
my ($self, undef, $instance) = @_;
my $session = $self->session;
my $message = $instance->getScratch('LowStockMessage') || '';
my $messageHeader =<<EOHEAD;
<table>
<tr><th>Quantity</th><th>Product</th></tr>
EOHEAD
my $message = $instance->getScratch('LowStockMessage') || $messageHeader;
my $counter = $instance->getScratch('LowStockLast') || 0;
my $belowThreshold = $instance->getScratch('LowStockBelow') || 0;
my $productIterator = WebGUI::Asset::Sku::Product->getIsa($session, $counter);
@ -110,8 +114,10 @@ sub execute {
if ($collateral->{quantity} <= $warningLimit) {
##Build message
$belowThreshold = 1;
$message .= $product->getUrl(sprintf 'func=editVariant;vid=%s', $collateral->{variantId})
. "\n";
$message .= sprintf qq{<tr><td>%d</td><td><a href="%s">%s</a></td></tr>\n},
$collateral->{quantity},
$session->url->getSiteURL.$session->url->gateway($product->getUrl(sprintf 'func=editVariant;vid=%s', $collateral->{variantId})),
$collateral->{shortdesc};
}
}
$counter++;
@ -133,6 +139,7 @@ sub execute {
$instance->deleteScratch('LowStockLast');
$instance->deleteScratch('LowStockBelow');
if ($belowThreshold) {
$message .= '</table>';
my $inbox = WebGUI::Inbox->new($session);
$inbox->addMessage({
status => 'unread',

View file

@ -111,9 +111,12 @@ my $message = $messages->[0];
my $body = $message->get('message');
is($message->get('subject'), 'Threshold=15', 'Message has the right subject');
my @urls = split /\n/, $body;
my @table = split /\n/, $body;
my @urls = @table[2..$#table];
pop @urls;
is (scalar @urls, 1, 'Only one variant is below the threshold');
my $url = pop @urls;
$url =~ s/^.+?href="([^"]+)".+$/$1/;
my $uri = URI->new($url);
is($uri->path, $posters->getUrl, 'Link in message has correct URL path');
is($uri->query, 'func=editVariant;vid='.$marilynVarId, 'Link in message has function and variant id');