kamshory / ZKLibrary

ZKLibrary is PHP library for reading and writing data to attendance device using UDP protocol. This library useful to comunicate between web server and attendance device directly without addition program. This library is implemented in the form of class. So that you can create an object and use it functions.
GNU General Public License v2.0
194 stars 176 forks source link

Attendance data format #10

Open RahamSher opened 6 years ago

RahamSher commented 6 years ago

@kamshory I have the array of all attendances.My array structure is like this. [0] => 1 [1] => 1 [2] => 8 //it is state.What does this means for??? [3] => 2016-12-27 11:51:33

And one more thing that I have all the attendances of users,Please guide me that how I differentiate the check in and check out of user.

kamshory commented 6 years ago

The state maybe difference each device. Normally, we don't need the state. The state of check in and check out can be determined from the sequence of attendance at certain time intervals. You should compare it with other attendance at that time span, for example employee shifts.

kamshory commented 6 years ago

My best practice, I get the attendance data and I save it into the database. I create a event trigger on the table on insert. If there is no attendance of the user at the time span, so the attendance will be considered as check in, else the attendance will be considered as check out. To get the real check out, select the last attendance of the user at the time span. But if the is only one attendance of the user at the time span, check out is not exist.

RahamSher commented 6 years ago

@kamshory hats off.Thank you sir...

abdulraheemzaqout commented 6 years ago

sir can i take the break time??

kamshory commented 6 years ago

I have any time. Tell me what can I do.

abdulraheemzaqout commented 6 years ago

hello sir i mean can i take the break in /out for employee?

kamshory commented 6 years ago

I live in Jakarta. How do we can talk?

abdulraheemzaqout commented 6 years ago

Dear kamashory Using Skype My skype ID is abdzozo this is in this pic [cid:image001.png@01D3985A.3A7A2B80]

Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10

From: Kamshory, MTmailto:notifications@github.com Sent: Saturday, January 27, 2018 1:46 AM To: kamshory/ZKLibrarymailto:ZKLibrary@noreply.github.com Cc: abdulraheemzaqoutmailto:abd96_2014@hotmail.com; Commentmailto:comment@noreply.github.com Subject: Re: [kamshory/ZKLibrary] Attendance data format (#10)

I live in Jakarta. How do we can talk?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kamshory/ZKLibrary/issues/10#issuecomment-360936225, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AeQmarwWVrli0LdldoyDBWgPb_nPL2beks5tOmPRgaJpZM4P5zUD.

junaidranjha commented 6 years ago

@RahamSher were you able to differtentiate between check in and check out? If yes, then how?

kamshory commented 6 years ago

The first check on the day is check in and the last check on the day is check out. So, at least user check twice in a day.

wombiro commented 5 years ago

So is the checkin/checkout showing now?

abdulraheemzaqout commented 5 years ago

sir i want to take the leave time from the machine and the overtime can i take this moves??

gusbenites commented 5 years ago

In the Zkteco MB360 the check in and check out value is in position 66 and they are 2 characters.

00: entry 01: output 04: intermediate entry 05: intermediate output

zkattendance.php in zkgetattendance($self) function


while ( strlen($attendancedata) > 40 ) {
                $u = unpack( 'H78', substr( $attendancedata, 0, 39 ) );
                //24s1s4s11s

                //$uid = hexdec( substr( $u[1], 0, 6 ) );
                //$uid = explode(chr(0), $uid);
                //$uid = intval( $uid[0] );
                /*$u1 = hexdec( substr($u[1], 4, 2) );
                $u2 = hexdec( substr($u[1], 6, 2) );
                $uid = $u1+($u2*256);*/
                $uid = trim(substr( $attendancedata, 4, 14 ), "\x0");

                $id = intval( str_replace("\0", '', hex2bin( substr($u[1], 6, 8) ) ) );
                $state = hexdec( substr( $u[1], 56, 2 ) );
                $timestamp = decode_time( hexdec( reverseHex( substr($u[1], 58, 8) ) ) ); 
                $sentido =hexdec(substr($u[1], 66,2));  // <---------------- check in - check out
                # Clean up some messy characters from the user name
                #uid = unicode(uid.strip('\x00|\x01\x10x'), errors='ignore')
                #uid = uid.split('\x00', 1)[0]
                #print "%s, %s, %s" % (uid, state, decode_time( int( reverseHex( timestamp.encode('hex') ), 16 ) ) )

               array_push( $attendance, array( $uid, $id, $sentido, $timestamp, $state  ) ); // <-- modify

                $attendancedata = substr( $attendancedata, 40 );
            }`