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