Fix problems with the Sales tab in the Shop Account plugin.
Only display the Sales tab to vendors, and prevent www_viewSales from erroring out if the user is not a vendor. New template, template variable, i18n.
This commit is contained in:
parent
022495506f
commit
1e7f443126
5 changed files with 36 additions and 21 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
- fixed #11348: Typ-o in debug notice SQLReport
|
- fixed #11348: Typ-o in debug notice SQLReport
|
||||||
- fixed #11350: Story Topic asset missing description...
|
- fixed #11350: Story Topic asset missing description...
|
||||||
- fixed #11351: Double submits on ITransact checkout
|
- fixed #11351: Double submits on ITransact checkout
|
||||||
|
- fixed #11353: shop - sales - error
|
||||||
|
|
||||||
7.8.9
|
7.8.9
|
||||||
- fixed #11235: wiki search
|
- fixed #11235: wiki search
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -6,6 +6,7 @@ use WebGUI::Exception;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Pluggable;
|
use WebGUI::Pluggable;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
use WebGUI::Shop::Vendor;
|
||||||
use JSON qw{ from_json };
|
use JSON qw{ from_json };
|
||||||
|
|
||||||
use base qw/WebGUI::Account/;
|
use base qw/WebGUI::Account/;
|
||||||
|
|
@ -58,6 +59,10 @@ sub appendCommonVars {
|
||||||
|
|
||||||
$var->{ 'manage_tax_url' } = $self->getUrl( 'module=shop;do=manageTaxData' );
|
$var->{ 'manage_tax_url' } = $self->getUrl( 'module=shop;do=manageTaxData' );
|
||||||
$var->{ 'manageTaxIsActive' } = $method eq 'manageTaxData';
|
$var->{ 'manageTaxIsActive' } = $method eq 'manageTaxData';
|
||||||
|
|
||||||
|
eval { WebGUI::Shop::Vendor->newByUserId($session, $session->user->userId); };
|
||||||
|
$var->{ 'userIsVendor' } = ! Exception::Class->caught();
|
||||||
|
$session->log->warn($@);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -253,32 +258,35 @@ Page that show your earnings if you are a vendor.
|
||||||
sub www_viewSales {
|
sub www_viewSales {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my $vendor = WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId );
|
my $vendor = eval { WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId ); };
|
||||||
|
|
||||||
my $var = $vendor->getPayoutTotals;
|
|
||||||
my $totalSales = 0;
|
|
||||||
my @products;
|
my @products;
|
||||||
|
my $totalSales = 0;
|
||||||
|
my $var = {};
|
||||||
|
if (! Exception::Class->caught()) {
|
||||||
|
|
||||||
my $sth = $session->db->read(
|
$var = $vendor->getPayoutTotals;
|
||||||
q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount }
|
|
||||||
. q{ FROM transactionItem as t1, transaction as t2 }
|
|
||||||
. q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 }
|
|
||||||
. q{ AND vendorId=? }
|
|
||||||
. q{ group by assetId order by quantity desc },
|
|
||||||
[ $vendor->getId ]
|
|
||||||
);
|
|
||||||
while (my $row = $sth->hashRef) {
|
|
||||||
my $data = $row;
|
|
||||||
|
|
||||||
# Add asset properties to tmpl_vars.
|
my $sth = $session->db->read(
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $row->{ assetId } );
|
q{ SELECT t1.*, sum(t1.quantity) as quantity, sum(t1.vendorPayoutAmount) as payoutAmount }
|
||||||
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
. q{ FROM transactionItem as t1, transaction as t2 }
|
||||||
|
. q{ WHERE t1.transactionId=t2.transactionId AND t2.isSuccessful <> 0 }
|
||||||
push @products, $row;
|
. q{ AND vendorId=? }
|
||||||
|
. q{ group by assetId order by quantity desc },
|
||||||
|
[ $vendor->getId ]
|
||||||
|
);
|
||||||
|
while (my $row = $sth->hashRef) {
|
||||||
|
my $data = $row;
|
||||||
|
|
||||||
$totalSales += $row->{quantity};
|
# Add asset properties to tmpl_vars.
|
||||||
|
my $asset = WebGUI::Asset->newByDynamicClass( $session, $row->{ assetId } );
|
||||||
|
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
||||||
|
|
||||||
|
push @products, $row;
|
||||||
|
|
||||||
|
$totalSales += $row->{quantity};
|
||||||
|
}
|
||||||
|
$sth->finish;
|
||||||
}
|
}
|
||||||
$sth->finish;
|
|
||||||
|
|
||||||
$var->{ product_loop } = \@products;
|
$var->{ product_loop } = \@products;
|
||||||
$var->{ total_products } = scalar @products;
|
$var->{ total_products } = scalar @products;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ our $HELP = {
|
||||||
variables => [
|
variables => [
|
||||||
{ name => "manage_purchases_url", },
|
{ name => "manage_purchases_url", },
|
||||||
{ name => "managePurchasesIsActive", },
|
{ name => "managePurchasesIsActive", },
|
||||||
|
{ name => "userIsVendor", },
|
||||||
],
|
],
|
||||||
related => [ ],
|
related => [ ],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,11 @@ our $I18N = {
|
||||||
lastUpdated => 1119068809,
|
lastUpdated => 1119068809,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'userIsVendor' => {
|
||||||
|
message => q{A boolean that is true if the current user is a vendor.},
|
||||||
|
lastUpdated => 1263833421,
|
||||||
|
},
|
||||||
|
|
||||||
'common account variables' => {
|
'common account variables' => {
|
||||||
message => q{Common Account, Shop Plugin, Template Variables.},
|
message => q{Common Account, Shop Plugin, Template Variables.},
|
||||||
lastUpdated => 1230867169,
|
lastUpdated => 1230867169,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue