- if ($searchfield ne '') {
- $template->param(searchfield => "You Searched for <b>$searchfield<b><p>");
- }
- my $env;
- my ($count,$results)=StringSearch($env,$searchfield,'web');
- my $toggle="white";
- my @loop_data = ();
- for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
- if ($toggle eq 'white'){
- $toggle="#ffffcc";
- } else {
- $toggle="white";
- }
- my %row_data; # get a fresh hash for the row data
- $row_data{tagfield} = $results->[$i]{'tagfield'};
- $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'};
- $row_data{bgcolor} = $toggle;
- push(@loop_data, \%row_data);
+ # here, $op can be unset or set to "framework_create_confirm".
+ if ($searchfield ne '') {
+ $template->param(searchfield => $searchfield);
+ }
+ my $cnt=0;
+ if ($dspchoice) {
+ #here, user only wants used tags/subfields displayed
+ $searchfield=~ s/\'/\\\'/g;
+ my @data=split(' ',$searchfield);
+ my $sth=$dbh->prepare("
+ SELECT marc_tag_structure.tagfield AS mts_tagfield,
+ marc_tag_structure.liblibrarian as mts_liblibrarian,
+ marc_tag_structure.libopac as mts_libopac,
+ marc_tag_structure.repeatable as mts_repeatable,
+ marc_tag_structure.mandatory as mts_mandatory,
+ marc_tag_structure.authorised_value as mts_authorized_value,
+ marc_subfield_structure.*
+ FROM marc_tag_structure
+ LEFT JOIN marc_subfield_structure ON (marc_tag_structure.tagfield=marc_subfield_structure.tagfield AND marc_tag_structure.frameworkcode=marc_subfield_structure.frameworkcode) WHERE (marc_tag_structure.tagfield >= ? and marc_tag_structure.frameworkcode=?) AND marc_subfield_structure.tab>=0 ORDER BY marc_tag_structure.tagfield,marc_subfield_structure.tagsubfield");
+ #could be ordoned by tab
+ $sth->execute($data[0], $frameworkcode);
+ my @results = ();
+ while (my $data=$sth->fetchrow_hashref){
+ push(@results,$data);
+ $cnt++;
+ }
+
+ my @loop_data = ();
+ my $j=1;
+ my $i=$offset;
+ while ( $i < $cnt ) {
+ my %row_data; # get a fresh hash for the row data
+ $row_data{tagfield} = $results[$i]->{'mts_tagfield'};
+ $row_data{liblibrarian} = $results[$i]->{'mts_liblibrarian'};
+ $row_data{repeatable} = $results[$i]->{'mts_repeatable'};
+ $row_data{mandatory} = $results[$i]->{'mts_mandatory'};
+ $row_data{authorised_value} = $results[$i]->{'mts_authorised_value'};
+ $row_data{subfield_link} = "marc_subfields_structure.pl?op=add_form&tagfield=".$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
+ $row_data{edit} = "$script_name?op=add_form&searchfield=" .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
+ $row_data{delete} = "$script_name?op=delete_confirm&searchfield=" .$results[$i]->{'mts_tagfield'}."&frameworkcode=".$frameworkcode;
+ $j=$i;
+ my @internal_loop = ();
+ while ( ( $results[$i]->{'tagfield'} == $results[$j]->{'tagfield'} ) and ( $j < $cnt ) ) {
+ my %subfield_data;
+ $subfield_data{tagsubfield} = $results[$j]->{'tagsubfield'};
+ $subfield_data{liblibrarian} = $results[$j]->{'liblibrarian'};
+ $subfield_data{kohafield} = $results[$j]->{'kohafield'};
+ $subfield_data{repeatable} = $results[$j]->{'repeatable'};
+ $subfield_data{mandatory} = $results[$j]->{'mandatory'};
+ $subfield_data{tab} = $results[$j]->{'tab'};
+ $subfield_data{seealso} = $results[$j]->{'seealso'};
+ $subfield_data{authorised_value} = $results[$j]->{'authorised_value'};
+ $subfield_data{authtypecode} = $results[$j]->{'authtypecode'};
+ $subfield_data{value_builder} = $results[$j]->{'value_builder'};
+# warn "tagfield : ".$results[$j]->{'tagfield'}." tagsubfield :".$results[$j]->{'tagsubfield'};
+ push @internal_loop,\%subfield_data;
+ $j++;
+ }
+ $row_data{'subfields'}=\@internal_loop;
+ push(@loop_data, \%row_data);
+ $i=$j;
+ }
+ $template->param(select_display => "True",
+ loop => \@loop_data);
+ } else {
+ #here, normal old style : display every tags
+ my ($count,$results)=StringSearch($searchfield,$frameworkcode);
+ $cnt = $count;
+ my @loop_data = ();
+ for ( my $i = $offset ; $i < $count ; $i++ ) {
+ my %row_data; # get a fresh hash for the row data
+ $row_data{tagfield} = $results->[$i]{'tagfield'};
+ $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'}."&frameworkcode=".$frameworkcode;
+ $row_data{edit} = "$script_name?op=add_form&searchfield=" .$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
+ $row_data{delete} = "$script_name?op=delete_confirm&searchfield=".$results->[$i]{'tagfield'}."&frameworkcode=".$frameworkcode;
+ push(@loop_data, \%row_data);
+ }
+ $template->param(loop => \@loop_data);