diff --git a/docs/upgrades/upgrade_6.8.7-6.99.0.pl b/docs/upgrades/upgrade_6.8.7-6.99.0.pl index ec86e45ea..c13ae87cc 100644 --- a/docs/upgrades/upgrade_6.8.7-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.7-6.99.0.pl @@ -381,6 +381,7 @@ sub updateTemplates { sub addEMSTemplates { print "\tAdding Event Management System Templates.\n" unless ($quiet); +## Display Template ## my $template = < @@ -399,12 +400,68 @@ my $template = < EOT1 +## Event Template ## my $template2 = <
 
EOT2 + +## Checkout Template ## +my $template3 = < + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ +
+ +EOT3 + +## End Templates + my $in = WebGUI::Asset->getImportNode($session); $in->addChild({ className=>'WebGUI::Asset::Template', @@ -419,6 +476,13 @@ EOT2 namespace=>'EventManagementSystem_product', }, "EventManagerTmpl000002" ); + + $in->addChild({ + className=>'WebGUI::Asset::Template', + template=>$template3, + namespace=>'EventManagementSystem_checkout', + }, "EventManagerTmpl000003" + ); } #------------------------------------------------- @@ -432,6 +496,7 @@ create table EventManagementSystem ( assetId varchar(22) not null, revisionDate bigint(20) not null, displayTemplateId varchar(22), + checkoutTemplateId varchar(22), paginateAfter int(11) default 10, groupToAddEvents varchar(22), groupToApproveEvents varchar(22), diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index 9940dc6ed..6a0b446ce 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -123,6 +123,14 @@ sub definition { hoverHelp=>$i18n->get('display template description'), label=>$i18n->get('display template') }, + checkoutTemplateId =>{ + fieldType=>"template", + defaultValue=>'EventManagerTmpl000003', + tab=>"display", + namespace=>"EventManagementSystem_checkout", + hoverHelp=>'', + label=>"Checkout Template" + }, paginateAfter =>{ fieldType=>"integer", defaultValue=>10, @@ -421,6 +429,38 @@ sub findSubEvents { return \@subEvents; } +#------------------------------------------------------------------ +sub getRegistrationInfo { + my $self = shift; + my %var; + + $var{'form.header'} = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl}) + .WebGUI::Form::hidden($self->session,{name=>"func",value=>"www_saveRegistration"}); + + $var{'form.footer'} = WebGUI::Form::formFooter($self->session); + $var{'form.submit'} = WebGUI::Form::submit($self->session); + $var{'form.firstName.label'} = "First Name"; + $var{'form.lastName.label'} = "Last Name"; + $var{'form.address.label'} = "Address"; + $var{'form.city.label'} = "City"; + $var{'form.state.label'} = "State"; + $var{'form.zipCode.label'} = "Zip Code"; + $var{'form.country.label'} = "Country"; + $var{'form.phoneNumber.label'} = "Phone Number"; + $var{'form.email.label'} = "Email Address"; + $var{'form.firstName'} = WebGUI::Form::Text($self->session,{}); + $var{'form.lastName'} = WebGUI::Form::Text($self->session,{}); + $var{'form.address'} = WebGUI::Form::Text($self->session,{}); + $var{'form.city'} = WebGUI::Form::Text($self->session,{}); + $var{'form.state'} = WebGUI::Form::Text($self->session,{}); + $var{'form.zipCode'} = WebGUI::Form::Text($self->session,{}); + $var{'form.country'} = WebGUI::Form::SelectList($self->session,{}); + $var{'form.phoneNumber'} = WebGUI::Form::Phone($self->session,{}); + $var{'form.email'} = WebGUI::Form::Email($self->session,{}); + $var{'registration'} = 1; + return \%var; +} + #------------------------------------------------------------------ sub getSubEventPrerequisites { my $self = shift; @@ -504,36 +544,40 @@ sub getSubEventForm { my $pids = shift; my $subEvents = $self->getSubEvents($pids); my @usedEventIds; - - # - # TODO : This will all be template variable assignments - # and need to make checkbox for each subevent so it can be selected - # and added to the cart - # - - my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl); + my %var; my $i18n = WebGUI::International->new($self->session, 'Asset_EventManagementSystem'); - $f->hidden(-name=>"func",-value=>"addToCart"); - $f->hidden(-name=>"method",-value=>"addSubEvents"); - $f->readOnly(-value=>$i18n->get('allowed sub events')); + $var{'form.header'} = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl}) + .WebGUI::Form::hidden($self->session,{name=>"func",value=>"addToCart"}) + .WebGUI::Form::hidden($self->session,{name=>"method",value=>"addSubEvents"} + ); + + $var{'form.footer'} = WebGUI::Form::formFooter($self->session); + $var{'form.submit'} = WebGUI::Form::Submit($self->session); + $var{'message'} = $i18n->get('allowed sub events'); + + my @subEventLoop; foreach my $subEvent (@$subEvents) { while (my $eventData = $subEvent->hashRef) { - + # Track used event ids so we can prevent listing a subevent more than once. next if (WebGUI::Utility::isIn($eventData->{productId}, @usedEventIds)); push (@usedEventIds, $eventData->{productId}); - - $f->checkbox(-value=>$eventData->{productId}, - -label=>$eventData->{title}. - " ".$eventData->{description}." ".$eventData->{price}."
", - -name=>"subEventPID" - ); + + push(@subEventLoop, { + 'form.checkBox' => WebGUI::Form::checkbox($self->session, { + value => $eventData->{productId}, + name => "subEventPID"}), + 'title' => $eventData->{title}, + 'description' => $eventData->{description}, + 'price' => $eventData->{price} + + }); } } - $f->submit; - - my $output = $f->print if (scalar (@$subEvents) > 0); + $var{'subevents_loop'} = \@subEventLoop; + $var{'chooseSubevents'} = 1; + my $output = \%var if (scalar (@$subEvents) > 0); return $output; } @@ -543,10 +587,9 @@ sub resolveConflictForm { my $self = shift; my $event1 = shift; my $event2 = shift; - my $output; my $extrasURL = $self->session->config->get("extrasURL"); my $deleteIcon = $extrasURL."/toolbar/bullet/delete.gif"; - + my %var; my $sth = $self->session->db->read(" select productId, title, price, description from products where productId in (".$self->session->db->quote($event1)."," @@ -554,28 +597,30 @@ sub resolveConflictForm { ); my $i18n = WebGUI::International->new($self->session, 'Asset_EventManagementSystem'); - $output .= sprintf "", $i18n->get('scheduling conflict message'); - $output .= "session,{action=>$self->getUrl}) + .WebGUI::Form::hidden($self->session,{name=>"func",value=>"deleteCartItem"}) + .WebGUI::Form::hidden($self->session,{name=>"event1",value=>"$event1"}) + .WebGUI::Form::hidden($self->session,{name=>"event2",value=>"$event2"} + ); + + $var{'form.footer'} = WebGUI::Form::formFooter($self->session); + $var{'form.submit'} = WebGUI::Form::Submit($self->session); + $var{'message'} = $i18n->get('allowed sub events'); + + my @loop; while (my $data = $sth->hashRef) { - $output .= ""; + push(@loop, { + 'form.deleteControl' => "", + 'title' => $data->{title}, + 'description' => $data->{description}, + 'price' => $data->{price} + }); } - $output .= ""; - $output .= "
%s
"; - $output .= ""; - $output .= ""; - $output .= $data->{title}." ".$data->{description}." ".$data->{price}; - $output .= "
"; - $output .= sprintf "%s", $i18n->get('scheduling conflict continue'); + $var{'conflict_loop'} = \@loop; + $var{'resolveConflicts'} = 1; - # - # This will all be templated - # - - - return $output; + return \%var; } #------------------------------------------------------------------ @@ -641,14 +686,12 @@ sub www_addToCart { $pid = shift; # Check if conflicts were found that the user needs to fix - $output = join '', @{ $conflicts } if defined $conflicts; - + $output = $conflicts->[0] if defined $conflicts; + unless ($output) { #Skip this if we have errors if ($self->session->form->get("method") eq "addSubEvents") { # List of ids from subevent form @pids = $self->session->form->process("subEventPID", "checkList"); - #Hack until the form->process method returns elements like it should - #@pids = split("\n", $pids[0]); } else { # A single id, i.e., a master event push(@pids, $self->session->form->get("pid") || $pid); @@ -664,11 +707,10 @@ sub www_addToCart { $errors = $self->checkConflicts; if (scalar(@$errors) > 0) { return $self->error($errors, "www_addToCart"); } - # - # Also need to make all of this output use a template + $output = $self->getRegistrationInfo unless ($output); + } - #return $self->session->style->process($self->processTemplate($f->print,$self->getValue("gradebookTemplateId")),$self->getValue("styleTemplateId")); - return $self->session->style->process($output,$self->getValue("styleTemplateId")); + return $self->session->style->process($self->processTemplate($output,$self->getValue("checkoutTemplateId")),$self->getValue("styleTemplateId")); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Commerce/Payment.pm b/lib/WebGUI/Commerce/Payment.pm index e91a9bbf2..e7b27feef 100644 --- a/lib/WebGUI/Commerce/Payment.pm +++ b/lib/WebGUI/Commerce/Payment.pm @@ -187,7 +187,9 @@ Returns a reference to an array of all enabled instantiated payment plugins. =cut sub getEnabledPlugins { - my ($session) = @_; + #my ($session) = @_; + my $class = shift; + my $session = shift; my (@enabledPlugins, $plugin, @plugins); @enabledPlugins = $session->db->buildArray("select namespace from commerceSettings where type='Payment' and fieldName='enabled' and fieldValue='1'"); diff --git a/lib/WebGUI/Commerce/Shipping.pm b/lib/WebGUI/Commerce/Shipping.pm index 5cc49c9eb..fb9cc0d91 100644 --- a/lib/WebGUI/Commerce/Shipping.pm +++ b/lib/WebGUI/Commerce/Shipping.pm @@ -148,7 +148,8 @@ Returns a reference to an array of all enabled instantiated payment plugins. =cut sub getEnabledPlugins { - my ($session) = @_; + my $class = shift; + my $session = shift; my (@enabledPlugins, $plugin, @plugins); @enabledPlugins = $session->db->buildArray("select namespace from commerceSettings where type='Shipping' and fieldName='enabled' and fieldValue='1'"); diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index 657b09bf4..df8bccaca 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -719,7 +719,7 @@ sub www_editCommerceSettingsSave { # Store the plugin configuration data in a special table for security and the general settings in the # normal settings table for easy access. if (/~([^~]*)~([^~]*)~([^~]*)/) { - WebGUI::Commerce::setCommerceSetting({ + WebGUI::Commerce::setCommerceSetting($session,{ type => $1, namespace => $2, fieldName => $3, @@ -915,7 +915,8 @@ sub www_selectPaymentGateway { }); } } elsif (scalar(@$plugins) == 1) { - $session->form->process("paymentGateway") = $plugins->[0]->namespace; + #$session->form->process("paymentGateway") = $plugins->[0]->namespace; + $session->stow->set("paymentGateway", $plugins->[0]->namespace); return WebGUI::Operation::execute($session,'selectPaymentGatewaySave'); } @@ -944,8 +945,10 @@ Returns the user to the operation C when it is done. sub www_selectPaymentGatewaySave { my $session = shift; - if (WebGUI::Commerce::Payment->load($session, $session->form->process("paymentGateway"))->enabled) { - $session->scratch->set('paymentGateway', $session->form->process("paymentGateway")); + # shifting stow first because it's only set when one payment gateway is defined + my $paymentGateway = $session->stow->get("paymentGateway") || $session->form->process("paymentGateway"); + if (WebGUI::Commerce::Payment->load($session, $paymentGateway)->enabled) { + $session->scratch->set('paymentGateway', $paymentGateway); } else { $session->scratch->set('paymentGateway', '-delete-'); } @@ -980,7 +983,8 @@ sub www_selectShippingMethod { }); } } elsif (scalar(@$plugins) == 1) { - $session->form->process("shippingMethod") = $plugins->[0]->namespace; + #$session->form->process("shippingMethod") = $plugins->[0]->namespace; + $session->stow->set('shippingMethod', $plugins->[0]->namespace); return WebGUI::Operation::execute($session,"selectShippingMethodSave"); } @@ -988,9 +992,9 @@ sub www_selectShippingMethod { $var{message} = $i18n->get('select shipping method'); $var{pluginsAvailable} = @$plugins; $var{noPluginsMessage} = $i18n->get('no shipping methods available'); - $var{formHeader} = WebGUI::Form::formHeader.WebGUI::Form::hidden($session,{name=>'op', value=>'selectShippingMethodSave'}); + $var{formHeader} = WebGUI::Form::formHeader($session).WebGUI::Form::hidden($session,{name=>'op', value=>'selectShippingMethodSave'}); $var{formSubmit} = WebGUI::Form::submit($session,{value=>$i18n->get('shipping select button')}); - $var{formFooter} = WebGUI::Form::formFooter; + $var{formFooter} = WebGUI::Form::formFooter($session); return $session->style->userStyle(WebGUI::Asset::Template->new($session,$session->setting->get("commerceSelectShippingMethodTemplateId"))->process(\%var)); } @@ -1012,7 +1016,9 @@ Returns the user to the operation C when it is done. sub www_selectShippingMethodSave { my $session = shift; - my $shipping = WebGUI::Commerce::Shipping->load($session, $session->form->process("shippingMethod")); + # Shifting stow first b/c it's only set when one shipping plug-in exists + my $shippingMethod = $session->stow->get('shippingMethod') || $session->form->process("shippingMethod"); + my $shipping = WebGUI::Commerce::Shipping->load($session, $shippingMethod); $shipping->processOptionsForm; return WebGUI::Operation::execute($session,'selectShipping') unless ($shipping->optionsOk); diff --git a/lib/WebGUI/Session/Stow.pm b/lib/WebGUI/Session/Stow.pm index 814fac512..950f30268 100644 --- a/lib/WebGUI/Session/Stow.pm +++ b/lib/WebGUI/Session/Stow.pm @@ -106,7 +106,8 @@ The name of the variable. sub get { my $self = shift; my $var = shift; - return undef if $self->session->config->get("disableCache"); + # wtf!? This line is breaking stuff, what does stow have to do with caching? + #return undef if $self->session->config->get("disableCache"); return $self->{_data}{$var}; }