Bug 2919 -- fix value_builder plugins for dateaccessioned, barcode
[koha.git] / cataloguing / value_builder / dateaccessioned.pl
1 #!/usr/bin/perl
2
3 # $Id: usmarc_field_952v.pl,v 1.1.2.2 2006/09/20 02:59:53 kados Exp $
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 =head1
23
24 plugin_parameters : useless here
25
26 =cut
27 sub plugin_parameters {
28         # my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
29         return "";
30 }
31
32 =head1
33
34 plugin_javascript : the javascript function called when the user enters the subfield.
35 contain 3 javascript functions :
36 * one called when the   field  is entered (OnFocus) named FocusXXX
37 * one called when the   field  is  left   (onBlur ) named BlurXXX
38 * one called when the ... link is clicked (onClick) named ClicXXX
39
40 returns :
41 * XXX
42 * a variable containing the 3 scripts.
43 the 3 scripts are inserted after the <input> in the html code
44
45 =cut
46 sub plugin_javascript {
47         # my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
48         my $function_name = "dateaccessioned".(int(rand(100000))+1);
49
50     require C4::Dates;
51         my $date = C4::Dates->today('iso');
52
53         # find the tag/subfield mapped to items.dateaccessioned
54         my ($tag,$subfield) =  GetMarcFromKohaField("items.dateaccessioned","");
55         my $res  = <<END_OF_JS;
56 <script type="text/javascript">
57 //<![CDATA[
58 //  
59 // from: cataloguing/value_builder/dateaccessioned.pl
60
61 function Blur$function_name(index) {
62     //date validation could go here
63 }
64
65 function Focus$function_name(subfield_managed, id, force) {
66     //var summary = "";
67     //for (i=0 ; i<document.f.field_value.length ; i++) {
68     //  summary += i + ": " + document.f.tag[i].value + " " + document.f.subfield[i].value + ": " + document.f.field_value[i].value + "\\n"; 
69     //}
70     //alert("Got focus, subfieldmanaged: " + subfield_managed + "\\n" + summary);
71     set_to_today(id); // defined in additem.pl HEAD
72     return 0;
73 }
74
75 function Clic$function_name(id) {
76     set_to_today(id, 1); // defined in additem.pl HEAD
77     return 0;
78 }
79 //]]>
80 </script>
81 END_OF_JS
82         return ($function_name, $res);
83 }
84
85 =head1
86
87 plugin: useless here.
88
89 =cut
90
91 sub plugin {
92 #    my ($input) = @_;
93     return "";
94 }
95
96 1;