Commit 0b60b74f authored by lrargerich's avatar lrargerich

Mini-calendar foundations

parent 17dd80d2
......@@ -1510,6 +1510,7 @@ tiki/templates/tiki-list_trackers.tpl -text
tiki/templates/tiki-listpages.tpl -text
tiki/templates/tiki-login.tpl -text
tiki/templates/tiki-minical.tpl -text
tiki/templates/tiki-minical_prefs.tpl -text
tiki/templates/tiki-my_tiki.tpl -text
tiki/templates/tiki-mytiki_bar.tpl -text
tiki/templates/tiki-newsletters.tpl -text
......@@ -1766,6 +1767,7 @@ tiki/tiki-login_validate.php -text
tiki/tiki-logout.php -text
tiki/tiki-mailin.php -text
tiki/tiki-minical.php -text
tiki/tiki-minical_prefs.php -text
tiki/tiki-modules.php -text
tiki/tiki-my_tiki.php -text
tiki/tiki-mytiki_shared.php -text
......
......@@ -25,7 +25,7 @@ class MiniCalLib extends TikiLib {
$aux['start']=$start;
$end_p = $start+$interval;
$aux['end']=$end_p;
$query = "select * from tiki_minical_events where user='$user' and start>=$start and start<$end_p";
$query = "select * from tiki_minical_events where user='$user' and start>=$start and start<$end_p order by start asc";
//print($query);print("<br/>");
$result = $this->query($query);
$events=Array();
......
{*Smarty template*}
<a class="pagetitle" href="tiki-minical.php">{tr}Mini Calendar{/tr}</a><br/><br/>
<a class="pagetitle" href="tiki-minical.php?view={$view}">{tr}Mini Calendar{/tr}</a><br/><br/>
{include file=tiki-mytiki_bar.tpl}
<br/>
[<a class="link" href="#add">{tr}Add{/tr}</a>]
[<a class="link" href="tiki-minical_prefs.php">{tr}Prefs{/tr}</a>]
[<a class="link" href="tiki-minical.php?view=daily">{tr}Daily{/tr}</a> |
<a class="link" href="tiki-minical.php?view=weekly">{tr}Weekly{/tr}</a>]
<br/><br/>
<!-- Time here -->
<!--[{$pdate_h|date_format:"%H"}:{$pdate_h|date_format:"%M"}]-->
{cycle values="odd,even" print=false}
{if $view eq 'daily'}
<b><a class="link" href="tiki-minical.php?view={$view}&amp;day={$yesterday|date_format:"%d"}&amp;mon={$yesterday|date_format:"%m"}&amp;year={$yesterday|date_format:"%Y"}">&lt;</a>
{$pdate|tiki_long_date}
<a class="link" href="tiki-minical.php?view={$view}&amp;day={$tomorrow|date_format:"%d"}&amp;mon={$tomorrow|date_format:"%m"}&amp;year={$tomorrow|date_format:"%Y"}">&gt;</a>
</b>
<table clas="normal" width="97%" >
{section name=ix loop=$slots}
<tr>
......@@ -15,7 +29,9 @@
</td>
<td>
{section name=jj loop=$slots[ix].events}
{$slots[ix].events[jj].title}<br/>
<a title="{$slots[ix].events[jj].start|tiki_short_time}:{$slots[ix].events[jj].description}" class="link" href="tiki-minical.php?view={$view}&amp;eventId={$slots[ix].events[jj].eventId}">{$slots[ix].events[jj].title}</a>
[<a class="link" href="tiki-minical.php?view={$view}&amp;remove={$slots[ix].events[jj].eventId}">x</a>]
<br/>
{/section}
</td>
</tr>
......@@ -24,8 +40,38 @@
</tr>
{/section}
</table>
{/if}
{if $view eq 'weekly'}
<a class="link" href="tiki-minical.php?view={$view}&amp;day={$prev_week_start|date_format:"%d"}&amp;mon={$prev_week_start|date_format:"%m"}&year={$prev_week_start|date_format:"%Y"}">&lt;</a>
<b>{$week_start|date_format:"%b"} {$week_start|date_format:"%d"}-{$week_end|date_format:"%b"} {$week_end|date_format:"%d"}</b>
<a class="link" href="tiki-minical.php?view={$view}&amp;day={$next_week_start|date_format:"%d"}&amp;mon={$next_week_start|date_format:"%m"}&year={$next_week_start|date_format:"%Y"}">&gt;</a>
<table class="normal" width="97%" >
{section name=ix loop=$slots}
<tr>
<td class="{cycle}">
<table width="100%">
<tr>
<td width="7%">
{$slots[ix].start|date_format:"%a"}<br/>
{$slots[ix].start|date_format:"%d"}
</td>
<td>
{section name=jj loop=$slots[ix].events}
{$slots[ix].events[jj].start|tiki_short_time}: <a title="{$slots[ix].events[jj].start|tiki_short_time}:{$slots[ix].events[jj].description}" class="link" href="tiki-minical.php?view={$view}&amp;eventId={$slots[ix].events[jj].eventId}">{$slots[ix].events[jj].title}</a>
[<a class="link" href="tiki-minical.php?view={$view}&amp;remove={$slots[ix].events[jj].eventId}">x</a>]
<br/>
{/section}
</td>
</tr>
</table>
</td>
</tr>
{/section}
</table>
{/if}
<a name="add"></a>
<h3>{tr}Add an event{/tr}</h3>
<form action="tiki-minical.php" method="post">
<input type="hidden" name="eventId" value="{$eventId}" />
......@@ -33,18 +79,15 @@
<input type="hidden" name="description" value="dummy" />
<table class="normal">
<tr><td class="formcolor">{tr}Title{/tr}</td>
<td class="formcolor"><input type="text" name="title" value="{$info.title}" /></td>
<td class="formcolor"><input type="text" name="title" value="{$info.title}" /><input type="submit" name="save" value="{tr}save{/tr}" /></td>
</tr>
<tr>
<td class="formcolor">{tr}Start{/tr}</td>
<td class="formcolor">
{html_select_time time=$pdate_h display_seconds=false use_24_hours=true}
{html_select_date time=$ev_pdate}
{html_select_time time=$ev_pdate_h display_seconds=false use_24_hours=true}
</td>
</tr>
<tr>
<td class="formcolor">&nbsp;</td>
<td class="formcolor"><input type="submit" name="save" value="{tr}save{/tr}" /></td>
</tr>
</table>
</form>
......
{*Smarty template*}
<a class="pagetitle" href="tiki-minical_prefs.php">{tr}Mini Calendar: Preferences{/tr}</a><br/><br/>
{include file=tiki-mytiki_bar.tpl}
<br/>
[<a class="link" href="tiki-minocal.php#add">{tr}Add{/tr}</a>]
[<a class="link" href="tiki-minical_prefs.php">{tr}Prefs{/tr}</a>]
[<a class="link" href="tiki-minical.php?view=daily">{tr}Daily{/tr}</a> |
<a class="link" href="tiki-minical.php?view=weekly">{tr}Weekly{/tr}</a>]
<br/><br/>
Prefs
......@@ -35,12 +35,26 @@ if(isset($_SESSION['thedate'])) {
} else {
$pdate = date("U");
}
$yesterday = $pdate - 60*60*24;
$tomorrow = $pdate + 60*60*24;
$smarty->assign('yesterday',$yesterday);
$smarty->assign('tomorrow',$tomorrow);
$smarty->assign('day',date("d",$pdate));
$smarty->assign('mon',date("m",$pdate));
$smarty->assign('year',date("Y",$pdate));
$pdate_h = mktime(date("G"),date("i"),date("s"),date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$smarty->assign('pdate',$pdate);
$smarty->assign('pdate_h',$pdate_h);
$ev_pdate = $pdate;
$ev_pdate_h = $pdate_h;
if($_REQUEST["eventId"]) {
$info = $minicallib->minical_get_event($user,$_REQUEST["eventId"]);
$ev_pdate = $info['start'];
$ev_pdate_h = $info['start'];
} else {
$info=Array();
$info['title']='';
......@@ -48,10 +62,12 @@ if($_REQUEST["eventId"]) {
$info['start']=mktime(date("H"),date("i"),date("s"),date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$info['duration']=1;
}
$smarty->assign('ev_pdate',$ev_pdate);
$smarty->assign('ev_pdate_h',$ev_pdate_h);
if(isset($_REQUEST['save'])) {
$start = mktime($_REQUEST['Time_Hour'],$_REQUEST['Time_Minute'],0,date("m",$pdate),date("d",$pdate),date("Y",$pdate));
$start = mktime($_REQUEST['Time_Hour'],$_REQUEST['Time_Minute'],0,$_REQUEST['Date_Month'],$_REQUEST['Date_Day'],$_REQUEST['Date_Year']);
$minicallib->minical_replace_event($user,$_REQUEST["eventId"],$_REQUEST["title"],$_REQUEST["description"],$start,$_REQUEST['duration']);
$info=Array();
$info['title']='';
......@@ -63,12 +79,41 @@ if(isset($_REQUEST['save'])) {
$smarty->assign('eventId',$_REQUEST["eventId"]);
$smarty->assign('info',$info);
$slot_start = $pdate + 60*60*9;
$slot_end = $pdate + 60*60*20;
//Check here the interval for the calendar
if(!isset($_REQUEST['view'])) {
$_REQUEST['view']='daily';
}
$smarty->assign('view',$_REQUEST['view']);
// Interval is in hours
if($_REQUEST['view']=='daily') {
$interval=1;
$slot_start = $pdate + 60*60*9;
$slot_end = $pdate + 60*60*20;
}
if($_REQUEST['view']=='weekly') {
$interval=24;
// Determine weekday
$wd = date('w',$pdate);
if($wd==0) $w=7;
$wd=$wd-1;
// Now get the number of days to substract
$week_start = $pdate - ($wd*60*60*24);
$week_end = $week_start + 60*60*24*7-1;
$smarty->assign('week_start',$week_start);
$smarty->assign('week_end',$week_end);
$next_week_start = $week_end+1;
$smarty->assign('next_week_start',$next_week_start);
$prev_week_start = $week_start - (60*60*24*7);
$smarty->assign('prev_week_start',$prev_week_start);
$slot_start = $pdate - ($wd*60*60*24);
$slot_end = $slot_start + 60*60*24*7-1;
}
$smarty->assign('slot_start',$slot_start);
$smarty->assign('slot_end',$slot_end);
$events = $minicallib->minical_events_by_slot($user,$slot_start,$slot_end,1);
$events = $minicallib->minical_events_by_slot($user,$slot_start,$slot_end,$interval);
//print_r($events);
$smarty->assign_by_ref('slots',$events);
......
<?php
require_once('tiki-setup.php');
include_once('lib/minical/minicallib.php');
if($feature_minical != 'y') {
$smarty->assign('msg',tra("This feature is disabled"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if(!$user) {
$smarty->assign('msg',tra("Must be logged to use this feature"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
//if($tiki_p_usermenu != 'y') {
// $smarty->assign('msg',tra("Permission denied to use this feature"));
// $smarty->display("styles/$style_base/error.tpl");
// die;
//}
include_once('tiki-mytiki_shared.php');
$smarty->assign('mid','tiki-minical_prefs.tpl');
$smarty->display("styles/$style_base/tiki.tpl");
?>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment