Customer-Controller: 'get_hourly_rate'-AJAX-Funktion
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 1 Feb 2013 15:04:36 +0000 (16:04 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:02:24 +0000 (13:02 +0200)
SL/Controller/Customer.pm [new file with mode: 0644]

diff --git a/SL/Controller/Customer.pm b/SL/Controller/Customer.pm
new file mode 100644 (file)
index 0000000..d6ba13d
--- /dev/null
@@ -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;