<?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}Time sheets{/t}" default_view="display" orderby="begin" order="asc" limit="20" enable_new="true" enable_edit="true" enable_asset_rights="owner_read" trigger_new="duration|createedit_payroll" trigger_edit="duration|createedit_payroll" disable_paste="true" disable_quick_add="true">
  <view name="display" displayname="{t}Open{/t}" groupby="project" where="completed=0 and status!='{t}booked{/t}'">
  </view>
  <view name="completed" displayname="{t}Completed{/t}" groupby="username" where="completed=1 and status NOT IN ('{t}booked{/t}','{t}canceled{/t}')" template="display">
  </view>
  <view name="canceled" displayname="{t}Canceled{/t}" groupby="username" where="completed=1 and status='{t}canceled{/t}'" template="display">
  </view>
  <view name="booked" displayname="{t}Booked{/t}" groupby="costcenter" where="status='{t}booked{/t}'" template="display">
  </view>
  <view name="calendar" displayname="{t}Calendar{/t}" template="display" groupby="project" where="status!='{t}canceled{/t}'" enable_calendar="begin,ending">
  </view>
  <view name="details" displayname="{t}Details{/t}" tfield_1="subject" show_preview="true">
  </view>

  <viewbutton name="complete" views="display" displayname="{t}Complete{/t}" onclick="if (asset_form_selected()) asset_update_confirm({completed:'1'},assets_get_selected(true));" right="write" icon="enabled.gif" />
  <viewbutton name="confirm" views="completed" displayname="{t}Confirm{/t}" onclick="if (asset_form_selected()) asset_update_confirm({status:'{t}confirmed{/t}'},assets_get_selected(true));" right="write" icon="accept.gif" />
  <viewbutton name="cancel" views="display|completed" displayname="{t}Cancel{/t}" onclick="if (asset_form_selected()) asset_update_confirm({status:'{t}canceled{/t}'},assets_get_selected(true));" right="write" icon="disabled.gif" />

  <singlebutton name="complete" displayname="{t}Complete{/t}" onclick="asset_update_confirm({completed:'1'},'@id@');" condition="completed|neq|1||status|eq|{t}unconfirmed{/t}" right="write" icon="enabled.gif" />
  <singlebutton name="confirm" displayname="{t}Confirm{/t}" onclick="asset_update_confirm({status:'{t}confirmed{/t}'},'@id@');" condition="completed|eq|1||status|eq|{t}unconfirmed{/t}" right="write" icon="accept.gif" />
  <singlebutton name="book" displayname="{t}Book{/t}" onclick="bnr=prompt('{t}Booking number{/t}', ''); if (bnr!=null) asset_update({status:'{t}booked{/t}', booking_number:bnr},'@id@');" condition="completed|eq|1||status|oneof|{t}unconfirmed{/t},{t}confirmed{/t}" right="write" icon="book.gif" />
  <singlebutton name="cancel" displayname="{t}Cancel{/t}" onclick="asset_update_confirm({status:'{t}canceled{/t}'},'@id@');" condition="status|eq|{t}unconfirmed{/t}" right="write" icon="disabled.gif" />

  <field name="completed" displayname="{t}Completed{/t}" simple_type="checkbox">
    <INDEX/>
    <hiddenin views="display|completed|canceled|booked|calendar"/>
  </field>
  <field name="subject" displayname="{t}Title{/t}" simple_type="text" required="true">
    <linktext views="display|completed|canceled|booked|calendar" value="#index.php?view=details&amp;iframe=1&amp;item[]=@id@"/>
  </field>
  <field name="begin" displayname="{t}Begin{/t}" simple_type="datetime" simple_default_function="dateformat_request|begin|now - 8 hour|{t}m/d/Y g:i a{/t}" required="true" nowrap="true">
    <filter views="display|completed|canceled|booked|calendar" function="dateformat||{t}m/d/Y g:i a{/t}"/>
    <filter views="details" 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|{t}m/d/Y g:i a{/t}" required="true" nowrap="true">
    <filter views="all" function="shortdatetimeformat"/>
	<notin views="display|completed|canceled|booked"/>
    <INDEX/>
  </field>
  <field name="pause" displayname="{t}Pause{/t} [h]" simple_type="float" sum="true">
    <filter views="all" function="duration|hours"/>
	<notin views="display|completed|canceled|booked|calendar"/>
  </field>
  <field name="duration" displayname="{t}Duration{/t}" simple_type="int" sum="true">
    <filter views="all" function="duration|hours"/>
	<notin views="new|edit|edit_as_new"/>
  </field>
  <field name="description" displayname="{t}Description{/t}" simple_type="textarea">
    <notin views="display|completed|canceled|booked|calendar"/>
  </field>
  <field name="project" displayname="{t}Project{/t}" simple_type="select" simple_size="1">
	<data function="dbselect|simple_projects|projectname,projectname||projectname asc|10"/>
  </field>
  <field name="costcenter" displayname="{t}Cost center{/t}" simple_type="select" simple_size="1" required="true">
    <data function="dbselect|simple_costcenter|cname,cname|activated=1|cname asc|10"/>
    <notin views="display|calendar"/>
  </field>
  <field name="category" displayname="{t}Category{/t}" simple_type="select" simple_size="1" required="true" simple_default="{t}Regular{/t}">
	<data values="regular_##_{t}Regular{/t}|nightwork_##_{t}Nightwork{/t}|weekend_##_{t}Weekend{/t}|overtime_##_{t}Overtime{/t}|holiday_##_{t}Holiday{/t}|other_##_{t}Other{/t}"/>
	<data function="dbselect|simple_categories|categoryname,categoryname|cattype='timesheets'|categoryname asc|10"/>
    <notin views="completed|canceled|booked"/>
  </field>
  <field name="username" displayname="{t}Username{/t}" simple_type="select" simple_size="1" simple_default="anonymous" simple_default_function="getusername" required="true">
    <data function="dbselect|simple_sys_users|username,concat(lastname;' ';firstname)||lastname asc|10"/>
	<link value="index.php?find=asset|simple_sys_users||username=@username@&amp;view=details"/>
  </field>
  <field name="booking_number" displayname="{t}Booking number{/t}" simple_type="text" is_unique="true">
    <notin views="display|completed|calendar"/>
	<validate function="require_group|admin_payroll" />
  </field>
  <field name="attachment" displayname="{t}Attachment{/t}" simple_type="files" simple_file_size="10M" simple_size="10">
    <notin views="display|completed|canceled|booked|calendar"/>
  </field>
  <field name="status" displayname="{t}Status{/t}" simple_type="select" simple_size="1" required="true">
	<data values="{t}unconfirmed{/t}|{t}confirmed{/t}|{t}booked{/t}|{t}canceled{/t}"/>
	<validate function="require_group|admin_payroll|{t}confirmed{/t},{t}booked{/t}" />
	<hiddenin views="canceled|booked"/>
  </field>
</table>