Clickable legend to change states

Got some ideas as to how the calendar could be improved?
No bugs, no installation issues, just your ideas as to what could be added or changed in this Availability Calendar (remember, this is NOT a bookings calendar by default)

Clickable legend to change states

Postby realfriend » Sat Jul 30, 2011 12:46 am

In the Bookings screen, I wanted the legend should work so that could click on one of the items to make that the current click state instead of using the pull-down menu.

I was able to get this working fairly quickly. Here are the changes that I made, in case anyone is interested:

In ac-admin/bookings.admin.php, I added a javascript function to change the selected click method depending on the number that is passed in.
Code: Select all
$contents.='
<script type="text/javascript">
   function changeClickMethod(num) {
      document.booking_state_selector.id_predefined_state[num+1].selected = "1";
   }
</script>
<form name="booking_state_selector">
...

I also changed $calendar_states to $calendar_states_admin, since I want to keep this change separate from the public view of the calendar.
Code: Select all
<div id="key_wrapper">
   '.$calendar_states_admin.'
</div>


In ac-includes/cal.inc.php, I added the onClick event handler to each list item. I only want to do this in the admin interface, that's why I am storing this in $list_states_admin which I created
Code: Select all
$sql="SELECT id,class,desc_".LANG." AS the_desc FROM ".T_BOOKING_STATES." WHERE state=1 ORDER BY list_order ASC";
$res=mysql_query($sql) or die("Error getting states");
$rownum=0;
while($row=mysql_fetch_assoc($res)){
   $list_states_admin.='<li class="'.$row["class"].' selectable" title="'.$row["the_desc"].'"
   onClick="changeClickMethod(' . $rownum++ . ')">
   <span>'.$row["the_desc"].'</span></li>
   ';
   $sel_list_states.='<option value="'.$row["id"].'">'.$row["the_desc"].'</option>';
}
...
$calendar_states_admin='
<div id="key" class="cal_month">
   <div class="cal_title">'.$lang["legend"].'</div>
   <ul>      
      '.$list_states_admin.'      
   </ul>   
</div>
';

?>


In ac-admin/css/admin-calendar.css:
Code: Select all
.selectable {
   cursor: pointer;
}
realfriend
 
Posts: 1
Joined: Sat Jul 09, 2011 9:33 am

Return to Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron