long is the road to 1.4.0
authortipaul <tipaul>
Fri, 20 Sep 2002 13:01:50 +0000 (13:01 +0000)
committertipaul <tipaul>
Fri, 20 Sep 2002 13:01:50 +0000 (13:01 +0000)
* MARCadditem and MARCmoditem now works
* various bugfixes in MARC management
!!! 1.3.0 should be released very soon now. Be careful !!!

acqui/addorder.pl
acqui/finishreceive.pl
search.pl
updatebibitem.pl
updateitem.pl

index e8e2a19..55d709e 100755 (executable)
@@ -60,9 +60,9 @@ my $ecost=$input->param('ecost');
 my $gst=$input->param('GST');
 my $orderexists=$input->param('orderexists');
 
+print STDERR "quantity = $quantity // existing = $existing\n";
 #check to see if biblio exists
 if ($quantity ne '0'){
-
   if ($existing eq 'no'){
     #if it doesnt create it
     $bibnum = &newbiblio({ title     => $title?$title:"",
@@ -84,14 +84,18 @@ if ($quantity ne '0'){
 #              copyrightdate => $copyright?$copyright:"",
 #              series        => $series?$series:"" });
   } else {
+print STDERR "inside loop\n";
     $bibnum=$input->param('biblio');
     $bibitemnum=$input->param('bibitemnum');
     my $oldtype=$input->param('oldtype');
+print STDERR  "bibitemnum : $bibitemnum itemtype:$itemtype oldtype:$oldtype\n";
     if ($bibitemnum eq '' || $itemtype ne $oldtype){
       $bibitemnum= &newbiblioitem({ biblionumber => $bibnum,
                                                         itemtype => $itemtype?$itemtype:"",
                                                         isbn => $isbn?$isbn:"" });
+      print STDERR "newbiblioitem\n";
     }
+print STDERR "modbiblio\n";
     &modbiblio({
         biblionumber  => $bibnum,
        title         => $title?$title:"",
index 3200aee..a5aa115 100755 (executable)
@@ -93,6 +93,7 @@ if ($quantity != 0){
   modbiblio($biblio);
   &modbibitem({
       biblioitemnumber => $bibitemno,
+      biblionumber     => $biblionumber,
       itemtype         => $itemtype?$itemtype:"",
       isbn             => $isbn?$isbn:"",
       publisher        => $publisher?$publisher:"",
@@ -118,6 +119,7 @@ if ($quantity != 0){
   #  print @barcodes;
   #  print $barcode;
   }
+#  print STDERR "************ biblionumber => $biblionumber\n";
   my ($error) = newitems({ biblioitemnumber => $bibitemno,
                           biblionumber     => $biblionumber,
                           replacementprice => $replacement,
index 4b0fc76..8686930 100755 (executable)
--- a/search.pl
+++ b/search.pl
@@ -1,4 +1,5 @@
 #!/usr/bin/perl
+use HTML::Template;
 #script to provide intranet (librarian) advanced search facility
 
 
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
-use C4::Search;
+require Exporter;
+use C4::Database;
 use CGI;
-use C4::Output;
-
-my $env;
-my $input = new CGI;
-print $input->header;
-#print $input->dump;
-
-#whether it is called from the opac or the intranet
-my $type=$input->param('type');if ($type eq ''){
-  $type = 'intra';
+use C4::Search;
+use C4::Output; # no contains picktemplate
+  
+my $query=new CGI;
+
+
+my $language='french';
+
+
+my %configfile;
+open (KC, "/etc/koha.conf");
+while (<KC>) {
+ chomp;
+ (next) if (/^\s*#/);
+ if (/(.*)\s*=\s*(.*)/) {
+   my $variable=$1;
+   my $value=$2;
+   # Clean up white space at beginning and end
+   $variable=~s/^\s*//g;
+   $variable=~s/\s*$//g;
+   $value=~s/^\s*//g;
+   $value=~s/\s*$//g;
+   $configfile{$variable}=$value;
+ }
+}
+#print $query->header;
+
+my $includes=$configfile{'includes'};
+($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
+my $templatebase="catalogue/searchresults.tmpl";
+my $startfrom=$query->param('startfrom');
+($startfrom) || ($startfrom=0);
+my $theme=picktemplate($includes, $templatebase);
+
+my $subject=$query->param('subject');
+# if its a subject we need to use the subject.tmpl
+if ($subject) {
+    $templatebase=~ s/searchresults\.tmpl/subject\.tmpl/;
+    $theme=picktemplate($includes, $templatebase);
 }
 
-my $ttype=$input->param('ttype');
-
-#setup colours                 
-my $main;
-my $secondary;
+my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]);
 
-if ($type eq 'opac'){
-  $main='#99cccc';    
-  $secondary='#efe5ef';
-} else {
-  $main='#cccc99';
-  $secondary='#ffffcc';
-}       
+my $env;
+$env->{itemcount}=1;
 
-#print $input->Dump;
-my $blah;
+# get all the search variables
+# we assume that C4::Search will validate these values for us
 my %search;
-
-#build hash of users input
-my $title=validate($input->param('title'));
-$search{'title'}=$title;
-
-my $keyword=validate($input->param('keyword'));
+my $keyword=$query->param('keyword');
 $search{'keyword'}=$keyword;
 
-$search{'front'}=validate($input->param('front'));
-
-my $author=validate($input->param('author'));
-$search{'author'}=$author;
-
-my $illustrator=validate($input->param('illustrator'));
-$search{'illustrator'}=$illustrator;
-
-my $subject=validate($input->param('subject'));
 $search{'subject'}=$subject;
-
-my $itemnumber=validate($input->param('item'));
-$search{'item'}=$itemnumber;
-
-my $isbn=validate($input->param('isbn'));
+my $author=$query->param('author');
+$search{'author'}=$author;
+my $illustrator=$query->param('illustrator');
+$search{'param'}=$illustrator;
+my $itemnumber=$query->param('itemnumber');
+$search{'itemnumber'}=$itemnumber;
+my $isbn=$query->param('isbn');
 $search{'isbn'}=$isbn;
-
-my $datebefore=validate($input->param('date-before'));
-$search{'date-before'};
-
-my $class=$input->param('class');
+my $datebefore=$query->param('date-before');
+$search{'date-before'}=$datebefore;
+my $class=$query->param('class');
 $search{'class'}=$class;
+my $dewey=$query->param('dewey');
+$search{'dewey'};
+my $branch=$query->param('branch');
+$search{'branch'}=$branch;
+my $title=$query->param('title');
+$search{'title'}=$title;
+my $abstract=$query->param('abstract');
+$search{'abstract'}=$abstract;
+my $publisher=$query->param('publisher');
+$search{'publisher'}=$publisher;
 
+my $ttype=$query->param('ttype');
 $search{'ttype'}=$ttype;
 
-my $dewey=validate($input->param('dewey'));
-$search{'dewey'}=$dewey;
-
-my $branch=validate($input->param('branch'));
-$search{'branch'}=$branch;
-
-my @results;
-my $offset=$input->param('offset');
-if ($offset eq ''){
-  $offset=0;
+my $forminputs;
+($keyword) && (push @$forminputs, { line => "keyword=$keyword"});
+($subject) && (push @$forminputs, { line => "subject=$subject"});
+($author) && (push @$forminputs, { line => "author=$author"});
+($illustrator) && (push @$forminputs, { line => "illustrator=$illustrator"});
+($itemnumber) && (push @$forminputs, { line => "itemnumber=$itemnumber"});
+($isbn) && (push @$forminputs, { line => "isbn=$isbn"});
+($datebefore) && (push @$forminputs, { line => "date-before=$datebefore"});
+($class) && (push @$forminputs, { line => "class=$class"});
+($dewey) && (push @$forminputs, { line => "dewey=$dewey"});
+($branch) && (push @$forminputs, { line => "branch=$branch"});
+($title) && (push @$forminputs, { line => "title=$title"});
+($ttype) && (push @$forminputs, { line => "ttype=$ttype"});
+($abstract) && (push @$forminputs, { line => "abstract=$abstract"});
+($publisher) && (push @$forminputs, { line => "publisher=$publisher"});
+$template->param(FORMINPUTS => $forminputs);
+# whats this for?
+# I think it is (or was) a search from the "front" page...   [st]
+$search{'front'}=$query->param('front');
+
+my $num=10;
+my ($count,@results)=catalogsearch($env,'',\%search,$num,$startfrom);
+
+my $resultsarray=\@results;
+
+my $search="num=20";
+if ($keyword){
+    $search=$search."&keyword=$keyword";
 }
-my $num=$input->param('num');
-if ($num eq ''){
-  $num=10;
+if ($subject){
+    $search=$search."&subject=$subject";
 }
-print startpage();
-print startmenu($type);
-#print $type;
-#print $search{'ttype'};
-if ($type eq 'intra'){
-  print mkheadr(1,'Catalogue Search Results');
-} elsif ($type eq 'catmain'){
-  print mkheadr(1,'Catalogue Maintenance');
-} else {
-  print mkheadr(1,'Opac Search Results');
+if ($author){
+    $search=$search."&author=$author";
 }
-print center();
-my $count;
-my @results;
-if ($itemnumber ne '' || $isbn ne ''){
-    ($count,@results)=&CatSearch(\$blah,'precise',\%search,$num,$offset);
-} else {
-  if ($subject ne ''){
-    ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset);
-  } else {
-    if ($keyword ne ''){
-      ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset);
-    }elsif ($title ne '' || $author ne '' || $illustrator ne '' || $dewey ne '' || $class ne '') {
-      ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset);
-    }
-  }
+if ($class){
+    $search=$search."&class=$class";
 }
-print "You searched on ";
-while ( my ($key, $value) = each %search) {                                 
-  if ($value ne '' && $key ne 'ttype'){
-    $value=~ s/\\//g;
-    print bold("$key $value,");
-  }                          
+if ($title){
+    $search=$search."&title=$title";
 }
-print " $count results found";
-my $offset2=$num+$offset;
-my $dispnum=$offset+1;
-print "<br> Results $dispnum to $offset2 displayed";
-print mktablehdr;
-if ($type ne 'opac'){
-  if ($subject ne ''){
-   print mktablerow(1,$main,'<b>SUBJECT</b>','/images/background-mem.gif');
-  } elsif ($illustrator ne '') {
-   print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>', '<b>ILLUSTRATOR<b>', bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
-  } else {
-   print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('&copy;'),'<b>COUNT</b>',bold('LOCATION'),'','/images/background-mem.gif');
-  }
-} else {
-  if ($subject ne ''){
-   print mktablerow(6,$main,'<b>SUBJECT</b>',' &nbsp; ',' &nbsp; ');
-  } elsif ($illustrator ne '') {
-   print mktablerow(7,$main,'<b>TITLE</b>','<b>AUTHOR</b>','<b>ILLUSTRATOR</b>', bold('&copy;'),'<b>COUNT</b>',bold('BRANCH'),'');
-  } else {
-   print mktablerow(6,$main,'<b>TITLE</b>','<b>AUTHOR</b>',bold('&copy;'),'<b>COUNT</b>',bold('BRANCH'),'');
-  }
+if ($dewey){
+    $search=$search."&dewey=$dewey";
 }
-my $count2=@results;
-if ($keyword ne '' && $offset > 0){
-  $count2=$count-$offset;
-  if ($count2 > 10){
-    $count2=10;
-  }
-}
-#print $count2;
-my $i=0;
-my $colour=1;
-while ($i < $count2){
-#    print $results[$i]."\n";
-#    my @stuff=split('\t',$results[$i]);
-    my $result=$results[$i];
-    $result->{'title'}=~ s/\`/\\\'/g;
-    my $title2=$result->{'title'};
-    $title2=~ s/ /%20/g;
-    my $location='';
-    my $itemcount;
-    if ($subject eq ''){
-      $result->{'title'}=mklink("/cgi-bin/koha/detail.pl?type=$type&bib=$result->{'biblionumber'}&title=$title2",$result->{'title'});
-      my $word=$result->{'author'};
-      $word=~ s/([a-z]) +([a-z])/$1%20$2/ig;
-      $word=~ s/  //g;
-      $word=~ s/ /%20/g;
-      $word=~ s/\,/\,%20/g;
-      $word=~ s/\n//g;
-      my $url="/cgi-bin/koha/search.pl?author=$word&type=$type";
-      $result->{'author'}=mklink($url,$result->{'author'});
-      my ($count,$lcount,$nacount,$fcount,$scount,$lostcount,$mending,$transit,$ocount)=itemcount($env,$result->{'biblionumber'},$type);
-      $itemcount=$count;
-      ####
-      # Fix this chunk below, remove all hardcoded branch references
-      # need to fix itemcount as well
-      ###
-      if ($nacount > 0){
-        $location=$location."On Loan";
-       if ($nacount >1 ){                                                                                                         
-         $location=$location." ($nacount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";
-      }
-      if ($lcount > 0){
-         $location=$location."Levin";
-         if ($lcount >1 ){                                                                                                         
-         $location=$location." ($lcount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";
-      }
-      if ($fcount > 0){
-        $location=$location."Foxton";
-         if ($fcount >1 ){                                                                                                         
-         $location=$location." ($fcount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      if ($scount > 0){
-        $location=$location."Shannon";
-         if ($scount >1 ){                                                                                                         
-         $location=$location." ($scount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      if ($lostcount > 0){
-        $location=$location."Lost";
-         if ($lostcount >1 ){                                                                                                         
-         $location=$location." ($lostcount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      if ($mending > 0){
-        $location=$location."Mending";
-         if ($mending >1 ){                                                                                                         
-         $location=$location." ($mending)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      if ($transit > 0){
-        $location=$location."In Transiit";
-         if ($transit >1 ){                                                                                                         
-         $location=$location." ($transit)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      if ($ocount > 0){
-        $location=$location."On Order";
-         if ($ocount >1 ){                                                                                                         
-         $location=$location." ($ocount)";                                                                                            
-         }                                                                                                                         
-        $location.=" ";        
-      }
-      
-#      if ($type ne 'opac'){
-#        $result->{'request'}=mklink("/cgi-bin/koha/request.pl?bib=$stuff[2]","Request");
-#      }
-    } else {
-      my $word=$result->{'subject'};
-      $word=~ s/ /%20/g;
-      
-        $result->{'title'}=mklink("/cgi-bin/koha/subjectsearch.pl?subject=$word&type=$type",$result->{'subject'});
+$search.="&ttype=$ttype";
 
-    }
+$search=~ s/ /%20/g;
+$template->param(startfrom => $startfrom+1);
+$template->param(endat => $startfrom+$num);
+$template->param(numrecords => $count);
+my $nextstartfrom=($startfrom+$num<$count-$num) ? ($startfrom+$num) : ($count-$num);
+my $prevstartfrom=($startfrom-$num>0) ? ($startfrom-$num) : (0);
+$template->param(nextstartfrom => $nextstartfrom);
+$template->param(prevstartfrom => $prevstartfrom);
+$template->param(search => $search);
+$template->param(SEARCH_RESULTS => $resultsarray);
+$template->param(includesdir => $includes);
 
-    if ($colour == 1){
-      if ($illustrator) {
-         print mktablerow(7,$secondary,$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
-      } else {
-         print mktablerow(6,$secondary,$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
-      }
-      $colour=0;
-    } else {
-      if ($illustrator) {
-         print mktablerow(7,'white',$result->{'title'},$result->{'author'},$result->{'illus'},$result->{'copyrightdate'},$itemcount,$location);
-      } else {
-         print mktablerow(6,'white',$result->{'title'},$result->{'author'},$result->{'copyrightdate'},$itemcount,$location);
-      }
-      $colour=1;
-    }
-    $i++;
-}
-$offset=$num+$offset;
-if ($type ne 'opac'){
-    if ($illustrator) {
-        print mktablerow(7,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp;','','','','/images/background-mem.gif');
-    } else {
-        print mktablerow(6,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp;','','','/images/background-mem.gif');
-    }
-} else {
- if ($illustrator) {
-     print mktablerow(7,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp; ','', '','');
- } else {
-     print mktablerow(6,$main,' &nbsp; ',' &nbsp; ',' &nbsp;',' &nbsp; ','','');
- }
-}
-print mktableft();
-my $search;
 
-    $search="num=$num&offset=$offset&type=$type";
-    if ($subject ne ''){
-      $subject=~ s/ /%20/g;
-      $search=$search."&subject=$subject";
-    }
-    if ($title ne ''){
-      $title=~ s/ /%20/g;
-      $search=$search."&title=$title";
-    }
-    if ($author ne ''){
-      $author=~ s/ /%20/g;
-      $search=$search."&author=$author";
-    }
-    if ($keyword ne ''){
-      $keyword=~ s/ /%20/g;
-      $search=$search."&keyword=$keyword";
-    }
-    if ($class ne ''){
-      $keyword=~ s/ /%20/g;
-      $search=$search."&class=$class";
-    }
-    if ($dewey ne ''){
-      $search=$search."&dewey=$dewey";
-    }
-    $search.="&ttype=$ttype";    
-if ($offset < $count){    
-    my $stuff=mklink("/cgi-bin/koha/search.pl?$search",'Next');
-    print $stuff;
-}
-print "<br>";
-my $pages=$count/10;
-$pages++;
-for (my $i=1;$i<$pages;$i++){
-  my $temp=$i*10;
-  $temp=$temp-10;
-  $search=~ s/offset=[0-9]+/offset=$temp/;
-  my $stuff=mklink("/cgi-bin/koha/search.pl?$search",$i);
-  print "$stuff ";
-}
-  
-print endcenter();
-print endmenu($type);
-print endpage();
+print "Content-Type: text/html\n\n", $template->output;
 
-
-sub validate {
-  my ($input)=@_;
-  $input=~ s/\<[a-z]+\>//gi;
-  $input=~ s/\<\/[a-z]+\>//gi;
-  $input=~ s/\<//g;
-  $input=~ s/\>//g;
-  $input=~ s/^%//g;
-  return($input);
-}
index 8c3851e..c5fd6b3 100755 (executable)
@@ -84,7 +84,11 @@ if ($existing eq 'YES'){
     my $temp="check_group_".$items[$i]->{'barcode'};
     my $barcode=$input->param($temp);
     if ($barcode ne ''){
-      moditem($items[$i]->{'notforloan'},$items[$i]->{'itemnumber'},$group);
+      moditem({ biblionumber => $bibnum,
+               notforloan   => $items[$i]->{'notforloan'},
+               itemnumber   => $items[$i]->{'itemnumber'},
+               group        => $group
+                   });
 #      print "modify $items[$i]->{'itemnumber'} $group";
     }
   }
@@ -126,13 +130,18 @@ if ($existing eq 'YES'){
       }
       for (my $i=0;$i<$count;$i++){
         if ($barcodes[$i] ne ''){
-         moditem($loan,$items[$i]->{'itemnumber'},$bibitemnum);
+         moditem({ biblionumber => $bibnum,
+                   loan         => $loan,
+                   itemnumber   => $items[$i]->{'itemnumber'},
+                   bibitemnum   => $bibitemnum
+                   });
        }
       }
       
    } elsif ($flag2 eq 'leastone') {
       &modbibitem({
          biblioitemnumber => $bibitemnum,
+         biblionumber     => $bibnum,
          itemtype         => $itemtype?$itemtype:"",
          url              => $url?$url:"",
          isbn             => $isbn?$isbn:"",
@@ -154,7 +163,11 @@ if ($existing eq 'YES'){
       }
        for (my $i=0;$i<$count;$i++){                                             
          if ($barcodes[$i] ne ''){                                               
-           moditem($loan,$items[$i]->{'itemnumber'},$bibitemnum);                
+           moditem( {biblionumber => $bibnum,
+                     loan         => $loan,
+                     itemnumber   => $items[$i]->{'itemnumber'},
+                     bibitemnum   => $bibitemnum
+                     });
          }                                                                       
        }
       
index f3948ff..8c5b2e2 100755 (executable)
@@ -76,7 +76,16 @@ my $pages=checkinp($input->param('Pages'));
 my $volumeddesc=checkinp($input->param('Volume'));
 
 if ($wthdrawn == 0 && $override ne 'yes'){
-  moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn);
+  moditem( { biblionumber => $bibnum,
+            loan         =>'loan',
+            itemnum      => $itemnum,
+            bibitemnum   => $bibitemnum,
+            barcode      => $barcode,
+            notes        => $notes,
+            homebranch   => $homebranch,
+            lost         => $lost,
+            wthdranw     => $wthdrawn
+            });
   if ($lost ==1){
     my $dbh=C4Connect;
     my $sth=$dbh->prepare("Select * from issues where (itemnumber='$itemnum') and (returndate is null)");
@@ -129,7 +138,16 @@ if ($wthdrawn == 0 && $override ne 'yes'){
     $url.="&override=yes";
     print "<p> <a href=$url>Cancel Anyway</a> &nbsp; or <a href=\"\">Back</a>";
   }else {
-    moditem('loan',$itemnum,$bibitemnum,$barcode,$notes,$homebranch,$lost,$wthdrawn);
+    moditem({ biblionumber => $bibnum,
+             loan         => 'loan',
+             itemnum      => $itemnum,
+             bibitemnum   => $bibitemnum,
+             barcode      => $barcode,
+             notes        => $notes,
+             homebranch   => $homebranch,
+             lost         => $lost,
+             wthdrawn     => $wthdrawn
+             });
     print $input->redirect("moredetail.pl?type=intra&bib=$bibnum&bi=$bibitemnum");
   }
 }