Database updates for hold policies
[koha.git] / tools / letter.pl
index edf5ec4..9c6a76e 100755 (executable)
@@ -48,15 +48,18 @@ sub StringSearch {
     my $dbh = C4::Context->dbh;
     $searchstring =~ s/\'/\\\'/g;
     my @data = split( ' ', $searchstring );
+    $data[0] = '' unless @data;
     my $sth = $dbh->prepare("SELECT * FROM letter WHERE (code LIKE ?) ORDER BY module, code");
     $sth->execute("$data[0]%");     # slightly bogus, only searching on first string.
     return $sth->fetchall_arrayref({});
 }
 
+# FIXME untranslateable
 our %column_map = (
     aqbooksellers => 'BOOKSELLERS',
     aqorders => 'ORDERS',
     serial => 'SERIALS',
+    reserves => 'HOLDS',
 );
 
 sub column_picks ($) {
@@ -77,12 +80,15 @@ sub column_picks ($) {
 
 my $input       = new CGI;
 my $searchfield = $input->param('searchfield');
+$searchfield = '' unless defined($searchfield);
 # my $offset      = $input->param('offset'); # pagination not implemented
 my $script_name = "/cgi-bin/koha/tools/letter.pl";
 my $code        = $input->param('code');
 my $module      = $input->param('module');
+$module = '' unless defined($module);
 my $content     = $input->param('content');
 my $op          = $input->param('op');
+$op = '' unless defined($op);
 $searchfield =~ s/\,//g;
 my $dbh = C4::Context->dbh;
 
@@ -128,7 +134,13 @@ if ( $op eq 'add_form' ) {
     push @SQLfieldname, column_picks('branches');
 
     # add acquisition specific tables
-    if ( index( $module, "acquisition" ) > 0 ) {       # FIXME: imprecise comparison
+    if ( $module eq "reserves" ) {
+        push @SQLfieldname, column_picks('borrowers'),
+                            column_picks('reserves'),
+                            column_picks('biblio'),
+                            column_picks('items');
+    }
+    elsif ( index( $module, "acquisition" ) > 0 ) {    # FIXME: imprecise comparison
         push @SQLfieldname, column_picks('aqbooksellers'), column_picks('aqorders');
         # add issues specific tables
     }