By: Jerome
Date: 2008-01-05
Time: 21:19
|
How to print out a calendar/planning
Hi, I would like to create a calendar (or planning).
I want a table for each month and 7 cells per row (and month in header); I tried with headergrp, serial, etc... I really don't know how to make it. Can you tell me how I should do it? Is there a plugin or something? (i did not find anything on this forum and in manual).
Thanks for your help!
Jérôme.
|
By: Pirjo Posio
Date: 2008-01-05
Time: 21:47
|
Re: How to print out a calendar/planning
Hi Jerome,
I don't know of any ready-made calendar plugin for TBS. But if someone has, or you make one, please share that solution with the TBS community.
However, I think that the dynamic columns example among TBS examples comes closest to a calendar. Have a look at that meanwhile you wait for someone coming up with a ready-made solution. :)
|
By: TomH
Date: 2008-01-07
Time: 02:31
|
Re: How to print out a calendar/planning
I have a prototype TBS calendar that you can try to use as a building block
It uses ezSQL for the db layer so you will need to fiddle a bit if your use another db class/plugin (but if you're a heavy TBS user like I am then you should really learn how great ezSQL is when used within TBS)
TBS php
// ----NOTE---- TBS and ezSQL are auto_prepend'ed in my .htaccess file
// stop ezSQL query caching while debugging
$db->use_disk_cache = false;
$db->cache_queries = false;
/* ======================================================================
Each month starts on the [day-of-week]th table td element
$month_first_day_of_week = date('w', mktime(0, 0, 0, 1, 1, 2008));
Stuff table blocks_array with this months records -- order by 'event_date'
======================================================================== */
//$debug_file = "debug.php"; // stuff all the print_r() dumps in here
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate(basename($_SERVER['SCRIPT_NAME'], ".php").".html") ;
// current month...
$displaymonth=(int)date("n");
$displayyear=date("Y");
$labelmonth=date('F', mktime(0, 0, 0, $displaymonth, 1, $displayyear));
// The table being used here is from the "LTW Calendar" application
// it contains records for each scheduled event
// Do query to get the "event" records
$sql = "SELECT id,name,event_date, DAYOFMONTH(event_date) AS dayofmonth, start_time,end_time,description FROM ltw_eventsv4 WHERE MONTH(event_date)= $displaymonth ORDER BY event_date,start_time";
$event = $db->get_results($sql);// use ezSQL
//$dumpevent = print_r($event,true);
// Create an array that sets an element for each <td> in the table
// do some arithmetic to make empty blocks (<td>'s) before first day of month
$month_first_day_of_week = date('w', mktime(0, 0, 0, $displaymonth, 1, $displayyear));
$month_days_in_month = date('t', mktime(0, 0, 0, $displaymonth, 1, $displayyear));
$totalblocks=$month_first_day_of_week + $month_days_in_month;
for ($i = 1; $i <= $totalblocks; $i++) {
$dateblocks[$i]=array(
'block'=>$i, // the 'block' refers to the <td>'s in the table
'day'=>$i-$month_first_day_of_week); // the days of the month
}
// Now... using the results of events from the database -- add "event" details
// to the table blocks
foreach($event AS $key=>$val){
$day = $val->dayofmonth;
$dateblocks[$day+$month_first_day_of_week]['event'][] = array(
'id'=>$val->id,
'daylabel'=>$val->dayofmonth,
'name'=>$val->name,
'start_time'=>$val->start_time,
'description'=>$val->description );
}
$dumped = print_r($dateblocks,true);
$TBS->MergeBlock('bx','array',$dateblocks);
$TBS->Show() ;
// Since we need to handle multiple events in a specific day
// we'll use the ondata function to merge them into a single value
function event_block($BlockName,&$CurrRec,$RecNum){
if($CurrRec['day']>0){
$CurrRec['daylabel']=$CurrRec['day'];
}
if(gettype($CurrRec['event'])=="array"){
foreach($CurrRec['event'] AS $key=>$val){
$time = substr($val['start_time'],0,5);
$valstuff .= $time." ".$val['name']."<br>";
}
$CurrRec['valstuff']=$valstuff;
}
} // --end-- ondata function
|
html template
<html>
<head>
<title>[var..template_name]</title>
<style type="text/css">
body{
font-size : 12px;
}
th{
font-size : 16px;
}
.blocksize{
height: 100;
width: 120;
vertical-align: top;
}
td{
font-size : 10px;
}
</style>
</head>
<body>
<hr color=Maroon size=4>
<table bgcolor="#E4F1E4" width=760 align=center border="1" cellpadding="4" cellspacing="0" summary="">
<tr><th bgcolor="Silver" colspan=7><b>[var.labelmonth] [var.displayyear]</b></th>
</tr>
<tr bgcolor="#F0F0F0">
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_1.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_1.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_2.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_2.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_3.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_3.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_4.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_4.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_5.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_5.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_6.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_6.valstuff;block=td;htmlconv=no;noerr]</b>
</div></td>
<td class=blocksize valign=top nowrap=nowrap><div align="left"><FONT color="#888888"> [bx_7.daylabel;htmlconv=no;noerr;.]</font><br>
<b>[bx_7.valstuff;block=td;htmlconv=no;noerr]</b>
[bx;block=tr;ondata=event_block;serial]</div></td>
</tr>
<tr bgcolor="#F0F0F0">
<td valign="middle" bgcolor="#E4F1E4"><div align="center">
<span class="text-mini">[bx_0;block=td]</span> [bx;block=tr;serial]
</div></td>
</tr>
</table>
<hr color=Maroon size=4>
onload;file=debug.html;noerr
</body>
</html>
|
Hope that helps -- butr` if you make some improvements then make sure you contribute them here!
Cheers,
TomH
|
By: TomH
Date: 2008-01-07
Time: 02:40
|
Re: How to print out a calendar/planning
|
By: Jerome
Date: 2008-01-07
Time: 13:45
|
Re: How to print out a calendar/planning
Thank to all of you for your replies. I will post my solution as soon as I will finish it!
|
By: Jerome
Date: 2008-01-08
Time: 19:36
|
Re: How to print out a calendar/planning
I chose the TomH solution so nothing new to provide. Thank you for your help!
|
By: TomH
Date: 2008-01-08
Time: 23:58
|
Re: How to print out a calendar/planning
Hi Jerome,
You can see the more refined version of the calendar app at
http://tomhenry.us/tbs3/
-It now does event administration... including add/edit/delete features at last :0)
I'll be posting the source code therein a dsy or do ;)
Hope that helps more,
TomH
|
By: TomH
Date: 2008-01-10
Time: 22:38
|
Re: How to print out a calendar/planning
Have released the TBS Calendar v.2.3 with all application source
You can see the new release at http://tomhenry.us/tbs3/
It now includes internationalization and event administration, including add/edit/delete features
Change log is at the top of the application php source code
|
|
Posting in progress.
Please wait...
|