7 Replies Latest reply on Sep 20, 2010 10:32 AM by philmodjunk

    Need help for Time In and Time Out script

    xtremu

      Title

      Need help for Time In and Time Out script

      Post

      New at FileMaker Pro 11 Advanced..

      I have two fields Time In and Time Out

      Time In field to record the first entry of the student in the database and the Time Out field to record the second entry of the student and so on, like the third entry will go to the Time In field again  and fourth entry will go to the Time Out field again and loop it up to the last entry of the student in the database.

      Probably missing the obvious, but hopefully someone could help. Thank all

      xtremu

        • 1. Re: Need help for Time In and Time Out script
          philmodjunk

          TimeStamp fields with very simple scripts to log the time in and time out can do this, but I'm not sure I follow every detail of what you want here.

          Do you have one record for each student's in and out?

          How do you plan to log them in and out? Magstripe Card, Barcode reader, typed in password, just click a button...?

          • 2. Re: Need help for Time In and Time Out script
            xtremu

            Thanks for the quick reply Phil.

            I have student Information in my database, what i want is to record the time in and the time out of the student in my database everytime they scan thier ID. For example, if they have morning classes then they will scan their ID at the gate for their first entry in the database and I want to record it in the TIME IN field and when they go out then this is their second entry and I want it to record that time in the TIME OUT field and so on, the next entry will be recorded to TIME IN field again next to TIME OUT field or loop it up to the last entry of the student.We're using barcode scanner PhilModJunk.

            I have TImeStart and TimeEnd field both type are time in my student table phil.

            For example during Student Find:

            If

            First TimeScan = current time then :record that current time to the TimeStart field

            Second TimeScan > TimeStart then : record that current time to the TimeEnd field

            Third TimeScan > TimeEnd then : record that time to the TimeStart field again

            Fourth TimeScan > TimeStart then: record that time to the TimeEnd field again and so on up to last scan..

            Note: TimeScan is the time when they scan their ID.

            I read a lot of script at FM help but i can't figure out that phil, and it is also possible to show this time in and time out time at the portal? How phil? I know that you guys can help me solve this problem. Thanks in advance PhilModJunk.

            xtremu

            • 3. Re: Need help for Time In and Time Out script
              philmodjunk

              Still don't have a complete picture. I am assuming you'd want an ongoing log of each student's entry and exit by date so that you can see all the dates and times they have entered/left the facility.

              1. Using a script, I'd capture the scanned barcode text into a global field.
              2. Then another script would use the global field text to perform a find for all log records with that barcode value (student ID) where the TimeEnd field is empty.
              3. If more than one record is found, use the most recent record, but log an error as the student previously left without swiping their card.
              4. I no records are found, start a new record and log the time in the TimeStart field.

              You can set up your barcode scanner to put a character or group of characters at the beggining and end of the barcode text. You can use OnKeystroke script triggers to perform the above scripts each time a card is swiped.

              If there is any chance that a student could enter before midnight and leave after midnight, I'd use time stamp fields instead of time fields for this as this will enable much more accurate manipulation of the data for your reports.

              • 4. Re: Need help for Time In and Time Out script
                xtremu

                Yes PhilModJunk your right, I want to record in the database the ongoing log of each student's entry and exit by time only they have entered/left the school under the TimeStart and TimeEnd field.

                Fields related to TimeStart/End under Student Table

                StudentNumber         Number                          
                StudentID                  Number
                TimeStart                   Time
                TimeEnd                     Time

                My current script log only the current time in the TimeStart field PhilModJunk, how about the next log for TimeEnd field and so on.

                What is the possible script or calculation result for TimeEnd field?

                 

                Please help. Thanks

                • 5. Re: Need help for Time In and Time Out script
                  philmodjunk

                  The fields you list should be defined in a table separate from your student table. You should have one record per student in the Student table and One record for each time a student enters and leaves the facility in the Access Log table. They should be linked in a relationship like this:

                  Students::StudentID = AccessLog::StudentID

                  The second script I mentioned in my last post would look something like this and would be performed from an AccessLog based layout.

                  #First script puts the cursor in a global text field: AccessLog::gScan
                  Enter Find Mode[]
                  Set Field [AccessLog::StudentID ; AccessLog::gScan ]
                  Set Field [AccessLog::TimeEnd ; "=" ] // "=" with no data searches for a record where this field is empty
                  Set Error Capture [on]
                  Perform Find []
                  If [ get ( FoundCount ) = 1 /* This should be a student exit */ ]
                      Set Field [ AccessLog::TimeEnd ; Get ( CurrentTime ) ]
                  Else IF [ Get ( FoundCount ) > 1 /* error student exited without card being scanned */ ]
                      Sort [no dialog ; Restore ] //Sort on TimeStart in descending order
                      Go To Record [First ]
                      Set Field [ AccessLog::TimeEnd ; Get ( CurrentTime ) ]
                      //Do any extra steps here needed to handle fact that student left without scanning card on a previous date
                  Else //no records were found, bad scan or this is an entry
                      Enter Find Mode[]
                      Set Field [ AccessLog::TimeEnd ; Get ( CurrentTime ) ]
                      Perform Find []
                      If [ Get ( FoundCount ) > 0 /* Good scan, this is an entry */ ]
                          New Record/Request
                          Set Field [ AccessLog::TimeEnd ; Get ( CurrentTime ) ]
                      Else
                           Beep
                           Show Custom Dialog ["Student record not found, scan again or...."]
                      End If
                  End If

                  After thinking this through some more. You'll have an ongoing issue if there is any chance at all that a student can leave the facility without scanning their ID card. (Given human falibility, this is almost always possible, no matter how secure your facility.) Such an event will cause exits to be treated as entries and no error will be automatically detected. You might want to give some thought to having either two bar codes, one for entry and one for exit or two barcode scanners, each programmed with a different triggering character so that you have separate entry and exit scripts.

                  • 6. Re: Need help for Time In and Time Out script
                    xtremu

                    Thanks PhilModJunk for the quick and detailed response, I tried the script but i think Im lost since I am new in FM pro 11 Advanced. You got already what i'm planning to do with my database and interface. I want to log each student's entry and exit by TIME so that I can monitor all the times they have entered/left the school. My StudentNumber field is the field which correspond to the student Barcode on their ID. Anyway what is AccessLog::gScan you mentioned? Is it a part of AccessLog field which is Global type?

                    I want to start again with this: I have two tables,

                    Studet Table:                                                                                              AccessLog Table:

                    1. StudentID            (Number)                                                                     1. StudentID            (Number)

                    2. StudentNumber   (Number)                                                                      2. TimeStart             (Time)

                    3. Student Info's, like FN,LN,Add, Contact No (CN),etc.                                3. TimeEnd              (Time)

                                                                                                                                         4. gScan (add this field?) (Global?)

                    Relationships --------- Student::StudentID = AccessLog::StudentID?

                    A. I want to have a script on the File Options under Open/Close script that automatically trigger the StudentNumber field ready to find any records in the database and automatically record also the current time of that particular StudentNumber in the TimeStart and TimeEnd field in the Student Table. Something like this PhilModJunk,

                    Use Loop?

                    1.Scan =>Find StudentNumber from the database, If find and,

                    2. If there is NO TIME in TimeStart field:

                    3. Get Current Time and record that current time to TimeStart field

                    Else

                    4. If there is a TIME in the TimeStart fieldof that StudentNumber :

                    5. Get the Current Time and record that time to TimeEnd field //*(dont know the calculation or formula for this)

                    End loop?

                    B. Is it possible that all the TimeStart and TimeEnd of that Student will be recorded and shown it in their specific field (TS&TE), how to add that item or logs.

                    Thanks in advance for the big help PhilModjunk

                    xtremu

                     

                    • 7. Re: Need help for Time In and Time Out script
                      philmodjunk

                      You've got the basic idea.

                      Anyway what is AccessLog::gScan you mentioned? Is it a part of AccessLog field which is Global type?

                      Yes, gScan would be a text field with global storage enabled. In actual fact, gScan could be defined in any table in your database and it would still work in this script.

                      The detail, I'm not sure you are getting is the need to set up your scanner to work with keystroke script triggers.

                      Script 1 would simply do the following:

                      If [Get (TriggerKeyStroke) = "~"]
                         Go To Field [AccessLog::gScan]
                         Exit Script [False]
                      End IF

                      It's purpose would be to simply place the cursor in the field so that the scanned barcode text is put there and not in some other field. This will only work if you configure your scanner to put a "~" at the beginning of the scanned text. You could use any key or combination of keys you want for this--you can even include modifier keys such as caps lock, control or shift if you want.

                      Script 2 is the script I previously posted and it is triggered by another such keystroke set to be appended to the end of the scan.

                      By using keystroke triggers in this fashion, a student's id card is simply scanned and the FileMaker scripts automatically kick in and process the scanned barcode text.