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

Clear Attendance #64

Open zkenstein opened 5 years ago

zkenstein commented 5 years ago

Question, how to clear attendance data for last 3 month only? is it possible?

kamshory commented 5 years ago

No. You must clear all attendance data

Darkthecar commented 5 years ago

Hello how is this, the library works fine but I can not use "clearAttendance" does not do anything, what is the correct way to make it work

kamshory commented 5 years ago

What device dou you have. I use Solution X-100C

samirqumsieh commented 4 years ago

I have the same issue with Granding 5000T-C

syedzain9 commented 4 years ago

Hi there

I think you need to change this function

public function clearAttendance(){
        $command = CMD_CLEAR_ATTLOG;
        return $this->execCommand($command);
}

with this function, this is working perfectly fine with (ZK uFace 800) and I think this also working with other types

function clearAttendance() {
        $command = CMD_CLEAR_ATTLOG;
        $command_string = '';
        $chksum = 0;
        $session_id = $this->session_id;

        $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6/H2h7/H2h8', substr( $this->received_data, 0, 8) );
        $reply_id = hexdec( $u['h8'].$u['h7'] );

        $buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string);

        socket_sendto($this->socket, $buf, strlen($buf), 0, $this->ip, $this->port);

        try {
            socket_recvfrom($this->socket, $this->received_data, 2048, 0, $this->ip, $this->port);

            $u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr( $this->received_data, 0, 39 ) );

            $this->session_id =  hexdec( $u['h6'].$u['h5'] );
            return substr( $this->received_data, 39 );
        }catch(exception $e) {
            return False;
        }
    }