moving fields around toCVS: ----------------------------------------------------...
[koha_fer] / admin / marctagstructure.pl
index 34c17e0..4a2315b 100755 (executable)
 
 use strict;
 use CGI;
+use C4::Auth;
 use C4::Context;
 use C4::Output;
+use C4::Interface::CGI::Output;
 use C4::Search;
 use C4::Context;
 use HTML::Template;
@@ -32,7 +34,7 @@ sub StringSearch  {
        $searchstring=~ s/\'/\\\'/g;
        my @data=split(' ',$searchstring);
        my $count=@data;
-       my $query="Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where (tagfield like \"$data[0]%\") order by tagfield";
+       my $query="Select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where (tagfield >= $data[0]) order by tagfield";
        my $sth=$dbh->prepare($query);
        $sth->execute;
        my @results;
@@ -48,6 +50,7 @@ sub StringSearch  {
 
 my $input = new CGI;
 my $searchfield=$input->param('searchfield');
+$searchfield=0 unless $searchfield;
 my $pkfield="tagfield";
 my $reqsel="select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where $pkfield='$searchfield'";
 my $offset=$input->param('offset');
@@ -55,7 +58,14 @@ my $script_name="/cgi-bin/koha/admin/marctagstructure.pl";
 
 my $dbh = C4::Context->dbh;
 
-my $template = gettemplate("parameters/marctagstructure.tmpl",0);
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "parameters/marctagstructure.tmpl",
+                            query => $input,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {parameters => 1},
+                            debug => 1,
+                            });
 my $pagesize=20;
 my $op = $input->param('op');
 $searchfield=~ s/\,//g;
@@ -126,7 +136,7 @@ if ($op eq 'add_form') {
                                                $authorised_value
                                                );
        $sth->finish;
-       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl\"></html>";
+       print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=marctagstructure.pl?tagfield=$tagfield\"></html>";
        exit;
                                                                                                        # END $OP eq ADD_VALIDATE
 ################## DELETE_CONFIRM ##################################
@@ -178,12 +188,13 @@ if ($op eq 'add_form') {
        $template->param(loop => \@loop_data);
        if ($offset>0) {
                my $prevpage = $offset-$pagesize;
-               $template->param(previous => "<a href=$script_name?offset=".$prevpage.'>&lt;&lt; Prev</a>');
+               $template->param(previous => "<a href=\"$script_name?offset=".$prevpage.'">');
        }
        if ($offset+$pagesize<$count) {
                my $nextpage =$offset+$pagesize;
-               $template->param(next => "<a href=$script_name?offset=".$nextpage.'>Next &gt;&gt;</a>');
+               $template->param(next => "<a href=\"$script_name?offset=".$nextpage.'">');
        }
 } #---- END $OP eq DEFAULT
 
-print "Content-Type: text/html\n\n", $template->output;
+$template->param(loggeninuser => $loggedinuser);
+output_html_with_http_headers $input, $cookie, $template->output;