# Timeclock Implementation Requirements - Discussion

**URL:** <https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842>\
**Category:** V4 Question\
**Created:** [October 3, 2014, 3:44pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842 "2014-10-03T15:44:28Z")\
**Posts on this page:** 17\
**Page:** 7

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 4:13am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/121 "2014-10-06T04:13:34Z")

</div>

Ooh check these bad boys out.

```
{REPORT ENTITY STATE DETAILS:X} Entity State Details
{REPORT ENTITY STATE TOTAL DURATION:X} Entity State Total Duration
{REPORT ENTITY STATE TOTAL HOURS:X} Entity State Total Hours
{REPORT ENTITY STATE TOTAL MINUTES:X} Entity State Total Minutes
{REPORT ENTITY STATE TOTAL SECONDS:X} Entity State Total Seconds
{ENTITY STATE ENTITY LIST:X} Entity State Log Entity Names
{ENTITY STATE START DATE LIST:X} Entity State Log Start Dates
{ENTITY STATE END DATE LIST:X} Entity State Log End Dates

```

EDIT: I cannot seem to get these to work… @QMcKay any luck? Most of them crash… ive had a few attempts not crash but nothing reports.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 4:55am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/123 "2014-10-06T04:55:57Z")

</div>

Guess I will wait to see the values for X

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 6, 2014, 6:34am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/124 "2014-10-06T06:34:57Z")

</div>

> [@Jesse](#):
>
> What if you tell it what State is start and what state is end… so it only looks for those states… instead of [:StateStart] do PunchIn

That’s what I was thinking. But it doesn’t quite work that way… I thought maybe it would pull the EndDate from the 2nd row and make it the StartDate in the first row (note: records are sorted to show most recent first)

 ![](https://forum.sambapos.com/uploads/default/original/3X/c/8/c85201ead1142bdecf03ffef4748aee255f10e89.png) 

Hmmm… I wonder now about maybe I could try setting `Async` to **False**?

EDIT: I’ve also been wondering how it knows to set `StartState` to **PunchOut** in the Log when you _Clock In_ for the first time?

EDIT: I give up on that for now (I won’t be using Break/Lunch States anyway, so I removed those choices - I was just trying to get a handle on how the Logging worked)

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [October 6, 2014, 9:33am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/125 "2014-10-06T09:33:12Z")

</div>

If it is not important you can keep in/out and create a separate state flow for break & lunch statuses.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 6, 2014, 9:38am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/126 "2014-10-06T09:38:16Z")

</div>

My simple TimeClock Implementation - it is not tied to Users or Logins and does not require PIN:

> [@Time Clock - Basic - Employee Entities (not users)](http://forum.sambapos.com/t/time-clock-simple-employee-entities-not-users/2881):
>
> Basic TimeClock implementation using Employee Entities (not Users) and 2 Entity States called PunchIn and PunchOut. REQUIRED: SambaPOS v4.1.65 + REQUIRED: Custom Report Module from [SambaMarket.com](http://SambaMarket.com) Database Tools Import Files: Automation (Automation Commands, Actions, Rules): [TimeClock\_Automation.zip](https://forum.sambapos.com/uploads/default/original/3X/1/5/15d11fcf8f8a0ef8d348d96cf9a530a45a0698e1.zip) (2.1 KB) Entity Type, Entity Screen, States [TimeClock\_EntityType\_EntityScreen\_States.zip](https://forum.sambapos.com/uploads/default/original/3X/2/7/27bc86fe4d05332c39606c45d7a7c7701b66f8b0.zip) (1.5 KB) FLOW: Button to show TimeClock screen: TimeClock screen with 4 Employee Entities…

---

<div class="post-metadata">

**Author:** ![emre](https://forum.sambapos.com/user_avatar/forum.sambapos.com/emre/32/39073_2.png) [@emre](https://forum.sambapos.com/u/emre)\
**Post date:** [October 6, 2014, 9:58am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/127 "2014-10-06T09:58:17Z")

</div>

For @QMcKay, @Jesse and other people who installed test releases…

Please check `EntityStateLogs` table and if that foreign key and index does not exists create them for better performance and stability.

```
ALTER TABLE [EntityStateLogs] ADD CONSTRAINT [FK_dbo.EntityStateLogs_dbo.Entities_EntityId] FOREIGN KEY ([EntityId]) REFERENCES [Entities] ([Id]) ON DELETE CASCADE 

```

and

```
CREATE NONCLUSTERED INDEX [IX_EntityId] ON [EntityStateLogs]([EntityId] ASC)
```

---

<div class="post-metadata">

**Author:** ![gerlandog](https://forum.sambapos.com/user_avatar/forum.sambapos.com/gerlandog/32/39076_2.png) [@gerlandog](https://forum.sambapos.com/u/gerlandog)\
**Post date:** [October 6, 2014, 11:27am UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/128 "2014-10-06T11:27:20Z")

</div>

> [@emre](#):
>
> test releases…

What I am missing here???

I cannot keep up… please SLOW DOWN!!!

G.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 6, 2014, 4:55pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/129 "2014-10-06T16:55:03Z")

</div>

@emre, you’re probably in the middle of writing a Tutorial that explains this; if so, feel free to ignore me…

Can you elaborate on what this function actually does? `Log Entity State`

- what does the `Async` True/False option do?

- **DISREGARD THIS QUESTION… Answer: No. `[EntityStateValues]` contains last known State and Date/Time**. I have a suspicion that it does not just log what you tell it to, instead it _ **reads** _ the last known State `[EndState]` from the Log based on `MAX([EndStateDate])` _first_, then performs the Logging _ **write** _ as requested. Is this True?

- **DISREGARD THIS QUESTION… Answer: `[EntityStateValues]` contains last known State and Date/Time**. If there is no Log Data (table `[EntityStateLogs]` is _empty_), and (presumably) the Entity is ‘_Stateless_’ (i.e. immediately after application launch), how does it know what to write into `[StartState]`? For me in this case, it seems to magically write _ **PunchOut** _ which is perfect, but how does it decide to do that?

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 6:00pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/130 "2014-10-06T18:00:31Z")

</div>

I just posted a link for the Database Tools import file for my Time Clock implementation. Few things you need to do and will be explained in more detail in the tutorial… Create your Employee entities … create users with same name… enter the same pin for both the entities and the users.

> [@On another topic](https://forum.sambapos.com/t/2797/1):
>
> Time Clock linked by Users: Tutorial will be posted soon it is in development. If not sure what to do then wait for tutorial before installing.Time Clock.zip (2.4 KB)

---

<div class="post-metadata">

**Author:** ![sukasem](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@sukasem](https://forum.sambapos.com/u/sukasem)\
**Post date:** [October 6, 2014, 7:13pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/131 "2014-10-06T19:13:54Z")

</div>

Can’t wait for official time clock release!  
It should have button in the main screen with Work Period, POS…right.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 7:14pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/132 "2014-10-06T19:14:35Z")

</div>

Personally I don’t like using the main screen for said function.

---

<div class="post-metadata">

**Author:** ![sukasem](https://forum.sambapos.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@sukasem](https://forum.sambapos.com/u/sukasem)\
**Post date:** [October 6, 2014, 7:17pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/133 "2014-10-06T19:17:23Z")

</div>

Or make Automation Button at the main entity screen

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 7:24pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/134 "2014-10-06T19:24:48Z")

</div>

I have a system that sort of answers that I am about to make it live.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 6, 2014, 7:56pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/135 "2014-10-06T19:56:06Z")

</div>

> [@sukasem](#):
>
> Can’t wait for official time clock release!It should have button in the main screen with Work Period, POS…right.

I think this is as “official” as it’s going to get for the next while. The added feature ( **`Log Entity State`** ) has allowed us to build a _basic_ TimeClock, but the feature can also be used for many other things (i.e. tracking table usage)… My guess is _that_ is the _primary reason_ for this feature addition, because it is not specific to TimeClock. I think we’ll be waiting a long while for an “official” TimeClock…

That said, this feature is _very_ powerful, and can be used to build a very decent TimeClock Implementation, _immediately_. How you do it is up to you.

@Jesse, in his implementation, links Employee `Entities` to `Users` and the `Login/Logout` mechanism, while _my_ posted implementation is _very_ basic to show _minimum requirements_ to implement it…

> [@Time Clock - Basic - Employee Entities (not users)](http://forum.sambapos.com/t/time-clock-basic-employee-entities-not-users/2881):
>
> Basic TimeClock implementation using Employee Entities (not Users) and 2 Entity States called PunchIn and PunchOut. REQUIRED: SambaPOS v4.1.65 + REQUIRED: Custom Report Module from [SambaMarket.com](http://SambaMarket.com) Database Tools Import Files: Automation (Automation Commands, Actions, Rules): [TimeClock\_Automation.zip](https://forum.sambapos.com/uploads/default/original/3X/1/5/15d11fcf8f8a0ef8d348d96cf9a530a45a0698e1.zip) (2.1 KB) Entity Type, Entity Screen, States [TimeClock\_EntityType\_EntityScreen\_States.zip](https://forum.sambapos.com/uploads/default/original/3X/2/7/27bc86fe4d05332c39606c45d7a7c7701b66f8b0.zip) (1.5 KB) FLOW: Button to show TimeClock screen: [image] TimeClock screen with 4 Employee Entities: …

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 6, 2014, 8:51pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/136 "2014-10-06T20:51:09Z")

</div>

> [@QMcKay](#):
>
> the feature can also be used for many other things (i.e. tracking table usage)… My guess is that is the primary reason for this feature addition

Another cool thing this might open up is the Order State tracking. You can track average time for an order to hit the kitchen vs Ready… You can track delivery times… all sorts of really cool things. This will enhance Kitchen screens…

EDIT: Sorry I jumped the gun Order State Logging is not currently available.

---

<div class="post-metadata">

**Author:** ![QMcKay](https://forum.sambapos.com/user_avatar/forum.sambapos.com/qmckay/32/27925_2.png) [@QMcKay](https://forum.sambapos.com/u/QMcKay)\
**Post date:** [October 7, 2014, 1:39pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/137 "2014-10-07T13:39:30Z")

</div>

> [@Jesse](#):
>
> Order State tracking

> [@emre](#):
>
> First of all that will be specific to Entity States.

While I did mention the design could have been made for any type of State, that’s not what we have here. It is specific to Entities [_Entity_StateLogs]… it won’t log Ticket or Order States, however…

> [@emre](#):
>
> Of course it will be easier to implement same thing for other states but there is no reason to make querying harder as we never need to query other state types together.

So it sounds like @emre could do some copy/paste of code to implement it for Ticket and Order withou too much hassle.

---

<div class="post-metadata">

**Author:** ![Jesse](https://forum.sambapos.com/user_avatar/forum.sambapos.com/jesse/32/61493_2.png) [@Jesse](https://forum.sambapos.com/u/Jesse)\
**Post date:** [October 7, 2014, 1:40pm UTC](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842/138 "2014-10-07T13:40:25Z")

</div>

Yeah sorry I got ahead of myself. You are correct it is not ready for that yet. I tried to say in the future… when I said “might open up” I just used bad wording.

[Previous page](https://forum.sambapos.com/t/timeclock-implementation-requirements-discussion/2842.md?page=6)
