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

(-)a/cataloguing/value_builder/unimarc_field_325h.pl (+72 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 Rijksmuseum
4
#
5
# This file is part of Koha.
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
21
22
######### ATTENTION c'est le contenu du fichier unimarc_field_181-2.tt %] #############
23
24
use Modern::Perl;
25
26
use Date::Calc;
27
28
use Koha::Util::FrameworkPlugin qw(wrapper);
29
use C4::Auth qw( get_template_and_user );
30
use CGI qw ( -utf8 );
31
use C4::Context;
32
use C4::Output qw( output_html_with_http_headers );
33
34
my $builder= sub {
35
    my $params = shift;
36
    my $id = $params->{id};
37
38
    return qq|
39
<script>
40
41
function Click$id(event) {
42
    var fieldvalue=\$('#'+event.data.id).val();
43
    window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_325h.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
44
    return false; /* prevents scrolling */
45
}
46
</script>|;
47
};
48
49
my $launcher= sub {
50
    my $params = shift;
51
    my $cgi = $params->{cgi};
52
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
53
        template_name => "cataloguing/value_builder/unimarc_field_325h.tt",
54
        query => $cgi,
55
        type => "intranet",
56
        flagsrequired => {editcatalogue => '*'},
57
    });
58
    my $results = scalar $cgi->param('result');
59
    my $input_a = substr $results, 0, 1;
60
61
    $template->param(
62
        index => scalar $cgi->param('index'),
63
        result => $results,
64
        f0 => $input_a,
65
    );
66
    output_html_with_http_headers $cgi, $cookie, $template->output;
67
};
68
69
# Return the hashref with the builder and launcher to FrameworkPlugin object.
70
# NOTE: If you do not need a popup but only use e.g. Focus, Blur etc. for a
71
# particular plugin, you only need to define and return the builder.
72
return { builder => $builder, launcher => $launcher };
(-)a/cataloguing/value_builder/unimarc_field_325j.pl (+78 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2014 Rijksmuseum
4
#
5
# This file is part of Koha.
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
21
22
######### ATTENTION c'est le contenu du fichier unimarc_field_181-2.tt %] #############
23
24
use Modern::Perl;
25
26
use Date::Calc;
27
28
use Koha::Util::FrameworkPlugin qw(wrapper);
29
use C4::Auth qw( get_template_and_user );
30
use CGI qw ( -utf8 );
31
use C4::Context;
32
use C4::Output qw( output_html_with_http_headers );
33
34
my $builder= sub {
35
    my $params = shift;
36
    my $id = $params->{id};
37
38
    return qq|
39
<script>
40
41
function Click$id(event) {
42
    var fieldvalue=\$('#'+event.data.id).val();
43
    window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_325j.pl&index=\"+event.data.id+\"&result=\"+fieldvalue,\"tag_editor\",'width=700,height=700,toolbar=false,scrollbars=yes');
44
    return false; /* prevents scrolling */
45
}
46
</script>|;
47
};
48
49
my $launcher= sub {
50
    my $params = shift;
51
    my $cgi = $params->{cgi};
52
    my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
53
        template_name => "cataloguing/value_builder/unimarc_field_325j.tt",
54
        query => $cgi,
55
        type => "intranet",
56
        flagsrequired => {editcatalogue => '*'},
57
    });
58
    my $results = scalar $cgi->param('result');
59
60
    $template->param(
61
        index => scalar $cgi->param('index'),
62
        result => $results,
63
    );
64
65
   # Return the result of the position in the string, ex: abcde = 1=a, 2=b, 3=c...
66
    my @x = split(//, $results);
67
    my $i = 0;
68
    for my $fresult (@x) {
69
        $template->param("f$i" => $fresult);
70
        ++$i;
71
    }
72
    output_html_with_http_headers $cgi, $cookie, $template->output;
73
};
74
75
# Return the hashref with the builder and launcher to FrameworkPlugin object.
76
# NOTE: If you do not need a popup but only use e.g. Focus, Blur etc. for a
77
# particular plugin, you only need to define and return the builder.
78
return { builder => $builder, launcher => $launcher };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_325h.tt (+53 lines)
Line 0 Link Here
1
[%# ATTENTION c'est le contenu du fichier unimarc_field_181-2.tt %]
2
3
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Framework plugin example &rsaquo; Cataloguing &rsaquo; Koha</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
8
9
<body id="cat_unimarc_field_325h" class="cat" style="padding:1em;">
10
11
<h3>UNIMARC field 325h builder</h3>
12
13
<form name="f_pop" action="">
14
<table>
15
    <tr>
16
        <td><label for="f0">Completeness of the reproduction code :</label></td>
17
        <td>
18
            <select name="f0" id="f0">
19
                [% IF ( f0 == "" ) %]
20
                    <option value=" " selected="selected"># - undetermined</option>
21
                [% ELSE %]
22
                    <option value=" "># - undetermined</option>
23
                [% END %]
24
25
                [% IF ( f0 == "0" ) %]
26
                    <option value="0" selected="selected">0 - reproduction is not complete</option>
27
                [% ELSE %]
28
                    <option value="0">0 - reproduction is not complete</option>
29
                [% END %]
30
31
                [% IF ( f0 == "1" ) %]
32
                    <option value="1" selected="selected">1 - reproduction is complete</option>
33
                [% ELSE %]
34
                    <option value="1">1 - reproduction is complete</option>
35
                [% END %]
36
            </select>
37
        </td>
38
    </tr>
39
</table>
40
<p><input type="button" value="OK"  onclick="submitMyForm();" /> <a href="#" class="cancel close">Cancel</a> </p>
41
</form>
42
43
<script>
44
45
    function submitMyForm() {
46
        var doc   = opener.document;
47
        var field = doc.getElementById("[% index | html %]");
48
49
        field.value = document.f_pop.f0.value;
50
        window.close();
51
        return false;
52
    }
53
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_325j.tt (-1 / +164 lines)
Line 0 Link Here
0
- 
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Framework plugin example &rsaquo; Cataloguing &rsaquo; Koha</title>
3
[% INCLUDE 'doc-head-close.inc' %]
4
</head>
5
6
<body id="cat_unimarc_field_325j" class="cat" style="padding:1em;">
7
8
<h3>UNIMARC field 325j builder</h3>
9
10
<form name="f_pop" action="" id="form">
11
<table>
12
    <tr>
13
        <td><label for="f0">Terms of access to the reproduction :</label></td>
14
        <td>
15
            <select name="f0" id="f0">
16
                [% IF ( f0 == "1" ) %]
17
                    <option value="1" selected="selected">1 - free-to-read</option>
18
                [% ELSE %]
19
                    <option value="1">1 - free-to-read</option>
20
                [% END %]
21
22
                [% IF ( f0 == "2" ) %]
23
                    <option value="2" selected="selected">2 - free-to-read, partly</option>
24
                [% ELSE %]
25
                    <option value="2">2 - free-to-read, partly</option>
26
                [% END %]
27
28
                [% IF ( f0 == "3" ) %]
29
                    <option value="3" selected="selected">3 - free-to-read, after embargo</option>
30
                [% ELSE %]
31
                    <option value="3">3 - free-to-read, after embargo</option>
32
                [% END %]
33
34
                [% IF ( f0 == "4" ) %]
35
                    <option value="4" selected="selected">4 - fully</option>
36
                [% ELSE %]
37
                    <option value="4">4 - fully</option>
38
                [% END %]
39
40
                [% IF ( f0 == "5" ) %]
41
                    <option value="5" selected="selected">5 - free-to-read upon subscription (requires signing up)</option>
42
                [% ELSE %]
43
                    <option value="5">5 - free-to-read upon subscription (requires signing up)</option>
44
                [% END %]
45
            </select>
46
        </td>
47
    </tr>
48
    <tr>
49
        <td><label for="f1">Qualifier type :</label></td>
50
        <td>
51
            <select name="f1" id="f1">
52
                [% IF ( f1 == "l" ) %]
53
                    <option value="l" selected="selected">l - latest</option>
54
                [% ELSE %]
55
                    <option value="l" >l - latest</option>
56
                [% END %]
57
58
                [% IF ( f1 == "p" ) %]
59
                    <option value="p" selected="selected">p - previous</option>
60
                [% ELSE %]
61
                    <option value="p">p - previous</option>
62
                [% END %]
63
64
                [% IF ( f1 == "x" ) %]
65
                    <option value="" selected="selected">x - not applicable</option>
66
                [% ELSE %]
67
                    <option value="">x - not applicable</option>
68
                [% END %]
69
70
                [% IF ( f1 == "#" ) %]
71
                    <option value="#" selected="selected"># - no attempt to code</option>
72
                [% ELSE %]
73
                    <option value="#"># - no attempt to code</option>
74
                [% END %]
75
            </select>
76
        </td>
77
    </tr>
78
    <tr>
79
        <td><label for="f2">Unit under embargo :</label></td>
80
        <td>
81
            <select name="f2" id="f2">
82
                [% IF ( f2 == "m" ) %]
83
                    <option value="m" selected="selected">m - month(s) time</option>
84
                [% ELSE %]
85
                    <option value="m">m - month(s) time</option>
86
                [% END %]
87
88
                [% IF ( f2 == "w" ) %]
89
                    <option value="w" selected="selected">w - week(s) time</option>
90
                [% ELSE %]
91
                    <option value="w">w - week(s) time</option>
92
                [% END %]
93
94
                [% IF ( f2 == "y" ) %]
95
                    <option value="y" selected="selected">y - year(s) time</option>
96
                [% ELSE %]
97
                    <option value="y">y - year(s) time</option>
98
                [% END %]
99
100
                [% IF ( f2 == "i" ) %]
101
                    <option value="i" selected="selected">i - issue(s) part</option>
102
                [% ELSE %]
103
                    <option value="i">i - issue(s) part</option>
104
                [% END %]
105
106
                [% IF ( f2 == "x" ) %]
107
                    <option value="" selected="selected">x - not applicable</option>
108
                [% ELSE %]
109
                    <option value="">x - not applicable</option>
110
                [% END %]
111
112
                [% IF ( f2 == "#" ) %]
113
                    <option value="#" selected="selected"># - no attempt to code</option>
114
                [% ELSE %]
115
                    <option value="#"># - no attempt to code</option>
116
                [% END %]
117
            </select>
118
        </td>
119
    </tr>
120
    <tr>
121
        <td><label for="f3">Number of units under embargo :</label></td>
122
        <td>
123
            <input name="f3" id="f3" inputmode="numeric" pattern="\d{1,2}" value="[% f3 | html %]"></input>
124
        </td>
125
    </tr>
126
</table>
127
<p><input type="submit" value="OK" /> <a href="#" class="cancel close">Cancel</a> </p>
128
</form>
129
130
<script>
131
    $("#form").on('submit', submitMyForm);
132
    $("#f0").on('change', function() {
133
        document.f_pop.f1.disabled = false;
134
        document.f_pop.f2.disabled = false;
135
        document.f_pop.f3.disabled = false;
136
137
        if ( document.f_pop.f0.value != "3" ) {
138
            document.f_pop.f1.value = "x";
139
            document.f_pop.f2.value = "x";
140
            document.f_pop.f1.disabled = true;
141
            document.f_pop.f2.disabled = true;
142
            document.f_pop.f3.disabled = true;
143
        }
144
    });
145
    $("#f0").trigger('change');
146
147
    function submitMyForm(event) {
148
        event.preventDefault();
149
        var doc   = opener.document;
150
        var field = doc.getElementById("[% index | html %]");
151
        if ( document.f_pop.f0.value == "3" ) {
152
            var f3v = document.f_pop.f3.value.padStart(2, '0');
153
            document.f_pop.f3.value = f3v;
154
        }
155
156
        field.value = document.f_pop.f0.value+
157
                      document.f_pop.f1.value+
158
                      document.f_pop.f2.value+
159
                      document.f_pop.f3.value;
160
        window.close();
161
    }
162
</script>
163
164
[% INCLUDE 'popup-bottom.inc' %]

Return to bug 31372