4 # Searching within results is done by simply adding on parameters onto the query, being careful to have the requried marclist etc fields.
6 use C4::Interface::CGI::Output;
11 my $allitemtypesbool = $query->param("allitemtypes");
12 my $allbranchesbool = $query->param("allbranches");
13 my $allcategoriesbool = $query->param("allcategories");
14 my $allsubcategoriesbool = $query->param("allsubcategories");
15 my $allmediatypesbool = $query->param("allmediatypes");
16 my $nbstatements = $query->param("nbstatementsori");
17 my $orderby = $query->param("orderbyori");
18 my @keywords = $query->param("keyword");
19 my @marclist = $query->param('marclist');
20 my @and_or = $query->param('and_or');
21 my @excluding = $query->param('excluding');
22 my @operator = $query->param('operator');
23 my @value = $query->param('value');
24 my $searchtype = $query->param('searchtype');
25 my $category = $query->param('categorylist');
26 my @itemtypeswanted = $query->param("itemtypeswanted");
27 my $itemtypessearched = $query->param("itemtypessearched");
28 my @mediatypeswanted = $query->param("mediatypeswanted");
29 my @subcategorieswanted = $query->param("subcategorieswanted");
30 my @brancheswanted = $query->param("brancheswanted");
31 my $avail = $query->param("avail");
37 my $itemtypefoundbool=0;
38 my $branchfoundbool=0;
41 my $itemtypessubcatlist;
44 my $dbh=C4::Context->dbh;
45 $newquery='op=do_search&nbstatements='.$nbstatements;
46 if ($allcategoriesbool eq '' && $category ne ''){
48 my $sth=$dbh->prepare("select itemtypecodes from categorytable where categorycode=?");
49 $sth->execute($category);
50 $itemtypescatlist = $sth->fetchrow .'|';
53 if ($allmediatypesbool eq '' && @mediatypeswanted ne ''){
54 foreach my $mediatype (@mediatypeswanted){
55 my $sth=$dbh->prepare("select itemtypecodes from mediatypetable where mediatypecode=?");
56 $sth->execute($mediatype);
57 $mediatypeslist .= $sth->fetchrow.'|';
62 if ($allsubcategoriesbool eq '' && @subcategorieswanted ne ''){
63 foreach my $subcategory (@subcategorieswanted){
64 my $sth=$dbh->prepare("select itemtypecodes from subcategorytable where subcategorycode=?");
65 $sth->execute($subcategory);
66 $itemtypessubcatlist .= $sth->fetchrow.'|';
71 if ($allitemtypesbool ne ''){
72 #warn @itemtypeswanted;
73 $itemtypeslist .=$itemtypescatlist.$itemtypessubcatlist.$mediatypeslist.$itemtypessearched.join ("|", @itemtypeswanted)
75 $itemtypeslist .=$itemtypescatlist.$itemtypessubcatlist.$mediatypeslist.$itemtypessearched
78 if ($allbranchesbool == 0){
79 $brancheslist = join("|",@brancheswanted)
82 if ($searchtype eq 'NewSearch'){
84 $newquery .= '&marclist=';
85 $newquery .= '&and_or=and';
86 $newquery .= '&excluding=';
87 $newquery .= '&operator=contains';
88 $newquery .= '&value=';
89 $newquery .=join(" ",@keywords)
90 } elsif ($searchtype eq 'SearchWithin'){
91 foreach my $marclistitem (@marclist) {
92 $newquery .= '&marclist='.$marclist[$count];
93 $newquery .= '&and_or='.$and_or[$count];
94 $newquery .= '&excluding='.$excluding[$count];
95 $newquery .= '&operator=';
96 $newquery .= $operator[$count];
97 $newquery .= '&value='.$value[$count];
98 if ($marclist[$count] eq ''){
101 $newquery .=" ".join(" ",@keywords)
107 if ($subfoundbool == 0 && $query->param('keysub') ne ''){
108 $newquery .= '&marclist=&and_or=and&excluding=&operator=contains&value=';
109 $newquery .=join(" ",@keywords)
112 $newquery .= '&orderby='.$orderby;
113 if ($itemtypeslist ne ''){
114 $newquery .= '&itemtypesstring="'.$itemtypeslist.'"'
116 if ($brancheslist ne ''){
117 $newquery .= '&branchesstring="'.$brancheslist.'"';
120 $newquery .= '&avail=1'
122 print $query->redirect("/cgi-bin/koha/opac-search.pl?$newquery");