31 lines
1 KiB
Ruby
31 lines
1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# Copyright (c) 2026, Kreisjagdverband Bautzen e.V. This file is part of
|
|
# hitobito_kjv and licensed under the Affero General Public License version 3
|
|
# or later. See the COPYING file at the top-level directory.
|
|
|
|
# Erzeugt das Sammel-PDF der Mitgliedsausweise im Hintergrund. Das Ergebnis erscheint
|
|
# wie andere Exporte unter "Downloads" (Job-Observation des Cores).
|
|
class Kjv::Export::MembershipCardsJob < Export::ExportBaseJob
|
|
self.parameters = PARAMETERS + [:people_ids]
|
|
|
|
def initialize(user_id, people_ids, options = {})
|
|
super(:pdf, user_id, options)
|
|
@people_ids = people_ids
|
|
end
|
|
|
|
def data
|
|
Kjv::Export::Pdf::MembershipCards.new(cards).render
|
|
end
|
|
|
|
private
|
|
|
|
def cards
|
|
Pass.joins(:pass_definition)
|
|
.includes(:person)
|
|
.where(person_id: @people_ids, state: "eligible",
|
|
pass_definitions: {template_key: Kjv::MembershipCard.template_key})
|
|
.sort_by { |pass| [pass.person.last_name.to_s, pass.person.first_name.to_s] }
|
|
.map { |pass| Kjv::MembershipCard.new(pass) }
|
|
end
|
|
end
|