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

(-)a/cataloguing/value_builder/barcode.pl (-19 / +17 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
3
# Converted to new plugin style (Bug 13437)
4
2
# Copyright 2000-2002 Katipo Communications
5
# Copyright 2000-2002 Katipo Communications
3
# Parts copyright 2008-2010 Foundations Bible College
6
# Parts copyright 2008-2010 Foundations Bible College
4
#
7
#
Lines 17-37 Link Here
17
# You should have received a copy of the GNU General Public License
20
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
22
20
use strict;
23
use Modern::Perl;
21
use warnings;
22
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
23
24
24
use C4::Context;
25
use C4::Context;
25
require C4::Barcodes::ValueBuilder;
26
use C4::Barcodes::ValueBuilder;
26
use Koha::DateUtils;
27
use Koha::DateUtils;
27
28
28
use Algorithm::CheckDigits;
29
use Algorithm::CheckDigits;
29
30
30
my $DEBUG = 0;
31
my $DEBUG = 0;
31
32
32
sub plugin_javascript {
33
my $builder = sub {
33
	my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
34
    my ( $params ) = @_;
34
	my $function_name= "barcode".(int(rand(100000))+1);
35
    my $function_name = $params->{id};
35
    my %args;
36
    my %args;
36
37
37
	# find today's date
38
	# find today's date
Lines 45-57 sub plugin_javascript { Link Here
45
    warn "Barcode type = $autoBarcodeType" if $DEBUG;
46
    warn "Barcode type = $autoBarcodeType" if $DEBUG;
46
	if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') {
47
	if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') {
47
        # don't return a value unless we have the appropriate syspref set
48
        # don't return a value unless we have the appropriate syspref set
48
		return ($function_name, 
49
        return q|<script type=\"text/javascript\"></script>|;
49
        "<script type=\"text/javascript\">
50
        // autoBarcodeType OFF (or not defined)
51
        function Focus$function_name() { return 0;}
52
        function  Clic$function_name() { return 0;}
53
        function  Blur$function_name() { return 0;}
54
        </script>");
55
    }
50
    }
56
	if ($autoBarcodeType eq 'annual') {
51
	if ($autoBarcodeType eq 'annual') {
57
        ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
52
        ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
Lines 65-70 sub plugin_javascript { Link Here
65
    elsif ($autoBarcodeType eq 'EAN13') {
60
    elsif ($autoBarcodeType eq 'EAN13') {
66
        # not the best, two catalogers could add the same barcode easily this way :/
61
        # not the best, two catalogers could add the same barcode easily this way :/
67
        my $query = "select max(abs(barcode)) from items";
62
        my $query = "select max(abs(barcode)) from items";
63
    my $dbh = $params->{dbh};
68
        my $sth = $dbh->prepare($query);
64
        my $sth = $dbh->prepare($query);
69
        $sth->execute();
65
        $sth->execute();
70
        while (my ($last)= $sth->fetchrow_array) {
66
        while (my ($last)= $sth->fetchrow_array) {
Lines 88-94 sub plugin_javascript { Link Here
88
    $scr or $scr = <<END_OF_JS;
84
    $scr or $scr = <<END_OF_JS;
89
if (\$('#' + id).val() == '' || force) {
85
if (\$('#' + id).val() == '' || force) {
90
    \$('#' + id).val('$nextnum');
86
    \$('#' + id).val('$nextnum');
91
}
87
};
92
END_OF_JS
88
END_OF_JS
93
89
94
    my $js  = <<END_OF_JS;
90
    my $js  = <<END_OF_JS;
Lines 100-110 $scr Link Here
100
    return 0;
96
    return 0;
101
}
97
}
102
98
103
function Clic$function_name(id) {
99
function Click$function_name(id) {
104
    return Focus$function_name('not_relavent', id, 1);
100
    return Focus$function_name('not_relevant', id, 1);
105
}
101
}
106
//]]>
102
//]]>
107
</script>
103
</script>
108
END_OF_JS
104
END_OF_JS
109
    return ($function_name, $js);
105
    return $js;
110
}
106
};
107
108
return { builder => $builder };
(-)a/cataloguing/value_builder/barcode_manual.pl (-18 / +16 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
3
# Converted to new plugin style (Bug 13437)
4
2
# Copyright 2000-2002 Katipo Communications
5
# Copyright 2000-2002 Katipo Communications
3
# Parts copyright 2008-2010 Foundations Bible College
6
# Parts copyright 2008-2010 Foundations Bible College
4
#
7
#
Lines 17-37 Link Here
17
# You should have received a copy of the GNU General Public License
20
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
21
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
22
20
use strict;
23
use Modern::Perl;
21
use warnings;
22
no warnings 'redefine'; # otherwise loading up multiple plugins fills the log with subroutine redefine warnings
23
24
24
use C4::Context;
25
use C4::Context;
25
require C4::Barcodes::ValueBuilder;
26
use C4::Barcodes::ValueBuilder;
26
use Koha::DateUtils;
27
use Koha::DateUtils;
27
28
28
my $DEBUG = 0;
29
my $DEBUG = 0;
29
30
30
sub plugin_javascript {
31
my $builder = sub {
31
    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
32
    my ( $params ) = @_;
32
    my $function_name= "barcode".(int(rand(100000))+1);
33
    my $function_name = $params->{id};
33
    my %args;
34
    my %args;
34
35
36
    my $dbh = $params->{dbh};
35
    $args{dbh} = $dbh;
37
    $args{dbh} = $dbh;
36
38
37
# find today's date
39
# find today's date
Lines 45-57 sub plugin_javascript { Link Here
45
    warn "Barcode type = $autoBarcodeType" if $DEBUG;
47
    warn "Barcode type = $autoBarcodeType" if $DEBUG;
46
    if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') {
48
    if ((not $autoBarcodeType) or $autoBarcodeType eq 'OFF') {
47
# don't return a value unless we have the appropriate syspref set
49
# don't return a value unless we have the appropriate syspref set
48
        return ($function_name,
50
        return q|<script type=\"text/javascript\"></script>|;
49
                "<script type=\"text/javascript\">
50
                // autoBarcodeType OFF (or not defined)
51
                function Focus$function_name() { return 0;}
52
                function  Clic$function_name() { return 0;}
53
                function  Blur$function_name() { return 0;}
54
                </script>");
55
    }
51
    }
56
    if ($autoBarcodeType eq 'annual') {
52
    if ($autoBarcodeType eq 'annual') {
57
        ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
53
        ($nextnum, $scr) = C4::Barcodes::ValueBuilder::annual::get_barcode(\%args);
Lines 70-85 sub plugin_javascript { Link Here
70
    }
66
    }
71
END_OF_JS
67
END_OF_JS
72
68
73
        my $js  = <<END_OF_JS;
69
    my $js  = <<END_OF_JS;
74
    <script type="text/javascript">
70
    <script type="text/javascript">
75
        //<![CDATA[
71
        //<![CDATA[
76
72
77
    function Clic$function_name(id) {
73
    function Click$function_name(id) {
78
        $scr
74
        $scr
79
            return 0;
75
            return 0;
80
    }
76
    }
81
    //]]>
77
    //]]>
82
    </script>
78
    </script>
83
END_OF_JS
79
END_OF_JS
84
        return ($function_name, $js);
80
    return $js;
85
}
81
};
82
83
return { builder => $builder };
(-)a/cataloguing/value_builder/callnumber-KU.pl (-14 / +18 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Converted to new plugin style (Bug 13437)
4
3
# Copyright 2012 CatalystIT Ltd
5
# Copyright 2012 CatalystIT Ltd
4
#
6
#
5
# This file is part of Koha.
7
# This file is part of Koha.
Lines 17-26 Link Here
17
# You should have received a copy of the GNU General Public License
19
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
21
20
use strict;
22
use Modern::Perl;
21
use warnings;
22
use C4::Auth;
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
25
use C4::Auth;
24
use C4::Context;
26
use C4::Context;
25
use C4::Output;
27
use C4::Output;
26
28
Lines 40-51 CCC QW - returns first unused number CCC QWxx starting with CCC QW01 Link Here
40
42
41
=cut
43
=cut
42
44
43
sub plugin_javascript {
45
my $builder = sub {
44
    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
46
    my ( $params ) = @_;
45
    my $res="
47
    my $res="
46
    <script type='text/javascript'>
48
    <script type='text/javascript'>
47
        function Clic$field_number() {
49
        function Click$params->{id}() {
48
                var code = document.getElementById('$field_number');
50
                var code = document.getElementById('$params->{id}');
49
                var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber-KU.pl&code=' + code.value;
51
                var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber-KU.pl&code=' + code.value;
50
                var req = \$.get(url);
52
                var req = \$.get(url);
51
                req.done(function(resp){
53
                req.done(function(resp){
Lines 56-68 sub plugin_javascript { Link Here
56
        }
58
        }
57
    </script>
59
    </script>
58
    ";
60
    ";
61
    return $res;
62
};
59
63
60
    return ($field_number,$res);
64
my $launcher = sub {
61
}
65
    my ( $params ) = @_;
62
66
    my $input = $params->{cgi};
63
my $BASE_CALLNUMBER_RE = qr/^(\w+) (\w+)$/;
64
sub plugin {
65
    my ($input) = @_;
66
    my $code = $input->param('code');
67
    my $code = $input->param('code');
67
68
68
    my ($template, $loggedinuser, $cookie) = get_template_and_user({
69
    my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 74-79 sub plugin { Link Here
74
        debug           => 1,
75
        debug           => 1,
75
    });
76
    });
76
77
78
    my $BASE_CALLNUMBER_RE = qr/^(\w+) (\w+)$/;
77
    my $ret;
79
    my $ret;
78
    my ($alpha, $num) = ($code =~ $BASE_CALLNUMBER_RE);
80
    my ($alpha, $num) = ($code =~ $BASE_CALLNUMBER_RE);
79
    if (defined $num) { # otherwise no point
81
    if (defined $num) { # otherwise no point
Lines 117-120 sub plugin { Link Here
117
        return => $ret || $code
119
        return => $ret || $code
118
    );
120
    );
119
    output_html_with_http_headers $input, $cookie, $template->output;
121
    output_html_with_http_headers $input, $cookie, $template->output;
120
}
122
};
123
124
return { builder => $builder, launcher => $launcher };
(-)a/cataloguing/value_builder/callnumber.pl (-14 / +18 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Converted to new plugin style (Bug 13437)
4
3
# Copyright 2010 BibLibre SARL
5
# Copyright 2010 BibLibre SARL
4
#
6
#
5
# This file is part of Koha.
7
# This file is part of Koha.
Lines 17-26 Link Here
17
# You should have received a copy of the GNU General Public License
19
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
21
20
use strict;
22
use Modern::Perl;
21
use warnings;
22
use C4::Auth;
23
use CGI qw ( -utf8 );
23
use CGI qw ( -utf8 );
24
25
use C4::Auth;
24
use C4::Context;
26
use C4::Context;
25
use C4::Output;
27
use C4::Output;
26
28
Lines 37-48 In this case, a callnumber has this form : "PREFIX 0009678570". Link Here
37
39
38
=cut
40
=cut
39
41
40
sub plugin_javascript {
42
my $builder = sub {
41
    my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
43
    my ( $params ) = @_;
42
    my $res="
44
    my $res="
43
    <script type='text/javascript'>
45
    <script type='text/javascript'>
44
        function Blur$field_number() {
46
        function Blur$params->{id}() {
45
                var code = document.getElementById('$field_number');
47
                var code = document.getElementById('$params->{id}');
46
                var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber.pl&code=' + code.value;
48
                var url = '../cataloguing/plugin_launcher.pl?plugin_name=callnumber.pl&code=' + code.value;
47
                var req = \$.get(url);
49
                var req = \$.get(url);
48
                req.done(function(resp){
50
                req.done(function(resp){
Lines 54-65 sub plugin_javascript { Link Here
54
56
55
    </script>
57
    </script>
56
    ";
58
    ";
59
    return $res;
60
};
57
61
58
    return ($field_number,$res);
62
my $launcher = sub {
59
}
63
    my ( $params ) = @_;
60
64
    my $input = $params->{cgi};
61
sub plugin {
62
    my ($input) = @_;
63
    my $code = $input->param('code');
65
    my $code = $input->param('code');
64
66
65
    my ($template, $loggedinuser, $cookie) = get_template_and_user({
67
    my ($template, $loggedinuser, $cookie) = get_template_and_user({
Lines 82-88 sub plugin { Link Here
82
                return => $max+1,
84
                return => $max+1,
83
            );
85
            );
84
        }
86
        }
85
    # If a prefix is submited, we look for the highest itemcallnumber with this prefix, and return it incremented
87
    # If a prefix is submitted, we look for the highest itemcallnumber with this prefix, and return it incremented
86
    } elsif ( $code =~ m/^[A-Z.\-']+$/ ) {
88
    } elsif ( $code =~ m/^[A-Z.\-']+$/ ) {
87
        my $sth = $dbh->prepare("SELECT MAX(CAST(SUBSTRING_INDEX(itemcallnumber,' ',-1) AS SIGNED)) FROM items WHERE itemcallnumber LIKE ?");
89
        my $sth = $dbh->prepare("SELECT MAX(CAST(SUBSTRING_INDEX(itemcallnumber,' ',-1) AS SIGNED)) FROM items WHERE itemcallnumber LIKE ?");
88
        $sth->execute($code.' %');
90
        $sth->execute($code.' %');
Lines 104-107 sub plugin { Link Here
104
        );
106
        );
105
    }
107
    }
106
    output_html_with_http_headers $input, $cookie, $template->output;
108
    output_html_with_http_headers $input, $cookie, $template->output;
107
}
109
};
110
111
return { builder => $builder, launcher => $launcher };
(-)a/cataloguing/value_builder/cn_browser.pl (-16 / +34 lines)
Lines 1-34 Link Here
1
use Modern::Perl;
1
#!/usr/bin/perl
2
no warnings 'redefine';
2
3
# Converted to new plugin style (Bug 13437)
4
5
# Copyright 2015 Koha Development Team
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 3 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
19
# with Koha; if not, write to the Free Software Foundation, Inc.,
20
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
3
21
22
use Modern::Perl;
4
use CGI;
23
use CGI;
24
5
use C4::Auth;
25
use C4::Auth;
6
use C4::ClassSource;
26
use C4::ClassSource;
7
use C4::Output;
27
use C4::Output;
8
28
9
sub plugin_javascript {
29
my $builder = sub {
10
    my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
30
    my ( $params ) = @_;
11
    my $function_name = "328" . ( int( rand(100000) ) + 1 );
31
    my $function_name = $params->{id};
12
    my $res = "
32
    my $res = "
13
<script type=\"text/javascript\">
33
<script type=\"text/javascript\">
14
//<![CDATA[
34
//<![CDATA[
15
35
16
function Clic$function_name(i) {
36
function Click$function_name(i) {
17
    q = document.getElementById('$field_number');
37
    q = document.getElementById('$params->{id}');
18
    window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q=\"+q.value,\"cnbrowser\",\"width=500,height=400,toolbar=false,scrollbars=yes\");
38
    window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=cn_browser.pl&popup&q=\"+q.value,\"cnbrowser\",\"width=500,height=400,toolbar=false,scrollbars=yes\");
19
}
39
}
20
40
21
//]]>
41
//]]>
22
</script>
42
</script>
23
";
43
";
44
    return $res;
45
};
24
46
25
    return ( $function_name, $res );
47
my $launcher = sub {
26
}
48
    my ( $params ) = @_;
27
49
    my $cgi = $params->{cgi};
28
sub plugin {
29
    my ($input)          = @_;
30
    my $cgi              = new CGI;
31
    my $params           = $cgi->Vars;
32
    my $results_per_page = 30;
50
    my $results_per_page = 30;
33
    my $current_page = $cgi->param('page') || 1;
51
    my $current_page = $cgi->param('page') || 1;
34
52
Lines 143-148 sub plugin { Link Here
143
    $template->param( 'popup'   => defined( $cgi->param('popup') ) );
161
    $template->param( 'popup'   => defined( $cgi->param('popup') ) );
144
162
145
    output_html_with_http_headers $cgi, $cookie, $template->output;
163
    output_html_with_http_headers $cgi, $cookie, $template->output;
146
}
164
};
147
165
148
1;
166
return { builder => $builder, launcher => $launcher };
(-)a/cataloguing/value_builder/dateaccessioned.pl (-20 / +17 lines)
Lines 1-5 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Converted to new plugin style (Bug 13437)
4
3
# Copyright 2000-2002 Katipo Communications
5
# Copyright 2000-2002 Katipo Communications
4
#
6
#
5
# This file is part of Koha.
7
# This file is part of Koha.
Lines 18-29 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
21
20
use Modern::Perl;
22
use Modern::Perl;
23
use C4::Biblio qw/GetMarcFromKohaField/;
21
use Koha::DateUtils;
24
use Koha::DateUtils;
22
no warnings 'redefine';
23
25
24
sub plugin_javascript {
26
my $builder = sub {
25
	# my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
27
    my ( $params ) = @_;
26
	my $function_name = "dateaccessioned".(int(rand(100000))+1);
28
    my $function_name = $params->{id};
27
29
28
    my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
30
    my $date = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
29
31
Lines 35-63 sub plugin_javascript { Link Here
35
//  
37
//  
36
// from: cataloguing/value_builder/dateaccessioned.pl
38
// from: cataloguing/value_builder/dateaccessioned.pl
37
39
38
function Focus$function_name(subfield_managed, id, force) {
40
function Focus$function_name(event) {
39
    //var summary = "";
41
    set_to_today(event.data.id);
40
    //for (i=0 ; i<document.f.field_value.length ; i++) {
41
    //  summary += i + ": " + document.f.tag[i].value + " " + document.f.subfield[i].value + ": " + document.f.field_value[i].value + "\\n"; 
42
    //}
43
    //alert("Got focus, subfieldmanaged: " + subfield_managed + "\\n" + summary);
44
    set_to_today(id);
45
    return 0;
46
}
42
}
47
43
48
function Clic$function_name(id) {
44
function Click$function_name(event) {
49
    set_to_today(id, 1);
45
    set_to_today(event.data.id);
50
    return 0;
46
    return false; // prevent page scroll
51
}
47
}
52
48
53
function set_to_today(id, force) {
49
function set_to_today( id ) {
54
    if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
50
    if (! id) { alert(_("Bad id ") + id + _(" sent to set_to_today()")); return 0; }
55
    if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' || force) {
51
    if (\$("#" + id).val() == '' || \$("#" + id).val() == '0000-00-00' ) {
56
        \$("#" + id).val("$date");
52
        \$("#" + id).val("$date");
57
    }
53
    }
58
}
54
}
59
//]]>
55
//]]>
60
</script>
56
</script>
61
END_OF_JS
57
END_OF_JS
62
	return ($function_name, $res);
58
    return $res;
63
}
59
};
60
61
return { builder => $builder };
64
- 

Return to bug 16203