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
};
33 <script type=\"text/javascript\">
35 function Click$function_name(i) {
36 newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=macles.pl&index=\"+i,\"MACLES\",',toolbar=false,scrollbars=yes');
46 my $input = $params->{cgi
};
47 my $index= $input->param('index');
49 my $dbh = C4
::Context
->dbh;
50 my $rq=$dbh->prepare("SELECT authorised_value, lib from authorised_values where category=\"MACLES\" order by authorised_value DESC");
54 my (%numbers,@lists,$table);
55 while (my $tab = $rq->fetchrow_hashref){
56 my $number=substr($tab->{authorised_value
},0,1);
57 if ($tab->{authorised_value
}=~/[0-9]XX/){
58 $numbers{$number}->{'hdr_tab'}=$tab->{lib
};
59 $numbers{$number}->{'Table'}=($number=~/[1-7]/);
60 } elsif ($tab->{authorised_value
}=~/.X./){
61 $tab->{authorised_value
}=~s/X/\./;
63 unshift @
{$numbers{$number}->{"col_hdr"}},{"colvalue"=>$tab->{authorised_value
},"collib"=>$tab->{lib
}};
64 } elsif ($tab->{authorised_value
}=~/..X/){
65 $tab->{authorised_value
}=~s/X/\./;
66 unshift @
{$numbers{$number}->{"row_hdr"}},{"rowvalue"=>$tab->{authorised_value
},"rowlib"=>$tab->{lib
}}
67 } elsif ($tab->{'authorised_value'}=~/,/){
68 my @listval=split /,/,$tab->{'authorised_value'};
69 # $tab->{authorised_value}=~s/,/","/g;
70 # $tab->{authorised_value}="(".$tab->{authorised_value}.")";
72 foreach my $val (@listval){
73 unshift @
{$numbers{$number}->{$val}},$tab->{'lib'};
74 my $mulrow=substr($val,0,2);
77 foreach my $mulrow (sort keys %mulrows){
78 unshift @
{$numbers{$number}->{$mulrow}},{'listlib' => $tab->{'lib'},'listvalue' => $tab->{'authorised_value'}};
81 unshift @
{$numbers{$number}->{$tab->{'authorised_value'}}},$tab->{'lib'};
84 foreach my $num ( sort keys %numbers ) {
87 @tmpcolhdr = @
{ $numbers{$num}->{'col_hdr'} }
88 if ( $numbers{$num}->{'col_hdr'} );
89 @tmprowhdr = @
{ $numbers{$num}->{"row_hdr"} }
90 if ( $numbers{$num}->{'row_hdr'} );
94 foreach my $row (@tmprowhdr) {
95 my $tmprowvalue = $row->{rowvalue
};
97 $rowcode = $1 if $tmprowvalue =~ /[0-9]([0-9])\./;
99 if ( scalar(@tmpcolhdr) > 0 ) {
101 #cas du tableau bidim
102 foreach my $col (@tmpcolhdr) {
103 my $tmpcolvalue = $col->{colvalue
};
105 $colcode = $1 if $tmpcolvalue =~ /[0-9]\.([0-9])/;
107 $cell{celvalue
} = $num . $rowcode . $colcode;
108 $cell{rowvalue
} = $tmprowvalue;
109 $cell{colvalue
} = $tmpcolvalue;
110 if ( $numbers{$num}->{ $num . $rowcode . $colcode } ) {
113 @
{ $numbers{$num}->{ $num . $rowcode . $colcode } }
116 push @
{ $cell{libs
} }, { 'lib' => $_ };
120 push @
{ $cell{libs
} },
121 { 'lib' => $num . $rowcode . $colcode };
125 if ( $numbers{$num}->{ $num . $rowcode } ) {
126 my @tmpliblist = @
{ $numbers{$num}->{ $num . $rowcode } };
128 { 'lib' => $row->{rowlib
}, 'liblist' => \
@tmpliblist };
133 #Cas de la liste simple
134 foreach my $key ( sort keys %{ $numbers{$num} } ) {
136 if ( $key =~ /$num$rowcode[0-9]/ ) {
137 $cell{celvalue
} = $key;
138 foreach my $lib ( @
{ $numbers{$num}->{$key} } ) {
139 push @
{ $cell{'libs'} }, { 'lib' => $lib };
148 'rowvalue' => $row->{rowvalue
},
149 'rowlib' => $row->{rowlib
}
152 $BIGLOOPcell{'Lists'} = \
@lists if ( scalar(@lists) > 0 );
153 $BIGLOOPcell{'lines'} = \
@lines if ( scalar(@lines) > 0 );
154 $BIGLOOPcell{'col_hdr'} = \
@tmpcolhdr if ( scalar(@tmpcolhdr) > 0 );
155 $BIGLOOPcell{'Table'} = $numbers{$num}->{'Table'};
156 $BIGLOOPcell{'hdr_tab'} = $numbers{$num}->{'hdr_tab'};
157 $BIGLOOPcell{'number'} = $num;
158 push @BIGLOOP, \
%BIGLOOPcell;
161 my ($template, $loggedinuser, $cookie)
162 = get_template_and_user
({template_name
=> "cataloguing/value_builder/macles.tt",
165 authnotrequired
=> 0,
166 flagsrequired
=> {editcatalogue
=> '*'},
169 $template->param(BIGLOOP
=>\
@BIGLOOP);
170 $template->param("index"=>$index);
171 output_html_with_http_headers
$input, $cookie, $template->output;
174 return { builder
=> $builder, launcher
=> $launcher };