diff --git a/installAdspace.pl b/installAdspace.pl
index 9bafb32df..508dd6a52 100644
--- a/installAdspace.pl
+++ b/installAdspace.pl
@@ -6,7 +6,7 @@ sub install {
print "inside install function\n";
my $confg = $ARGV[0];
my $home = $ARGV[1] || "/data/WebGUI";
- my $className = "WebGUI::Asset::SKu::Ad";
+ my $className = "WebGUI::Asset::Sku::Ad";
unless ($home && $confg) {
die "usage: Perl -M$className -e install yoursite.conf\n";
}
@@ -40,11 +40,16 @@ sub install {
#Create the templates
print "create purchase Ad Template\n";
my $purchaseAdTmpl = q|
+
+
+
+
+
- TODO:Manage my ads link
+
@@ -64,13 +69,13 @@ sub install {
| number of clicks |
- @ per click |
- |
+ ^International("per click","Asset_AdSku", );
+ ^International("click discount","Asset_AdSku",); |
| number of impressions |
- @ per impression |
- |
+ ^International("per impression","Asset_AdSku", );
+ ^International("impression discount","Asset_AdSku",); |
|
@@ -81,24 +86,36 @@ sub install {
|;
print "Manage Ads Template\n";
my $manageAdTmpl = q|
- Manage My Ads
- TODO:Buy Ad Space link
+
+
+
+
+
+
+
+
+ ^International("form manage title","Asset_AdSku");
+
-
- Title|
- |
Clicks|
- |
impressions|
- |
renew|
- |
-
+
+ | ^International("manage form table header title","Asset_AdSku"); |
+ ^International("manage form table header clicks","Asset_AdSku"); |
+ ^International("manage form table header impressions","Asset_AdSku"); |
+ ^International("manage form table header renew","Asset_AdSku"); |
+
+
- |
- |
- |
- |
+ |
+ |
+ |
+
+ ^International("manage form table value deleted","Asset_AdSku");
+
+ ^International("manage form table value renew","Asset_AdSku");
+ |
-
+
|;
diff --git a/lib/WebGUI/Asset/Sku/Ad.pm b/lib/WebGUI/Asset/Sku/Ad.pm
index 55f0f3ad2..e3e978f8f 100644
--- a/lib/WebGUI/Asset/Sku/Ad.pm
+++ b/lib/WebGUI/Asset/Sku/Ad.pm
@@ -167,9 +167,80 @@ sub prepareView {
#-------------------------------------------------------------------
+=head2 prepareManage
+
+Prepares the template.
+
+=cut
+
+sub prepareManage {
+ my $self = shift;
+ $self->SUPER::prepareView();
+ my $templateId = $self->get("manageTemplate");
+ my $template = WebGUI::Asset::Template->new($self->session, $templateId);
+ $template->prepare($self->getMetaDataAsTemplateVariables);
+ $self->{_viewTemplate} = $template;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_manage
+
+manage previously purchased ads
+
+=cut
+
+sub www_manage {
+ my $self = shift;
+ my $check = $self->checkView;
+ return $check if (defined $check);
+ $self->session->http->setLastModified($self->getContentLastModified);
+ $self->session->http->sendHeader;
+ $self->prepareManage;
+ my $style = $self->processStyle($self->getSeparator);
+ my ($head, $foot) = split($self->getSeparator,$style);
+ $self->session->output->print($head, 1);
+ $self->session->output->print($self->manage);
+ $self->session->output->print($foot, 1);
+ return "chunked";
+}
+
+#-------------------------------------------------------------------
+
+=head2 manage
+
+generate template vars for manage page
+
+=cut
+
+sub manage {
+ my ($self) = @_;
+ my $session = $self->session;
+
+ my $i18n = WebGUI::International->new($session, "Asset_AdSku");
+# TODO get the user id, get the asset collateral crud by uid, sort by purchase date descending, pull out unique adids
+ my %var = (
+ formHeader => WebGUI::Form::formHeader($session, { action=>$self->getUrl })
+ . WebGUI::Form::hidden( $session, { name=>"func", value=>"purchaseAdSku" }),
+ formFooter => WebGUI::Form::formFooter($session),
+ form_submit => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
+ hasAddedToCart => $self->{_hasAddedToCart},
+ continueShoppingUrl => $self->getUrl,
+ purchaseLink => $self->getUrl,
+ myAds => [
+# TODO foreach unique adis create a row here
+ { rowTitle => 'here is an ad', rowClicks => '5/200', rowImpressions => '100/2000', rowDeleted => 0, rowRenewLink => '' },
+ { rowTitle => 'yet another ad', rowClicks => '99/4000', rowImpressions => '10/200', rowDeleted => 1, rowRenewLink => '' },
+ ],
+ );
+ return $self->processTemplate(\%var,undef,$self->{_viewTemplate});
+}
+
+#-------------------------------------------------------------------
+
=head2 view
-Displays the donation form.
+Displays the purchase adspace form
=cut
@@ -182,16 +253,88 @@ sub view {
formHeader => WebGUI::Form::formHeader($session, { action=>$self->getUrl })
. WebGUI::Form::hidden( $session, { name=>"func", value=>"purchaseAdSku" }),
formFooter => WebGUI::Form::formFooter($session),
- purchaseButton => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
+ form_submit => WebGUI::Form::submit( $session, { value => $i18n->get("purchase button") }),
hasAddedToCart => $self->{_hasAddedToCart},
continueShoppingUrl => $self->getUrl,
- price => sprintf("%.2f", $self->getPrice),
+ manageLink => $self->getUrl("func=manage"),
+ adSkuTitle => $self->get('title'),
+ adSkuDescription => $self->get('description'),
+ form_title => WebGUI::Form::text($session, {
+ -name=>"form_title",
+ -value=>$self->{title},
+ -size=>40
+ }),
+ form_link => WebGUI::Form::Url($session, {
+ -name=>"form_link",
+ -value=>$self->{link},
+ -size=>40
+ }),
+ form_image => WebGUI::Form::Image($session, {
+ -name=>"form_image",
+ -value=>$self->{image},
+ -size=>40
+ }),
+ form_clicks => WebGUI::Form::Integer($session, {
+ -name=>"form_clicks",
+ -value=>$self->{clicks},
+ -size=>40
+ }),
+ form_impressions => WebGUI::Form::Integer($session, {
+ -name=>"form_impressions",
+ -value=>$self->{impressions},
+ -size=>40
+ }),
+ click_price => $self->get('pricePerClick'),
+ impression_price => $self->get('pricePerImpression'),
+ click_discount => $self->getClickDiscountText,
+ impression_discount => $self->getImpressionDiscountText,
);
return $self->processTemplate(\%var,undef,$self->{_viewTemplate});
}
#-------------------------------------------------------------------
+=head2 getDiscountCountList -- class level function
+
+returns a string with a coma seperated list of counts fromt he discount text
+
+=cut
+
+sub getDiscountCountList {
+# TODO
+# parse the discount text -- for each line, get the first number
+# join all the number in a coma,list
+ return '500';
+}
+
+#-------------------------------------------------------------------
+
+=head2 getClickDiscountText
+
+returns the text to display the number of clicks purchasaed where discounts apply
+
+=cut
+
+sub getClickDiscountText {
+ my $self = shift;
+ return getDiscountCountList($self->get('ClickDiscounts'));
+}
+
+#-------------------------------------------------------------------
+
+=head2 getImpressionDiscountText
+
+returns the text to display the number of impressions purchased where discounts apply
+
+=cut
+
+sub getImpressionDiscountText {
+ my $self = shift;
+ return getDiscountCountList($self->get('impressionDiscounts'));
+}
+
+#-------------------------------------------------------------------
+
=head2 www_purchaseAdSKu
Add this subscription to the cart.
diff --git a/lib/WebGUI/AssetCollateral/Sku/Ad/Ad.pm b/lib/WebGUI/AssetCollateral/Sku/Ad/Ad.pm
new file mode 100644
index 000000000..f9b2d6cd4
--- /dev/null
+++ b/lib/WebGUI/AssetCollateral/Sku/Ad/Ad.pm
@@ -0,0 +1,80 @@
+package WebGUI::AssetCollateral::Sku::Ad::Ad;
+
+=head1 LEGAL
+
+ -------------------------------------------------------------------
+ WebGUI is Copyright 2001-2009 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 base WebGUI::Crud;
+
+#------------------------------------------------
+
+=head crud_definition
+
+defines the field this crud will contain
+
+userID => the id of the user that purchased the ad
+transactionItemid => the id if the transaction item that completes this purchase
+adId => th id if the ad purchased
+clicksPurchased => the number of clicks the user purchased
+impressionsPurchased => the number of impressions the user purchased
+storedImage => temp storage for the image
+isRenewal => indicates if this purchase is a renewal -- are the counts increased or just assigned
+isDeleted => boolean that indicates whether the ad has been deleted from the system
+
+=cut
+
+sub crud_definition {
+ my ($class, $session) = @_;
+ my $definition = $class->SUPER::crud_definition($session);
+ $definition->{tableName} = 'adSkuPurchase';
+ $definition->{tableKey} = 'userId';
+ $definition->{properties} = {
+ userId => {
+ fieldType => 'user',
+ defaultValue => undef,
+ },
+ transactionItemid => {
+ fieldType => 'guid',
+ defaultValue => undef,
+ },
+ adId => {
+ fieldType => 'guid',
+ defaultValue => undef,
+ },
+ clicksPurchased => {
+ fieldType => 'integer',
+ defaultValue => undef,
+ },
+ impressionsPurchased => {
+ fieldType => 'integer',
+ defaultValue => undef,
+ },
+ storedImage => {
+ fieldType => 'guid',
+ defaultValue => undef,
+ },
+ isRenewal => {
+ fieldType => 'yesNo',
+ defaultValue => 0,
+ },
+ isDeleted => {
+ fieldType => 'yesNo',
+ defaultValue => 0,
+ },
+ };
+ return $definition;
+}
+
+
diff --git a/lib/WebGUI/i18n/English/Asset_AdSku.pm b/lib/WebGUI/i18n/English/Asset_AdSku.pm
index 957c1646e..ff553676a 100644
--- a/lib/WebGUI/i18n/English/Asset_AdSku.pm
+++ b/lib/WebGUI/i18n/English/Asset_AdSku.pm
@@ -117,6 +117,114 @@ our $I18N = {
context => q|name for the Ad Space Sku|
},
+ 'Ad Title' => {
+ message => q|Ad Title|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'Ad Link' => {
+ message => q|Ad Link|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'Image' => {
+ message => q|Image|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'number of clicks' => {
+ message => q|number of clicks|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'number of impressions' => {
+ message => q|number of impressions|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'click discount' => {
+ message => q|Discount at %s clicks|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'impression discount' => {
+ message => q|Discount at %s impressions|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'per click' => {
+ message => q|@ %f per click|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'per impression' => {
+ message => q|@ %f per impression|,
+ lastUpdated => 0,
+ context => q|TODO|
+ },
+
+ 'form manage title' => {
+ message => q|Manage My Ads|,
+ lastUpdated => 0,
+ context => q|text for the title of the form where the user can manage previously purchased advertisements|
+ },
+
+ 'form manage link' => {
+ message => q|Manage My Ads|,
+ lastUpdated => 0,
+ context => q|text for a link to the form where the user can manage previously purchased advertisements|
+ },
+
+ 'form purchase link' => {
+ message => q|Purchase Ads|,
+ lastUpdated => 0,
+ context => q|text for a link to the form where the user can purchase advertisements|
+ },
+
+ 'manage form table header title' => {
+ message => q|Title|,
+ lastUpdated => 0,
+ context => q|header for the adspace manage form: the title field|
+ },
+
+ 'manage form table header clicks' => {
+ message => q|Clicks|,
+ lastUpdated => 0,
+ context => q|header for the adspace manage form: the clicks field|
+ },
+
+ 'manage form table header impressions' => {
+ message => q|Impressions|,
+ lastUpdated => 0,
+ context => q|header for the adspace manage form: the impressions field|
+ },
+
+ 'manage form table header renew' => {
+ message => q|Renew|,
+ lastUpdated => 0,
+ context => q|header for the adspace manage form: the renew field|
+ },
+
+ 'manage form table value deleted' => {
+ message => q|Deleted|,
+ lastUpdated => 0,
+ context => q|contents for the renew field on the manage ads table: indicates a deleted item|
+ },
+
+ 'manage form table value renew' => {
+ message => q|Renew|,
+ lastUpdated => 0,
+ context => q|contents for the renew field on the manage ads table: indicates a renewable item|
+ },
+
'TODO' => {
message => q|TODO|,
lastUpdated => 0,