View | Details | Raw Unified | Return to bug 8334
Collapse All | Expand All

(-)a/cataloguing/value_builder/unimarc_field_100_authorities.pl (+128 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright (C) 2013 Vitor Fernandes
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use C4::Auth;
22
use CGI;
23
use C4::Context;
24
use C4::Output;
25
26
27
=head1 FUNCTIONS
28
29
=head2 plugin_parameters
30
31
Other parameters added when the plugin is called by the dopop function
32
33
=cut
34
35
sub plugin_parameters {
36
    my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
37
    return "";
38
}
39
40
sub plugin_javascript {
41
    my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
42
    my $res           = "
43
        <script type='text/javascript'>
44
            function Focus$field_number() {
45
                return 1;
46
            }
47
48
            function Blur$field_number() {
49
                return 1;
50
            }
51
52
            function Clic$field_number(i) {
53
                var defaultvalue;
54
                try {
55
                    defaultvalue = document.getElementById(i).value;
56
                } catch(e) {
57
                    alert('error when getting '+i);
58
                    return;
59
                }
60
                window.open(\"/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_100_authorities.pl&index=\"+i+\"&result=\"+defaultvalue,\"unimarc_field_100\",'width=1000,height=600,toolbar=false,scrollbars=yes');
61
            }
62
        </script>
63
";
64
65
    return ( $field_number, $res );
66
}
67
68
sub wrapper {
69
    my ($char) = @_;
70
    return "space" if $char eq " ";
71
    return "dblspace" if $char eq "  ";
72
    return "pipe" if $char eq "|";
73
    return $char;
74
}
75
76
sub plugin {
77
    my ($input) = @_;
78
    my $index  = $input->param('index');
79
    my $result = $input->param('result');
80
81
    my $dbh = C4::Context->dbh;
82
83
    my $defaultlanguage = C4::Context->preference("UNIMARCField100Language");
84
    $defaultlanguage = "fre" if (!$defaultlanguage || length($defaultlanguage) != 3);
85
86
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
87
        {
88
            template_name => "cataloguing/value_builder/unimarc_field_100_authorities.tmpl",
89
            query         => $input,
90
            type          => "intranet",
91
            authnotrequired => 0,
92
            flagsrequired   => { editcatalogue => '*' },
93
            debug           => 1,
94
        }
95
    );
96
    $result = "        a".$defaultlanguage."y50      ba0" unless $result;
97
    my $f1 = substr( $result, 0, 8 );
98
    if ( $f1 eq '        ' ) {
99
        my @today = Date::Calc::Today();
100
        $f1 = $today[0] . sprintf('%02s',$today[1]) . sprintf('%02s',$today[2]);
101
    }
102
103
    my $f2  = substr( $result, 8,  1 ); $f2  = wrapper( $f2 ) if $f2;
104
    my $f3  = substr( $result, 9,  3 );
105
    my $f4  = substr( $result, 12, 1 ); $f4  = wrapper( $f4 ) if $f4;
106
    my $f5  = substr( $result, 13, 2 ); $f5  = wrapper( $f5 ) if $f5;
107
    my $f6  = substr( $result, 15, 2 ); $f6  = wrapper( $f6 ) if $f6;
108
    my $f7  = substr( $result, 17, 4 ); $f7  = wrapper( $f7 ) if $f7;
109
    my $f8  = substr( $result, 21, 2 ); $f8  = wrapper( $f8 ) if $f8;
110
    my $f9  = substr( $result, 23, 1 ); $f9  = wrapper( $f9 ) if $f9;
111
112
    $template->param(
113
        index     => $index,
114
        f1        => $f1,
115
        "f2$f2"   => 1,
116
        f3        => $f3,
117
        "f4$f4"   => 1,
118
        "f5$f5"   => 1,
119
        "f6$f6"   => 1,
120
        f7        => $f7,
121
        "f8$f8"   => 1,
122
        "f9$f9"   => 1,
123
    );
124
    output_html_with_http_headers $input, $cookie, $template->output;
125
}
126
127
1;
128
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_100_authorities.tt (-1 / +412 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>UNIMARC field 100 builder</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
<body id="cat_unimarc_field_100" class="cat" style="padding:1em;">
6
<h3>UNIMARC field 100 builder</h3>
7
<form name="f_pop" action="">
8
<table>
9
    <tr>
10
        <td><label for="f1">Date entered on file</label></td>
11
        <td><input type="text" name="f1" id="f1" maxlength="8" size="9" value="[% f1 %]" /></td>
12
    </tr>
13
    <tr>
14
        <td><label for="f2">States of authority heading code</label></td>
15
        <td>
16
            <select name="f2" id="f2" size="1">
17
            [% IF ( f2a ) %]
18
                <option value="a" selected="selected">a - established</option>
19
            [% ELSE %]
20
                <option value="a">a - established</option>
21
            [% END %]
22
            [% IF ( f2c ) %]
23
                <option value="c" selected="selected">c - provisional</option>
24
            [% ELSE %]
25
                <option value="c">c - provisional</option>
26
            [% END %]
27
            [% IF ( f2x ) %]
28
                <option value="x" selected="selected">x - not applicable</option>
29
            [% ELSE %]
30
                <option value="x">x - not applicable</option>
31
            [% END %]
32
            </select>
33
        </td>
34
    </tr>
35
36
    <tr>
37
    <td><label for="f3">Language of cataloguing (mandatory)</label></td>
38
    <td><input type="text" name="f3" id="f3" maxlength="3" size="4" value="[% f3 %]" /></td>
39
    </tr>
40
41
    <tr>
42
        <td><label for="f4">Transliteration code</label></td>
43
        <td>
44
            <select name="f4" id="f4" size="1">
45
46
            [% IF ( f4a ) %]
47
                <option value="a" selected="selected">a- ISO transliteration scheme</option>
48
            [% ELSE %]
49
                <option value="a">a- ISO transliteration scheme</option>
50
            [% END %]
51
            [% IF ( f4b ) %]
52
                <option value="b" selected="selected">b- other</option>
53
            [% ELSE %]
54
                <option value="b">b- other</option>
55
            [% END %]
56
            [% IF ( f4c ) %]
57
                <option value="c"
58
 selected="selected">c- multiple transliterations: ISO or other schemes</option>
59
            [% ELSE %]
60
                <option value="c">c- multiple transliterations: ISO or other schemes</option>
61
            [% END %]
62
            [% IF ( f4y ) %]
63
                <option value="y" selected="selected">y- no transliteration scheme used</option>
64
            [% ELSE %]
65
                <option value="y">y- no transliteration scheme used</option>
66
            [% END %]
67
            </select>
68
        </td>
69
    </tr>
70
    <tr>
71
    <td><label for="f5">Character sets (mandatory) 1</label></td>
72
        <td>
73
            <select name="f5" id="f5" size="1">
74
75
            [% IF ( f501 ) %]
76
                <option value="01" selected="selected">01- ISO 646, IRV version (basic Latin set)</option>
77
            [% ELSE %]
78
                <option value="01">01- ISO 646, IRV version (basic Latin set)</option>
79
            [% END %]
80
            [% IF ( f502 ) %]
81
                <option value="02" selected="selected">02- ISO Registration # 37 (basic Cyrillic set)</option>
82
            [% ELSE %]
83
                <option value="02">02- ISO Registration # 37 (basic Cyrillic set)</option>
84
            [% END %]
85
            [% IF ( f503 ) %]
86
                <option value="03" selected="selected">03- ISO 5426 (extended Latin set)</option>
87
            [% ELSE %]
88
                <option value="03">03- ISO 5426 (extended Latin set)</option>
89
            [% END %]
90
            [% IF ( f504 ) %]
91
                <option value="04" selected="selected">04- ISO 5427 (extended Cyrillic set)</option>
92
            [% ELSE %]
93
                <option value="04">04- ISO 5427 (extended Cyrillic set)</option>
94
            [% END %]
95
            [% IF ( f505 ) %]
96
                <option value="05" selected="selected">05- ISO 5428 (Greek set)</option>
97
            [% ELSE %]
98
                <option value="05">05- ISO 5428 (Greek set)</option>
99
            [% END %]
100
101
            [% IF ( f506 ) %]
102
                <option value="06" selected="selected">06- ISO 6438 (African coded character set)</option>
103
            [% ELSE %]
104
                <option value="06">06- ISO 6438 (African coded character set)</option>
105
            [% END %]
106
107
             [% IF ( f507 ) %]
108
                <option value="07" selected="selected">07- ISO 10586 (Georgian set)</option>
109
            [% ELSE %]
110
                <option value="07">07- ISO 10586 (Georgian set)</option>
111
            [% END %]
112
113
             [% IF ( f508 ) %]
114
                <option value="08" selected="selected">08- ISO 8957 (Hebrew set) Table 1</option>
115
            [% ELSE %]
116
                <option value="08">08- ISO 8957 (Hebrew set) Table 1</option>
117
            [% END %]
118
119
             [% IF ( f509 ) %]
120
                <option value="09" selected="selected">09- ISO 8957 (Hebrew set) Table 2</option>
121
            [% ELSE %]
122
                <option value="09">09- ISO 8957 (Hebrew set) Table 2</option>
123
            [% END %]
124
125
             [% IF ( f511 ) %]
126
                <option value="11" selected="selected">11- ISO 5426-2 (Latin characters used in minor European
127
languages and obsolete typography)
128
</option>
129
            [% ELSE %]
130
                <option value="11">11- ISO 5426-2 (Latin characters used in minor European
131
languages and obsolete typography)
132
</option>
133
            [% END %]
134
135
            [% IF ( f550 ) %]
136
                <option value="50" selected="selected">50- ISO 10646 Level 3 (Unicode, UTF-8)
137
                </option>
138
            [% ELSE %]
139
                <option value="50">50- ISO 10646 Level 3 (Unicode, UTF-8)</option>
140
            [% END %]
141
            </select>
142
        </td>
143
144
    </tr>
145
    <tr>
146
    <td><label for="f6">Character sets (mandatory) 2</label></td>
147
        <td>
148
            <select name="f6" id="f6" size="1">
149
150
            [% IF ( f6dblspace ) %]
151
                    <option value="  " selected="selected">non required value</option>
152
            [% ELSE %]
153
                    <option value="  ">non required value</option>
154
            [% END %]
155
156
            [% IF ( f601 ) %]
157
                <option value="01" selected="selected">01- ISO 646, IRV version (basic Latin set)</option>
158
            [% ELSE %]
159
                <option value="01">01- ISO 646, IRV version (basic Latin set)</option>
160
            [% END %]
161
            [% IF ( f602 ) %]
162
                <option value="02" selected="selected">02- ISO Registration # 37 (basic Cyrillic set)</option>
163
            [% ELSE %]
164
                <option value="02">02- ISO Registration # 37 (basic Cyrillic set)</option>
165
            [% END %]
166
            [% IF ( f603 ) %]
167
                <option value="03"
168
 selected="selected">03- ISO 5426 (extended Latin set)</option>
169
            [% ELSE %]
170
                <option value="03">03- ISO 5426 (extended Latin set)</option>
171
            [% END %]
172
            [% IF ( f604 ) %]
173
                <option value="04" selected="selected">04- ISO 5427 (extended Cyrillic set)</option>
174
            [% ELSE %]
175
                <option value="04">04- ISO 5427 (extended Cyrillic set)</option>
176
            [% END %]
177
            [% IF ( f605 ) %]
178
                <option value="05" selected="selected">05- ISO 5428 (Greek set)</option>
179
            [% ELSE %]
180
                <option value="05">05- ISO 5428 (Greek set)</option>
181
            [% END %]
182
            [% IF ( f606 ) %]
183
                <option value="06" selected="selected">06- ISO 6438 (African coded character set)</option>
184
            [% ELSE %]
185
                <option value="06">06- ISO 6438 (African coded character set)</option>
186
            [% END %]
187
188
            [% IF ( f607 ) %]
189
                <option value="07" selected="selected">07- ISO 10586 (Georgian set)</option>
190
            [% ELSE %]
191
                <option value="07">07- ISO 10586 (Georgian set)</option>
192
            [% END %]
193
194
             [% IF ( f608 ) %]
195
                <option value="08" selected="selected">08- ISO 8957 (Hebrew set) Table 1</option>
196
            [% ELSE %]
197
                <option value="08">08- ISO 8957 (Hebrew set) Table 1</option>
198
            [% END %]
199
200
             [% IF ( f609 ) %]
201
                <option value="09" selected="selected">09- ISO 8957 (Hebrew set) Table 2</option>
202
            [% ELSE %]
203
                <option value="09">09- ISO 8957 (Hebrew set) Table 2</option>
204
            [% END %]
205
206
             [% IF ( f611 ) %]
207
                <option value="11" selected="selected">11- ISO 5426-2 (Latin characters used in minor European
208
languages and obsolete typography)</option>
209
            [% ELSE %]
210
                <option value="11">11- ISO 5426-2 (Latin characters used in minor European
211
languages and obsolete typography)</option>
212
            [% END %]
213
214
            [% IF ( f650 ) %]
215
                <option value="50" selected="selected">50- ISO 10646 Level 3 (Unicode, UTF-8)</option>
216
            [% ELSE %]
217
                <option value="50">ISO 10646 Level 3 (Unicode, UTF-8)</option>
218
            [% END %]
219
            </select>
220
        </td>
221
    </tr>
222
223
    <tr>
224
        <td><label for="f7">Additional character sets</label></td>
225
        <td>
226
            <input type="text" name="f7" id="f7" maxlength="4" size="5" value="[% f7 %]" />
227
        </td>
228
    </tr>
229
230
    <tr>
231
    <td><label for="f8">Script of title</label></td>
232
    <td>
233
    <select name="f8" id="f8" size="1">
234
            [% IF ( f8dblspace ) %]
235
                    <option value="  " selected="selected">Non required value</option>
236
            [% ELSE %]
237
                    <option value="  ">Non required value</option>
238
            [% END %]
239
240
            [% IF ( f8ba ) %]
241
                <option value="ba" selected="selected">ba- Latin</option>
242
            [% ELSE %]
243
                <option value="ba">ba- Latin</option>
244
            [% END %]
245
            [% IF ( f8ca ) %]
246
                <option value="ca" selected="selected">ca- Cyrillic</option>
247
            [% ELSE %]
248
                <option value="ca">ca- Cyrillic</option>
249
            [% END %]
250
251
            [% IF ( f8da ) %]
252
                <option value="da" selected="selected">da- Japanese - script unspecified</option>
253
            [% ELSE %]
254
                <option value="da">da- Japanese - script unspecified</option>
255
            [% END %]
256
257
            [% IF ( f8db ) %]
258
                <option value="db" selected="selected">db- Japanese -
259
                Kanji</option>
260
            [% ELSE %]
261
                <option value="db">db- Japanese - Kanji</option>
262
            [% END %]
263
264
            [% IF ( f8dc ) %]
265
                <option value="dc" selected="selected">dc- Japanese -
266
                Kana</option>
267
            [% ELSE %]
268
                <option value="dc">dc- Japanese - Kana</option>
269
            [% END %]
270
            [% IF ( f8ea ) %]
271
                <option value="ea" selected="selected">ea- Chinese</option>
272
            [% ELSE %]
273
                <option value="ea">ea- Chinese</option>
274
            [% END %]
275
            [% IF ( f8fa ) %]
276
                <option value="fa" selected="selected">fa- Arabic</option>
277
            [% ELSE %]
278
                <option value="fa">fa- Arabic</option>
279
            [% END %]
280
            [% IF ( f8ga ) %]
281
                <option value="ga" selected="selected">ga- Greek</option>
282
            [% ELSE %]
283
                <option value="ga">ga- Greek</option>
284
            [% END %]
285
            [% IF ( f8ha ) %]
286
                <option value="ha" selected="selected">ha- Hebrew</option>
287
            [% ELSE %]
288
                <option value="ha">ha- Hebrew</option>
289
            [% END %]
290
            [% IF ( f8ia ) %]
291
                <option value="ia" selected="selected">ia- Thai</option>
292
            [% ELSE %]
293
                <option value="ia">ia- Thai</option>
294
            [% END %]
295
            [% IF ( f8ja ) %]
296
                <option value="ja" selected="selected">ja- Devanagari</option>
297
            [% ELSE %]
298
                <option value="ja">ja- Devanagari</option>
299
            [% END %]
300
            [% IF ( f8ka ) %]
301
                <option value="ka" selected="selected">ka- Korean</option>
302
            [% ELSE %]
303
                <option value="ka">ka- Korean</option>
304
            [% END %]
305
            [% IF ( f8la ) %]
306
                <option value="la" selected="selected">la- Tamil</option>
307
            [% ELSE %]
308
                <option value="la">la- Tamil</option>
309
            [% END %]
310
            [% IF ( f8zz ) %]
311
                <option value="zz" selected="selected">zz- Other</option>
312
            [% ELSE %]
313
                <option value="zz">zz- Other</option>
314
            [% END %]
315
316
            [% IF ( f8ma ) %]
317
                <option value="ma" selected="selected">ma- Georgian</option>
318
            [% ELSE %]
319
                <option value="ma">ma- Georgian</option>
320
            [% END %]
321
322
            [% IF ( f8mb ) %]
323
                <option value="mb" selected="selected">mb- Armenian</option>
324
            [% ELSE %]
325
                <option value="mb">mb- Armenian</option>
326
            [% END %]
327
            </select>
328
    </td>
329
    </tr>
330
331
    <tr>
332
        <td><label for="f9">Direction of Script Cataloguing</label></td>
333
        <td>
334
            <select name="f9" id="f9" size="1">
335
            [% IF ( f90 ) %]
336
                <option value="0" selected="selected">0 - left to right</option>
337
            [% ELSE %]
338
                <option value="0">0 - left to right</option>
339
            [% END %]
340
            [% IF ( f91 ) %]
341
                <option value="1" selected="selected">1 - right to left</option>
342
            [% ELSE %]
343
                <option value="1">1 - right to left</option>
344
            [% END %]
345
            </select>
346
        </td>
347
    </tr>
348
</table>
349
<p><input type="button" value="OK"  onclick="report();" /> <a href="#" class="cancel close">Cancel</a> </p>
350
</form>
351
<script type="text/javascript">
352
//<![CDATA[
353
//     GetPublicationDate(); // running directly.
354
//
355
//     /**
356
//      *  GetPublicationDate.
357
//      *  This function get the publication date if it's writen on 210d
358
//      */
359
//     function GetPublicationDate() {
360
//         var PublicationDate = null;
361
//
362
//         for (i=0 ; i<NbFields ; i++) {
363
//             if (doc.f.tag[i].value == '210' && doc.f.subfield[i].value == 'd') {
364
//                 if (doc.f.field_value[i].value != ""){
365
//                     PublicationDate = doc.f.field_value[i].value;
366
//                     document.getElementById('pubdate1').value = PublicationDate;
367
//                 }
368
//                 return;
369
//             }
370
//         }
371
//     }
372
//
373
//     /**
374
//      *  SetPublicationDate.
375
//      *  This function set the publication date here
376
//      */
377
//     function SetPublicationDate() {
378
//         var PublicationDate = document.getElementById('pubdate1').value;
379
//         if (PublicationDate == "    " || !PublicationDate){
380
//             return ;
381
//         }
382
//         for (i=0 ; i<NbFields ; i++) {
383
//             if (doc.f.tag[i].value == '210' && doc.f.subfield[i].value == 'd') {
384
//                 doc.f.field_value[i].value = PublicationDate;
385
//                 break;
386
//             }
387
//         }
388
//     }
389
390
    function report() {
391
        var doc   = opener.document;
392
        var field = doc.getElementById("[% index %]");
393
394
        document.f_pop.f1.value=document.f_pop.f1.value+'        ';
395
        document.f_pop.f3.value=document.f_pop.f3.value+'   ';
396
        document.f_pop.f7.value=document.f_pop.f7.value+'    ';
397
398
        document.f_pop.f1.value=document.f_pop.f1.value.substring(0,8);
399
        document.f_pop.f3.value=document.f_pop.f3.value.substring(0,3);
400
        document.f_pop.f7.value=document.f_pop.f7.value.substring(0,4);
401
402
        field.value= document.f_pop.f1.value +
403
        document.f_pop.f2.value +document.f_pop.f3.value
404
        +document.f_pop.f4.value+document.f_pop.f5.value+document.f_pop.f6.value+document.f_pop.f7.value+document.f_pop.f8.value+document.f_pop.f9.value;
405
406
//         SetPublicationDate();
407
        self.close();
408
        return false;
409
    }
410
//]]>
411
</script>
412
[% INCLUDE 'popup-bottom.inc' %]

Return to bug 8334