brunitika wrote:3. Add comments to a booked date (I need a simply pop-up or similar to show some extra informations about)
After a strenuous effort

I could find a solution for my need. Then, first I add a new table column to the db an to the table "bookings":
- Code: Select all
ALTER TABLE `bookings` ADD `date_comment` TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
The I create a new form input field on bookings.admin.php that appear only if I have availability:
- Code: Select all
<input type="text" id="comment" name="comment">
(I've put a new js function that show the input field only if I have a certain availability but this is only for a specific use that I need)
Then I changed the function update_calendar(el,date_num) on mootools-cal-admin.js to catch the new text field. First to catch the variable:
- Code: Select all
var text_comment = document.getElementById('comment');
and then add to the the other data the new variable:
- Code: Select all
var req = new Request({
method: 'get',
url: url_ajax_update,
data: {
'id_item':id_item,
'the_date':el.id.replace("date_",""),
'lang':lang,
'id_state':id_pre_state,
'comment':text_comment.value
pass the variable via ajax via update_calendar.ajax.php:
- Code: Select all
$the_date = $_GET["the_date"];
$id_item = $_GET["id_item"];
$comment = $_GET["comment"];
add the comment to the first query on db on same file:
- Code: Select all
INSERT INTO ".T_BOOKINGS." SET id_item='".$id_item."',the_date='".$the_date."', id_state='".$new_state."',date_comment='".$comment."'
and on the update query
- Code: Select all
UPDATE ".T_BOOKINGS." SET id_state='".$new_state."',date_comment='".$comment."' WHERE id_item='".$id_item."' AND the_date='".$the_date."' LIMIT 1
to the last change the function draw_mycal($id_item,$month,$year) (I use the multi items view) on functions.inc.php. First add the comment on select:
- Code: Select all
SELECT
t3.desc_".AC_LANG." AS the_item ,
t1.the_date,
t1.date_comment,
t2.class,
t2.desc_".AC_LANG." AS the_state
add it to the array
- Code: Select all
$booked_days[$row["the_item"]][$row["the_date"]]=array("class"=>$row["class"],"state"=>$row["the_state"],"item"=>$row["the_item"],"comment"=>$row["date_comment"]);
check it with other variable
- Code: Select all
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"];
$comment_date=" - ".$booked_days_item[$date_db]["comment"];
}
and add it to the title of the days
- Code: Select all
//'.$lang["day_".$getdate["wday"].""].'
$list_days[$items] .= '
<li class="'.$day_classes.' " id="'.$date_db.'" title="'.$date_format.$day_title_state.$comment_date.'">'.$day_counter.'</li>';
The method is actually a little bit limited to my specifically use, but could be in each case the base for adding custom comment to an availability.
Cheers
Bruno