Page 1 of 1

Clickable legend to change states

PostPosted: Sat Jul 30, 2011 12:46 am
by realfriend
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
<script type="text/javascript">
   function changeClickMethod(num) {
      document.booking_state_selector.id_predefined_state[num+1].selected = "1";
<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">

In ac-includes/, 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");
   $list_states_admin.='<li class="'.$row["class"].' selectable" title="'.$row["the_desc"].'"
   onClick="changeClickMethod(' . $rownum++ . ')">
   $sel_list_states.='<option value="'.$row["id"].'">'.$row["the_desc"].'</option>';
<div id="key" class="cal_month">
   <div class="cal_title">'.$lang["legend"].'</div>


In ac-admin/css/admin-calendar.css:
Code: Select all
.selectable {
   cursor: pointer;