---
#
#  Copyright 2020 Koha Development Team
#
#  This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.

description:
  - "CSV profiles"
  - ""
  - "Default CSV export profiles; including one for exporting serial claims."

tables:
  - export_format:
      translatable: [ profile, description ]
      multiline: [ content ]
      rows:
        - profile: "issues to claim"
          description: "Default CSV export for serial issue claims"
          content:
            - "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate"
          csv_separator: ","
          type: sql
          used_for: late_issues
        - profile: "Late orders (CSV profile)"
          description: "Default CSV export for late orders"
          content:
            - 'Title[% separator %]Author[% separator %]Publication year[% separator %]ISBN[% separator %]Quantity[% separator %]Number of claims'
            - '[% FOR order IN orders ~%]'
            - '[%~ SET biblio = order.biblio ~%]'
            - '"[% biblio.title %]"[% separator ~%]'
            - '"[% biblio.author %]"[% separator ~%]'
            - '"[% bibio.biblioitem.publicationyear %]"[% separator ~%]'
            - '"[% biblio.biblioitem.isbn %]"[% separator ~%]'
            - '"[% order.quantity%]"[% separator ~%]'
            - '"[% order.claims.count%][% IF order.claims.count %]([% FOR c IN order.claims %][% c.claimed_on | $KohaDates %][% UNLESS loop.last %], [% END %][% END %])[% END %]"'
            - '[% END %]'
          csv_separator: ","
          type: sql
          used_for: late_orders
