/*
* Themed output to display monthperline
*/
function theme_availability_calendars_node_line($node, $year = 2008, $month = 1, $monthstodisplay = 24) {
drupal_add_css(drupal_get_path('module', 'availability_calendars') .'/availability_calendars.css');
$rows = array();
// Fill availability array
/* foreach ($node->availability_dates as $k => $v) {
foreach ($v as $i) {
$booked[date("Y", $i['date'])][date("m", $i['date'])][date("d", $i['date'])] = 1;
}
} */
// Calendar code based on example at http://evolt.org/node/60673 :
$day = 1;
//$startofweek = variable_get('availability_calendars_'. $node->nid .'_startofweek', 1);
// Montag als Start der Woche
$startofweek = 6;
$monthsremaining = $monthstodisplay;
while ($monthsremaining > 0) {
/*
* Ausgabe der Tage für Kalender in Line-Ausgabe
*/
if($monthsremaining==$monthstodisplay && $year==date("Y")) {
$output .= "<p style=\"clear:left\"></p>
<table class=\"cal_neu\">";
$output .= "<tr>";
for($yy=0;$yy<=31;$yy++) {
if($yy==0) {
$output .= "<td class=\"year_strong\">".$year."</td>";
}
else {
$output .= "<td class=\"days\">".$yy."</td>";
}
}
$output .= "</tr>";
/*
$output .= "<tr>";
$output .= "<td colspan=32 class=\"year\">".$year."</td>";
$output .= "</tr>";
*/
$output .= "</table>";
}
//$output .= theme('availability_calendars_line', $node, $year, $month, $startofweek, $booked);
$output .= theme_availability_calendars_line( $node, $year, $month, $startofweek, $booked);
$monthsremaining--;
$month++;
if ($month > 12) {
$month = 1;
$year++;
$output .= "<table class=\"cal_neu\">";
$output .= "<tr>";
$output .= "<td class=\"year_strong\" >".$year."</td>";
for($yy=1;$yy<=31;$yy++) {
$output .= "<td class=\"days\">".$yy."</td>";
}
$output .= "</tr>";
$output .= "</table>";
}
}
return $output;
}
/*
* theme for month/line
*/
function theme_availability_calendars_line($node, $year, $month, $startofweek, $booked,$extra) {
$month_meta = availability_calendars_month_meta($year, $month, $startofweek);
// read Day Status
$status_result = db_query('SELECT day, status FROM {availability_calendars_day}
WHERE nid = %d AND year = %d AND month = %d', $node, $year, $month);
while ($status = db_fetch_array($status_result)) {
$day_status[$status['day']] = $status['status'];
}
// get current day
if($month == date("m") && $year == date("Y")) {
$day_status[date("j")] = 4;
}
//$availability_calendars_options = availability_calendars_options();
$output = "<table class='cal_neu'><tr>\n";
// $output .= "<td class=\"month_name\">". t("@date", array('@date' => format_date(mktime(12, 0, 0, $month, 1, $year), 'custom', 'F Y')))."</td>\n";
if($extra!='nomonth') {
$output .= "<td class=\"monthname\">". t("@date", array('@date' => format_date(mktime(12, 0, 0, $month, 1, $year), 'custom', 'F')))."</td>\n";
}
for($xx=1;$xx<=$month_meta['daysinmonth'];$xx++) {
if($extra!='nomonth' || $node==0 )
$xx_day = format_date(mktime(12, 0, 0, $month, $xx, $year), 'custom', 'D');
else {
$xx_day = format_date(mktime(12, 0, 0, $month, $xx, $year), 'custom', 'j');
}
if ($day_status[$xx] == 0) {
$output .= " <td class='calavailable day'>". $xx_day ."</td>\n";
}
elseif ($day_status[$xx] == 1) {
$output .= " <td class='calnotavailable day'>". $xx_day ."</td>\n";
}
elseif ($day_status[$xx] == 2) {
$output .= " <td class='calnotavailableprov day'>". $xx_day ."</td>\n";
}
elseif ($day_status[$xx] == 3) {
$output .= " <td class='calarrivaldeparture day'>". $xx_day ."</td>\n";
}
elseif ($day_status[$xx] == 4) {
$output .= " <td class='caltoday day'>". $xx_day ."</td>\n";
}
else {
$output .= " <td class='calotherday day'>". $xx_day ."</td>\n";
}
}
$output .="</tr></table>";
return $output;
}