Merge remote-tracking branch 'kc/new/enh/bug_6871' into kcmaster
[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
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22 #use strict;
23 #use warnings; FIXME - Bug 2505
24
25 =head1
26
27 plugin_parameters : useless here
28
29 =cut
30
31 sub plugin_parameters {
32         # my ($dbh,$record,$tagslib,$i,$tabloop) = @_;
33         return "";
34 }
35
36 =head1
37
38 plugin_javascript : the javascript function called when the user enters the subfield.
39 contain 3 javascript functions :
40 * one called when the   field  is entered (OnFocus) named FocusXXX
41 * one called when the   field  is  left   (onBlur ) named BlurXXX
42 * one called when the ... link is clicked (onClick) named ClicXXX
43
44 returns :
45 * XXX
46 * a variable containing the 3 scripts.
47 the 3 scripts are inserted after the <input> in the html code
48
49 =cut
50
51 sub plugin_javascript {
52         # my ($dbh,$record,$tagslib,$field_number,$tabloop) = @_;
53         my $function_name = "dateaccessioned".(int(rand(100000))+1);
54
55     require C4::Dates;
56         my $date = C4::Dates->today('iso');
57
58         # find the tag/subfield mapped to items.dateaccessioned
59         my ($tag,$subfield) =  GetMarcFromKohaField("items.dateaccessioned","");
60         my $res  = <<END_OF_JS;
61 <script type="text/javascript">
62 //<![CDATA[
63 //  
64 // from: cataloguing/value_builder/dateaccessioned.pl
65
66 function Blur$function_name(index) {
67     //date validation could go here
68 }
69
70 function Focus$function_name(subfield_managed, id, force) {
71     //var summary = "";
72     //for (i=0 ; i<document.f.field_value.length ; i++) {
73     //  summary += i + ": " + document.f.tag[i].value + " " + document.f.subfield[i].value + ": " + document.f.field_value[i].value + "\\n"; 
74     //}
75     //alert("Got focus, subfieldmanaged: " + subfield_managed + "\\n" + summary);
76     set_to_today(id); // defined in additem.pl HEAD
77     return 0;
78 }
79
80 function Clic$function_name(id) {
81     set_to_today(id, 1); // defined in additem.pl HEAD
82     return 0;
83 }
84 //]]>
85 </script>
86 END_OF_JS
87         return ($function_name, $res);
88 }
89
90 =head1
91
92 plugin: useless here.
93
94 =cut
95
96 sub plugin {
97 #    my ($input) = @_;
98     return "";
99 }
100
101 1;