Merge remote-tracking branch 'origin/new/bug_8062'
[koha.git] / cataloguing / value_builder / labs_theses.pl
index 4497461..d486649 100755 (executable)
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
-require Exporter;
+#use warnings; FIXME - Bug 2505
+
 use CGI;
 
 use C4::Output;
@@ -50,7 +51,7 @@ function Blur$function_name(subfield_managed) {
 
 function Clic$function_name(i) {
        defaultvalue=document.f.field_value[i].value;
-       newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&cat_auth=LABTHE&index=\"+i+\"&result=\"+defaultvalue,\"unimarc field 328\",'width=700,height=700,toolbar=false,scrollbars=yes');
+       newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=labs_theses.pl&cat_auth=LABTHE&index=\"+i+\"&result=\"+defaultvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
 
 }
 //]]>
@@ -72,24 +73,22 @@ sub plugin {
        my ($template, $loggedinuser, $cookie);
        my $resultsperpage;
        my $search = $query->param('search');
-       
+
        if ($op eq "do_search") {
-       
+
                $resultsperpage= $query->param('resultsperpage');
                $resultsperpage = 19 if(!defined $resultsperpage);
 #              my $upperlimit=$startfrom+$resultsperpage;
                # builds tag and subfield arrays
                my $strquery = "SELECT authorised_value, lib from authorised_values where category = ? and lib like ?";
 #              $strquery .= " LIMIT $startfrom,$upperlimit";
-               
-               warn 'category : '.$cat_auth.' recherche :'.$search;
-               warn "$strquery";
+
                $search=~s/\*/%/g;
                my $sth = $dbh->prepare($strquery);
                $sth->execute($cat_auth,$search);
                $search=~s/%/\*/g;
-               
-               
+
+
                my @results;
                my $total;
                while (my $data = $sth->fetchrow_hashref){
@@ -100,28 +99,28 @@ sub plugin {
                        push @results, {'libjs'=>$libjs,
                                                        'lib'=>$data->{'lib'},
                                                        'authjs'=>$authjs,
-                                                       'auth_value'=>$data->{'authorised_value'}} 
+                                                       'auth_value'=>$data->{'authorised_value'}}
                                                        unless (($total<$startfrom) or ($total>$startfrom+$resultsperpage));
                        $total++;
                }
-               
+
                ($template, $loggedinuser, $cookie)
                        = get_template_and_user({template_name => "value_builder/labs_theses.tmpl",
                                        query => $query,
                                        type => 'intranet',
-                                       authnotrequired => 1,
+                                       authnotrequired => 0,
                                        debug => 1,
                                        });
-       
+
                # multi page display gestion
                my $displaynext=0;
                my $displayprev=$startfrom;
                if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
                        $displaynext = 1;
                }
-       
+
                my @numbers = ();
-       
+
                if ($total>$resultsperpage)
                {
                        for (my $i=1; (($i<$total/$resultsperpage+1) && ($i<16)); $i++)
@@ -134,10 +133,10 @@ sub plugin {
                                                startfrom => $resultsperpage*($i-1)};
                        }
                }
-       
+
                my $from = $startfrom+1;
                my $to;
-       
+
                if($total < (($startfrom+1)*$resultsperpage))
                {
                        $to = $total;
@@ -160,26 +159,25 @@ sub plugin {
                                                                numbers=>\@numbers,
                                                                resultlist=>1
                                                                );
-       
+
        } else {
                ($template, $loggedinuser, $cookie)
                        = get_template_and_user({template_name => "value_builder/labs_theses.tmpl",
                                                query => $query,
                                                type => "intranet",
-                                               authnotrequired => 1,
+                                               authnotrequired => 0,
                                        });
-               
+
                $template->param(
                                                'search'=>$query->param('search'),
                );
                $template->param(
                                                'index'=>''.$query->param('index')
                ) if ($query->param('index'));
-               warn 'index : '.$query->param('index');
                $template->param(
                                                'cat_auth'=>$cat_auth
                ) if ($cat_auth);
-       }       
+       }
        output_html_with_http_headers $query, $cookie, $template->output ;
 }