Adding Log Facility.
[koha.git] / acqui.simple / addbiblio.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 # Copyright 2000-2002 Katipo Communications
6 #
7 # This file is part of Koha.
8 #
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
12 # version.
13 #
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along with
19 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
20 # Suite 330, Boston, MA  02111-1307 USA
21
22 use strict;
23 use CGI;
24 use C4::Auth;
25 use C4::Output;
26 use C4::Interface::CGI::Output;
27 use C4::Biblio;
28 use C4::SearchMarc; # also includes Biblio.pm, SearchMarc is used to FindDuplicate
29 use C4::Context;
30 use C4::Log;
31 use C4::Koha; # XXX subfield_is_koha_internal_p
32 use HTML::Template;
33 use MARC::File::USMARC;
34
35 use vars qw( $tagslib);
36 use vars qw( $authorised_values_sth);
37 use vars qw( $is_a_modif );
38
39 my $itemtype; # created here because it can be used in build_authorized_values_list sub
40
41 =item find_value
42
43     ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
44
45 Find the given $subfield in the given $tag in the given
46 MARC::Record $record.  If the subfield is found, returns
47 the (indicators, value) pair; otherwise, (undef, undef) is
48 returned.
49
50 =cut
51
52 sub find_value {
53         my ($tagfield,$insubfield,$record,$encoding) = @_;
54         my @result;
55         my $indicator;
56         if ($tagfield <10) {
57                 if ($record->field($tagfield)) {
58                         push @result, $record->field($tagfield)->data();
59                 } else {
60                         push @result,"";
61                 }
62         } else {
63                 foreach my $field ($record->field($tagfield)) {
64                         my @subfields = $field->subfields();
65                         foreach my $subfield (@subfields) {
66                                 if (@$subfield[0] eq $insubfield) {
67                                         push @result,char_decode(@$subfield[1],$encoding);
68                                         $indicator = $field->indicator(1).$field->indicator(2);
69                                 }
70                         }
71                 }
72         }
73         return($indicator,@result);
74 }
75
76
77 =item MARCfindbreeding
78
79     $record = MARCfindbreeding($dbh, $breedingid);
80
81 Look up the breeding farm with database handle $dbh, for the
82 record with id $breedingid.  If found, returns the decoded
83 MARC::Record; otherwise, -1 is returned (FIXME).
84 Returns as second parameter the character encoding.
85
86 =cut
87
88 sub MARCfindbreeding {
89         my ($dbh,$id) = @_;
90         my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
91         $sth->execute($id);
92         my ($file,$marc,$encoding) = $sth->fetchrow;
93         if ($marc) {
94                 my $record = MARC::File::USMARC::decode($marc);
95                 if (ref($record) eq undef) {
96                         return -1;
97                 } else {
98                         return $record,$encoding;
99                 }
100         }
101         return -1;
102 }
103
104
105 =item build_authorized_values_list
106
107 =cut
108
109 sub build_authorized_values_list ($$$$$) {
110         my($tag, $subfield, $value, $dbh,$authorised_values_sth) = @_;
111
112         my @authorised_values;
113         my %authorised_lib;
114
115         # builds list, depending on authorised value...
116
117         #---- branch
118         if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
119         my $sth=$dbh->prepare("select branchcode,branchname from branches order by branchname");
120         $sth->execute;
121         push @authorised_values, ""
122                 unless ($tagslib->{$tag}->{$subfield}->{mandatory});
123
124         while (my ($branchcode,$branchname) = $sth->fetchrow_array) {
125                 push @authorised_values, $branchcode;
126                 $authorised_lib{$branchcode}=$branchname;
127         }
128
129         #----- itemtypes
130         } elsif ($tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes") {
131                 my $sth=$dbh->prepare("select itemtype,description from itemtypes order by description");
132                 $sth->execute;
133                 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
134         
135                 while (my ($itemtype,$description) = $sth->fetchrow_array) {
136                         push @authorised_values, $itemtype;
137                         $authorised_lib{$itemtype}=$description;
138                 }
139                 $value=$itemtype unless ($value);
140
141         #---- "true" authorised value
142         } else {
143                 $authorised_values_sth->execute($tagslib->{$tag}->{$subfield}->{authorised_value});
144
145                 push @authorised_values, "" unless ($tagslib->{$tag}->{$subfield}->{mandatory});
146         
147                 while (my ($value,$lib) = $authorised_values_sth->fetchrow_array) {
148                         push @authorised_values, $value;
149                         $authorised_lib{$value}=$lib;
150                 }
151     }
152     return CGI::scrolling_list( -name     => 'field_value',
153                                 -values   => \@authorised_values,
154                                 -default  => $value,
155                                 -labels   => \%authorised_lib,
156                                 -size     => 1,
157                                 -multiple => 0 );
158 }
159
160 =item create_input
161  builds the <input ...> entry for a subfield.
162 =cut
163 sub create_input () {
164         my ($tag,$subfield,$value,$i,$tabloop,$rec,$authorised_values_sth) = @_;
165         $value =~ s/"/&quot;/g;
166         my $dbh = C4::Context->dbh;
167         my %subfield_data;
168         $subfield_data{tag}=$tag;
169         $subfield_data{subfield}=$subfield;
170         $subfield_data{marc_lib}="<span id=\"error$i\">".$tagslib->{$tag}->{$subfield}->{lib}."</span>";
171         $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory};
172         $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
173         $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
174         $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield};
175         # it's an authorised field
176         if ($tagslib->{$tag}->{$subfield}->{authorised_value}) {
177                 $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth);
178         # it's a thesaurus / authority field
179         } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) {
180                 $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"47\" maxlength=\"255\" DISABLE READONLY> <a href=\"javascript:Dopop('../authorities/auth_finder.pl?authtypecode=".$tagslib->{$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">...</a>";
181         # it's a plugin field
182         } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) {
183                 # opening plugin. Just check wether we are on a developper computer on a production one
184                 # (the cgidir differs)
185                 my $cgidir = C4::Context->intranetdir ."/cgi-bin/value_builder";
186                 unless (opendir(DIR, "$cgidir")) {
187                         $cgidir = C4::Context->intranetdir."/value_builder";
188                 } 
189                 my $plugin=$cgidir."/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; 
190                 require $plugin;
191                 my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop);
192                 my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop);
193                 $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\"  value=\"$value\" size=\"47\" maxlength=\"255\" OnFocus=\"javascript:Focus$function_name($i)\" OnBlur=\"javascript:Blur$function_name($i)\"> <a href=\"javascript:Clic$function_name($i)\">...</a> $javascript";
194         # it's an hidden field
195         } elsif  ($tag eq '') {
196                 $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value\" value=\"$value\">";
197         } elsif  ($tagslib->{$tag}->{$subfield}->{'hidden'}) {
198                 $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"50\" maxlength=\"255\" DISABLE READONLY>";
199         # it's a standard field
200         } else {
201                 if (length($value) >200) {
202                         $subfield_data{marc_value}="<textarea name=\"fieldvalue\" cols=\"50\" rows=\"5\" >$value</textarea>";
203                 } else {
204                         $subfield_data{marc_value}="<input type=\"text\" name=\"field_value\" value=\"$value\" size=\"50\">"; #"
205                 }
206         }
207         return \%subfield_data;
208 }
209
210 sub build_tabs ($$$$) {
211     my($template, $record, $dbh,$encoding) = @_;
212     # fill arrays
213     my @loop_data =();
214     my $tag;
215     my $i=0;
216         my $authorised_values_sth = $dbh->prepare("select authorised_value,lib
217                 from authorised_values
218                 where category=? order by lib");
219
220 # loop through each tab 0 through 9
221         for (my $tabloop = 0; $tabloop <= 9; $tabloop++) {
222                 my @loop_data = ();
223                 foreach my $tag (sort(keys (%{$tagslib}))) {
224                         my $indicator;
225         # if MARC::Record is not empty => use it as master loop, then add missing subfields that should be in the tab.
226         # if MARC::Record is empty => use tab as master loop.
227                         if ($record ne -1 && $record->field($tag)) {
228                                 my @fields = $record->field($tag);
229                                 foreach my $field (@fields)  {
230                                         my @subfields_data;
231                                         if ($tag<10) {
232                                                 my $value=$field->data();
233                                                 my $subfield="@";
234                                                 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
235                                                 push(@subfields_data, &create_input($tag,$subfield,char_decode($value,$encoding),$i,$tabloop,$record,$authorised_values_sth));
236                                                 $i++;
237                                         } else {
238                                                 my @subfields=$field->subfields();
239                                                 foreach my $subfieldcount (0..$#subfields) {
240                                                         my $subfield=$subfields[$subfieldcount][0];
241                                                         my $value=$subfields[$subfieldcount][1];
242                                                         next if (length $subfield !=1);
243                                                         next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
244                                                         push(@subfields_data, &create_input($tag,$subfield,char_decode($value,$encoding),$i,$tabloop,$record,$authorised_values_sth));
245                                                         $i++;
246                                                 }
247                                         }
248 # now, loop again to add parameter subfield that are not in the MARC::Record
249                                         foreach my $subfield (sort( keys %{$tagslib->{$tag}})) {
250                                                 next if (length $subfield !=1);
251                                                 next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
252                                                 next if ($tag<10);
253                                                 next if (defined($field->subfield($subfield)));
254                                                 push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
255                                                 $i++;
256                                         }
257                                         if ($#subfields_data >= 0) {
258                                                 my %tag_data;
259                                                 $tag_data{tag} = $tag;
260                                                 $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
261                                                 $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
262                                                 $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10);
263                                                 $tag_data{subfield_loop} = \@subfields_data;
264                                                 push (@loop_data, \%tag_data);
265                                         }
266 # If there is more than 1 field, add an empty hidden field as separator.
267                                         if ($#fields >1) {
268                                                 my @subfields_data;
269                                                 my %tag_data;
270                                                 push(@subfields_data, &create_input('','','',$i,$tabloop,$record,$authorised_values_sth));
271                                                 $tag_data{tag} = '';
272                                                 $tag_data{tag_lib} = '';
273                                                 $tag_data{indicator} = '';
274                                                 $tag_data{subfield_loop} = \@subfields_data;
275                                                 push (@loop_data, \%tag_data);
276                                                 $i++;
277                                         }
278                                 }
279         # if breeding is empty
280                         } else {
281                                 my @subfields_data;
282                                 foreach my $subfield (sort(keys %{$tagslib->{$tag}})) {
283                                         next if (length $subfield !=1);
284                                         next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop);
285                                         push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth));
286                                         $i++;
287                                 }
288                                 if ($#subfields_data >= 0) {
289                                         my %tag_data;
290                                         $tag_data{tag} = $tag;
291                                         $tag_data{tag_lib} = $tagslib->{$tag}->{lib};
292                                         $tag_data{repeatable} = $tagslib->{$tag}->{repeatable};
293                                         $tag_data{indicator} = $indicator;
294                                         $tag_data{subfield_loop} = \@subfields_data;
295                                         push (@loop_data, \%tag_data);
296                                 }
297                         }
298                 }
299                 $template->param($tabloop."XX" =>\@loop_data);
300         }
301 }
302
303
304 sub build_hidden_data () {
305     # build hidden data =>
306     # we store everything, even if we show only requested subfields.
307
308     my @loop_data =();
309     my $i=0;
310     foreach my $tag (keys %{$tagslib}) {
311         my $previous_tag = '';
312
313         # loop through each subfield
314         foreach my $subfield (keys %{$tagslib->{$tag}}) {
315             next if ($subfield eq 'lib');
316             next if ($subfield eq 'tab');
317             next if ($subfield eq 'mandatory');
318                 next if ($subfield eq 'repeatable');
319             next if ($tagslib->{$tag}->{$subfield}->{'tab'}  ne "-1");
320             my %subfield_data;
321             $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
322             $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
323             $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
324             $subfield_data{marc_value}="<input type=\"hidden\" name=\"field_value[]\">";
325             push(@loop_data, \%subfield_data);
326             $i++
327         }
328     }
329 }
330
331
332 # ======================== 
333 #          MAIN 
334 #=========================
335 my $input = new CGI;
336 my $error = $input->param('error');
337 my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio.
338 my $breedingid = $input->param('breedingid');
339 my $z3950 = $input->param('z3950');
340 my $op = $input->param('op');
341 my $frameworkcode = $input->param('frameworkcode');
342 my $dbh = C4::Context->dbh;
343 my $bibid;
344
345
346 if ($oldbiblionumber) {
347         $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$oldbiblionumber);
348         # find framework type
349         $frameworkcode = &MARCfind_frameworkcode($dbh,$bibid) if ($bibid and not ($frameworkcode));
350 }else {
351         $bibid = $input->param('bibid');
352         $frameworkcode = &MARCfind_frameworkcode($dbh,$bibid) if ($bibid and not ($frameworkcode));
353 }
354 $frameworkcode='' if ($frameworkcode eq 'Default');
355 my ($template, $loggedinuser, $cookie)
356     = get_template_and_user({template_name => "acqui.simple/addbiblio.tmpl",
357                              query => $input,
358                              type => "intranet",
359                              authnotrequired => 0,
360                              flagsrequired => {editcatalogue => 1},
361                              debug => 1,
362                              });
363
364 #Getting the list of all frameworks
365 my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from biblio_framework");
366 $queryfwk->execute;
367 my %select_fwk;
368 my @select_fwk;
369 my $curfwk;
370 push @select_fwk,"Default";
371 $select_fwk{"Default"} = "Default";
372 while (my ($description, $fwk) =$queryfwk->fetchrow) {
373         push @select_fwk, $fwk;
374         $select_fwk{$fwk} = $description;
375 }
376 $curfwk=$frameworkcode;
377 my $framework=CGI::scrolling_list( -name     => 'Frameworks',
378                         -id => 'Frameworks',
379                         -default => $curfwk,
380                         -OnChange => 'Changefwk(this);',
381                         -values   => \@select_fwk,
382                         -labels   => \%select_fwk,
383                         -size     => 1,
384                         -multiple => 0 );
385 $template->param( framework => $framework);
386
387 $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
388 my $record=-1;
389 my $encoding="";
390 $record = MARCgetbiblio($dbh,$bibid) if ($bibid);
391 ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
392
393 $is_a_modif=0;
394 my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
395 my ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield,$bibitem,$oldbiblioitemnumber);
396 if ($bibid) {
397         $is_a_modif=1;
398         # if it's a modif, retrieve old biblio and bibitem numbers for the future modification of old-DB.
399         ($oldbiblionumtagfield,$oldbiblionumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblio.biblionumber",$frameworkcode);
400         ($oldbiblioitemnumtagfield,$oldbiblioitemnumtagsubfield) = &MARCfind_marc_from_kohafield($dbh,"biblioitems.biblioitemnumber",$frameworkcode);
401         # search biblioitems value
402         my $sth=$dbh->prepare("select biblioitemnumber from biblioitems where biblionumber=?");
403         $sth->execute($oldbiblionumber);
404         ($oldbiblioitemnumber) = $sth->fetchrow;
405 }
406 #------------------------------------------------------------------------------------------------------------------------------
407 if ($op eq "addbiblio") {
408 #------------------------------------------------------------------------------------------------------------------------------
409         # rebuild
410         my @tags = $input->param('tag');
411         my @subfields = $input->param('subfield');
412         my @values = $input->param('field_value');
413         # build indicator hash.
414         my @ind_tag = $input->param('ind_tag');
415         my @indicator = $input->param('indicator');
416         my %indicators;
417         for (my $i=0;$i<=$#ind_tag;$i++) {
418                 $indicators{$ind_tag[$i]} = $indicator[$i];
419         }
420         my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
421         # check for a duplicate
422         my ($duplicatebiblionumber,$duplicatebibid,$duplicatetitle) = FindDuplicate($record) if ($op eq "addbiblio") && (!$is_a_modif);
423         my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
424         # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
425         if (!$duplicatebiblionumber or $confirm_not_duplicate) {
426                 # MARC::Record built => now, record in DB
427                 my $oldbibnum;
428                 my $oldbibitemnum;
429                 if ($is_a_modif) {
430                         NEWmodbiblioframework($dbh,$bibid,$frameworkcode);
431                         NEWmodbiblio($dbh,$record,$bibid,$frameworkcode);
432                         logaction($loggedinuser,"acqui.simple","modify","biblionumber :$oldbiblionumber\nrecord : ".$record->as_formatted) if (logstatus);
433                 } else {
434                         ($bibid,$oldbibnum,$oldbibitemnum) = NEWnewbiblio($dbh,$record,$frameworkcode);
435                         logaction($loggedinuser,"acqui.simple","add","biblionumber :$oldbibnum\nrecord : ".$record->as_formatted) if (logstatus);
436                 }
437         # now, redirect to additem page
438                 print $input->redirect("additem.pl?bibid=$bibid&frameworkcode=$frameworkcode");
439                 exit;
440         } else {
441         # it may be a duplicate, warn the user and do nothing
442                 build_tabs ($template, $record, $dbh,$encoding);
443                 build_hidden_data;
444                 $template->param(
445                         oldbiblionumber             => $oldbiblionumber,
446                         bibid                       => $bibid,
447                         oldbiblionumtagfield        => $oldbiblionumtagfield,
448                         oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
449                         oldbiblioitemnumtagfield    => $oldbiblioitemnumtagfield,
450                         oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
451                         oldbiblioitemnumber         => $oldbiblioitemnumber,
452                         duplicatebiblionumber           => $duplicatebiblionumber,
453                         duplicatebibid                          => $duplicatebibid,
454                         duplicatetitle                          => $duplicatetitle,
455                          );
456         }
457 #------------------------------------------------------------------------------------------------------------------------------
458 } elsif ($op eq "addfield") {
459 #------------------------------------------------------------------------------------------------------------------------------
460         my $addedfield = $input->param('addfield_field');
461         my @tags = $input->param('tag');
462         my @subfields = $input->param('subfield');
463         my @values = $input->param('field_value');
464         # build indicator hash.
465         my @ind_tag = $input->param('ind_tag');
466         my @indicator = $input->param('indicator');
467         my %indicators;
468         for (my $i=0;$i<=$#ind_tag;$i++) {
469                 $indicators{$ind_tag[$i]} = $indicator[$i];
470         }
471         my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
472         # adding an empty field
473         my $field = MARC::Field->new("$addedfield",'','','a'=> "");
474         $record->append_fields($field);
475         build_tabs ($template, $record, $dbh,$encoding);
476         build_hidden_data;
477         $template->param(
478                 oldbiblionumber             => $oldbiblionumber,
479                 bibid                       => $bibid,
480                 oldbiblionumtagfield        => $oldbiblionumtagfield,
481                 oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
482                 oldbiblioitemnumtagfield    => $oldbiblioitemnumtagfield,
483                 oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
484                 oldbiblioitemnumber         => $oldbiblioitemnumber );
485 } elsif ($op eq "delete") {
486 #------------------------------------------------------------------------------------------------------------------------------
487         &NEWdelbiblio($dbh,$bibid);
488         logaction($loggedinuser,"acqui.simple","del","biblionumber :$bibid") if (logstatus);
489         
490         print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=/cgi-bin/koha/search.marc/search.pl?type=intranet\"></html>";
491         exit;
492 #------------------------------------------------------------------------------------------------------------------------------logaction($loggedinuser,"acqui.simple","add","biblionumber :$oldbibnum");
493 #------------------------------------------------------------------------------------------------------------------------------
494 } else {
495 #------------------------------------------------------------------------------------------------------------------------------
496         # If we're in a duplication case, we have to set to "" the bibid and biblionumber
497         # as we'll save the biblio as a new one.
498         if ($op eq "duplicate")
499         {
500                 $bibid = "";
501                 $oldbiblionumber= "";
502         }
503  
504         build_tabs ($template, $record, $dbh,$encoding);
505         build_hidden_data;
506         $template->param(
507                 oldbiblionumber             => $oldbiblionumber,
508                 bibid                       => $bibid,
509                 oldbiblionumtagfield        => $oldbiblionumtagfield,
510                 oldbiblionumtagsubfield     => $oldbiblionumtagsubfield,
511                 oldbiblioitemnumtagfield    => $oldbiblioitemnumtagfield,
512                 oldbiblioitemnumtagsubfield => $oldbiblioitemnumtagsubfield,
513                 oldbiblioitemnumber         => $oldbiblioitemnumber,
514                 );
515 }
516 $template->param(
517                 frameworkcode => $frameworkcode,
518                 itemtype => $frameworkcode # HINT: if the library has itemtype = framework, itemtype is auto filled !
519                 );
520 output_html_with_http_headers $input, $cookie, $template->output;