Zeiterfassung: Bei Projektauswahl ggf. Kunde daraus setzen
[kivitendo-erp.git] / SL / Controller / TimeRecording.pm
index db8d226..e97c3c1 100644 (file)
@@ -13,6 +13,7 @@ use SL::DB::Customer;
 use SL::DB::Employee;
 use SL::DB::Order;
 use SL::DB::Part;
+use SL::DB::Project;
 use SL::DB::TimeRecording;
 use SL::DB::TimeRecordingArticle;
 use SL::Helper::Flash qw(flash);
@@ -137,6 +138,22 @@ sub action_ajaj_get_order_info {
   $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
 }
 
+sub action_ajaj_get_project_info {
+
+  my $project = SL::DB::Project->new(id => $::form->{id})->load;
+
+  my $data;
+  if ($project->customer_id) {
+    $data = { customer => { id    => $project->customer_id,
+                            value => $project->customer->displayable_name,
+                            type  => 'customer'
+                          },
+    };
+  }
+
+  $_[0]->render(\SL::JSON::to_json($data), { type => 'json', process => 0 });
+}
+
 sub init_time_recording {
   my ($self) = @_;