12) $m = date('m');
$cyr = ($sly) ? true : false;
if($sly && $sly < $year_start) $sly = $year_start;
if($sly && $sly > $year_end) $sly = $year_end;
if(isset($_REQUEST["y"]))
$y = $_REQUEST["y"];
else
$y = ($cyr) ? $sly : date('Y');
//echo(" y: ".$y);
if($y <= 0) $y = date('Y');
$objname = (isset($_REQUEST["objname"])) ? $_REQUEST["objname"] : "";
$dp = (isset($_REQUEST["dp"])) ? $_REQUEST["dp"] : "";
$cobj = new tc_calendar("");
$cobj->startMonday($startMonday);
if(!$year_start || !$year_end){
$year_start = $cobj->year_start; //get default value of year start
$year_end = $cobj->year_end; //get default value of year end
}
//$cobj->setDate($sld, $slm, $sly);
$total_thismonth = $cobj->total_days($m, $y);
if($m == 1){
$previous_month = 12;
$previous_year = $y-1;
}else{
$previous_month = $m-1;
$previous_year = $y;
}
if($m == 12){
$next_month = 1;
$next_year = $y+1;
}else{
$next_month = $m+1;
$next_year = $y;
}
$total_lastmonth = $cobj->total_days($previous_month, $previous_year);
$today = date('Y-m-d');
//$startdate = $cobj->getDayNum(date('D', strtotime($y."-".$m."-1")));
$startdate = date('w', strtotime($y."-".$m."-1"));
if($startMonday)
if($startdate == 0)
$startwrite = $total_lastmonth - 5;
else
$startwrite = $total_lastmonth - ($startdate - 2);
else
$startwrite = $total_lastmonth - ($startdate - 1);
?>
TriConsole.com - PHP Calendar Date Picker
getDayHeaders());
echo("");
//write calendar day header
foreach($day_headers as $dh){
echo("");
}
echo(" ");
echo("");
$dayinweek_counter = 0;
$row_count = 0;
//write previous month
for($day=$startwrite; $day<=$total_lastmonth; $day++){
echo("$day ");
$dayinweek_counter++;
}
$pvMonthTime = strtotime($previous_year."-".$previous_month."-".$total_lastmonth);
//check lastmonth is on allowed date
if($date_allow1 && !$show_not_allow){
if($pvMonthTime >= strtotime($date_allow1)){
$show_previous = true;
}else $show_previous = false;
}else $show_previous = true; //always show when not set
//$date_num = $cobj->getDayNum(date('D', strtotime($previous_year."-".$previous_month."-".$total_lastmonth)));
$date_num = date('w', $pvMonthTime);
if((!$startMonday && $date_num == 6) || ($startMonday && $date_num == 0)){
echo(" ");
$row_count++;
}
//write current month
for($day=1; $day<=$total_thismonth; $day++){
//$date_num = $cobj->getDayNum(date('D', strtotime($y."-".$m."-".$day)));
$date_num = date('w', strtotime($y."-".$m."-".$day));
$currentTime = strtotime($y."-".$m."-".$day);
$htmlClass = array();
$is_today = $currentTime - strtotime($today);
$htmlClass[] = ($is_today == 0) ? "today" : "general";
$is_selected = strtotime($y."-".$m."-".$day) - strtotime($sly."-".$slm."-".$sld);
if($is_selected == 0) $htmlClass[] = "select";
//check date allowed
if($date_allow1 || $date_allow2){
//at least one date allowed specified
$dateLink = true;
if($date_allow1 && $date_allow2){
//both date specified
$da1Time = strtotime($date_allow1);
$da2Time = strtotime($date_allow2);
if($da1Time < $da2Time){
$dateLink = ($da1Time <= $currentTime && $da2Time >= $currentTime) ? true : false;
}else{
$dateLink = ($da1Time >= $currentTime && $da2Time <= $currentTime) ? true : false;
}
}elseif($date_allow1){
//only date 1 specified
$da1Time = strtotime($date_allow1);
$dateLink = ($currentTime >= $da1Time) ? true : false;
}elseif($date_allow2){
//only date 2 specified
$da2Time = strtotime($date_allow2);
$dateLink = ($currentTime <= $da2Time) ? true : false;
}
}else{
//no date allow specified, assume show all
$dateLink = true;
}
if($dateLink){
//write date with link
$class = implode(" ", $htmlClass);
if($class) $class = " class=\"$class\"";
echo("$day ");
}else{
$htmlClass[] = "disabledate";
$class = implode(" ", $htmlClass);
if($class) $class = " class=\"$class\"";
//write date without link
echo("$day ");
}
if((!$startMonday && $date_num == 6) || ($startMonday && $date_num == 0)){
echo(" ");
if($day < $total_thismonth) echo("");
$row_count++;
$dayinweek_counter = 0;
}else $dayinweek_counter++;
}
//write next other month
$write_end_days = (6-$dayinweek_counter)+1;
if($write_end_days > 0){
for($day=1; $day<=$write_end_days; $day++){
echo("$day ");
}
echo(" ");
$row_count++;
}
//write fulfil row to 6 rows
for($day=$row_count; $day<=5; $day++){
echo("");
$tmpday = $write_end_days+1;
for($f=$tmpday; $f<=($tmpday+6); $f++){
echo("$f ");
}
$write_end_days += 6;
echo(" ");
}
//check next month is on allowed date
if($date_allow2 && !$show_not_allow){
$nxMonthTime = strtotime($next_year."-".$next_month."-1");
if($nxMonthTime <= strtotime($date_allow2)){
$show_next = true;
}else $show_next = false;
}else $show_next = true; //always show when not set
?>
= $year_start || $next_year <= $year_end) && ($show_previous || $show_next)){
?>