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");
36 my $keywordfoundbool=0;
39 my $itemtypessubcatlist;
43 my $dbh=C4::Context->dbh;
44 $newquery='op=do_search&nbstatements='.$nbstatements;
45 if ($allcategoriesbool == 0 && $category ne ''){
47 my $sth=$dbh->prepare("select itemtypecodes from categorytable where categorycode=?");
48 $sth->execute($category);
49 $itemtypescatlist = $sth->fetchrow .'|';
52 if ($allmediatypesbool == 0 && @mediatypeswanted ne ''){
53 foreach my $mediatype (@mediatypeswanted){
54 my $sth=$dbh->prepare("select itemtypecodes from mediatypetable where mediatypecode=?");
55 $sth->execute($mediatype);
56 $mediatypeslist .= $sth->fetchrow.'|';
61 if ($allsubcategoriesbool == 0 && @subcategorieswanted ne ''){
62 foreach my $subcategory (@subcategorieswanted){
63 my $sth=$dbh->prepare("select itemtypecodes from subcategorytable where subcategorycode=?");
64 $sth->execute($subcategory);
65 $itemtypessubcatlist .= $sth->fetchrow.'|';
70 if ($allitemtypesbool == 0){
72 $itemtypeslist .=$itemtypescatlist.$itemtypessubcatlist.$mediatypeslist.$itemtypessearched.join ("|", @itemtypeswanted)
74 $itemtypeslist .=$itemtypescatlist.$itemtypessubcatlist.$mediatypeslist.$itemtypessearched
77 if ($allbranchesbool == 0){
78 $brancheslist = join("|",@brancheswanted)
81 if ($searchtype eq 'NewSearch'){
83 $newquery .= '&marclist=';
84 $newquery .= '&and_or=and';
85 $newquery .= '&excluding=';
86 $newquery .= '&operator=contains';
87 $newquery .= '&value=';
88 $newquery .=join(" ",@keywords)
89 } elsif ($searchtype eq 'SearchWithin'){
90 foreach my $marclistitem (@marclist) {
91 $newquery .= '&marclist='.$marclist[$count];
92 $newquery .= '&and_or='.$and_or[$count];
93 $newquery .= '&excluding='.$excluding[$count];
94 $newquery .= '&operator=';
95 $newquery .= $operator[$count];
96 $newquery .= '&value='.$value[$count];
97 if ($marclist[$count] eq ''){
98 if ($keywordfoundbool=0){
100 $newquery .=" ".join(" ",@keywords)
106 if ($keywordfoundbool == 0 && $query->param('keysub') ne ''){
107 $newquery .= '&marclist=&and_or=and&excluding=&operator=contains&value=';
108 $newquery .=join(" ",@keywords)
111 $newquery .= '&orderby='.$orderby;
112 if ($itemtypeslist ne ''){
113 $newquery .= '&itemtypesstring="'.$itemtypeslist.'"'
115 if ($brancheslist ne ''){
116 $newquery .= '&branchesstring="'.$brancheslist.'"';
119 $newquery .= '&avail=1'
121 print $query->redirect("/cgi-bin/koha/opac-search.pl?$newquery");