FFZG #390 - sigurature zs -- perl replacement for function, encoding
[koha.git] / cataloguing / value_builder / ffzg-signatura-zatvoreno-spremiste.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use C4::Auth;
5 use CGI;
6 use C4::Context;
7
8 use C4::Search;
9 use C4::Output;
10 use utf8;
11
12 =head1 NAME
13
14 plugin ffzg-signatura-zatvoreno-spremiste
15
16 =head1 SYNOPSIS
17
18 generate signatura
19
20 =head1 DESCRIPTION
21
22 =head1 FUNCTIONS
23
24 =over 2
25
26 =cut
27
28 sub plugin_parameters {
29 my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
30 return "";
31 }
32
33 sub plugin_javascript {
34         my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
35         my $function_name= $field_number;
36         my $res="
37 <script type=\"text/javascript\">
38 //<![CDATA[
39
40 function Focus$function_name(subfield_managed) {
41
42 /*
43         if ( document.getElementById(\"$field_number\").value ) {
44         }
45         else {
46                 document.getElementById(\"$field_number\").value='default value for onclick';
47         }
48 */
49     return 1;
50 }
51
52 function Blur$function_name(subfield_managed) {
53         return 1;
54 }
55
56 function Clic$function_name(i) {
57         defaultvalue=document.getElementById(\"$field_number\").value;
58         newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=ffzg-signatura-zatvoreno-spremiste.pl&index=$field_number&result=\"+defaultvalue,\"Odabir signature u zatvorenom spremištu\",'width=800,height=600,toolbar=false,scrollbars=yes');
59
60 }
61 //]]>
62 </script>
63 ";
64
65         return ($function_name,$res);
66 }
67
68
69 my $signature = [
70         "knjige (formalno signiranje)" => [
71                 [ "PA 100001-999999", "do 18 cm" ],
72                 [ "PB 100001-999999", "18,1-25 cm" ],
73                 [ "PC 100001-999999", "25,1-35 cm" ],
74                 [ "PD 100001-999999", "iznad 35 cm" ],
75                 [ "PE 100001-999999", "poprečni format" ],
76         ],
77         "posebne zbirke" => [
78                 [ "DD 100001-999999", "Doktorske disertacije" ],
79                 [ "MR 100001-999999", "Magistarski i specijalistički radovi" ],
80                 [ "DR 100001-999999", "Diplomski i završni radovi" ],
81                 [ "FO 100001-999999", "Fotokopije" ],
82                 [ "SE 100001-999999", "Separati" ],
83         ],
84 ];
85
86
87 sub plugin {
88         my ($input) = @_;
89         my $index= $input->param('index');
90         my $index2= $input->param('index2');
91         $index2=-1 unless($index2);
92         my $result= $input->param('result');
93
94
95         my @optgroup;
96
97         while( my $optgroup = shift @$signature ) {
98
99                 my $g = { label => $optgroup };
100
101                 my $o = shift @$signature;
102                 foreach my $option ( @$o ) {
103
104                         my ( $template, $display ) = @$option;
105                         push @{ $g->{option} }, { display => $display, value => $template };
106                 }
107                 push @optgroup, $g;
108         }
109
110         my ($template, $loggedinuser, $cookie)
111         = get_template_and_user({template_name => "cataloguing/value_builder/ffzg-signatura-zatvoreno-spremiste.tt",
112                                         query => $input,
113                                         type => "intranet",
114                                         authnotrequired => 0,
115                                         flagsrequired => {editcatalogue => 1},
116                                         debug => 1,
117                                         });
118         $template->param(
119                 index => $index,
120                 index2 => $index2,
121                 "f1_$result" => "f1_".$result,
122                 optgroup => [ @optgroup ],
123         );
124         output_html_with_http_headers $input, $cookie, $template->output;
125 }
126
127 1;