Some new features

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)

Some new features

Postby brunitika » Sun Aug 26, 2012 6:16 pm

Hi there!

I would work in the next time to implement some new features; i write this thread to remember me what i need :mrgreen: and to follow progress.

1. On admin panel add a button/dropdown/radio to select in "new user" the type of it: admin (level1) or "normal" user (level2)

2. Send notification to admin (for example email) when there's a new booking on a calendar

3. Add comments to a booked date (I need a simply pop-up or similar to show some extra informations about)

4. Add button "today" on multi items view to come back to actually months (useful in "only" one month view)

5. Updating wordpress plugin (with very very low priority ;) we will see my motivation after doing the others features)

So, go on and I will posting here if I succeed on something above.

Cheers

Bruno
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm

Re: Some new features

Postby brunitika » Sat Sep 08, 2012 7:12 pm

brunitika wrote:4. Add button "today" on multi items view to come back to actually months (useful in "only" one month view)


Maybe you can call a function on mootools-cal-public.js to load calendar of today with javascript, but I think the easiest way is to make a button to reload the page:

Code: Select all
<button type="button" onclick="document.location.reload(false)">Today</button>


-> http://brunitika.ch/magazzino/
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm

Re: Some new features

Postby brunitika » Sun Sep 09, 2012 9:58 pm

brunitika wrote:2. Send notification to admin (for example email) when there's a new booking on a calendar


I had a php mail() function to update_calendar.ajax.php on line #115 to the

Code: Select all
mysql_query($update)


but the problem is that you have a email for each click (alias booking). I think the best solution for me was to add a function mail() on admin-logout.php, considering that I've got 5 people who change the availability of a item and one really admin that control the items and considering that if you make a login is to change something.
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm

Re: Some new features

Postby brunitika » Mon Sep 17, 2012 12:19 am

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
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm

Re: Some new features

Postby brunitika » Tue Sep 18, 2012 10:33 am

I integrate moopopup to display the data, so that after integrating moopup (I updated mootools to 1.4.5 just right now without problem). The last code looks like:

Code: Select all
//'.$lang["day_".$getdate["wday"].""].'
$list_days[$items] .= '
<li class="'.$day_classes.' "  id="'.$date_db.'" onclick="var mp = new moopopup({overlay: false, title: \'Prenotazione del '.$date_format.'\', text: \'<p>Prenotazione di '.substr($day_title_state,15).'</p><p>'.$comment_date.'</p>\'});mp.display();">'.$day_counter.'</li>';


To pictures of admin page and on view
Attachments
main.png
main.png (57.27 KiB) Viewed 6410 times
admin.png
admin.png (30.27 KiB) Viewed 6410 times
brunitika
 
Posts: 15
Joined: Fri Aug 24, 2012 8:07 pm


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests