已更新同类文章,请传送查看:
通达OA 同步中控考勤机 增强版 http://blog.csdn.net/tao2581/article/details/7393967
通达oa2011已经支持 指纹考勤机 但只限中控iclock660 这款2000大洋的型号
通过本文的开发接口,可以与任意一款指纹机集成, 需求指纹机管理软件能实时保存数据
我这里用的是 中控u160 指纹考勤机, 这款机器支持WIFI ,可以实现实时传输考勤数据,
特别指出的一点是这款机器的中控u160WIFI配置 容易出错的是 网线连接的ip网段 设置192.168.3.x
WIFI ip网段是在192.168.1.x ,这样才能保证成功, 大多数都是错在这里
考勤机管理软件会生成一个 Access 数据库以保存信息,或其他数据库同理, 我们的目的就是用通达OA的
php连接此库,将信息同步到 OA考勤记录上, 本接口适用 通达oa2011 通达oa2010 ,通达oa早期版本未测试
代码中 将 通达oa的 attend_duty表 加了俩个字段 type和 update_time 自行添加或修改吧,
同步代码:
include_once( "inc/td_core.php" );
include_once( "inc/conn.php" );
include_once( "inc/utility.php" );
include_once( "inc/utility_all.php" );
$ACCESS_PATH="D:\Program Files\Att2008\att2000.mdb";
$CUR_DATE = date( "Y-m-d", time( ) );
$conn = new COM( "ADODB.Connection" );
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=".realpath( "{$ACCESS_PATH}" );
$conn->Open( $connstr );
$rs = new COM( "ADODB.RecordSet" );
$query = "select CHECKINOUT.USERID as USERID,CHECKINOUT.CHECKTIME as CHECKTIME ,USERINFO.name as name from CHECKINOUT,USERINFO where CHECKINOUT.USERID=USERINFO.USERID ";
$rs->Open( $query, $conn, 1, 1 );
$i=0;
while ( !$rs->eof )
{
$query1 = "SELECT USER_ID from USER where USER_NAME='".$rs->Fields("name")."'";
$cursor1 = exequery( $connection, $query1 );
if ( $ROW1 = mysql_fetch_array( $cursor1 ) )
{
$USER_ID = $ROW1['USER_ID'];
//
$CUR_DATE = date( "Y-m-d", time( ) );
$CUR_TIME = $rs->Fields("checktime");
$CUR_TIME=str_replace("上午","",$CUR_TIME);
$CUR_TIME=str_replace("下午 12","12",$CUR_TIME);
if((strpos($CUR_TIME,"下午")>-1))
{
//处理时间格式 删除上午 下午则加12小时
$CUR_TIME=str_replace("下午","",$CUR_TIME);
$CUR_TIME=strtotime($CUR_TIME)+43200;
$CUR_TIME=date("Y-m-d H:i:s",$CUR_TIME+12);
}
$update_time=date("Y-m-d H:i:s",time());
$REGISTER_TYPE="2";
$t=$_REQUEST['tcode'];
$query = "SELECT * from ATTEND_DUTY where USER_ID='".$USER_ID."' and to_days(REGISTER_TIME)=to_days('{$CUR_TIME}') order by id desc limit 1";
$cursor = exequery( $connection, $query );
if ( !( $ROW = mysql_fetch_array( $cursor ) ) )
{
$REGISTER_TYPE=1;
$query = "insert into ATTEND_DUTY(USER_ID,REGISTER_TYPE,REGISTER_TIME,REGISTER_IP,type,UPDATE_TIME) values ('".$USER_ID."','{$REGISTER_TYPE}','{$CUR_TIME}','zk指纹考勤机','0','{$update_time}')";
exequery( $connection, $query );
$i++;
}
else
{
$REGISTER_TYPE=2;
if($ROW['REGISTER_TYPE']==1)
{
if( strtotime($CUR_TIME) > strtotime($ROW['REGISTER_TIME']) )
$query = "insert into ATTEND_DUTY(USER_ID,REGISTER_TYPE,REGISTER_TIME,REGISTER_IP,type,UPDATE_TIME) values ('".$USER_ID."','{$REGISTER_TYPE}','{$CUR_TIME}','zk指纹考勤机','0','{$update_time}')";
}
else
$query = "update ATTEND_DUTY set type='0',REGISTER_TIME='".$CUR_TIME."',REGISTER_IP='zk指纹考勤机',UPDATE_TIME='".$update_time."' where USER_ID='".$USER_ID."' and REGISTER_TYPE='{$REGISTER_TYPE}' and to_days(REGISTER_TIME)=to_days('{$CUR_TIME}')" ;
exequery( $connection, $query );
$i++;
}
}
$rs->MoveNext( );
}
echo "成功更新".($i)."条记录!";
?>
下面奉上 通达oa 定时执行代码
可以实现上午9点前每隔1分钟执行一次 同步程序, 9-17点每隔5分钟一次 5-6点 1分钟一次。
具体内容大家自己研究 不详细解释了
webroot\ispirit\status_bar.php.
短信";
if ( $CALL_SOUND != "0" )
{
$NEW_SMS_SOUND_HTML = "";
}
else
{
$NEW_SMS_SOUND_HTML = "";
}
echo "\r\n\r\n\r\n\r\n\r\n";
//echo "";
echo "状态栏 \r\n\r\n\r\n";
echo"\r\n\r\n";
//查询考勤记录
$CUR_DATE = date( "Y-m-d", time( ) );
$CUR_TIME = date( "Y-m-d H:i:s", time( ) );
$REGISTER_TYPE=1;
$query = "SELECT * from ATTEND_DUTY where USER_ID='".$LOGIN_USER_ID."' and REGISTER_TYPE='{$REGISTER_TYPE}' and to_days(REGISTER_TIME)=to_days('{$CUR_TIME}')";
$cursor = exequery( $connection, $query );
$duty="指纹机未打卡";
if ( ( $ROW = mysql_fetch_array( $cursor ) ) )
{
//执行你今天打卡了嘛?
$duty="指纹机打卡时间:".date('H:i:s', strtotime($ROW['REGISTER_TIME']))."";
}
if(date("H",time())>9 && date("i",time()>30) )
$duty="";
echo"\r\n\r\n \r\n \r\n \r\n \r\n 共人 ".$duty." \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n";
if ( !tdoa_check_reg( ) )
{
echo "未注册";
}
echo " \r\n \r\n
\r\n\r\n\r\n\r\n\r\n\r\n";
?>