From d157b20fa9377ec48a8b00b7f5ccf8299897f0d2 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 1 Feb 2013 16:04:36 +0100 Subject: [PATCH] Customer-Controller: 'get_hourly_rate'-AJAX-Funktion --- SL/Controller/Customer.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 SL/Controller/Customer.pm diff --git a/SL/Controller/Customer.pm b/SL/Controller/Customer.pm new file mode 100644 index 000000000..d6ba13dc6 --- /dev/null +++ b/SL/Controller/Customer.pm @@ -0,0 +1,29 @@ +package SL::Controller::Customer; + +use strict; +use parent qw(SL::Controller::Base); + +use SL::DB::Customer; +use SL::JSON; + +# safety +__PACKAGE__->run_before(sub { $::auth->assert('customer_vendor_edit') }); + +sub action_get_hourly_rate { + my ($self, %params) = @_; + + my $customer; + $customer = SL::DB::Customer->new(id => $::form->{id})->load if $::form->{id}; + my $data = {}; + + if ($customer) { + $data = { + hourly_rate => $customer->hourly_rate * 1, + hourly_rate_formatted => $::form->format_amount(\%::myconfig, $customer->hourly_rate, 2), + }; + } + + $self->render(\to_json($data), { type => 'json' }); +} + +1; -- 2.20.1