Line # Revision Author
1 8 ahitrov@rambler.ru <%args>
2 $prop => undef
3 $name => undef
4 $check => undef
5 </%args>
6
7 <%init>
8
9 my @localtime = localtime(); $localtime[4]++; $localtime[5] += 1900;
10
11 # Формируем данные для select'а...
12 my @days = map { $_ => $_ } (1 .. 31);
13 my $months = $m->comp('/contenido/components/get_months.msn');
14 my @years = map { $_ => $_ } (1940 .. $localtime[5] + 5);
15
16 322 ahitrov if ( ref $prop && exists $prop->{attr} && $prop->{allow_null}) {
17 8 ahitrov@rambler.ru unshift @days, '', '';
18 unshift @$months, '', '';
19 unshift @years, '', '';
20 }
21
22 # Устанавалием текущие даты...
23 my ($year,$month,$day);
24 if ($check) {
25 $check =~ /(\d{4})-(\d{1,2})-(\d{1,2})/;
26 ($year, $month, $day) = ($1+0, $2+0, $3+0);
27 } elsif(!$prop->{allow_null}) {
28 ($day,$month,$year) = @localtime[3 .. 5];
29 }
30 59 ahitrov@rambler.ru my $now = Contenido::DateTime->new;
31
32 8 ahitrov@rambler.ru </%init>
33
34 <& "/contenido/components/select.msn", name => $name.'_day', values => \@days, check => $day &><&
35 '/contenido/components/select.msn', name => $name.'_month', values => $months, check => $month &><&
36 '/contenido/components/select.msn', name => $name.'_year', values => \@years, check => $year &>
37 61 ahitrov@rambler.ru % if ( ref $prop && exists $prop->{attr} ) {
38 59 ahitrov@rambler.ru <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
39 <script type="text/javascript">
40 <!--
41 function set_<% $prop->{attr} %>_now () {
42 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
43 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
44 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
45 }
46 //-->
47 </script>
48 322 ahitrov % if ( $prop->{allow_null} ) {
49 &nbsp; <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_clear()" style="color:red;">Очистить!</a></span>
50 <script type="text/javascript">
51 <!--
52 function set_<% $prop->{attr} %>_clear () {
53 document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '';
54 document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '';
55 document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '';
56 }
57 //-->
58 </script>
59 % }
60 61 ahitrov@rambler.ru % }