3 # Converted to new plugin style (Bug 13437)
5 # Copyright 2000-2002 Katipo Communications
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
31 my $function_name = $params->{id};
34 function Click$function_name(i) {
35 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=macles.pl&index=\"+i,\"MACLES\",',toolbar=false,scrollbars=yes');
44 my $input = $params->{cgi};
45 my $index= $input->param('index');
47 my $dbh = C4::Context->dbh;
48 my $rq=$dbh->prepare("SELECT authorised_value, lib from authorised_values where category=\"MACLES\" order by authorised_value DESC");
52 my (%numbers,@lists,$table);
53 while (my $tab = $rq->fetchrow_hashref){
54 my $number=substr($tab->{authorised_value},0,1);
55 if ($tab->{authorised_value}=~/[0-9]XX/){
56 $numbers{$number}->{'hdr_tab'}=$tab->{lib};
57 $numbers{$number}->{'Table'}=($number=~/[1-7]/);
58 } elsif ($tab->{authorised_value}=~/.X./){
59 $tab->{authorised_value}=~s/X/\./;
61 unshift @{$numbers{$number}->{"col_hdr"}},{"colvalue"=>$tab->{authorised_value},"collib"=>$tab->{lib}};
62 } elsif ($tab->{authorised_value}=~/..X/){
63 $tab->{authorised_value}=~s/X/\./;
64 unshift @{$numbers{$number}->{"row_hdr"}},{"rowvalue"=>$tab->{authorised_value},"rowlib"=>$tab->{lib}}
65 } elsif ($tab->{'authorised_value'}=~/,/){
66 my @listval=split /,/,$tab->{'authorised_value'};
67 # $tab->{authorised_value}=~s/,/","/g;
68 # $tab->{authorised_value}="(".$tab->{authorised_value}.")";
70 foreach my $val (@listval){
71 unshift @{$numbers{$number}->{$val}},$tab->{'lib'};
72 my $mulrow=substr($val,0,2);
75 foreach my $mulrow (sort keys %mulrows){
76 unshift @{$numbers{$number}->{$mulrow}},{'listlib' => $tab->{'lib'},'listvalue' => $tab->{'authorised_value'}};
79 unshift @{$numbers{$number}->{$tab->{'authorised_value'}}},$tab->{'lib'};
82 foreach my $num ( sort keys %numbers ) {
85 @tmpcolhdr = @{ $numbers{$num}->{'col_hdr'} }
86 if ( $numbers{$num}->{'col_hdr'} );
87 @tmprowhdr = @{ $numbers{$num}->{"row_hdr"} }
88 if ( $numbers{$num}->{'row_hdr'} );
92 foreach my $row (@tmprowhdr) {
93 my $tmprowvalue = $row->{rowvalue};
95 $rowcode = $1 if $tmprowvalue =~ /[0-9]([0-9])\./;
97 if ( scalar(@tmpcolhdr) > 0 ) {
100 foreach my $col (@tmpcolhdr) {
101 my $tmpcolvalue = $col->{colvalue};
103 $colcode = $1 if $tmpcolvalue =~ /[0-9]\.([0-9])/;
105 $cell{celvalue} = $num . $rowcode . $colcode;
106 $cell{rowvalue} = $tmprowvalue;
107 $cell{colvalue} = $tmpcolvalue;
108 if ( $numbers{$num}->{ $num . $rowcode . $colcode } ) {
111 @{ $numbers{$num}->{ $num . $rowcode . $colcode } }
114 push @{ $cell{libs} }, { 'lib' => $_ };
118 push @{ $cell{libs} },
119 { 'lib' => $num . $rowcode . $colcode };
123 if ( $numbers{$num}->{ $num . $rowcode } ) {
124 my @tmpliblist = @{ $numbers{$num}->{ $num . $rowcode } };
126 { 'lib' => $row->{rowlib}, 'liblist' => \@tmpliblist };
131 #Cas de la liste simple
132 foreach my $key ( sort keys %{ $numbers{$num} } ) {
134 if ( $key =~ /$num$rowcode[0-9]/ ) {
135 $cell{celvalue} = $key;
136 foreach my $lib ( @{ $numbers{$num}->{$key} } ) {
137 push @{ $cell{'libs'} }, { 'lib' => $lib };
146 'rowvalue' => $row->{rowvalue},
147 'rowlib' => $row->{rowlib}
150 $BIGLOOPcell{'Lists'} = \@lists if ( scalar(@lists) > 0 );
151 $BIGLOOPcell{'lines'} = \@lines if ( scalar(@lines) > 0 );
152 $BIGLOOPcell{'col_hdr'} = \@tmpcolhdr if ( scalar(@tmpcolhdr) > 0 );
153 $BIGLOOPcell{'Table'} = $numbers{$num}->{'Table'};
154 $BIGLOOPcell{'hdr_tab'} = $numbers{$num}->{'hdr_tab'};
155 $BIGLOOPcell{'number'} = $num;
156 push @BIGLOOP, \%BIGLOOPcell;
159 my ($template, $loggedinuser, $cookie)
160 = get_template_and_user({template_name => "cataloguing/value_builder/macles.tt",
163 flagsrequired => {editcatalogue => '*'},
165 $template->param(BIGLOOP=>\@BIGLOOP);
166 $template->param("index"=>$index);
167 output_html_with_http_headers $input, $cookie, $template->output;
170 return { builder => $builder, launcher => $launcher };