From 9284f8744f71eb568fd71a54d560ba9b03d1e0b3 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 7 Mar 2008 03:50:40 +0000 Subject: [PATCH] beginnings of shipping mangement interface --- lib/WebGUI/Content/Shop.pm | 10 ++++---- lib/WebGUI/Shop/Admin.pm | 4 ++-- lib/WebGUI/Shop/Ship.pm | 47 ++++++++++++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/lib/WebGUI/Content/Shop.pm b/lib/WebGUI/Content/Shop.pm index e808c83bf..4ce60275e 100644 --- a/lib/WebGUI/Content/Shop.pm +++ b/lib/WebGUI/Content/Shop.pm @@ -128,9 +128,8 @@ sub www_pay { my $session = shift; my $output = undef; my $method = "www_".$session->form->get("method"); - my $pay = WebGUI::Shop::Pay->create($session); - if ($method ne "www_" && $pay->can($method)) { - $output = $pay->$method(); + if ($method ne "www_" && WebGUI::Shop::Pay->can($method)) { + $output = WebGUI::Shop::Pay->$method($session); } return $output; } @@ -147,9 +146,8 @@ sub www_ship { my $session = shift; my $output = undef; my $method = "www_".$session->form->get("method"); - my $ship = WebGUI::Shop::Ship->create($session); - if ($method ne "www_" && $ship->can($method)) { - $output = $ship->$method(); + if ($method ne "www_" && WebGUI::Shop::Ship->can($method)) { + $output = WebGUI::Shop::Ship->$method($session); } return $output; } diff --git a/lib/WebGUI/Shop/Admin.pm b/lib/WebGUI/Shop/Admin.pm index e30150f32..6cff0e4c0 100644 --- a/lib/WebGUI/Shop/Admin.pm +++ b/lib/WebGUI/Shop/Admin.pm @@ -45,8 +45,8 @@ sub getAdminConsole { my $url = $self->session->url; $ac->addSubmenuItem($url->page("shop=admin"), $i18n->get("shop settings")); $ac->addSubmenuItem($url->page("shop=tax"), $i18n->get("taxes")); - $ac->addSubmenuItem($url->page("shop=pay"), $i18n->get("payment methods")); - $ac->addSubmenuItem($url->page("shop=ship"), $i18n->get("shipping methods")); + $ac->addSubmenuItem($url->page("shop=pay;method=manage"), $i18n->get("payment methods")); + $ac->addSubmenuItem($url->page("shop=ship;method=manage"), $i18n->get("shipping methods")); $ac->addSubmenuItem($url->page("shop=transactions"), $i18n->get("transactions")); return $ac; } diff --git a/lib/WebGUI/Shop/Ship.pm b/lib/WebGUI/Shop/Ship.pm index 64b062396..1486788ef 100644 --- a/lib/WebGUI/Shop/Ship.pm +++ b/lib/WebGUI/Shop/Ship.pm @@ -2,11 +2,12 @@ package WebGUI::Shop::Ship; use strict; -use WebGUI::International; -use WebGUI::Shop::ShipDriver; -use WebGUI::Pluggable; -use WebGUI::Utility; use WebGUI::Exception; +use WebGUI::International; +use WebGUI::Pluggable; +use WebGUI::Shop::Admin; +use WebGUI::Shop::ShipDriver; +use WebGUI::Utility; =head1 NAME @@ -176,4 +177,42 @@ sub new { return $driver; } +#------------------------------------------------------------------- + +=head2 www_do ( ) + +Let's ship drivers do method calls. Requires a driver param in the post form vars which contains the id of the driver to load. + +=cut + +sub www_do { + my ($class, $session) = @_; + my $form = $session->form; + my $driver = $class->new($session, $form->get("driver")); + my $output = undef; + my $method = "www_". ( $form->get("do")); + if ($driver->can($method)) { + $output = $driver->$method(); + } + return $output; +} + +#------------------------------------------------------------------- + +=head2 www_manage ( ) + +The main management screen for shippers. + +=cut + +sub www_manage { + my ($class, $session) = @_; + return $session->privilege->adminOnly() unless ($session->user->isInGroup("3")); + my $admin = WebGUI::Shop::Admin->new($session); + my $console = $admin->getAdminConsole; + my $output = "Test"; + my $i18n = WebGUI::International->new($session, "Shop"); + return $console->render($output, $i18n->get("shipping methods")); +} + 1;