added token and ribbon skus

This commit is contained in:
JT Smith 2008-03-20 18:57:35 +00:00
parent 345c54db92
commit 5a50203b35
6 changed files with 303 additions and 15 deletions

View file

@ -69,11 +69,23 @@ sub upgradeEMS {
index badgeAssetId_purchaseComplete (badgeAssetId,purchaseComplete)
)");
$db->write("create table EMSRegistrantTicket (
badgeId varchar(22) binary not null primary key,
badgeId varchar(22) binary not null,
ticketAssetId varchar(22) binary not null,
purchaseComplete boolean,
primary key (badgeId, ticketAssetId),
index ticketAssetId_purchaseComplete (ticketAssetId,purchaseComplete)
)");
$db->write("create table EMSRegistrantToken (
badgeId varchar(22) binary not null,
tokenAssetId varchar(22) binary not null,
quantity int,
primary key (badgeId,tokenAssetId)
)");
$db->write("create table EMSRegistrantRibbon (
badgeId varchar(22) binary not null,
tokenAssetId varchar(22) binary not null,
primary key (badgeId,tokenAssetId)
)");
$db->write("create table EMSBadge (
assetId varchar(22) binary not null,
revisionDate bigint not null,
@ -81,7 +93,6 @@ sub upgradeEMS {
seatsAvailable int not null default 100,
primary key (assetId, revisionDate)
)");
$db->write("insert into incrementer values ('EMSBadgeNumber', 1)");
$db->write("create table EMSTicket (
assetId varchar(22) binary not null,
revisionDate bigint not null,
@ -93,6 +104,18 @@ sub upgradeEMS {
relatedBadges mediumtext,
primary key (assetId, revisionDate)
)");
$db->write("create table EMSToken (
assetId varchar(22) binary not null,
revisionDate bigint not null,
price float not null default 0.00,
primary key (assetId, revisionDate)
)");
$db->write("create table EMSRibbon (
assetId varchar(22) binary not null,
revisionDate bigint not null,
price float not null default 0.00,
primary key (assetId, revisionDate)
)");
}
#-------------------------------------------------

View file

@ -28,7 +28,7 @@ Package WebGUI::Asset::Sku::EMSBadge
=head1 DESCRIPTION
A badge for the Event Manager.
A badge for the Event Manager. Badges allow you into the convention.
=head1 SYNOPSIS
@ -47,7 +47,7 @@ sub addToCart {
$badgeInfo->{badgeAssetId} = $self->getId;
$badgeInfo->{emsAssetId} = $self->getParent->getId;
my $badgeId = $self->session->db->setRow("EMSRegistrant","badgeId", $badgeInfo);
$self->SUPER::addToCart({badgeId=>$badgeId, name=>$badgeInfo->{name}});
$self->SUPER::addToCart({badgeId=>$badgeId});
}
#-------------------------------------------------------------------
@ -89,7 +89,8 @@ sub definition {
#-------------------------------------------------------------------
sub getConfiguredTitle {
my $self = shift;
return $self->getTitle." (".$self->getOptions->{name}.")";
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}
@ -107,7 +108,7 @@ sub getPrice {
#-------------------------------------------------------------------
sub getQuantityAvailable {
my $self = shift;
my $seatsTaken = $self->session->db->quickScalar("select count(*) from EMSRegistrant where badgeAssetId=? and purchaseComplete=1",[$self->getId]);
my $seatsTaken = $self->session->db->quickScalar("select count(*) from EMSRegistrant where badgeAssetId=?",[$self->getId]);
return $self->get("seatsAvailable") - $seatsTaken;
}
@ -218,7 +219,7 @@ sub view {
label => $i18n->get('email address'),
defaultValue => $form->get("email","email")
);
$info->submit(value=>"add to cart");
$info->submit(value=>$i18n->get('add to cart','Shop'));
# render the page;
my $output = '<h1>'.$self->getTitle.'</h1>'

View file

@ -0,0 +1,120 @@
package WebGUI::Asset::Sku::EMSRibbon;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2008 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use Tie::IxHash;
use base 'WebGUI::Asset::Sku';
=head1 NAME
Package WebGUI::Asset::Sku::EMSRibbon
=head1 DESCRIPTION
A ribbon for the Event Manager. Ribbons are like coupons that give you discounts on events.
=head1 SYNOPSIS
use WebGUI::Asset::Sku::EMSRibbon;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my %properties;
tie %properties, 'Tie::IxHash';
my $i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
my $date = WebGUI::DateTime->new($session, time());
%properties = (
price => {
tab => "commerce",
fieldType => "float",
defaultValue => 0.00,
label => $i18n->get("price"),
hoverHelp => $i18n->get("price help"),
},
);
push(@{$definition}, {
assetName => $i18n->get('ems ribbon'),
icon => 'EMSRibbon.gif',
autoGenerateForms => 1,
tableName => 'EMSRibbon',
className => 'WebGUI::Asset::Sku::EMSRibbon',
properties => \%properties
});
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}
#-------------------------------------------------------------------
sub getMaxAllowedInCart {
return 1;
}
#-------------------------------------------------------------------
sub getPrice {
my $self = shift;
return $self->get("price");
}
#-------------------------------------------------------------------
sub onCompletePurchase {
my ($self, $item) = @_;
$self->session->db->write("insert into EMSRegistrationRibbon (ribbonAssetId, badgeId) values (?,?)",
[$self->getId, $self->getOptions->{badgeId}]);
return undef;
}
#-------------------------------------------------------------------
sub purge {
my $self = shift;
$self->session->db->write("delete from EMSRegistrantRibbon where tokenAssetId=?",[$self->getId]);
$self->SUPER::purge;
}
#-------------------------------------------------------------------
sub view {
my ($self) = @_;
return $self->getParent->view;
}
#-------------------------------------------------------------------
sub www_addToCart {
my ($self) = @_;
return $self->session->privilege->noAccess() unless $self->getParent->canView;
$self->addToCart({badgeId=>$self->session->form->get('badgeId')});
return $self->getParent->www_view;
}
1;

View file

@ -22,15 +22,15 @@ use base 'WebGUI::Asset::Sku';
=head1 NAME
Package WebGUI::Asset::Sku::EMSBadge
Package WebGUI::Asset::Sku::EMSTicket
=head1 DESCRIPTION
A badge for the Event Manager.
A ticket for the Event Manager. Tickets allow you into invidivual events at a convention.
=head1 SYNOPSIS
use WebGUI::Asset::Sku::EMSBadge;
use WebGUI::Asset::Sku::EMSTicket;
=head1 METHODS
@ -43,7 +43,7 @@ sub addToCart {
my ($self, $badgeInfo) = @_;
$self->session->db->write("insert into EMSRegistrantTicket (badgeId, ticketAssetId) values (?,?)",
[$badgeInfo->{badgeId},$self->getId]);
$self->addToCart($badgeInfo);
$self->SUPER::addToCart($badgeInfo);
}
#-------------------------------------------------------------------
@ -115,7 +115,8 @@ sub definition {
#-------------------------------------------------------------------
sub getConfiguredTitle {
my $self = shift;
return $self->getTitle." (".$self->getOptions->{name}.")";
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}
#-------------------------------------------------------------------
@ -132,7 +133,7 @@ sub getPrice {
#-------------------------------------------------------------------
sub getQuantityAvailable {
my $self = shift;
my $seatsTaken = $self->session->db->quickScalar("select count(*) from EMSRegistrantTicket where ticketAssetId=? and purchaseComplete=1",[$self->getId]);
my $seatsTaken = $self->session->db->quickScalar("select count(*) from EMSRegistrantTicket where ticketAssetId=?",[$self->getId]);
return $self->get("seatsAvailable") - $seatsTaken;
}
@ -161,8 +162,15 @@ sub purge {
#-------------------------------------------------------------------
sub view {
my ($self) = @_;
my $session = $self->session;
return "Don't know what it is to view this thing.";
return $self->getParent->view;
}
#-------------------------------------------------------------------
sub www_addToCart {
my ($self) = @_;
return $self->session->privilege->noAccess() unless $self->getParent->canView;
$self->addToCart({badgeId=>$self->session->form->get('badgeId')});
return $self->getParent->www_view;
}

View file

@ -0,0 +1,124 @@
package WebGUI::Asset::Sku::EMSToken;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2008 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use Tie::IxHash;
use base 'WebGUI::Asset::Sku';
=head1 NAME
Package WebGUI::Asset::Sku::EMSToken
=head1 DESCRIPTION
A token for the Event Manager. Tokens are like convention currency.
=head1 SYNOPSIS
use WebGUI::Asset::Sku::EMSToken;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my %properties;
tie %properties, 'Tie::IxHash';
my $i18n = WebGUI::International->new($session, "Asset_EventManagementSystem");
my $date = WebGUI::DateTime->new($session, time());
%properties = (
price => {
tab => "commerce",
fieldType => "float",
defaultValue => 0.00,
label => $i18n->get("price"),
hoverHelp => $i18n->get("price help"),
},
);
push(@{$definition}, {
assetName => $i18n->get('ems token'),
icon => 'EMSToken.gif',
autoGenerateForms => 1,
tableName => 'EMSToken',
className => 'WebGUI::Asset::Sku::EMSToken',
properties => \%properties
});
return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}
#-------------------------------------------------------------------
sub getPrice {
my $self = shift;
return $self->get("price");
}
#-------------------------------------------------------------------
sub onCompletePurchase {
my ($self, $item) = @_;
my $db = $self->session->db;
my @params = ($self->getId, $self->getOptions->{badgeId});
my $currentQuantity = $db->quickScalar("select quantity from EMSRegistrantToken where tokenAssetId=? and badgeId=?",\@params);
unshift @params, $item->get("quantity");
if (defined $currentQuantity) {
$db->write("update EMSRegistrationToken set quantity=quantity+? where tokenAssetId=? and badgeId=?",\@params);
}
else {
$db->write("insert into EMSRegistrationToken (quantity, tokenAssetId, badgeId) values (?,?,?)",\@params);
}
return undef;
}
#-------------------------------------------------------------------
sub purge {
my $self = shift;
$self->session->db->write("delete from EMSRegistrantToken where tokenAssetId=?",[$self->getId]);
$self->SUPER::purge;
}
#-------------------------------------------------------------------
sub view {
my ($self) = @_;
return $self->getParent->view;
}
#-------------------------------------------------------------------
sub www_addToCart {
my ($self) = @_;
return $self->session->privilege->noAccess() unless $self->getParent->canView;
$self->addToCart({badgeId=>$self->session->form->get('badgeId')});
return $self->getParent->www_view;
}
1;

View file

@ -1064,6 +1064,18 @@ by setting the "hide" form variable.|,
context => q|name of asset|,
},
'ems ribbon' => {
message => q|Event Manager Ribbon|,
lastUpdated => 0,
context => q|name of asset|,
},
'ems token' => {
message => q|Event Manager Token|,
lastUpdated => 0,
context => q|name of asset|,
},
'type name here' => {
message => q|Type Name Here|,
lastUpdated => 1140469381,