Recently I have searched for something like this, and finally here it is

Thank you!
I needed to show rooms reservations, so I changed the script a bit, and now all the rooms can be shown in a single calendar.
Here is a screenshot (the mod is only for front-end viewing, not for admin section):

Below you can find my Hack, to the script. It is not fully tested yet, but it works quite well. Use it for your own responsibility.
How to use it
- First possibility - additional option in dropdown (modify the default index.php, line 40, add the line with value="0"):
- Code: Select all
<select name="id_item" class="select" onchange="this.form.submit();">
<option value="0">Show All</option> '.sel_list_items($_REQUEST["id_item"]).'
</select>
- Second possibility - always show all entries, without dropdown. Remove the select lines in index.php lines 39-41, and modify the line 20:
- Code: Select all
var id_item = 0;
Now the hacking
1. In ac-includes/ajax/calendar.ajax.php, at the bottom:
- Code: Select all
// create the calendar
if ($id_item ==0 )
echo draw_mycal($id_item,$the_month,$the_year);
else
echo draw_cal($id_item,$the_month,$the_year);
2. In ac-content/themes/default/css/avail-calendar.css, at the bottom add:
- Code: Select all
/* all items addition */
.allitems .cal_month {
width: 525px;
}
.allitems .cal_month ul{
width: 525px;
}
.allitems .cal_month ul li {
width:12px;
}
.allitems .cal_month ul li.item_name {
width:50px;
}
3. The most important part, new function draw_mycal(), which is adapted original draw_cal() function. Just add the code to ac-includes/functions.inc.php:
- Code: Select all
/* script: Show all items hack to Ajax availability calendar
original script author: Chris Bolson
hacked script author: Cypriano.pl
*/
// my calendar
function draw_mycal($id_item,$month,$year){
global $lang;
$month=sprintf("%02s",$month);
// define vars
$today_timestamp = mktime(0,0,0,date('m'),date('d'),date('Y')); # current timestamp - used to check if date is in past
$this_month = getDate(mktime(0, 0, 0, $month, 1, $year)); # convert month to timestamp
$first_week_day = $this_month["wday"]; # define first weekday (0-6)
$days_in_this_month = cal_days_in_month(CAL_GREGORIAN,$month,$year); # define number of days in month
$day_counter_tot = 0; # count total number of days showin INCLUDING previous and next months - use to get 6th row of dates
// CREATE THE CALENDAR
$list_day_titles = '<li class="item_name" title="">Item</li>';
// day column titles - using first letter of each day
if($show_week_num) $list_day_titles='<li class="weeknum_spacer"></li>';
if(AC_START_DAY=="sun"){
//$cal_row_counter=0;
for($k=0; $k<7; $k++){
$weekday = substr($lang["day_".$k.""],0,1);
$list_day_titles.='<li class="cal_weekday"> '.$weekday.'</li>';
}
}else{
//$cal_row_counter=1;
if ($first_week_day == 0) $first_week_day =7;
for($k=0; $k<$days_in_this_month; $k++){
//echo "<br>".$k;
if($first_week_day==7) $first_week_day = 0;
$weekday = substr($lang["day_".$first_week_day.""],0,2);
$list_day_titles.='<li title="'.$lang["day_".$first_week_day++.""].'"> '.$weekday.'</li>';
}
}
// get bookings for this month and item from database
$booked_days=array();
$sql = "
SELECT
t3.desc_".LANG." AS the_item ,
t1.the_date,
t2.class,
t2.desc_".LANG." AS the_state
FROM
".T_BOOKINGS_ITEMS." AS t3
LEFT JOIN ".T_BOOKINGS." AS t1 ON t1.id_item=t3.id AND MONTH(t1.the_date)=".$month." AND YEAR(t1.the_date)=".$year."
LEFT JOIN ".T_BOOKING_STATES." AS t2 ON t2.id=t1.id_state
";
//echo $sql;
if(!$res=mysql_query($sql)) die("ERROR checking id item availability dates<br>".mysql_error());
while($row=mysql_fetch_assoc($res)){
$booked_days[$row["the_item"]][$row["the_date"]]=array("class"=>$row["class"],"state"=>$row["the_state"],"item"=>$row["the_item"]);
}
// loop thorugh days (til max in month) to draw calendar
$list_days=array();
$items=0;
foreach ($booked_days as $booked_days_item) {
$the_item = reset($booked_days_item);
$list_days[$items] .= '
<li class="item_name" title="">'.$the_item["item"].'</li>';
for($day_counter = 1; $day_counter <= $days_in_this_month; $day_counter++){
// reset xtra classes for each day
// note - these classes acumulate for each day according to state, current and clickable
$day_classes = "";
$day_title_state= " - ".$lang["available"];
// set all dates to clickable for now.... need to control this for admin OR for user side booking
$day_classes.=' clickable';
// turn date into timestamp for comparison with current timestamp (defined above)
$date_timestamp = mktime(0,0,0, $month,($day_counter),$year);
// get week number
$week_num=date("W",$date_timestamp);
if($week_num!=$last_week_num){
// new week
//$list_days .= '<li>-</li>';
}
// highlight current day
if($date_timestamp==$today_timestamp) $day_classes.=' today';
// format date for db modifying - the date is passed via ajax
$date_db = $year."-".sprintf("%02s",$month)."-".sprintf("%02s",$day_counter);
// format date for display only
if(AC_DATE_DISPLAY_FORMAT=="us") $date_format = $month."/".$day_counter."/".$year;
else $date_format = $day_counter."/".$month."/".$year;
// check if day is available
if(array_key_exists($date_db,$booked_days_item)){
$day_classes.=" ".$booked_days_item[$date_db]["class"];
$day_title_state=" - ".$booked_days_item[$date_db]["state"];
}
// check if date is past
if( $date_timestamp<$today_timestamp){
$day_classes.=" past"; #add "past" class to be modified via mootools if required
// overwrite clickable state if CLICKABLE_PAST is off
if(AC_ACTIVE_PAST_DATES=="off"){
// date is previous - strip out "clickable" from classes
$day_classes=str_replace(' clickable','',$day_classes);
}
}
// add weekend class - used in javascript to alter class or set opacity
$getdate=getdate($date_timestamp);
$day_num=$getdate["wday"]+1;
if ($day_num % 7 == 1) $day_classes.=' weekend';
elseif ($day_num % 6 == 1) $day_classes.=' weekend';
//'.$lang["day_".$getdate["wday"].""].'
$list_days[$items] .= '
<li class="'.$day_classes.' " id="'.$date_db.'" title="'.$date_format.$day_title_state.'">'.$day_counter.'</li>';
// reset weekday counter if 7 (6)
$week_day %= 7; # reset weekday to 0
++$week_day; # increase weekday counter
++$day_counter_tot; # add 1 to total days shown
//echo "<br>".$week_day;
if($show_week_num){
if ($week_day==1) $list_days[$items] .= '<li class="weeknum">'.$week_num.'</li>';
}
$last_week_num=$week_num;
}
$items++;
}
// put it all together (parent div defined in parent file)
$the_cal='
<div id="'.$month.'_'.$year.'" class="cal_title">'.$lang["month_".$month.""].' '.$year.'</div>
<ul class="cal_weekday">
'.$list_day_titles.'
</ul>';
foreach ($list_days as $list_days_single ) {
$the_cal.='<ul>
'.$list_days_single.'
</ul> ';
}
$the_cal.='<div class="clear"></div>';
return $the_cal;
}