added a very basic in shop credit manager screen
This commit is contained in:
parent
75c44c110f
commit
b7840e7ed9
5 changed files with 93 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ use WebGUI::AdminConsole;
|
|||
use WebGUI::Exception::Shop;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
use WebGUI::Shop::Cart;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::Shop::Pay;
|
||||
use WebGUI::Shop::Ship;
|
||||
use WebGUI::Shop::Tax;
|
||||
|
|
@ -142,6 +143,28 @@ sub www_cart {
|
|||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_credit ()
|
||||
|
||||
Hand off to the credit system.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_credit {
|
||||
my $session = shift;
|
||||
my $output = undef;
|
||||
my $method = "www_".$session->form->get("method");
|
||||
if ($method ne "www_" && WebGUI::Shop::Credit->can($method)) {
|
||||
$output = WebGUI::Shop::Credit->$method($session);
|
||||
}
|
||||
else {
|
||||
WebGUI::Error::MethodNotFound->throw(error=>"Couldn't call non-existant method $method", method=>$method);
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_pay ()
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ sub getAdminConsole {
|
|||
$ac->addSubmenuItem($url->page("shop=ship;method=manage"), $i18n->get("shipping methods"));
|
||||
$ac->addSubmenuItem($url->page("shop=transaction;method=manage"), $i18n->get("transactions"));
|
||||
$ac->addSubmenuItem($url->page("shop=vendor;method=manage"), $i18n->get("vendors"));
|
||||
$ac->addSubmenuItem($url->page("shop=credit;method=manage"), $i18n->get("in shop credit"));
|
||||
return $ac;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ use Class::InsideOut qw{ :std };
|
|||
use WebGUI::Shop::Admin;
|
||||
use WebGUI::Exception::Shop;
|
||||
use WebGUI::International;
|
||||
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::User;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -166,5 +167,59 @@ Returns a reference to the userId.
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_adjust
|
||||
|
||||
Adjust credit for a user.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_adjust {
|
||||
my ($class, $session) = @_;
|
||||
my $admin = WebGUI::Shop::Admin->new($session);
|
||||
return $session->privilege->insufficient() unless $admin->canManage;
|
||||
my $form = $session->form;
|
||||
my $credit = $class->new($session, $form->get('userId'));
|
||||
$credit->adjust($form->get('amount'), $form->get('comment'));
|
||||
my $i18n = WebGUI::International->new($session, "Shop");
|
||||
my $message = sprintf $i18n->get('add credit message'), $form->get('amount'), WebGUI::User->new($session, $form->get('userId'))->username, $credit->getSum;
|
||||
return $class->www_manage($session, $message);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_manage
|
||||
|
||||
Displays a credit management interface.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_manage {
|
||||
my ($class, $session, $message) = @_;
|
||||
my $admin = WebGUI::Shop::Admin->new($session);
|
||||
return $session->privilege->insufficient() unless $admin->canManage;
|
||||
my $i18n = WebGUI::International->new($session, "Shop");
|
||||
my $f = WebGUI::HTMLForm->new($session);
|
||||
$f->hidden(name=>'shop',value=>'credit');
|
||||
$f->hidden(name=>'method',value=>'adjust');
|
||||
$f->user(
|
||||
name => 'userId',
|
||||
label => $i18n->get('username'),
|
||||
value => $session->user->userId,
|
||||
);
|
||||
$f->float(
|
||||
name => 'amount',
|
||||
label => $i18n->get('amount'),
|
||||
);
|
||||
$f->text(
|
||||
name => 'comment',
|
||||
label => $i18n->get('notes'),
|
||||
);
|
||||
$f->submit;
|
||||
return $admin->getAdminConsole->render($message.$f->print, $i18n->get('in shop credit'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ sub www_view {
|
|||
<th>}. $i18n->get("username") .q{</th><td><a href="}.$url->page('op=editUser;uid='.$transaction->get('userId')).q{">}. $transaction->get('username') .q{</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>}. $i18n->get("price") .q{</th><td><b>}. sprintf("%.2f", $transaction->get('amount')) .q{</b></td>
|
||||
<th>}. $i18n->get("amount") .q{</th><td><b>}. sprintf("%.2f", $transaction->get('amount')) .q{</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>}. $i18n->get("in shop credit used") .q{</th><td>}. sprintf("%.2f", $transaction->get('shopCreditDeduction')) .q{</td>
|
||||
|
|
@ -846,7 +846,6 @@ sub www_view {
|
|||
</table>
|
||||
};
|
||||
|
||||
|
||||
# send output
|
||||
if ($print) {
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -105,6 +105,18 @@ our $I18N = {
|
|||
context => q|field label|
|
||||
},
|
||||
|
||||
'add credit message' => {
|
||||
message => q|%s was added to %s's in-shop credit account, for a total credit of %s.|,
|
||||
lastUpdated => 0,
|
||||
context => q|field label|
|
||||
},
|
||||
|
||||
'amount' => {
|
||||
message => q|Amount|,
|
||||
lastUpdated => 0,
|
||||
context => q|field label|
|
||||
},
|
||||
|
||||
'notes' => {
|
||||
message => q|Notes|,
|
||||
lastUpdated => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue