<?xml version="1.0" encoding="utf-8"?>
<!--
	/**************************************************************************\
	* Simple Groupware 0.724                                                   *
	* http://www.simple-groupware.de                                           *
	* Copyright (C) 2002-2011 by Thomas Bley                                   *
	* ------------------------------------------------------------------------ *
	*  This program is free software; you can redistribute it and/or           *
	*  modify it under the terms of the GNU General Public License Version 2   *
	*  as published by the Free Software Foundation; only version 2            *
	*  of the License, no later version.                                       *
	*                                                                          *
	*  This program is distributed in the hope that it will be useful,         *
	*  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
	*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
	*  GNU General Public License for more details.                            *
	*                                                                          *
	*  You should have received a copy of the GNU General Public License       *
	*  Version 2 along with this program; if not, write to the Free Software   *
	*  Foundation, Inc., 59 Temple Place - Suite 330, Boston,                  *
	*  MA  02111-1307, USA.                                                    *
	\**************************************************************************/
-->
<table modulename="{t}Calendar{/t}" default_view="display" orderby="begin" order="asc" limit="20" enable_new="true" enable_edit="true" enable_delete="true" enable_empty="true" enable_calendar="begin,ending,recurrence,until,allday,repeatinterval,repeatexcludes,repeatbegin,repeatend" trigger_new="calcappointment|sync4j::createedit" trigger_edit="calcappointment|sync4j::createedit" trigger_delete="sync4j::delete">
  <view name="display" displayname="{t}Display{/t}" groupby="category">
  </view>
  <view name="details" displayname="{t}Details{/t}" tfield_1="subject" show_preview="true">
  </view>
  <view name="freebusy" displayname="{t}Free/busy{/t}" template="display" visibility="active" nosinglebuttons="true" noviewbuttons="history">
  </view>
  <singlebutton name="attend" displayname="{t}Attend{/t}" onclick="asset_update_confirm({participants:sys.username,participants_append:true},'@id@');" condition="participants|nlike|@username@" right="write" icon="user_add.gif" />
  <singlebutton name="dontattend" displayname="{t}Don't attend{/t}" onclick="asset_update_confirm({participants:sys.username,participants_remove:true},'@id@');" condition="participants|like|@username@" right="write" icon="user_delete.gif" />

  <tab name="general" displayname="{t}General{/t}" />
  <tab name="recurrence" displayname="{t}Recurrence{/t}" />
  <tab name="participants" displayname="{t}Participants{/t}" />

  <field name="subject" displayname="{t}Subject{/t}" simple_type="text" required="true">
    <notin views="freebusy"/>
    <linktext views="display" value="%index.php?folder=@folder@&amp;view=details&amp;item[]=@id@&amp;iframe=1"/>
  </field>
  <field name="createdby" simple_type="text" notinall="true">
    <onlyin views="freebusy"/>
  </field>
  <field name="begin" displayname="{t}Begin{/t}" simple_type="datetime" simple_default_function="dateformat_request|begin|now|{t}m/d/Y g:i a{/t}" required="true" nowrap="true">
    <filter views="all" function="shortdatetimeformat"/>
    <link value="index.php?view=display&amp;today=@begin@"/>
    <INDEX/>
	<description hint="{t}Relative formats{/t}" value="nWin('http://www.php.net/manual/en/datetime.formats.relative.php');"/>
  </field>
  <field name="ending" displayname="{t}End{/t}" simple_type="datetime" simple_default_function="dateformat_request|ending|now + 2 hour|{t}m/d/Y g:i a{/t}" required="true" nowrap="true">
    <filter views="all" function="shortdatetimeformat"/>
    <INDEX/>
  </field>
  <field name="duration" displayname="{t}Duration{/t}" simple_type="int" notinall="true" sum="true">
    <filter views="all" function="duration"/>
	<onlyin views="display|details"/>
  </field>
  <field name="allday" displayname="{t}All day{/t}" simple_type="checkbox" simple_default_function="fillform|allday" hidden="true" editable="true">
  </field>
  <field name="location" displayname="{t}Location{/t}" simple_type="select" simple_size="1" allow_custom="true">
    <data function="dbselect|simple_locations|locationname,locationname||locationname asc|10" />
    <notin views="freebusy"/>
	<link value="index.php?find=asset|simple_locations||locationname=@location@&amp;view=display"/>
	<description title="{t}Free/busy{/t}" value="show_freebusy_location('@prefix@');"/>
    <INDEX/>
  </field>
  <field name="description" displayname="{t}Description{/t}" simple_type="textarea">
	<notin views="display|freebusy" />
  </field>
  <field name="priority" displayname="{t}Priority{/t}" simple_type="select" simple_size="1" simple_default="3">
	<data reverse="true" values="1_##_{t}lowest{/t}|2_##_{t}low{/t}|3_##_{t}normal{/t}|4_##_{t}urgent{/t}|5_##_{t}immediate{/t}"/>
  </field>
  <field name="image" displayname="{t}Image{/t}" simple_type="files" simple_file_size="5M" simple_size="10">
    <validate function="fileupload|jpg,jpeg,gif,png"/>
	<notin views="display|freebusy" />
  </field>
  <field name="attachment" displayname="{t}Attachment{/t}" simple_type="files" simple_file_size="10M" simple_size="10">
	<notin views="display|freebusy"/>
  </field>
  <field name="recurrence" displayname="{t}Recurrence{/t}" simple_type="select" simple_size="1" simple_tab="recurrence">
    <data reverse="true" values="days_##_{t}daily{/t}|weeks_##_{t}weekly{/t}|months_##_{t}monthly{/t}|years_##_{t}yearly{/t}"/>
  </field>
  <field name="repeatinterval" displayname="{t}Repeat interval{/t}" simple_type="int" simple_default="1" simple_tab="recurrence">
    <filter views="all" function="calendar_repeat"/>
  </field>
  <field name="repeatcount" displayname="{t}Repeat count{/t}" simple_type="int" simple_default="0" simple_tab="recurrence">
    <filter views="all" function="calendar_repeat"/>
  </field>
  <field name="repeatuntil" displayname="{t}Repeat until{/t}" simple_type="date" simple_tab="recurrence">
    <filter views="all" function="dateformat||{t}m/d/Y{/t}"/>
  </field>
  <field name="repeatexcludes" displayname="{t}Repeat exclusions{/t}" simple_type="dateselect" separator=", " simple_tab="recurrence">
    <filter views="all" function="dateformat||{t}m/d/Y{/t}"/>
  </field>
  <field name="nrecurs" displayname="{t}Next recurrences{/t}" simple_type="text" simple_tab="recurrence">
	<filter views="all" function="recurrences|4|NOW|recurs"/>
	<onlyin views="details"/>
	<!-- TODO link days -->
  </field>
  <field name="recurs" displayname="{t}Recurrences{/t}" simple_type="textarea" simple_tab="recurrence">
	<filter views="all" function="recurrences|10"/>
	<onlyin views="details"/>
  </field>
  <field name="until" simple_type="int" simple_default="0" hidden="true">
    <INDEX/>
  </field>
  <field name="repeatbegin" simple_type="int" notinall="true">
    <INDEX/>
  </field>
  <field name="repeatend" simple_type="int" notinall="true">
    <INDEX/>
  </field>
  <field name="occurs" simple_type="textarea" notinall="true">
  </field>
  <field name="occurs_weeks" simple_type="textarea" notinall="true">
  </field>
  <field name="repeatbegin" simple_type="int" notinall="true">
    <INDEX/>
  </field>
  <field name="repeatend" simple_type="int" notinall="true">
    <INDEX/>
  </field>
  <field name="organizer" displayname="{t}Organizer{/t}" simple_type="select" simple_size="1" simple_tab="participants" allow_custom="true">
    <data function="dbselect|simple_sys_users|username,concat(lastname;' ';firstname)||lastname asc|10"/>
	<notin views="freebusy"/>
	<link value="index.php?find=asset|simple_sys_users||username=@organizer@&amp;view=details"/>
  </field>
  <field name="participants" displayname="{t}Participants (internal){/t}" simple_type="select" simple_size="5" simple_tab="participants">
    <data function="dbselect|simple_sys_users|username,concat(lastname;' ';firstname)||lastname asc|10"/>
	<notin views="freebusy"/>
	<description title="{t}Free/busy{/t}" value="show_freebusy('@prefix@');"/>
	<link value="index.php?find=asset|simple_sys_users||username=@participants@&amp;view=details"/>
  </field>
  <field name="participants_ext" displayname="{t}Participants (external){/t}" simple_type="select" simple_size="5" simple_tab="participants" allow_custom="true">
    <data function="dbselect|simple_contacts|contactid,concat(lastname;' ';firstname)||lastname asc|10"/>
	<notin views="freebusy"/>
	<link value="index.php?find=asset|simple_contacts||contactid=@participants_ext@&amp;view=details"/>
  </field>
  <field name="category" displayname="{t}Category{/t}" simple_type="select" simple_size="1">
	<data sort="asc" values="{t}Birthday{/t}|{t}Business{/t}|{t}Competition{/t}|{t}Favorites{/t}|{t}Gifts{/t}|{t}Holiday{/t}|{t}Ideas{/t}|{t}Key customer{/t}|{t}Miscellaneous{/t}|{t}Objectives{/t}|{t}Personal{/t}|{t}Phone calls{/t}|{t}Status{/t}|{t}Strategies{/t}|{t}Suppliers{/t}|{t}Time and expenses{/t}|{t}Vacation{/t}" />
	<data function="dbselect|simple_categories|categoryname,categoryname|cattype='calendar'|categoryname asc|10"/>
	<notin views="freebusy"/>
  </field>
  <field name="reminder" displayname="{t}Reminder{/t}" simple_type="select" simple_size="1" db_type="int">
	<data values="300_##_5 minutes|600_##_10 minutes|900_##_15 minutes|1200_##_20 minutes|1800_##_30 minutes|2700_##_45 minutes|3600_##_1 hour|7200_##_2 hours|10800_##_3 hours|18000_##_5 hours|86400_##_1 day|172800_##_2 days|259200_##_3 days|604800_##_1 week" />
	<notin views="display|freebusy"/>
    <filter views="all" function="duration"/>
  </field>
  <field name="syncid" simple_type="id" hidden="true">
  </field>
</table>