Line # Revision Author
1 8 ahitrov@rambler.ru <& '/contenido/components/select.msn', name => $name.'_day', values => \@days, check => $day &>
2 <& '/contenido/components/select.msn', name => $name.'_month', values => \@months, check => $month &>
3 <& '/contenido/components/select.msn', name => $name.'_year', values => \@years, check => $year &>
4 &nbsp;&nbsp;
5 <& '/contenido/components/select.msn', name => $name.'_hour', values => \@hours, check => $hour &>
6 <& '/contenido/components/select.msn', name => $name.'_minute', values => \@minutes, check => $minute &>
7 59 ahitrov@rambler.ru % if ( $prop->{noseconds} ) {
8 <input type="hidden" name="<% $prop->{attr} %>_second" value="0">
9 % } else {
10 8 ahitrov@rambler.ru <& '/contenido/components/select.msn', name => $name.'_second', values => \@seconds, check => $second &>
11 59 ahitrov@rambler.ru % }
12 61 ahitrov@rambler.ru % if ( ref $prop && exists $prop->{attr} ) {
13 59 ahitrov@rambler.ru <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
14 <script type="text/javascript">
15 <!--
16 function set_<% $prop->{attr} %>_now () {
17 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
18 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
19 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
20 document.forms['form'].elements['<% $prop->{attr} %>_hour'].value = '<% $now->hour %>';
21 document.forms['form'].elements['<% $prop->{attr} %>_minute'].value = '<% $now->minute %>';
22 61 ahitrov@rambler.ru % unless ( $prop->{noseconds} ) {
23 59 ahitrov@rambler.ru document.forms['form'].elements['<% $prop->{attr} %>_second'].value = '<% $now->second %>';
24 61 ahitrov@rambler.ru % }
25 59 ahitrov@rambler.ru }
26 //-->
27 </script>
28 323 ahitrov % if ( $prop->{allow_null} ) {
29 &nbsp; <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_clear()" style="color:red;">Очистить!</a></span>
30 <script type="text/javascript">
31 <!--
32 function set_<% $prop->{attr} %>_clear () {
33 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '';
34 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '';
35 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '';
36 document.forms['form'].elements['<% $prop->{attr} %>_hour'].value = '';
37 document.forms['form'].elements['<% $prop->{attr} %>_minute'].value = '';
38 % unless ( $prop->{noseconds} ) {
39 document.forms['form'].elements['<% $prop->{attr} %>_second'].value = '';
40 % }
41 }
42 //-->
43 </script>
44 % }
45 61 ahitrov@rambler.ru % }
46 8 ahitrov@rambler.ru <%args>
47 $prop
48 $name => undef
49 $check => undef
50 </%args>
51
52 <%init>
53
54 my @localtime = localtime(); $localtime[4]++; $localtime[5] += 1900;
55
56 # Формируем данные для select'а...
57 my @days = map { $_ => $_ } (1..31);
58 my @months = @{ $m->comp('/contenido/components/get_months.msn') };
59 278 ahitrov my $start_year = $check && $check =~ /(\d{4})/ ? int($1) - 5 : $localtime[5] - 5;
60 my @years = map { $_ => $_ } ( $start_year .. $localtime[5] + 5);
61 8 ahitrov@rambler.ru my @hours = map { $_ => sprintf('%02d', $_) } (0 .. 23);
62 59 ahitrov@rambler.ru my @minutes = map { $_ => sprintf('%02d', $_) } (0 .. 59);
63 my @seconds;
64 if ( exists $prop->{seconds_step} && $prop->{seconds_step} > 1 ) {
65 @seconds = grep { ($_ % $prop->{seconds_step}) == 0 } map { $_ => sprintf('%02d', $_) } (0 .. 59);
66 } else {
67 @seconds = map { $_ => sprintf('%02d', $_) } (0 .. 59);
68 }
69 8 ahitrov@rambler.ru
70 if ($prop->{allow_null}) {
71 unshift @days, '', '';
72 unshift @months, '', '';
73 unshift @years, '', '';
74 unshift @hours, '', '';
75 unshift @minutes, '', '';
76 unshift @seconds, '', '';
77 }
78
79 my ($year,$month,$day,$hour,$minute, $second);
80 if ($check) {
81 $check =~ /(\d{4})-(\d{1,2})-(\d{1,2})\s+(\d{1,2}):(\d{1,2}):(\d{1,2})/;
82 ($year, $month, $day, $hour, $minute, $second) = ($1 + 0, $2 + 0, $3 + 0, $4 + 0, $5 + 0, $6 + 0);
83 } elsif(!$prop->{allow_null}) {
84 ($second,$minute,$hour,$day,$month,$year) = @localtime[0 .. 5];
85 }
86 59 ahitrov@rambler.ru my $now = Contenido::DateTime->new;
87
88 8 ahitrov@rambler.ru </%init>