<?php


function T_WORKPOINTS_MONTH( $cmd, $value ) {
	global $result, $thiss;

	if ($cmd == 'POST_VERIFY') {
		return;
	}

	$field_name = 'T_WORKPOINTS_MONTH';

	$now_year = date("Y");

	$date_select_list = array();
	// show current year, before and after
	for ($y = $now_year - 1; $y <= $now_year + 1; $y++) {
		for ($m = 1; $m <= 12; $m++) {
			$cur_date = sprintf("%4d-%02d", $y, $m);
			$date_select_list [$cur_date] = $cur_date;
		}
	}

	// set default value
	if (empty($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name])) {
		$_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name] = date("Y-m", mktime(0,0,0,date('m') + 1, date('d'), date('Y')));
	}

	echo '<select name="' . $field_name . '">';
		foreach ($date_select_list as $k_date => $v_date) {
			$sel = ($_SESSION[$thiss->DETECT_TABLE_COLUMN]['EDITRECORD'][$field_name] == $k_date)? ' selected="selected"' : '';
			echo '<option value="' . $k_date . '"' . $sel . '>' . $v_date . '</option>';
		}//end foreach
	echo '</select>';
}
