+sub prepare_pictures_for_printing {
+  my ($self) = @_;
+
+  my @files;
+  my $userspath = File::Spec->rel2abs($::lx_office_conf{paths}->{userspath});
+  my $target    =  "${userspath}/kivitendo-print-requirement-spec-picture-" . Common::unique_id() . '-';
+
+  foreach my $picture (map { @{ $_->pictures } } @{ $self->requirement_spec->text_blocks }) {
+    my $output_file_name        = $target . $picture->id . '.' . $picture->get_default_file_name_extension;
+    $picture->{print_file_name} = File::Spec->abs2rel($output_file_name, $userspath);
+    my $out                     = IO::File->new($output_file_name, 'w') || die("Could not create file " . $output_file_name);
+    $out->binmode;
+    $out->print($picture->picture_content);
+    $out->close;
+
+    push @files, $output_file_name;
+  }
+
+  return @files;
+}
+
+sub update_project_link_none_keep_existing {
+  my ($self, $action) = @_;
+
+  $self->requirement_spec->update_attributes(project_id => undef)                     if $action eq 'none';
+  $self->requirement_spec->update_attributes(project_id => $::form->{new_project_id}) if $action eq 'existing';
+
+  return $self->invalidate_version
+    ->replaceWith('#basic_settings', $self->render('requirement_spec/_show_basic_settings', { output => 0 }))
+    ->remove('#project_link_form')
+    ->flash('info', t8('The project link has been updated.'))
+    ->render($self);
+}
+
+sub update_project_link_new {
+  my ($self) = @_;
+
+  return $self->js
+    ->replaceWith('#project_link_form', $self->render('requirement_spec/_new_project_form', { output => 0 }))
+    ->render($self);
+}
+
+sub update_project_link_create {
+  my ($self)  = @_;
+  my $params  = delete($::form->{project}) || {};
+  my $project = SL::DB::Project->new(
+    %{ $params },
+    valid  => 1,
+    active => 1,
+  );
+
+  my @errors = $project->validate;
+
+  return $self->js->error(@errors)->render($self) if @errors;
+
+  my $db = $self->requirement_spec->db;
+  if (!$db->do_transaction(sub {
+    $project->save;
+    $self->requirement_spec->update_attributes(project_id => $project->id);
+
+  })) {
+    $::lxdebug->message(LXDebug::WARN(), "Error: " . $db->error);
+    return $self->js->error(t8('Saving failed. Error message from the database: #1', $db->error))->render($self);
+  }
+
+  return $self->invalidate_version
+    ->replaceWith('#basic_settings', $self->render('requirement_spec/_show_basic_settings', { output => 0 }))
+    ->remove('#project_link_form')
+    ->flash('info', t8('The project has been created.'))
+    ->flash('info', t8('The project link has been updated.'))
+    ->render($self);
+}
+
+sub init_models {
+  my ($self) = @_;
+
+  SL::Controller::Helper::GetModels->new(
+    controller   => $self,
+    sorted       => {
+      _default     => {
+        by           => 'customer',
+        dir          => 1,
+      },
+      %sort_columns,
+    },
+    query => [
+      and => [
+        working_copy_id => undef,
+        is_template     => $::form->{is_template} ? 1 : 0,
+      ],
+    ],
+    with_objects => [ 'customer', 'type', 'status', 'project' ],
+  );
+}
+