Serhioromano / bootstrap-calendar

Full view calendar with year, month, week and day views based on templates with Twitter Bootstrap.
http://bootstrap-calendar.eivissapp.com/
MIT License
3.02k stars 1.29k forks source link

starting date on the calendar #8

Closed devaizu closed 11 years ago

devaizu commented 11 years ago

hi serhio, this is great calendar for bootstrap. i've trying to work on implentation the calendar to my project. i'm making an meeting room reservation system, in which the calendar showing the event that called from the database. but i kinda stuck at modifying the starting date on the calendar. when the calendar opened at my system, it always showing 11 week of year 2013 (the event showing march 2nd week). where do i modify the script so the system starting on today date? i know that i could access today date with clicking on today button, but i want the system to start showing today date as default. and for the events.json.php i've tried to make some json data for the system to catch. but the system couldn't get the output. as i tinker with the output, the calendar is accepting data that formatted as string (not json). kindly need your enlightment on this serhio, thank you.

devaizu commented 11 years ago

i've found the starting date on the app.js, and i've changed the day var into now.

var options = {
    events_url: 'events.json.php',
    view: 'week',
    day: 'now',

just the events.json.php that remains :)

Serhioromano commented 11 years ago

Good. Also you can open js/calendar.js and see all options available. You can see var defaults = {..... This is parameters that you may override on initialization.

app.js is not part od calendar itself. it is example how it may be implemented.

You can start from month view byt changing view: 'week' to view: 'month',.

I would also very eager to look at what you are doing in real environment and may be get some ideas. Do you have online link?

devaizu commented 11 years ago

hi serhio. thx for the prompt reply.

sorry, i got some bad connection just now. here's the project that i'm working right now http://pecellele.my3gb.com in localhost it's already fine with the calendar calling the data from the database. it show the calendar as it show in the demo, xcept i pull the data via the events.json.php

here's the script that i wrote for the events.json.php :

$sched = "select * from schedule";
$hsched = mysql_query($sched);
$rosched = mysql_fetch_assoc($hsched);
$idvent = $rosched['sched_id'];
$sevent="select * from events";
$hevent=mysql_query($sevent);
$he=mysql_query($sevent);
//echo $hevent;
$ida=0;
While($re=mysql_fetch_assoc($he)){
$ida++;
//echo "a =".$ida;
}
$idb=0;
While($revnt=mysql_fetch_assoc($hevent)){
    $idb++;
    //echo "b =".$idb;
    $result.="{\"id\":\"$revnt[event_id]\",\"title\":\"$revnt[subject]\",\"url\":\"index.php?viewevent=$revnt[event_id]\",\"class\":\"event-info\",\"start\":\"$revnt[starting_date_time]000\",\"end\":\"$revnt[ending_date_time]000\"}";
    if ($idb < $ida){ $result.=",";}
}
$show = "{\"success\":1,\"result\": [$result] }";
echo $show;

it's storing the $result as string only and after it concate with the $success, it's forming $show. that's the one that i use for the data.

since i've try using json last night, but the callendar wouldn't pick up the data.

Serhioromano commented 11 years ago

I would change this code a little.

While($revnt=mysql_fetch_assoc($hevent)){
    $e = array();
    $e['id'] = $event['id'];
    $e['start'] = $event['starting_date_time'];
    $e['end'] = $event['ending_date_time'];
    $e['title'] = $event['subject'];
    $result[] = $e;
}
echo json_encode(array('success' => 1, 'result' => $result));

This way JSON will be encoded properly. Also pay attantion that end and start dates best to be timestamp in miliseconds format. Like time() + '000'

devaizu commented 11 years ago

will test the code, i'm sure that the code is more simple than mine to show event at the calendar. for the date i'm formating it using this code : $date = date( "D m/d/y $TIMEZONE_FORMAT:i$TIMEZONE_AMPM", ( $ro['time'] + ($TIMEZONE*3600) ) ) ;

thx serhio.