[hack] show all items in single calendar

Help with installation and general calendar setttings

Re: [hack] show all items in single calendar

Postby omnia » Wed Aug 10, 2011 11:30 pm

Congratulations for the great script!

is my time to try to help..

following the instructions of Cypriano

some things are left undone, here's my solution:

for the version:
Version 3.3.04

# 1) on the select index should be starting in line 23, thus:


Code: Select all
<select name="id_item" class="select" onchange="this.form.submit();">
                <option value="0"> Show All </ option>
                <?php sel_list_items php echo ($ _REQUEST ["id_item"]);?>
             </ select>


# 2) to fix the problem in CSS you need to know when you are viewing all the items or not:
at index:

replace:
Code: Select all
<div id="the_months">
<? php echo $ calendar_months;?>
</ div>

TO:
Code: Select all
<php
if ($ _REQUEST ["id_item"] == 0) {
?>
   
<div id="the_months" class="allitems">
<? php echo $ calendar_months;?>
</ div>

<php

else {}

    ?>
<div id="the_months">
<? php echo $ calendar_months;?>
</ div>

<? php}?>

.....
doing so when you have selected SELECT ALL the class = "AllItems" will be applied and then the CSS will work only in that case!

....


everything worked PERFECTLY! updates I do notice here!

THANK YOU FOR EVERYTHING!

hugs,
omnia
 
Posts: 1
Joined: Wed Aug 10, 2011 11:21 pm

Re: [hack] show all items in single calendar

Postby chris_b » Thu Nov 03, 2011 12:48 pm

Hi

Great Script and Great Hack, this makes the calendar work exactly how I would like, however I am having difficulties making the days of the week work.

For example using the script in this topic it always starts the month with a sunday and then only populates the days for a week:

Here is where I have implemented the calendar, any advice/ideas would be appreciated :)

http://bit.ly/sR0DbJ

Thanks

Chris
chris_b
 
Posts: 1
Joined: Thu Nov 03, 2011 12:44 pm

Re: [hack] show all items in single calendar

Postby flowbox » Fri Nov 04, 2011 2:54 am

hello @ all
Thanks for the great calendar (and sorry for my english)

I'm not familiar with php but I refined little bit the code of omnia, now is working for me...
in line 34 of index.php change from:

Code: Select all
      <div id="the_months">
         <?php echo $calendar_months; ?>
      </div>


to:

Code: Select all
<?php
      if ($_REQUEST ["id_item"] == 0) {
?>   
      <div id="the_months" class="allitems">
<?php echo $calendar_months; ?>
      </div>
<?php
      }else {
?>
      <div id="the_months">
<?php echo $calendar_months; ?>
      </div>
<?php
      }
?>


now... the only problem is the weekdays .. like on the picture
Attachments
calendar.jpg
calendar.jpg (90.03 KiB) Viewed 5787 times
flowbox
 
Posts: 4
Joined: Fri Nov 04, 2011 2:30 am

Re: [hack] show all items in single calendar

Postby flowbox » Fri Nov 04, 2011 3:49 am

ok resolved the problem

I have commented some line of unnecessary code of cypriano modification in the file functions.inc.php

this is the working code for me:

Code: Select all
/* script:   Show all items hack to Ajax availability calendar
original script author: Chris Bolson
hacked script author: Cypriano.pl
Modificated from flowbox
*/
// 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>';

   //Here is the commented unnecessary code
   
    /*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,1);
         $list_day_titles.='<li title="'.$lang["day_".$first_week_day++.""].'"> '.$weekday.'</li>';
     
      /* The curly bracket also
      }*/
     
   }
   
   
   //   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;
}
?>
flowbox
 
Posts: 4
Joined: Fri Nov 04, 2011 2:30 am

Re: [hack] show all items in single calendar

Postby flowbox » Fri Nov 04, 2011 7:03 am

another little change for optimizing is change the code on file index.php ... using ID_ITEM instead $_REQUEST

so the first part of the code is:

Code: Select all
         <!-- optional calendar change options -->
         
         <div id="cal_admin">
            <form method="get">
            <select name="id_item" class="select" onchange="this.form.submit();">
               <option value="0"> Show All </option>
                     <?php echo sel_list_items(ID_ITEM); ?>
            </select>
            <select name="lang" class="select" onchange="this.form.submit();">
                  <?php echo $list_languages_web; ?>
               </select>
            </form>
         </div>
         <!-- end options -->


And change also the method for choosing the class:

Code: Select all
<?php
      if (ID_ITEM == 0) {
?>   
      <div id="the_months" class="allitems">
<?php echo $calendar_months; ?>
      </div>
<?php
   }else{
?>
   <div id="the_months">
<?php echo $calendar_months; ?>
      </div>   
<?php

}
?>
flowbox
 
Posts: 4
Joined: Fri Nov 04, 2011 2:30 am

Re: [hack] show all items in single calendar

Postby amocco » Mon Aug 20, 2012 1:12 pm

hi ,
many thanks for this code .
but is it possible to explain me in detail where i change the code ?

best regards
amocco
 
Posts: 6
Joined: Mon Jun 21, 2010 8:55 am

Re: [hack] show all items in single calendar

Postby brunitika » Sun Aug 26, 2012 5:44 pm

Great works for this hack!

Following the modifications was (quite) perfectly doing the job with last version :) ! I had only to change in functions.inc.php the variable LANG with AC_LANG on lines 349 and 352 and then adapt the CSS (till now I'm doing only "experiment" but the layout would be something similar into a page -> http://www.brunitika.ch/magazzino/?id_item=0).

I used the function draw_mycal() with the modifications of flowbox, also in index.php (I don't need the options, but I will signalizing that is good).

The modifications seems to cause problems in the admin panel with strange layout... I have to take a better look there (see attachment).

@amocco: just follow the instructions of the users: it's really good explicated ;) you have to make modifications in 4 files: index.php, calendar.ajax.php, functions.inc.php, avail-calendar.css

Now go on with new functions :mrgreen: !

Cheers

Bruno
Attachments
admin_panel.png
admin_panel.png (41.28 KiB) Viewed 5387 times
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm

Re: [hack] show all items in single calendar

Postby steph2saly » Tue Aug 28, 2012 12:14 pm

hi,
I'm interested by this one.
Just one question is there a good code ?
I have a look about this subject and i see a lot of difficulty...
Could you tell me which is the good code to modify ? and what is the good step to modify it ?
Thanks
ps: excuse me for my english !
steph2saly
 
Posts: 9
Joined: Mon Aug 27, 2012 5:12 pm

Re: [hack] show all items in single calendar

Postby flowbox » Tue Aug 28, 2012 4:24 pm

here You can download the calendar ready to install

the version is ac-v3.03.05

http://www.mediafire.com/?hd8o8hdb8l9ep10
flowbox
 
Posts: 4
Joined: Fri Nov 04, 2011 2:30 am

Re: [hack] show all items in single calendar

Postby steph2saly » Tue Aug 28, 2012 9:06 pm

Great !!!
Thanks a lot
I'm going to test it now
steph2saly
 
Posts: 9
Joined: Mon Aug 27, 2012 5:12 pm

PreviousNext

Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron