cobisja / tad-php

PHP Library for ZK Time & Attendance Devices
MIT License
213 stars 159 forks source link

connection problem #70

Open haseebhk22 opened 5 years ago

haseebhk22 commented 5 years ago

connection problem i have done everything but i got an error Fatal error: Uncaught exception 'TADPHP\Exceptions\ConnectionError' with message 'Imposible iniciar conexión con dispositivo 192.168.2.200' in C:\wamp64\www\tad\lib\TAD.php on line

Here is my code

`<?php require 'lib/TADFactory.php'; require 'lib/TAD.php'; require 'lib/TADResponse.php'; require 'lib/Providers/TADSoap.php'; require 'lib/Providers/TADZKLib.php'; require 'lib/Exceptions/ConnectionError.php'; require 'lib/Exceptions/FilterArgumentError.php'; require 'lib/Exceptions/UnrecognizedArgument.php'; require 'lib/Exceptions/UnrecognizedCommand.php';

 $tad_factory = new TADPHP\TADFactory();

 use TADPHP\TADFactory;
 use TADPHP\TAD;
 $comands = TAD::commands_available();
 $options =array(
                'ip' => '192.168.2.200',   //Any of the above IP addresses from image above
                'internal_id' => 100,    // 1 by default.
                'com_key' => 123,        // 0 by default.
                'description' => 'TAD1', // 'N/A' by default.
                'soap_port' => 80,     // 80 by default,
                'udp_port' => 4370,      // 4370 by default.
                'encoding' => 'utf-8'    // iso8859-1 by default.
                );
  $tad_factory = new TADFactory($options);
  $tad = $tad_factory->get_instance();  
  $logs = $tad->get_att_log();
  var_dump($logs);

?>`

haseebhk22 commented 5 years ago

can any one help me please

send2dawood commented 5 years ago

I have wirking code i will share it with you

On Thu, 31 Jan 2019, 1:31 pm haseebhk22 <notifications@github.com wrote:

can any one help me please

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cobisja/tad-php/issues/70#issuecomment-459259166, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 .

haseebhk22 commented 5 years ago

I have wirking code i will share it with you On Thu, 31 Jan 2019, 1:31 pm haseebhk22 @.*** wrote: can any one help me please — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#70 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 .

yes please i will be thankful if you share your working code

send2dawood commented 5 years ago

require 'vendor/autoload.php'; require 'tad/lib/TADFactory.php'; require 'tad/lib/TAD.php'; require 'tad/lib/TADResponse.php'; require 'tad/lib/TADPHP/Providers/TADSoap.php'; require 'tad/lib/TADPHP/Providers/TADZKLib.php'; require 'tad/lib/TADPHP/Exceptions/ConnectionError.php'; require 'tad/lib/TADPHP/Exceptions/FilterArgumentError.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedArgument.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedCommand.php';

use TADPHP\TADFactory; use TADPHP\TAD;

try { $tad = (new TADFactory(['ip' => '182.180.150.260','com_key'=>0]))->get_instance(); if($tad->is_alive()) { //$tad->disable(); $att_logs = $tad->get_att_log(); $att_logs=$att_logs->filter_by_date(['start' => date('Y-m-d'),'end' => date('Y-m-d')]); if ($att_logs->is_empty_response()) { my_log('Does not have logs recorded'); //continue; } else { $array_att_logs = $att_logs->to_array(); $device_logs = array(); $counter=1; if(!empty($array_att_logs)) foreach($array_att_logs as $key =>$val ) { foreach($val as $log) { $device_logs[]= array( 'institutes_inst_id' => $row['inst_id'], 'employees_machine_user_id' => $log['PIN'], 'date' => date('Y-m-d',strtotime($log['DateTime'])), 'time' => date('H:i:s',strtotime($log['DateTime'])) ); $counter++; } } add_att_logs($device_logs); //$tad->enable(); my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] has ' . $counter . ' records'); } } else { my_log('Device in ' . $row['inst_name'] . ' is off-line'); continue; } } catch(Exception $e) { my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] is offline'); }

On Thu, Feb 7, 2019 at 3:07 PM Haseeb khan notifications@github.com wrote:

I have wirking code i will share it with you … <#m-7494239903006511939> On Thu, 31 Jan 2019, 1:31 pm haseebhk22 @.*** wrote: can any one help me please — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#70 (comment) https://github.com/cobisja/tad-php/issues/70#issuecomment-459259166>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 .

yes please i will be thankful if you share your working code

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cobisja/tad-php/issues/70#issuecomment-461357593, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w5zt_dSgUfEiv1Mh-FpaYJpla4HB0ks5vK_rWgaJpZM4abzx1 .

haseebhk22 commented 5 years ago

require 'vendor/autoload.php'; require 'tad/lib/TADFactory.php'; require 'tad/lib/TAD.php'; require 'tad/lib/TADResponse.php'; require 'tad/lib/TADPHP/Providers/TADSoap.php'; require 'tad/lib/TADPHP/Providers/TADZKLib.php'; require 'tad/lib/TADPHP/Exceptions/ConnectionError.php'; require 'tad/lib/TADPHP/Exceptions/FilterArgumentError.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedArgument.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedCommand.php'; use TADPHP\TADFactory; use TADPHP\TAD; try { $tad = (new TADFactory(['ip' => '182.180.150.260','com_key'=>0]))->get_instance(); if($tad->is_alive()) { //$tad->disable(); $att_logs = $tad->get_att_log(); $att_logs=$att_logs->filter_by_date(['start' => date('Y-m-d'),'end' => date('Y-m-d')]); if ($att_logs->is_empty_response()) { my_log('Does not have logs recorded'); //continue; } else { $array_att_logs = $att_logs->to_array(); $device_logs = array(); $counter=1; if(!empty($array_att_logs)) foreach($array_att_logs as $key =>$val ) { foreach($val as $log) { $device_logs[]= array( 'institutes_inst_id' => $row['inst_id'], 'employees_machine_user_id' => $log['PIN'], 'date' => date('Y-m-d',strtotime($log['DateTime'])), 'time' => date('H:i:s',strtotime($log['DateTime'])) ); $counter++; } } add_att_logs($device_logs); //$tad->enable(); my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] has ' . $counter . ' records'); } } else { my_log('Device in ' . $row['inst_name'] . ' is off-line'); continue; } } catch(Exception $e) { my_log('Device in ' . $row['inst_name']. '['.$row['ipaddress']. '] is offline'); } On Thu, Feb 7, 2019 at 3:07 PM Haseeb khan @.***> wrote: I have wirking code i will share it with you … <#m-7494239903006511939_> On Thu, 31 Jan 2019, 1:31 pm haseebhk22 @.*** wrote: can any one help me please — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#70 (comment) <#70 (comment)>>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 . yes please i will be thankful if you share your working code — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#70 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w5zt_dSgUfEiv1Mh-FpaYJpla4HB0ks5vK_rWgaJpZM4abzx1 .

Thanks for sharing code but where is vedor/autoload.php this file is not exist

send2dawood commented 5 years ago

you have to download it from github

On Mon, Feb 11, 2019 at 11:33 AM Haseeb khan notifications@github.com wrote:

require 'vendor/autoload.php'; require 'tad/lib/TADFactory.php'; require 'tad/lib/TAD.php'; require 'tad/lib/TADResponse.php'; require 'tad/lib/TADPHP/Providers/TADSoap.php'; require 'tad/lib/TADPHP/Providers/TADZKLib.php'; require 'tad/lib/TADPHP/Exceptions/ConnectionError.php'; require 'tad/lib/TADPHP/Exceptions/FilterArgumentError.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedArgument.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedCommand.php'; use TADPHP\TADFactory; use TADPHP\TAD; try { $tad = (new TADFactory(['ip' => '182.180.150.260','com_key'=>0]))->get_instance(); if($tad->is_alive()) { //$tad->disable(); $att_logs = $tad->get_att_log(); $att_logs=$att_logs->filter_by_date(['start' => date('Y-m-d'),'end' => date('Y-m-d')]); if ($att_logs->is_empty_response()) { my_log('Does not have logs recorded'); //continue; } else { $array_att_logs = $att_logs->to_array(); $device_logs = array(); $counter=1; if(!empty($array_att_logs)) foreach($array_att_logs as $key =>$val ) { foreach($val as $log) { $device_logs[]= array( 'institutes_inst_id' => $row['inst_id'], 'employees_machine_user_id' => $log['PIN'], 'date' => date('Y-m-d',strtotime($log['DateTime'])), 'time' => date('H:i:s',strtotime($log['DateTime'])) ); $counter++; } } add_att_logs($device_logs); //$tad->enable(); my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] has ' . $counter . ' records'); } } else { my_log('Device in ' . $row['inst_name'] . ' is off-line'); continue; } } catch(Exception $e) { my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] is offline'); } … <#m8444458323558097279> On Thu, Feb 7, 2019 at 3:07 PM Haseeb khan @.> wrote: I have wirking code i will share it with you … <#m-7494239903006511939> On Thu, 31 Jan 2019, 1:31 pm haseebhk22 @. wrote: can any one help me please — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#70 https://github.com/cobisja/tad-php/issues/70 (comment) <#70 (comment) https://github.com/cobisja/tad-php/issues/70#issuecomment-459259166>>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 . yes please i will be thankful if you share your working code — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#70 (comment) https://github.com/cobisja/tad-php/issues/70#issuecomment-461357593>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w5zt_dSgUfEiv1Mh-FpaYJpla4HB0ks5vK_rWgaJpZM4abzx1 .

Thanks for sharing code but where is vedor/autoload.php this file is not exist

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cobisja/tad-php/issues/70#issuecomment-462229949, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w56c8SBq16KrwJfhPd3A8UVEmw1Prks5vMQ7AgaJpZM4abzx1 .

haseebhk22 commented 5 years ago

you have to download it from github On Mon, Feb 11, 2019 at 11:33 AM Haseeb khan notifications@github.com wrote: require 'vendor/autoload.php'; require 'tad/lib/TADFactory.php'; require 'tad/lib/TAD.php'; require 'tad/lib/TADResponse.php'; require 'tad/lib/TADPHP/Providers/TADSoap.php'; require 'tad/lib/TADPHP/Providers/TADZKLib.php'; require 'tad/lib/TADPHP/Exceptions/ConnectionError.php'; require 'tad/lib/TADPHP/Exceptions/FilterArgumentError.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedArgument.php'; require 'tad/lib/TADPHP/Exceptions/UnrecognizedCommand.php'; use TADPHP\TADFactory; use TADPHP\TAD; try { $tad = (new TADFactory(['ip' => '182.180.150.260','com_key'=>0]))->get_instance(); if($tad->is_alive()) { //$tad->disable(); $att_logs = $tad->get_att_log(); $att_logs=$att_logs->filter_by_date(['start' => date('Y-m-d'),'end' => date('Y-m-d')]); if ($att_logs->is_empty_response()) { my_log('Does not have logs recorded'); //continue; } else { $array_att_logs = $att_logs->to_array(); $device_logs = array(); $counter=1; if(!empty($array_att_logs)) foreach($array_att_logs as $key =>$val ) { foreach($val as $log) { $device_logs[]= array( 'institutes_inst_id' => $row['inst_id'], 'employees_machine_user_id' => $log['PIN'], 'date' => date('Y-m-d',strtotime($log['DateTime'])), 'time' => date('H:i:s',strtotime($log['DateTime'])) ); $counter++; } } add_att_logs($device_logs); //$tad->enable(); my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] has ' . $counter . ' records'); } } else { my_log('Device in ' . $row['inst_name'] . ' is off-line'); continue; } } catch(Exception $e) { my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] is offline'); } … <#m8444458323558097279> On Thu, Feb 7, 2019 at 3:07 PM Haseeb khan @.> wrote: I have wirking code i will share it with you … <#m-7494239903006511939> On Thu, 31 Jan 2019, 1:31 pm haseebhk22 @. wrote: can any one help me please — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#70 <#70> (comment) <#70 (comment) <#70 (comment)>>>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w57LZjdYHEUhXpkyf-lMt7cAhZYBiks5vIqnNgaJpZM4abzx1 . yes please i will be thankful if you share your working code — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#70 (comment) <#70 (comment)>>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w5zt_dSgUfEiv1Mh-FpaYJpla4HB0ks5vK_rWgaJpZM4abzx1 . Thanks for sharing code but where is vedor/autoload.php this file is not exist — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#70 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5w56c8SBq16KrwJfhPd3A8UVEmw1Prks5vMQ7AgaJpZM4abzx1 .

sir i already download from github but in the folder the vendor folder or autoload.php not exist

zkenstein commented 5 years ago

Run this on tad folder php composer.phar dump-autoload to create autoload file

haseebhk22 commented 5 years ago

Run this on tad folder php composer.phar dump-autoload to create autoload file

Sir I have done this now in your code that you provide , I change the ip address but result is the same no connection is made : Here is my code : `<?php

require 'vendor/autoload.php'; require 'lib/TADFactory.php'; require 'lib/TAD.php'; require 'lib/TADResponse.php'; require 'lib/Providers/TADSoap.php'; require 'lib/Providers/TADZKLib.php'; require 'lib/Exceptions/ConnectionError.php'; require 'lib/Exceptions/FilterArgumentError.php'; require 'lib/Exceptions/UnrecognizedArgument.php'; require 'lib/Exceptions/UnrecognizedCommand.php';

use TADPHP\TADFactory; use TADPHP\TAD;

try { $tad = (new TADFactory(['ip' => 'MY.IP.ADDRESS','com_key'=>0]))->get_instance(); if($tad->is_alive()) { echo "done";exit(); //$tad->disable(); $att_logs = $tad->get_att_log(); print_r($att_logs);exit(); $att_logs=$att_logs->filter_by_date(['start' => date('Y-m-d'),'end' => date('Y-m-d')]); if ($att_logs->is_empty_response()) { my_log('Does not have logs recorded'); //continue; } else { $array_att_logs = $att_logs->to_array(); $device_logs = array(); $counter=1; if(!empty($array_att_logs)) foreach($array_att_logs as $key =>$val ) { foreach($val as $log) { $device_logs[]= array( 'institutes_inst_id' => $row['inst_id'], 'employees_machine_user_id' => $log['PIN'], 'date' => date('Y-m-d',strtotime($log['DateTime'])), 'time' => date('H:i:s',strtotime($log['DateTime'])) ); $counter++; } } add_att_logs($device_logs); //$tad->enable(); my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] has ' . $counter . ' records'); } } else { echo "not";exit(); my_log('Device in ' . $row['inst_name'] . ' is off-line'); continue; } } catch(Exception $e) { my_log('Device in ' . $row['inst_name']. '['.$row['ip_address']. '] is offline'); }

?>`

haseebhk22 commented 5 years ago

@zkenstein Sir my attendance machine is running and the Zk software is successfully connected to the machine and I can get all the attendance but when i use TAD class there is always connection problem . Can you help me what is the reason ??

haseebhk22 commented 5 years ago

@zkenstein When i run your code i got this error : Fatal error: Call to undefined function my_log() in C:\wamp64\www\tad_php\index.php on line 62