Optimize "Customer has a referring customer" condition, RT#74452
[freeside.git] / httemplate / elements / tr-input-beginning_ending.html
1 % unless ( $m->count == $previous_request_count ) {
2   <LINK REL="stylesheet" TYPE="text/css" HREF="<%$fsurl%>elements/calendar-win2k-2.css" TITLE="win2k-2">
3   <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar_stripped.js"></SCRIPT>
4   <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-en.js"></SCRIPT>
5   <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/calendar-setup.js"></SCRIPT>
6 % }
7
8 <TR>
9   <TD ALIGN="right">From date: </TD>
10   <TD><INPUT TYPE="text" NAME="<% $opt{prefix} %>beginning" ID="<% $opt{prefix} %>beginning_text" VALUE="<% $from ? time2str($date_format, $from) : '' %>" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="<%$fsurl%>images/calendar.png" ID="<% $opt{prefix} %>beginning_button" STYLE="cursor: pointer" TITLE="Select date"><IMG SRC="<%$fsurl%>images/calendar-disabled.png" ID="<% $opt{prefix} %>beginning_disabled" STYLE="display:none"><BR><i>m/d/y<% $time_hint %></i></TD>
11 <SCRIPT TYPE="text/javascript">
12   Calendar.setup({
13     inputField: "<% $opt{prefix} %>beginning_text",
14     ifFormat:   "<% $date_format. $time_format %>",
15     button:     "<% $opt{prefix} %>beginning_button",
16     align:      "BR"
17     <% $input_time %>
18   });
19 </SCRIPT>
20
21 % unless ( $opt{layout} =~ /^h/i ) { #horizontal
22
23 </TR>
24 <TR>
25
26 % }
27
28   <TD ALIGN="right">To date: </TD>
29   <TD><INPUT TYPE="text" NAME="<% $opt{prefix} %>ending" ID="<% $opt{prefix} %>ending_text" VALUE="<% $to ? time2str($date_format, $to) : '' %>" SIZE=<%$size%> MAXLENGTH=<%$maxlength%>> <IMG SRC="<%$fsurl%>images/calendar.png" ID="<% $opt{prefix} %>ending_button" STYLE="cursor: pointer" TITLE="Select date"><IMG SRC="<%$fsurl%>images/calendar-disabled.png" ID="<% $opt{prefix} %>ending_disabled" STYLE="display:none"><BR><i>m/d/y<% $time_hint %></i></TD>
30 <SCRIPT TYPE="text/javascript">
31   Calendar.setup({
32     inputField: "<% $opt{prefix} %>ending_text",
33     ifFormat:   "<% $date_format. $time_format %>",
34     button:     "<% $opt{prefix} %>ending_button",
35     align:      "BR"
36     <% $input_time %>
37   });
38 </SCRIPT>
39 </TR>
40
41 % unless ( $datesrequired ) {
42 <TR>
43   <TD></TD>
44   <TD COLSPAN=<% $opt{layout} =~ /^h/i ? 3 : 1 %>>
45     <FONT SIZE="-1">(leave one or both dates blank for an open-ended search)</FONT>
46   </TD>
47 </TR>
48 % }
49
50 <%once>
51
52 my $previous_request_count = '';
53
54 </%once>
55 <%init>
56
57 my %opt = @_;
58
59 my $conf = new FS::Conf;
60
61 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
62 my $datesrequired = 0;
63 $datesrequired = $opt{'datesrequired'} if $opt{'datesrequired'};
64
65 my $from = '';
66 $from = $opt{'from'} if $opt{'from'};
67 my $to = '';
68 $to = $opt{'to'} if $opt{'to'};
69
70 $opt{prefix} = '' unless defined $opt{prefix};
71 $opt{prefix} .= '_' if $opt{prefix};
72
73 my( $input_time, $time_format, $time_hint ) = ( '', '', '' );
74 my( $size, $maxlength ) = ( 11, 10 );
75 if ( $opt{'input_time'} ) {
76   $input_time  = ', showsTime: true, timeFormat: "12"'; # http://www.dynarch.com/demos/jscalendar/doc/html/reference.html#node_sec_2.3
77   $time_format = ' %H:%M:%S'; # http://www.dynarch.com/demos/jscalendar/doc/html/reference.html#node_sec_5.3.5
78   $time_hint   = ' h:m:s';
79   $size = 21;
80   $maxlength = 27;
81 }
82
83 </%init>
84 <%cleanup>
85
86 $previous_request_count = $m->count;
87
88 </%cleanup>