{* $Id: tiki-calendar.tpl 19579 2009-06-15 21:55:25Z nyloth $ *}
{popup_init src="lib/overlib.js"}

{title admpage="calendar"}
	{if $displayedcals|@count eq 1}
		{tr}Calendar{/tr}: {assign var=x value=$displayedcals[0]}{$infocals[$x].name}
	{else}
		{tr}Calendar{/tr}
	{/if}
{/title}

<div id="calscreen"{if $prefs.calendar_sticky_popup eq 'y'} onClick="nd();"{/if}>

	<div class="navbar">
		{if $displayedcals|@count eq 1 and $prefs.feature_group_watches eq 'y' and ( $tiki_p_admin_users eq 'y' or $tiki_p_admin eq 'y' )}
			<a href="tiki-object_watches.php?objectId={$displayedcals[0]|escape:"url"}&amp;watch_event=calendar_changed&amp;objectType=calendar&amp;objectName={$infocals[$x].name|escape:"url"}&amp;objectHref={'tiki-calendar.php?calIds[]='|cat:$displayedcals[0]|escape:"url"}" class="icon">{icon _id='eye_group' alt='{tr}Group Monitor{/tr}' align='right' hspace="1"}</a>
		{/if}
		{if $displayedcals|@count eq 1 and $user and $prefs.feature_user_watches eq 'y'}
			{if $user_watching eq 'y'}
				<a href="tiki-calendar.php?watch_event=calendar_changed&amp;watch_action=remove" class="icon">{icon _id='no_eye' alt="{tr}Stop Monitoring this Page{/tr}" align="right" hspace="1"}</a>
			{else}
				<a href="tiki-calendar.php?watch_event=calendar_changed&amp;watch_action=add" class="icon">{icon _id='eye' alt="{tr}Monitor this Page{/tr}" align="right" hspace="1"}</a>
			{/if}
		{/if}

		{if $tiki_p_admin_calendar eq 'y' or $tiki_p_admin eq 'y'}
			{if $displayedcals|@count eq 1}
				{button href="tiki-admin_calendars.php?calendarId=$displayedcals[0]" _text="{tr}Admin Calendar{/tr}"}
			{else}
				{button href="tiki-admin_calendars.php" _text="{tr}Admin Calendar{/tr}"}
			{/if}
		{/if}

		{if $tiki_p_add_events eq 'y'}
			{button href="tiki-calendar_edit_item.php" _text="{tr}Add Event{/tr}"}
		{/if}

		{if $tiki_p_admin_calendar eq 'y'}
			{button href="#" _onclick="javascript:toggle('exportcal');" _text="{tr}Export Calendars{/tr}" _title="{tr}Click to export calendars{/tr}"}
		{/if}

		{if $viewlist eq 'list'}
			{capture name=href}?viewlist=table{if $smarty.request.todate}&amp;todate={$smarty.request.todate}{/if}{/capture}
			{button href="`$smarty.capture.href`" _text="{tr}Calendar View{/tr}"}
		{else}
			{capture name=href}?viewlist=list{if $smarty.request.todate}&amp;todate={$smarty.request.todate}{/if}{/capture}
			{button href="`$smarty.capture.href`" _text="{tr}List View{/tr}"}
		{/if}

		{if count($listcals) >= 1}
			{button href="#" _onclick="javascript:toggle('filtercal');" _text="{tr}Visible Calendars{/tr}" _title="{tr}Click to select visible calendars{/tr}"}

			{if count($thiscal)}
				<div id="configlinks">
				{foreach item=k from=$listcals name=listc}
					{if $thiscal.$k}
						{assign var=thiscustombgcolor value=$infocals.$k.custombgcolor}
						{assign var=thiscustomfgcolor value=$infocals.$k.customfgcolor}
						{assign var=thisinfocalsname value=$infocals.$k.name}
						{button href="#" _style="background-color:#$thiscustombgcolor;color:#$thiscustomfgcolor;border:1px solid #$thiscustomfgcolor;" _onclick="toggle('filtercal');" _text="$thisinfocalsname"}
					{/if}
				{/foreach}
				</div>
			{else}
				{button href="" _style="background-color:#fff;padding:0 4px;" _text="{tr}None{/tr}"}
			{/if}
		{/if}

	</div>



	<div class="navbar" align="right">
		{if $user and $prefs.feature_user_watches eq 'y'}
			{if $category_watched eq 'y'}
				{tr}Watched by categories{/tr}:
				{section name=i loop=$watching_categories}
					{assign var=thiswatchingcateg value=$watching_categories[i].categId}
					{button href="tiki-browse_categories.php?parentId=$thiswatchingcateg" _text=$watching_categories[i].name}
					&nbsp;
				{/section}
			{/if}	
		{/if}
	</div>

	{if count($listcals) >= 1}
		<form id="filtercal" method="get" action="{$myurl}" name="f" style="display:none;">
			<div class="caltitle">{tr}Group Calendars{/tr}</div>
			<div class="caltoggle">
				{select_all checkbox_names='calIds[]' label="{tr}Check / Uncheck All{/tr}"}				
			</div>
			{foreach item=k from=$listcals}
				<div class="calcheckbox">
					<input type="checkbox" name="calIds[]" value="{$k|escape}" id="groupcal_{$k}" {if $thiscal.$k}checked="checked"{/if} />
					<label for="groupcal_{$k}" class="calId{$k}">{$infocals.$k.name} (id #{$k})</label>
				</div>
			{/foreach}
			<div class="calinput">
				<input type="submit" name="refresh" value="{tr}Refresh{/tr}"/>
			</div>
		</form>
	{/if}

	{if $tiki_p_admin_calendar eq 'y'}
		<form id="exportcal" method="post" action="{$exportUrl}" name="f" style="display:none;">
			<input type="hidden" name="export" value="y"/>
			<div class="caltitle">{tr}Export calendars{/tr}</div>
			<div class="caltoggle">
				{select_all checkbox_names='calendarIds[]' label="{tr}Check / Uncheck All{/tr}"}
			</div>
			{foreach item=k from=$listcals}
				<div class="calcheckbox">
					<input type="checkbox" name="calendarIds[]" value="{$k|escape}" id="groupcal_{$k}" {if $thiscal.$k}checked="checked"{/if} />
					<label for="groupcal_{$k}" class="calId{$k}">{$infocals.$k.name}</label>
				</div>
			{/foreach}
			<div class="calcheckbox">
				<a href="{$iCalAdvParamsUrl}">{tr}advanced parameters{/tr}</a>
			</div>
			<div class="calinput">
				<input type="submit" name="valid" value="{tr}Export{/tr}"/>
			</div>
		</form>
	{/if}

	{include file="tiki-calendar_nav.tpl"}
	{if $viewlist eq 'list'}
		{include file="tiki-calendar_listmode.tpl"'}
	{elseif $viewmode eq 'day'}
		{include file="tiki-calendar_daymode.tpl"}
	{elseif $viewmode eq 'week'}
		{include file="tiki-calendar_weekmode.tpl"}
	{else}
		{include file="tiki-calendar_calmode.tpl"}
	{/if}
<p>&nbsp;</p>
</div>
