can now add a badge to your cart

This commit is contained in:
JT Smith 2008-03-21 23:48:22 +00:00
parent 8a07dde303
commit 1623356e4b
8 changed files with 177 additions and 17 deletions

View file

@ -2179,7 +2179,7 @@ sub update {
# check the definition of all properties against what was given to us
foreach my $definition (reverse @{$self->definition($self->session)}) {
my @setPairs;
my %setPairs = ();
# deal with all the properties in this part of the definition
foreach my $property (keys %{$definition->{properties}}) {
@ -2222,12 +2222,14 @@ sub update {
# set the property
$self->{_properties}{$property} = $value;
push(@setPairs, $property."=".$self->session->db->quote($value));
$setPairs{$property.'=?'} = $value;
}
# if there's anything to update, then do so
if (scalar(@setPairs) > 0) {
$self->session->db->write("update ".$definition->{tableName}." set ".join(",",@setPairs)." where assetId=".$self->session->db->quote($self->getId)." and revisionDate=".$self->get("revisionDate"));
if (scalar(keys %setPairs) > 0) {
my @values = values %setPairs;
push(@values, $self->getId, $self->get("revisionDate"));
$self->session->db->write("update ".$definition->{tableName}." set ".join(",",keys %setPairs)." where assetId=? and revisionDate=?",\@values);
}
}

View file

@ -20,6 +20,7 @@ use base 'WebGUI::Asset::Sku';
use JSON;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Shop::AddressBook;
use WebGUI::Utility;
=head1 NAME
@ -81,7 +82,7 @@ sub definition {
hoverHelp => $i18n->get("price help"),
},
seatsAvailable => {
tab => "properties",
tab => "commerce",
fieldType => "integer",
defaultValue => 100,
label => $i18n->get("seats available"),
@ -110,7 +111,7 @@ Returns title + badgeholder name
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
my $name = $self->session->db->quickScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}
@ -235,7 +236,7 @@ sub view {
$book->submit(value=>$i18n->get("populate from address book"));
# instanciate address
my $address = WebGUI::Shop::Address->new($self->session, $form->get("addressId")) if ($form->get("addressId"));
my $address = WebGUI::Shop::AddressBook->create($self->session)->getAddress($form->get("addressId")) if ($form->get("addressId"));
# build the form that the user needs to fill out with badge holder information
my $info = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
@ -350,4 +351,37 @@ sub www_addToCart {
return $self->getParent->www_viewExtras($self->getOptions->{badgeId});
}
#-------------------------------------------------------------------
=head2 www_edit ()
Displays the edit form.
=cut
sub www_edit {
my ($self) = @_;
return $self->session->privilege->insufficient() unless $self->canEdit;
return $self->session->privilege->locked() unless $self->canEditIfLocked;
$self->session->style->setRawHeadTags(q|
<style type="text/css">
.forwardButton {
background-color: green;
color: white;
font-weight: bold;
padding: 3px;
}
.backwardButton {
background-color: red;
color: white;
font-weight: bold;
padding: 3px;
}
</style>
|);
my $i18n = WebGUI::International->new($self->session, "Asset_EventManagementSystem");
return $self->processStyle('<h1>'.$i18n->get('ems badge').'</h1>'.$self->getEditForm->print);
}
1;

View file

@ -86,7 +86,7 @@ Return title + badge holder name.
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
my $name = $self->session->db->quickScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}

View file

@ -78,7 +78,7 @@ sub definition {
hoverHelp => $i18n->get("price help"),
},
seatsAvailable => {
tab => "properties",
tab => "commerce",
fieldType => "integer",
defaultValue => 25,
label => $i18n->get("seats available"),
@ -105,6 +105,13 @@ sub definition {
label => $i18n->get("event end date"),
hoverHelp => $i18n->get("event end date help"),
},
location => {
tab => "properties",
fieldType => "comboBox",
options => $session->db->buildHashRef("select distinct(location) from EMSTicket order by location"),
label => $i18n->get("seats available"),
hoverHelp => $i18n->get("seats available help"),
},
relatedBadges => {
tab => "properties",
fieldType => "checkList",
@ -136,7 +143,7 @@ Returns title + badgeholder name.
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
my $name = $self->session->db->quickScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}

View file

@ -86,7 +86,7 @@ Returns title + badgeholder name.
sub getConfiguredTitle {
my $self = shift;
my $name = $self->session->db->getScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
my $name = $self->session->db->quickScalar("select name from EMSRegistrant where badgeId=?",[$self->getOptions->{badgeId}]);
return $self->getTitle." (".$name.")";
}

View file

@ -62,6 +62,34 @@ sub definition {
hoverHelp => $i18n->get('extras template help'),
namespace => 'EMS/Extras',
},
badgeInstructions => {
fieldType => 'HTMLArea',
defaultValue => $i18n->get('default badge instructions'),
tab => 'properties',
label => $i18n->get('badge instructions'),
hoverHelp => $i18n->get('badge instructions help'),
},
ticketInstructions => {
fieldType => 'HTMLArea',
defaultValue => $i18n->get('default ticket instructions'),
tab => 'properties',
label => $i18n->get('ticket instructions'),
hoverHelp => $i18n->get('ticket instructions help'),
},
ribbonInstructions => {
fieldType => 'HTMLArea',
defaultValue => $i18n->get('default ribbon instructions'),
tab => 'properties',
label => $i18n->get('ribbon instructions'),
hoverHelp => $i18n->get('ribbon instructions help'),
},
tokenInstructions => {
fieldType => 'HTMLArea',
defaultValue => $i18n->get('default token instructions'),
tab => 'properties',
label => $i18n->get('token instructions'),
hoverHelp => $i18n->get('token instructions help'),
},
);
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
@ -104,6 +132,18 @@ sub prepareView {
border:1px solid #000;
padding:10px;
}
.forwardButton {
background-color: green;
color: white;
font-weight: bold;
padding: 3px;
}
.backwardButton {
background-color: red;
color: white;
font-weight: bold;
padding: 3px;
}
</style>
|);
return undef;
@ -138,6 +178,7 @@ sub view {
<div class=" yui-skin-sam">
<a href="|.$self->getUrl('func=add;class=WebGUI::Asset::Sku::EMSBadge').q|">Add a badge</a>
<p>|.$self->get('badgeInstructions').q|</p>
<div id="emsBadgeList"></div>
</div>
@ -186,7 +227,7 @@ STOP
# add to cart formatter
$output .= q|
var formatAddToCart = function(elCell, oRecord, oColumn, url) {
elCell.innerHTML = '<a href="' + url + '">Add To Cart</a>';
elCell.innerHTML = (oRecord.getData('quantityAvailable') < 1) ? '' : '<a href="' + url + '" class="forwardButton">Buy</a>';
};
|;
@ -200,7 +241,7 @@ STOP
# quantity available formatter
$output .= q|
var formatQuantityAvailable = function(elCell, oRecord, oColumn, quantityAvailable) {
elCell.innerHTML = (quantityAvailable == 0) ? '<strong>Sold Out!</strong>' : quantityAvailable;
elCell.innerHTML = (quantityAvailable < 1) ? '<strong>Sold Out!</strong>' : quantityAvailable;
};
|;
@ -215,7 +256,7 @@ STOP
if ($session->var->isAdminOn) {
$output .= '{key:"editUrl", label:"Manage", formatter:formatManageBadge},';
}
$output .= '{key:"url", label:"Add To Cart", formatter:formatAddToCart},';
$output .= '{key:"url", label:"Buy", formatter:formatAddToCart},';
$output .= '{key:"title", label:"Title",sortable:true,formatter:formatViewBadgeDescription},';
$output .= '{key:"price", label:"Price",sortable:true,formatter:YAHOO.widget.DataTable.formatCurrency},';
$output .= '{key:"quantityAvailable",sortable:true,label:"Quantity Available", formatter:formatQuantityAvailable},';
@ -300,10 +341,9 @@ sub www_viewExtras {
return $self->session->privilege->noAccess() unless $self->canView;
$badgeId = $self->session->form->get("badgeId") unless ($badgeId eq "");
return "got here";
my %var = ();
# other template variables
$self->appendBadgeVars($badgeId, \%var);
# render
return $self->processTemplate(\%var,$self->get('viewRibbonsTemplate'));

View file

@ -2,6 +2,78 @@ package WebGUI::i18n::English::Asset_EventManagementSystem;
use strict;
our $I18N = { ##hashref of hashes
'badge instructions' => {
message => q|Badge Instructions|,
lastUpdated => 0,
context => q|a property label|,
},
'badge instructions help' => {
message => q|Give the user some help on what to do with a badge.|,
lastUpdated => 0,
context => q|help for a property label|,
},
'default badge instructions' => {
message => q|You need a badge to attend this convention. Choose a badge that meets your needs and budget.|,
lastUpdated => 0,
context => q|the default value for a property|,
},
'ticket instructions' => {
message => q|Ticket Instructions|,
lastUpdated => 0,
context => q|a property label|,
},
'ticket instructions help' => {
message => q|Give the user some help on what to do with a ticket.|,
lastUpdated => 0,
context => q|help for a property label|,
},
'default ticket instructions' => {
message => q|Tickets allow you to reserve a seat at events that are going on at the convention. Add tickets to your badge for any events you plan to attend.|,
lastUpdated => 0,
context => q|the default value for a property|,
},
'ribbon instructions' => {
message => q|Ribbon Instructions|,
lastUpdated => 0,
context => q|a property label|,
},
'ribbon instructions help' => {
message => q|Give the user some help on what to do with a ribbon.|,
lastUpdated => 0,
context => q|help for a property label|,
},
'default ribbon instructions' => {
message => q|Ribbons give you discounts on a group of related events. You may add one ore more ribbons to your badge to give you discounts on related events.|,
lastUpdated => 0,
context => q|the default value for a property|,
},
'token instructions' => {
message => q|Token Instructions|,
lastUpdated => 0,
context => q|a property label|,
},
'token instructions help' => {
message => q|Give the user some help on what to do with a ribbon.|,
lastUpdated => 0,
context => q|help for a property label|,
},
'default token instructions' => {
message => q|Tokens are like convention currency. They allow you to purchase events and other items without buying a specific ticket.|,
lastUpdated => 0,
context => q|the default value for a property|,
},
'assetName' => {
message => q|Event Manager (beta)|,
lastUpdated => 1131394072,