11 Replies Latest reply on Aug 5, 2013 10:07 PM by GuyStevens

    Staff time stamping

    AustinEckman

      Title

      Staff time stamping

      Post

      How do I make it so that someone picks their name from a staff member list and then hits a login button a script runs to save their timestamp to a timecard of their own. I have it to the point where they pick their name and press the button but I think I did the script wrong because it doesnt do anything to the timestamp database. 

            

      I have as my three databases and layouts

      TimeCard - TimestampIn, TimestampOut, Id,

      EmpCard - FirstName, LastName, Id,

      LoginScreen - NameList, Acceptbutton, 

            

      How do you suggest I have my relationships and if anyone is good at scripting can they help me? Thank you so much for reading this I am kinda new here.

        • 1. Re: Staff time stamping
          GuyStevens

               Hey Austin, Guy Stevens here from Youtube.

               Here's the simple way to do it.

               Table "Employees"
               ID - A number field set to auto enter a serial number
               FirstName - Text field
               LastName - Text field
               c_FullName - Calculation fiels. The calculation would be:  FirstName & " " & LastName

               Table "Timecards"
               ID - A number field set to auto enter a serial number
               EmployeeIdFk - A Number field - Here we will be storing the ID of the Employee; This is called a foreign key.
               TimestampIn - A Timestamp field
               TimestampOut - A Timestamp field

          Relationship

               The relationship is between the ID field in the Employee table and the EmployeeIdFk field in the Timecards table.

               Then you create a list view layout based on the Employees table to display all the employees. And in the body part you create two buttons.
               "Clock in" and "Clock Out"

          Script

               The script performed by the "Clock In" button:

               - Set Variable [ $EmployeeId ; Employee::ID ]
               This means there are two settings to make here, the name of the variable ($Employee) and the value for this variable. This would be the ID field in the Employee table. We will be taking this value with us to another table.
               - Freeze Window
               - Go To Layout [A layout based on the Timecards table] possibly a simple layout in table view.
               - Create new record / request
               - Set Field [Timecards::EmployeeId ; $EmployeeId]
               This is where we set the variable we created in the beginning of the script into a field.
               - Set Field [Timecards::TimestampIn ; Get (CurrentTimestamp) ]
               - Go to Layout (Original)

               There, now this is all off the top of my head, but it should be something like this.

               If you want you can add all kinds of funky things to make it all smoother and prettier, but basically this is it.

               The clock out script can be done very simply, you can set the TimestampOut field in the related Timestamp record but you need to make sure your relationship is sorted so that the most recent record is sorted on top.

               Then the script is a simple set field step where you set the Timestamp::TimestampOut field to the value os: Get ( CurrentTimestamp )

               If you need any help, just let us know.

          • 2. Re: Staff time stamping
            AustinEckman

                 Thanks it works fine! I will come back to you if I need any more help but thanks again!

            • 3. Re: Staff time stamping
              AustinEckman

                   Is there a way to have it so that you cant clock in two times without clocking out?

              • 4. Re: Staff time stamping
                GuyStevens

                     Clocking in always makes a new record. So clocking out always happens on the last record you created.

                     What is it you would like to avoid?

                     Accidents, or tampering?

                     Because what if someone forgets to clock out? And clocks in again the next day without having clocked out the previous day?

                     Maybe your script could do a find on the date and check if a record already exists of a clock in on the current date.

                     And if so doesn't allow a new clock in record.

                      

                • 5. Re: Staff time stamping
                  AustinEckman

                       Thats a good idea, any tips on how to code that though I am not that good at this yet :P Thanks again though for helping!

                  • 6. Re: Staff time stamping
                    AustinEckman

                         People will be signing in at night and signing out the morning of the next day so that wouldnt work out 

                          

                    • 7. Re: Staff time stamping
                      GuyStevens

                           Maybe you can perform a find between the current timestamp and something like 8 hours ago to see if the person checked in during that timeframe.

                           In calculating with timestamps you would need to subtract the amount of seconds. 8 hours is 28800 seconds.

                           I made a quick test file:

                      https://dl.dropboxusercontent.com/u/18099008/Demo_Files_FMP12/Timecards.fmp12

                            

                      • 8. Re: Staff time stamping
                        AustinEckman

                             Thank you, thats how I will do that! :)

                        • 9. Re: Staff time stamping
                          GuyStevens

                               I forgot to sort the relationship.

                               That means you will always see the first check in and check out in the list layout.

                               I just changed that in my example file, so you can re-download it and look at the sort I defined in the relationship between the two tables.

                          • 10. Re: Staff time stamping
                            AustinEckman

                                 For the total time worked how do you get it where it only shows the hours and minutes mine is showing seconds also and I dont want that. I tried to copy what you had but it didnt work

                                  

                            • 11. Re: Staff time stamping
                              GuyStevens

                                   In layout mode, select the Merge Field and then in the inspector (I think in the Data tab) change the display format to time. There you can choose the format to hh:mm