This patch create a sub in Koha.pm which get the list of .pm files in acqui/pdfformat. The list is used to build an option list for OrderPdfFormat syspref, instead of a free input.
In a standard Koha, only the design of OrderPdfFormat should be altered.
If you put a new .pm file in acqui/pdfformat (and if needed a new pdf file in koha-tmpl/intranet/prog/pdf), you will see the name of the file as a new option in OrderPdfFormat.

To test :
A. in a standard Koha, check everything is working like before:
- 1. you have 2 options in OrderPdfFormat (pdfformat::layout2pages ; pdfformat::layout3pages)
- 2. select one layout, and try to print a basketgroup
- 3. select the 2d layout, and try to print a basketgroup

B. check you can add a new layout
- 1. Either create your own layout if you know how to do
Or dowload and apply the 2d attachment to this bug. It contains an example : a layout named "pdfformat::msaby"
- 2. Check the new layout is visible in OrderPdfFormat
- 3. Select it, and try to print a basketgroup
- 4. Select one of the "old" layouts, and try to print a basketgroup.
---
C4/Koha.pm | 28 ++++++++++++++++++++
 acqui/basketgroup.pl                               |   11 --------
 admin/preferences.pl                               |    2 ++
 .../en/modules/admin/preferences/acquisitions.pref |    1 +
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/C4/Koha.pm b/C4/Koha.pm
index 3648dcc..383ff8a 100644
--- a/C4/Koha.pm
+++ b/C4/Koha.pm
@@ -47,6 +47,7 @@ BEGIN {
         &getframeworks &getframeworkinfo
         &getauthtypes &getauthtype
         &getallthemes
+        getallbasketgroupslayouts
         &getFacets
         &displayServers
         &getnbpages
@@ -684,6 +685,33 @@ sub getallthemes {
     return @themes;
 }

+=head2 getallbasketgroupslayouts
+
+  (@pdflayouts) = &getallbasketgroupslayouts();
+
+Returns an array of all available basketgroup layouts
+based on *. pm files in acqui/pdfformat
+
+=cut
+
+sub getallbasketgroupslayouts {
+    my $type = shift;
+    my $pdfdir;
+    my @pdflayouts;
+    $pdfdir = C4::Context->config('intranetdir');
+    $pdfdir .= "/acqui/pdfformat";
+    opendir DIR, $pdfdir;
+    my @filelist = readdir DIR;
+    foreach my $myfile (@filelist) {
+        next unless (-f "$pdfdir/$myfile");
+        next unless ($myfile =~ m/\.pm$/);
+#keeping only *.pm files
+        $myfile =~s/\.pm$//;
+        push @pdflayouts,"pdfformat::".$myfile;
+    }
+    return @pdflayouts;
+}
+
 sub getFacets {
     my $facets;
     if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
diff --git a/acqui/basketgroup.pl b/acqui/basketgroup.pl
index d6bd5d1..8cc2c41 100755
--- a/acqui/basketgroup.pl
+++ b/acqui/basketgroup.pl
@@ -184,24 +184,13 @@ sub displaybasketgroups {

 sub printbasketgrouppdf{
     my ($basketgroupid) = @_;
-
     my $pdfformat = C4::Context->preference("OrderPdfFormat");
- if ($pdfformat eq 'pdfformat::layout3pages' || $pdfformat eq 'pdfformat::layout2pages'){
     eval {
         eval "require $pdfformat";
         import $pdfformat;
     };
     if ($@){
     }
-    }
-    else {
-    print $input->header;
-    print $input->start_html;  # FIXME Should do a nicer page
-    print "<h1>Invalid PDF Format set</h1>";
-    print "Please go to the systempreferences and set a valid pdfformat";
-    exit;
-    }
-
     my $basketgroup = GetBasketgroup($basketgroupid);
     my $bookseller = GetBookSellerFromId($basketgroup->{'booksellerid'});
     my $baskets = GetBasketsByBasketgroup($basketgroupid);
diff --git a/admin/preferences.pl b/admin/preferences.pl
index 2182591..dcfe4a0 100755
--- a/admin/preferences.pl
+++ b/admin/preferences.pl
@@ -93,6 +93,8 @@ sub _get_chunk {
$options{'choices'} = { map { $_ => $_ } getallthemes( 'opac' ) }
             } elsif ( $options{'choices'} eq 'staff-templates' ) {
$options{'choices'} = { map { $_ => $_ } getallthemes( 'intranet' ) }
+            } elsif ( $options{'choices'} eq 'basketgroupspdflayouts' ) {
+ $options{'choices'} = { map { $_ => $_ } getallbasketgroupslayouts ()}
             } else {
die 'Unrecognized source of preference values: ' . $options{'choices'};
             }
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref
index 1ec49ff..e16e1bc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/acquisitions.pref
@@ -40,4 +40,5 @@ Acquisitions:
         -
             - Use
             - pref: OrderPdfFormat
+              choices: basketgroupspdflayouts
             - when printing basket groups.
--
1.7.9.5


--
Mathieu Saby
Service d'Informatique Documentaire
Service Commun de Documentation
Université Rennes 2
Téléphone : 02 99 14 12 65
Courriel : [email protected]

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to