From ebb6609879197a3c509fdede6c216b13960b0702 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 12 Nov 2002 16:41:12 +0000 Subject: [PATCH] *** empty log message *** --- admin/marc_subfields_structure.pl | 83 ++++++++++++++++++++++++------- admin/marctagstructure.pl | 31 ++++++++++-- admin/thesaurus.pl | 75 ++++++++++++---------------- currency.pl | 2 +- opac/opac-main.pl | 1 + showbudget.pl | 2 +- 6 files changed, 126 insertions(+), 68 deletions(-) diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index 184c5f91fb..7eaa8a20b6 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -31,7 +31,7 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $query="Select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab, authorised_value from marc_subfield_structure where (tagfield like \"$searchstring%\") order by tagfield"; + my $query="Select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where (tagfield like \"$searchstring%\") order by tagfield"; my $sth=$dbh->prepare($query); $sth->execute; my @results; @@ -50,7 +50,7 @@ my $input = new CGI; my $tagfield=$input->param('tagfield'); my $tagsubfield=$input->param('tagsubfield'); my $pkfield="tagfield"; -my $reqsel="select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value from marc_subfield_structure where tagfield='$tagfield'"; +my $reqsel="select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where tagfield='$tagfield'"; my $reqdel="delete from marc_subfield_structure where tagfield='$tagfield' and tagsubfield='$tagsubfield'"; my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/marc_subfields_structure.pl"; @@ -75,8 +75,7 @@ $template->param(script_name => $script_name, if ($op eq 'add_form') { my $data; my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value from marc_subfield_structure where tagfield='$tagfield'"); # and tagsubfield='$tagsubfield'"); - $sth->execute; + my $more_subfields = $input->param("more_subfields")+1; # builds kohafield tables my @kohafields; push @kohafields, ""; @@ -95,7 +94,7 @@ if ($op eq 'add_form') { while ((my $field) = $sth2->fetchrow_array) { push @kohafields, "items.".$field; } - # buiild authorised value list + # build authorised value list $sth2->finish; $sth2 = $dbh->prepare("select distinct category from authorised_values"); $sth2->execute; @@ -104,9 +103,29 @@ if ($op eq 'add_form') { while ((my $category) = $sth2->fetchrow_array) { push @authorised_values, $category; } - $template->param(action => "Edit subfields", - tagfield => "$tagfield", - ); + # build thesaurus categories list + $sth2->finish; + $sth2 = $dbh->prepare("select distinct category from bibliothesaurus"); + $sth2->execute; + my @thesaurus_category; + push @thesaurus_category,""; + while ((my $category) = $sth2->fetchrow_array) { + push @thesaurus_category, $category; + } + # build value_builder list + my @value_builder=(''); + opendir(DIR, "../value_builder") || die "can't opendir ../value_builder: $!"; + while (my $line = readdir(DIR)) { + if ($line =~ /\.pl$/) { + push (@value_builder,$line); + } + } + closedir DIR; + + warn "$value_builder[0] ยง $value_builder[1]"; + # build values list + my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where tagfield='$tagfield'"); # and tagsubfield='$tagsubfield'"); + $sth->execute; my @loop_data = (); my $toggle="white"; my $i=0; @@ -129,8 +148,8 @@ if ($op eq 'add_form') { -multiple=>0, ); $row_data{tagsubfield} =$data->{'tagsubfield'}.""; - $row_data{liblibrarian} = $data->{'liblibrarian'}; - $row_data{libopac} = $data->{'libopac'}; + $row_data{liblibrarian} = CGI::escapeHTML($data->{'liblibrarian'}); + $row_data{libopac} = CGI::escapeHTML($data->{'libopac'}); $row_data{kohafield}= CGI::scrolling_list( -name=>"kohafield", -values=> \@kohafields, -default=> "$data->{'kohafield'}", @@ -143,6 +162,18 @@ if ($op eq 'add_form') { -size=>1, -multiple=>0, ); + $row_data{value_builder} = CGI::scrolling_list(-name=>'value_builder', + -values=> \@value_builder, + -default=>$data->{'thesaurus_category'}, + -size=>1, + -multiple=>0, + ); + $row_data{thesaurus_category} = CGI::scrolling_list(-name=>'thesaurus_category', + -values=> \@thesaurus_category, + -default=>$data->{'thesaurus_category'}, + -size=>1, + -multiple=>0, + ); # $row_data{kohafield} = $data->{'kohafield'}; $row_data{repeatable} = CGI::checkbox("repeatable$i",$data->{'repeatable'}?'checked':'',1,''); $row_data{mandatory} = CGI::checkbox("mandatory$i",$data->{'mandatory'}?'checked':'',1,''); @@ -150,7 +181,8 @@ if ($op eq 'add_form') { push(@loop_data, \%row_data); $i++; } - # add an empty line for add if needed + # add more_subfields empty lines for add if needed + for (my $i=1;$i<=$more_subfields;$i++) { my %row_data; # get a fresh hash for the row data $row_data{tab} = CGI::scrolling_list(-name=>'tab', -values=>['-1','0','1','2','3','4','5','6','7','8','9','10'], @@ -179,25 +211,36 @@ if ($op eq 'add_form') { -size=>1, -multiple=>0, ); + $row_data{thesaurus_category} = CGI::scrolling_list(-name=>'thesaurus_category', + -values=> \@thesaurus_category, + -size=>1, + -multiple=>0, + ); $row_data{bgcolor} = $toggle; push(@loop_data, \%row_data); + } + $template->param(action => "Edit subfields", + tagfield => "$tagfield", + loop => \@loop_data, + more_subfields => $more_subfields, + more_tag => $tagfield); - $template->param(loop => \@loop_data); - - # END $OP eq ADD_FORM + # END $OP eq ADD_FORM ################## ADD_VALIDATE ################################## # called by add_form, used to insert/modify data in DB } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; $template->param(tagfield => "$input->param('tagfield')"); - my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value) - values (?,?,?,?,?,?,?,?,?)"); + my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder) + values (?,?,?,?,?,?,?,?,?,?,?)"); my @tagsubfield = $input->param('tagsubfield'); my @liblibrarian = $input->param('liblibrarian'); my @libopac = $input->param('libopac'); my @kohafield = $input->param('kohafield'); my @tab = $input->param('tab'); my @authorised_values = $input->param('authorised_value'); + my @thesaurus_category = $input->param('thesaurus_category'); + my @value_builder =$input->param('value_builder'); for (my $i=0; $i<= $#tagsubfield ; $i++) { my $tagfield =$input->param('tagfield'); my $tagsubfield =$tagsubfield[$i]; @@ -208,6 +251,8 @@ if ($op eq 'add_form') { my $kohafield =$kohafield[$i]; my $tab =$tab[$i]; my $authorised_value =$authorised_values[$i]; + my $thesaurus_category =$thesaurus_category[$i]; + my $value_builder=$value_builder[$i]; if ($tagsubfield) { $sth->execute ($tagfield, $tagsubfield, @@ -217,7 +262,9 @@ if ($op eq 'add_form') { $mandatory, $kohafield, $tab, - $authorised_value); + $authorised_value, + $thesaurus_category, + $value_builder); } } $sth->finish; @@ -272,6 +319,8 @@ if ($op eq 'add_form') { $row_data{mandatory} = $results->[$i]{'mandatory'}; $row_data{tab} = $results->[$i]{'tab'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; + $row_data{thesaurus_category} = $results->[$i]{'thesaurus_category'}; + $row_data{value_builder} = $results->[$i]{'value_builder'}; $row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}; $row_data{bgcolor} = $toggle; push(@loop_data, \%row_data); diff --git a/admin/marctagstructure.pl b/admin/marctagstructure.pl index 7d73774503..34c17e049f 100755 --- a/admin/marctagstructure.pl +++ b/admin/marctagstructure.pl @@ -32,7 +32,7 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $query="Select tagfield,liblibrarian,libopac,repeatable,mandatory 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 like \"$data[0]%\") order by tagfield"; my $sth=$dbh->prepare($query); $sth->execute; my @results; @@ -49,10 +49,12 @@ sub StringSearch { my $input = new CGI; my $searchfield=$input->param('searchfield'); my $pkfield="tagfield"; -my $reqsel="select tagfield,liblibrarian,libopac,repeatable,mandatory from marc_tag_structure where $pkfield='$searchfield'"; +my $reqsel="select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where $pkfield='$searchfield'"; my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/marctagstructure.pl"; +my $dbh = C4::Context->dbh; + my $template = gettemplate("parameters/marctagstructure.tmpl",0); my $pagesize=20; my $op = $input->param('op'); @@ -72,12 +74,25 @@ if ($op eq 'add_form') { #---- if primkey exists, it's a modify action, so read values to modify... my $data; if ($searchfield) { - my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory from marc_tag_structure where $pkfield='$searchfield'"); + my $sth=$dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where $pkfield='$searchfield'"); $sth->execute; $data=$sth->fetchrow_hashref; $sth->finish; } + my $sth = $dbh->prepare("select distinct category from authorised_values"); + $sth->execute; + my @authorised_values; + push @authorised_values,""; + while ((my $category) = $sth->fetchrow_array) { + push @authorised_values, $category; + } + my $authorised_value = CGI::scrolling_list(-name=>'authorised_value', + -values=> \@authorised_values, + -size=>1, + -multiple=>0, + -default => $data->{'authorised_value'}, + ); + if ($searchfield) { $template->param(action => "Modify tag", searchfield => "$searchfield"); @@ -89,25 +104,30 @@ if ($op eq 'add_form') { libopac => $data->{'libopac'}, repeatable => CGI::checkbox('repeatable',$data->{'repeatable'}?'checked':'',1,''), mandatory => CGI::checkbox('mandatory',$data->{'mandatory'}?'checked':'',1,''), + authorised_value => $authorised_value, ); # END $OP eq ADD_FORM ################## ADD_VALIDATE ################################## # called by add_form, used to insert/modify data in DB } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("replace marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory) values (?,?,?,?,?)"); + my $sth=$dbh->prepare("replace marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value) values (?,?,?,?,?,?)"); my $tagfield =$input->param('tagfield'); my $liblibrarian = $input->param('liblibrarian'); my $libopac =$input->param('libopac'); my $repeatable =$input->param('repeatable'); my $mandatory =$input->param('mandatory'); + my $authorised_value =$input->param('authorised_value'); $sth->execute($tagfield, $liblibrarian, $libopac, $repeatable?1:0, $mandatory?1:0, + $authorised_value ); $sth->finish; + print "Content-Type: text/html\n\n"; + exit; # END $OP eq ADD_VALIDATE ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB @@ -148,6 +168,7 @@ if ($op eq 'add_form') { $row_data{liblibrarian} = $results->[$i]{'liblibrarian'}; $row_data{repeatable} = $results->[$i]{'repeatable'}; $row_data{mandatory} = $results->[$i]{'mandatory'}; + $row_data{authorised_value} = $results->[$i]{'authorised_value'}; $row_data{subfield_link} ="marc_subfields_structure.pl?tagfield=".$results->[$i]{'tagfield'}; $row_data{edit} = "$script_name?op=add_form&searchfield=".$results->[$i]{'tagfield'}; $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}; diff --git a/admin/thesaurus.pl b/admin/thesaurus.pl index 699bab26d7..57fedfd418 100755 --- a/admin/thesaurus.pl +++ b/admin/thesaurus.pl @@ -24,33 +24,7 @@ use C4::Output; use C4::Search; use HTML::Template; use C4::Context; - - -sub StringSearch { - my ($env,$category,$toponly,$branch,$searchstring,$type)=@_; - my $dbh = C4::Context->dbh; - $searchstring=~ s/\'/\\\'/g; - my $query="Select distinct stdlib,id,hierarchy,level from bibliothesaurus where (category like \"$category%\")"; - $query .= " and hierarchy='$branch'" if ($branch && $toponly); - $query .= " and hierarchy like \"$branch%\"" if ($branch && !$toponly); - $query .= " and hierarchy=''" if (!$branch & $toponly); - $query .= " and stdlib like \"$searchstring%\"" if ($searchstring); - $query .= " order by category,stdlib"; - my $sth=$dbh->prepare($query); - $sth->execute; - my @results; - my $cnt=0; - my $old_stdlib=""; - while (my $data=$sth->fetchrow_hashref){ - if ($old_stdlib ne $data->{'stdlib'}) { - $cnt ++; - push(@results,$data); - } - $old_stdlib = $data->{'stdlib'}; - } - $sth->finish; - return ($cnt,\@results); -} +use C4::Authorities; my $input = new CGI; my $search_category=$input->param('search_category'); @@ -59,11 +33,15 @@ my $branch = $input->param('branch'); my $searchstring = $input->param('searchstring'); $searchstring=~ s/\,//g; my $id = $input->param('id'); +my $offset=$input->param('offset'); +my $father=$input->param('father'); + my $reqsel="select category,stdlib,freelib from authorised_values where id='$id'"; my $reqdel="delete from authorised_values where id='$id'"; -my $offset=$input->param('offset'); my $script_name="/cgi-bin/koha/admin/thesaurus.pl"; my $dbh = C4::Context->dbh; +my $authoritysep = C4::Context->preference("authoritysep"); +warn "authority : $authoritysep"; my $template = gettemplate("parameters/thesaurus.tmpl",0); my $pagesize=20; @@ -81,6 +59,7 @@ $template->param(script_name => $script_name, if ($op eq 'add_form') { my $data; if ($id) { + warn "id => $id"; my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("select id,category,freelib,stdlib from bibliothesaurus where id='$id'"); $sth->execute; @@ -98,7 +77,13 @@ if ($op eq 'add_form') { $template->param(category => $data->{'category'}, stdlib => $data->{'stdlib'}, freelib => $data->{'freelib'}, - id => $data->{'id'} + id => $data->{'id'}, + branch => $branch, + toponly => $toponly, + search_category => $search_category, + searchstring => $searchstring, + offset => $offset, + father => $father, ); if ($data->{'category'}) { $template->param(category => "$data->{'category'}"); @@ -109,10 +94,10 @@ if ($op eq 'add_form') { # called by add_form, used to insert/modify data in DB } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("replace bibliothesaurus (id,category,stdlib,freelib) values (?,?,?,?)"); - $sth->execute($input->param('id'), $input->param('category'), $input->param('stdlib'), $input->param('freelib')); + my $sth=$dbh->prepare("replace bibliothesaurus (id,category,stdlib,freelib,father,hierarchy) values (?,?,?,?,?)"); + $sth->execute($input->param('id'), $input->param('category'), $input->param('stdlib'), $input->param('freelib'),$father); $sth->finish; - print "Content-Type: text/html\n\nparam('category')."\">"; + print "Content-Type: text/html\n\n"; exit; ################## DELETE_CONFIRM ################################## # called by default form, used to confirm deletion of data in DB @@ -149,7 +134,7 @@ if ($op eq 'add_form') { } my $tab_list = CGI::scrolling_list(-name=>'search_category', -values=> \@category_list, - -default=>"", + -default=>"$search_category", -size=>1, -multiple=>0, ); @@ -160,7 +145,6 @@ if ($op eq 'add_form') { my $sth = $dbh->prepare("select stdlib,category from bibliothesaurus where id=?"); $sth->execute($id); my ($stdlib,$category) = $sth->fetchrow_array; - warn "ID : $id / $stdlib / $category"; $sth->finish; $sth= $dbh->prepare("select id,freelib from bibliothesaurus where stdlib=?"); $sth->execute($stdlib); @@ -198,7 +182,7 @@ if ($op eq 'add_form') { } my $tab_list = CGI::scrolling_list(-name=>'search_category', -values=> \@category_list, - -default=>"", + -default=>"$search_category", -size=>1, -multiple=>0, ); @@ -206,7 +190,7 @@ if ($op eq 'add_form') { $search_category=$category_list[0]; } my $env; - my ($count,$results)=StringSearch($env,$search_category,$toponly,$branch,$searchstring,'web'); + my ($count,$results)=searchauthority($env,$search_category,$toponly,$branch,$searchstring); my $toggle="white"; my @loop_data = (); # builds value list @@ -220,18 +204,18 @@ if ($op eq 'add_form') { $row_data{category} = $results->[$i]{'category'}; $row_data{stdlib} = ("    " x $results->[$i]{'level'}).$results->[$i]{'stdlib'}; $row_data{stdlib} = $results->[$i]{'stdlib'}; - $row_data{dig} ="[$i]{'hierarchy'}".($results->[$i]{'hierarchy'}?"|":"")."$results->[$i]{'id'}&toponly=$toponly>"; - $row_data{related} ="[$i]{'id'}&op=detail_form>"; - $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}; + $row_data{dig} ="[$i]{'hierarchy'}".($results->[$i]{'hierarchy'}?"|":"")."$results->[$i]{'id'}&toponly=$toponly&search_category=$search_category>"; + $row_data{related} ="[$i]{'id'}&search_category=$search_category&op=detail_form>"; + $row_data{edit} = "$script_name?op=add_form&branch=$branch&toponly=$toponly&search_category=$search_category&searchstring=$searchstring&offset=$offset&id=".$results->[$i]{'id'}; $row_data{delete} = "$script_name?op=delete_confirm&search_category=$search_category&id=".$results->[$i]{'id'}; push(@loop_data, \%row_data); } - # rebuild coplete hierarchy + # rebuild complete hierarchy my $sth = $dbh->prepare("select stdlib from bibliothesaurus where id=?"); my @hierarchy = split(/\|/,$branch); my @hierarchy_loop; - warn "total : $#hierarchy"; my $x; + my $father; for (my $xi=0;$xi<=$#hierarchy;$xi++) { my %link; $sth->execute($hierarchy[$xi]); @@ -241,20 +225,23 @@ if ($op eq 'add_form') { $link{'branch'}=$x; push (@hierarchy_loop, \%link); $x.='|'; + $father = $t." $authoritysep "; } $template->param(loop => \@loop_data, tab_list => $tab_list, category => $search_category, toponly => $toponly, searchstring => $searchstring, - hierarchy_loop => \@hierarchy_loop); + hierarchy_loop => \@hierarchy_loop, + branch => $branch, + father => $father); if ($offset>0) { my $prevpage = $offset-$pagesize; - $template->param(previous => "<< Prev"); + $template->param(previous => "<< Prev"); } if ($offset+$pagesize<$count) { my $nextpage =$offset+$pagesize; - $template->param(next => "Next >>"); + $template->param(next => "Next >>"); } } #---- END $OP eq DEFAULT diff --git a/currency.pl b/currency.pl index 363d00968a..78aa974982 100755 --- a/currency.pl +++ b/currency.pl @@ -28,7 +28,7 @@ # to be used. Is it obsolete? use CGI; -use C4::Acquisitions; +use C4::Catalogue; use C4::Biblio; my $input=new CGI; diff --git a/opac/opac-main.pl b/opac/opac-main.pl index c030609759..8ad7e92ab9 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -2,6 +2,7 @@ use strict; require Exporter; use CGI; +use HTML::Template; use C4::Output; # gettemplate use C4::Auth; # checkauth diff --git a/showbudget.pl b/showbudget.pl index 2b49a94cdd..efcd96e38a 100755 --- a/showbudget.pl +++ b/showbudget.pl @@ -24,7 +24,7 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -use C4::Acquisitions; +use C4::Catalogue; use C4::Biblio; #use CGI; #my $inp=new CGI; -- 2.39.5