Merge branch 'master' into WebGUI8
This commit is contained in:
commit
2400f19099
797 changed files with 33894 additions and 27196 deletions
|
|
@ -6,6 +6,7 @@ use WebGUI::Exception;
|
|||
use WebGUI::International;
|
||||
use WebGUI::Pluggable;
|
||||
use WebGUI::Utility;
|
||||
use WebGUI::Shop::Vendor;
|
||||
use JSON qw{ from_json };
|
||||
|
||||
use base qw/WebGUI::Account/;
|
||||
|
|
@ -58,6 +59,10 @@ sub appendCommonVars {
|
|||
|
||||
$var->{ 'manage_tax_url' } = $self->getUrl( 'module=shop;do=manageTaxData' );
|
||||
$var->{ 'manageTaxIsActive' } = $method eq 'manageTaxData';
|
||||
|
||||
eval { WebGUI::Shop::Vendor->newByUserId($session, $session->user->userId); };
|
||||
$var->{ 'userIsVendor' } = ! Exception::Class->caught();
|
||||
$session->log->warn($@);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -253,36 +258,39 @@ Page that show your earnings if you are a vendor.
|
|||
sub www_viewSales {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $vendor = WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId );
|
||||
|
||||
my $var = $vendor->getPayoutTotals;
|
||||
my $totalSales = 0;
|
||||
my $vendor = eval { WebGUI::Shop::Vendor->newByUserId( $session, $session->user->userId ); };
|
||||
my @products;
|
||||
my $totalSales = 0;
|
||||
my $var = {};
|
||||
if (! Exception::Class->caught()) {
|
||||
|
||||
my $sth = $session->db->read(
|
||||
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 ]
|
||||
);
|
||||
ROW: while (my $row = $sth->hashRef) {
|
||||
my $data = $row;
|
||||
$var = $vendor->getPayoutTotals;
|
||||
|
||||
# Add asset properties to tmpl_vars.
|
||||
my $asset = eval { WebGUI::Asset->newById( $session, $row->{ assetId } ); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->log->error('Unable to instanciate assetId '.$row->{ assetId }.": $@");
|
||||
next ROW;
|
||||
my $sth = $session->db->read(
|
||||
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 $asset = eval { WebGUI::Asset->newById( $session, $row->{ assetId } ); };
|
||||
if (Exception::Class->caught()) {
|
||||
$session->log->error('Unable to instanciate assetId '.$row->{ assetId }.": $@");
|
||||
next;
|
||||
}
|
||||
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
||||
|
||||
push @products, $row;
|
||||
|
||||
$totalSales += $row->{quantity};
|
||||
}
|
||||
$row = { %{ $row }, %{ $asset->get } } if $asset;
|
||||
|
||||
push @products, $row;
|
||||
|
||||
$totalSales += $row->{quantity};
|
||||
$sth->finish;
|
||||
}
|
||||
$sth->finish;
|
||||
|
||||
$var->{ product_loop } = \@products;
|
||||
$var->{ total_products } = scalar @products;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue