nuther check point
This commit is contained in:
parent
e6fc38a502
commit
3c56bb64ae
4 changed files with 371 additions and 23 deletions
|
|
@ -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.
|
||||
|
|
|
|||
80
lib/WebGUI/AssetCollateral/Sku/Ad/Ad.pm
Normal file
80
lib/WebGUI/AssetCollateral/Sku/Ad/Ad.pm
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue