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

getting attendance data #4

Closed junaidranjha closed 3 years ago

junaidranjha commented 6 years ago

untitled my device is connected i can get user data and attendance data but problem is i am not able to get attendance of last whole month its like if i am accessing getattendance() it returns data from last months 31st uptill now while i want it to get all the data.

kamshory commented 6 years ago

I have test it using Solution X100-C and there is no problem. Can you tell me about your device?

junaidranjha commented 6 years ago

Thanks for the reply my device name is ZKT Iface 302. As i told earlier i am able to connect the device with help of this library but the problem is when i get attendance data through its getattendance() method i only get data from 31st of last month while i neeed more data as i require data of last whole month

On Tue, Sep 19, 2017 at 2:23 PM, Kamshory, MT notifications@github.com wrote:

I have test it using Solution X100-C and there is no problem. Can you tell me about your device?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kamshory/ZKLibrary/issues/4#issuecomment-330482074, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac0-wJdM67rG2Jw4lXasxAAZeAlhueyDks5sj4gjgaJpZM4PXS0V .

kamshory commented 6 years ago

How much data that you can retrieve using this library? In my case, I can get more than 3000 attendance data and not limited by date.

junaidranjha commented 6 years ago

I am getting like 3712 records right now. The problem is i don,t need data of this month but the previous month i have applied those checks in my php code but that only shows me data of 31st and of last month and that is beacause the oldest record i can see from this library data is 31st of last month and then onwards.

kamshory commented 6 years ago

Oh. I see. You can read data from the device and save it into you database. You can clear attendance data on your device after you save it on the database. Then you can read data from your database and you can filter it by time and others.

junaidranjha commented 6 years ago

Is there a way to get all data present on the device? I mean is there any other method rather than get attendance to get whole data of device

kamshory commented 6 years ago

You can not filter attendance data when you get it directly from the device because the firmware is not designed for this purpose.

junaidranjha commented 6 years ago

Yes, i understand that what I am doing is getting data from get attendance method but this method is not able to show whole data like from the start of the day is there any other method to get whole data from a database of the device?

kamshory commented 6 years ago

If you want to add filter, you can modify the library but you MUST read all data first. You can skip data if it not match with your filter. So the function will not return the skipped data.

junaidranjha commented 6 years ago

So you are saying get attendance method of this library doesn't have a limitation and it shows all the data(from beginning) right?

kamshory commented 6 years ago

Yes.

junaidranjha commented 6 years ago

Alright, thanks a lot for your help.

kamshory commented 6 years ago

OK. You are welcome. I hope this library helps you.

junaidranjha commented 6 years ago

Yeah, it really helped me a lot keep doing wonders like this. Thumbs Up.

RahamSher commented 6 years ago

@kamshory & @junaidranjha Sir please guide me that how I differentiate check in check out of a user in my attendance.

harisklana commented 6 years ago

brother how i can get all data attandence check in and chect out thanks so much brother

RahamSher commented 6 years ago

Dear @harisklana I know its too late to reply but it never too late to mend.Any how please visit the following link and use that library. https://github.com/dnaextrim/php_zklib

kamshory commented 6 years ago

You can use code bellow:

<?php
include "zklibrary.php";
$zk = new ZKLibrary('192.168.1.102', 4370);
$zk->connect();
$zk->disableDevice();

$data = $zk->getAttendance();
foreach($data as $key=>$value)
{
    $uid = $value[0];
    $id = $value[1];
    $state = $value[2];
    $time = $value[3];
    $sql = "insert into attendace(uid, id, state, time) values
    ('$uid', '$id', '$state', '$time')
    ";
    mysql_query($sql);
}
//$zk->clearAttendance();
?>
klowor88 commented 6 years ago

I use primatech machine. is it also?

kamshory commented 6 years ago

I think so.

kamshory commented 6 years ago

I think so.

rajaanas786 commented 6 years ago

well with the db insertion code you wrote above it inserts 0 in status... Which is incorrect

marcoscolombo66 commented 6 years ago

Hi, excelent your job. Do you know if there is something to be able to save in real time using the adms? Thank you very much

neel55555 commented 6 years ago

Hi, i have two ZKTeco attendance devices. Both are ZKTeco Multi-Bio 800. One of them is manufactured in 2016 and another in 2017. I can get user data from both devices but only getting attendance log from the device manufactured in 2016. I don't know whats wrong with the new device. It is not sending attendance log. Could you please help me to figure out the issue. The software shipped with the device-2017 works properly and fetches attendance log. Please help me to figure out the issue. Thanks in advance.

achsany commented 6 years ago

@kamshory , saya sdah pakai zklib anda dan berhasil ambil data.

  1. untuk melihat status masuk dan keluar bagaimana? (status semua 1 atau check in)
  2. dapatkah dibuat realtime? ( jika ada yang menggunakan fingerprint maka ada notifikasi di sistem) Thanks
maynar commented 5 years ago

Hi , we got a software that manage Zkteco pull devices , does anybody has http get / post protocol to manage Zkteco devices with ADMS function ?

cortejojicoy commented 5 years ago

capture111

can anyone help this error. thanks in advance

kamshory commented 5 years ago

You have an internal error on your script or server configuration.

cortejojicoy commented 5 years ago

You have an internal error on your script or server configuration.

I'll try this zklib granding

but no result of info.. Im using 5000T-C Granding TFT.

warwar9 commented 5 years ago

image why the attendance time "1970-01-01 01:00:00/2000-01-01 01:00:00" of attendance data are wrong. This must be current date and time. how will i fix it ? Could u help me?

warwar9 commented 5 years ago

image The results of attendance data with wrong attendance time from fingerprint. Could u tell me how to fix it?

kamshory commented 5 years ago

It can be time encoding on your version of the firmware. You can fix it by modify the function

    private function decodeTime($data)
    {
        $second = $data % 60;
        $data = $data / 60;
        $minute = $data % 60;
        $data = $data / 60;
        $hour = $data % 24;
        $data = $data / 24;
        $day = $data % 31+1;
        $data = $data / 31;
        $month = $data % 12+1;
        $data = $data / 12;
        $year = floor( $data + 2000 );
        $d = date("Y-m-d H:i:s", strtotime($year.'-'.$month.'-'.$day.' '.$hour.':'.$minute.':'.$second));
        return $d;
    }
warwar9 commented 5 years ago

This code is already added. But the result attendance time is still wrong. How will i fix it? image

kamshory commented 5 years ago

I mean that you MUST change the code by yourself. You MUST know the time encoding of your firmware. You can debug your code before you save your data to the database.

full-stack-king commented 5 years ago

Hi @kamshory is there any way to check if my device firmware supports filtering data directly from the device.?

e-time track lite windows app works fine when fetching all data, but my PHP code times out after 15 mins. So, it would be good to take only small amount of data out of device (it is currently holding around 100K records)

rediamoe commented 5 years ago

capture

please help

maynar commented 5 years ago

Hi Kmshory,

We are looking for Push Sdk documentation , can you kindly share such doc with us?

Thanks in advance .

Ivan

El El sáb, 13 oct. 2018 a las 02:48, Kamshory, MT notifications@github.com escribió:

I mean that you MUST change the code by yourself. You MUST know the time encoding of your firmware. You can debug your code before you save your data to the database.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kamshory/ZKLibrary/issues/4#issuecomment-429516532, or mute the thread https://github.com/notifications/unsubscribe-auth/AXMYwiipasqAeOlkT3Y69D7UKWCRD0CXks5ukYzAgaJpZM4PXS0V .

-- Enviado con Gmail Mobile

pabloruizfaundez commented 5 years ago

Hello, I have the ZKTeco SF200 TCP, and I have not been able to make it work. Any recommendation? Thanks...

muzafar commented 5 years ago

Hi, could you please help me how can i get current month data?

muzafar commented 5 years ago

brother how i can get all data attendance check in and check out thanks so much brother

brother have you got this work? i need the same and also i want to get the data for current month only?

junaidranjha commented 5 years ago

brother how i can get all data attendance check in and check out thanks so much brother

brother have you got this work? i need the same and also i want to get the data for current month only?

By get attendance you get all the data now it isn't a good way but in my case in foreah loop of get_attendance() data add an if check regarding the date

RahamSher commented 5 years ago

@muzafar First of all you need to retrieve the data from your device/machine and populate that into your database.From there you may reach to your goal.But if you are not doing like this then you will retrieve the data as a whole and then will going to filter that. And if you the solution besides this please share.

junaidranjha commented 5 years ago

@muzafar First of all you need to retrieve the data from your device/machine and populate that into your database.From there you may reach to your goal.But if you are not doing like this then you will retrieve the data as a whole and then will going to filter that. And if you the solution besides this please share.

$data = $zk->getAttendance(); foreach($data as $key=>$value) { $uid = $value[0]; $id = $value[1]; $state = $value[2]; $time = $value[3]; $sql = "insert into attendace(uid, id, state, time) values ('$uid', '$id', '$state', '$time') "; mysql_query($sql); } In code written above you see we are storing whole data in database now in this data array you also get date so just put an if condition on the date and do whatever with the data of your choice

RahamSher commented 5 years ago

@muzafar First of all you need to retrieve the data from your device/machine and populate that into your database.From there you may reach to your goal.But if you are not doing like this then you will retrieve the data as a whole and then will going to filter that. And if you the solution besides this please share.

Of course its the feasible solution.

muzafar commented 5 years ago

Thanks @junaidranjha and @RahamSher. Actually the problem is that there is almost 56 thousand records in machine and when i try to run the script then due to heavy amount of data the browser load and load and hanged. What actually i want is two things. first to get check in and check out date, currently there is nothing to differentiate whether it is check in or check out. 2nd if possible, only current month attendance through getAttendance method.

junaidranjha commented 5 years ago

@muzafar there will be user id in data the first time for the user in a day will be check in and last time of a user in a day is checkout i myself got stuck in this thing as there is no status present

muzafar commented 5 years ago

@junaidranjha you mean if there are two entries for a day of same users, the first one will be check in and 2nd one will be checkout?

junaidranjha commented 5 years ago

@muzafar yes exactly,that's what it is and in case we have more than two entries of a user then first entry will be a checkin and last will be a checkout

muzafar commented 5 years ago

Thanks @junaidranjha for your valuable time, I got it, but I think its not a good way and they must have a status column to differentiate check in and check out because its already in the machine.

junaidranjha commented 5 years ago

@muzafar Yeah they do have a column but i wasn't able to differentiate checkin and checkout from their status column value so just shared a way how i solved that