Revision 322 (by ahitrov, 2013/04/28 20:22:40) Очистка дат
<%args>
	$prop  => undef
	$name  => undef
	$check => undef
</%args>

<%init>

	my @localtime = localtime(); $localtime[4]++; $localtime[5] += 1900;

	# Формируем данные для select'а...
	my @days = map { $_ => $_ } (1 .. 31);
	my $months = $m->comp('/contenido/components/get_months.msn');
	my @years = map { $_ => $_ } (1940 .. $localtime[5] + 5);

	if ( ref $prop && exists $prop->{attr} && $prop->{allow_null}) {
		unshift @days,    '', '';
		unshift @$months, '', '';
		unshift @years,   '', '';
	}

	# Устанавалием текущие даты...
	my ($year,$month,$day);
	if ($check) {
		$check =~ /(\d{4})-(\d{1,2})-(\d{1,2})/;
		($year, $month, $day) = ($1+0, $2+0, $3+0);
	} elsif(!$prop->{allow_null}) {
		($day,$month,$year) = @localtime[3 .. 5];
	}
	my $now = Contenido::DateTime->new;

</%init>

<& "/contenido/components/select.msn",  name => $name.'_day', values => \@days, check => $day &><& 
	'/contenido/components/select.msn', name => $name.'_month', values => $months, check => $month &><& 
	'/contenido/components/select.msn', name => $name.'_year', values => \@years, check => $year &> 
%  if ( ref $prop && exists $prop->{attr} ) {
<span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_now()" style="color:red;">Сейчас!</a></span>
<script type="text/javascript">
<!--
function set_<% $prop->{attr} %>_now () {
   document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '<% $now->day %>';
   document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '<% $now->mon %>';
   document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '<% $now->year %>';
}
//-->
</script>
%	if ( $prop->{allow_null} ) {
&nbsp; <span style="padding-left:20px;"><a href="javascript:void(0)" onclick="set_<% $prop->{attr} %>_clear()" style="color:red;">Очистить!</a></span>
<script type="text/javascript">
<!--
function set_<% $prop->{attr} %>_clear () {
   document.forms['form'].elements['<% $prop->{attr} %>_day'].value = '';
   document.forms['form'].elements['<% $prop->{attr} %>_month'].value = '';
   document.forms['form'].elements['<% $prop->{attr} %>_year'].value = '';
}
//-->
</script>
%	}
%  }