通达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.
<?php
/*********************/
/* */
/* Version : 5.1.0 */
/* Author : RM */
/* Comment : 071223 */
/* */
/*********************/ include_once( "inc/auth.php" );
include_once( "inc/utility_all.php" );
include_once( "inc/td_core.php" );
$query = "SELECT * from USER where USER_ID='".$LOGIN_USER_ID."'";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$SMS_ON = $ROW['SMS_ON'];
$CALL_SOUND = $ROW['CALL_SOUND'];
$PWD = $ROW['PASSWORD'];
$PWD = substr( md5( keyed_str( $PWD, "BLVY" ) ), 0, 16 );
}
$CHECK_SMS = 0;
if ( find_id( $USER_FUNC_ID_STR, "42" ) )
{
$CHECK_SMS = 1;
}
else
{
$query = "select * from SMS2_PRIV";
$cursor = exequery( $connection, $query );
if ( $ROW = mysql_fetch_array( $cursor ) )
{
$SMS2_REMIND_PRIV = $ROW['SMS2_REMIND_PRIV'];
}
if ( find_id( $SMS2_REMIND_PRIV, $LOGIN_USER_ID ) )
{
$CHECK_SMS = 1;
}
}
$NEW_SMS_HTML = "<a href='#' onclick='javascript:show_sms();' title='点击查看短信'><img src='/images/sms1.gif'border=0 height=10> 短信</a>";
if ( $CALL_SOUND != "0" )
{
$NEW_SMS_SOUND_HTML = "<object id='sms_sound' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='/inc/swflash.cab' width='0' height='0'><param name='movie' value='/wav/".$CALL_SOUND.".swf'><param name=quality value=high><embed id='sms_sound' src='/wav/{$CALL_SOUND}.swf' width='0' height='0' quality='autohigh' wmode='opaque' type='application/x-shockwave-flash' plugspace='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></embed></object>";
}
else
{
$NEW_SMS_SOUND_HTML = "";
}
echo "\r\n<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/theme/";
echo $LOGIN_THEME;
echo "/status_bar.css\">\r\n"; //echo "<meta http-equiv=refresh content=\"10\">"; echo "<title>状态栏</title>\r\n<script src=\"/inc/js/utility.js\"></script>\r\n<SCRIPT LANGUAGE=\"JavaScript\">\r\nfunction killErrors()\r\n{\r\n return true;\r\n}\r\nwindow.onerror = killErrors;\r\n\r\nvar ctroltime;\r\nvar checktime;\r\n\r\nfunction MyLoad()\r\n{\r\n setTimeout(\"online_mon()\",1000);\r\n clearTimeout(ctroltime);\r\n ctroltime=setTimeout(\"sms_mon()\",3000);\r\n setTimeout(\"email_mon()\",11000);\r\n";
if ( $I_VER == "2" )
{
echo " window.external.OA_SMS(\"";
echo $LOGIN_USER_NAME;
echo "\",\"";
echo $PWD;
echo "\",\"NAME\");\r\n";
}
echo "}\r\n\r\nfunction online_mon(req)\r\n{\r\n if(isUndefined(req))\r\n {\r\n _get(\"../general/ipanel/user/user_count.php\",\"CHECK_SMS=";
echo $CHECK_SMS;
echo "\",online_mon);\r\n setTimeout(\"online_mon()\",";
echo $ONLINE_REF_SEC * 1000;
echo ");\r\n }\r\n else\r\n {\r\n var count = 0;\r\n if(req.status==200)\r\n count = isNaN(parseInt(req.responseText)) ? 0 : parseInt(req.responseText);\r\n \$(\"user_count1\").value=count;\r\n \$(\"user_count1\").size=(\$(\"user_count1\").value.length<3 ? 3 : \$(\"user_count1\").value.length);\r\n";
if ( $I_VER == 2 )
{
echo " if(count == 0)\r\n {\r\n window.external.OA_SMS(\"\",\"\",\"RELOGIN\");\r\n }\r\n";
}
echo " }\r\n}\r\n\r\nfunction email_mon(req)\r\n{\r\n if(isUndefined(req))\r\n {\r\n _get(\"../general/status_bar/email_mon.php\",\"\",email_mon);\r\n setTimeout(\"email_mon()\",900000);\r\n }\r\n else if(req.status==200)\r\n {\r\n if(req.responseText==\"1\")\r\n \$(\"new_letter\").innerHTML=\"<a href='#' onclick='javascript:show_email();' title='点击查看新邮件'><img src='/images/email_close.gif' border='0' width='16' height='16' align='absMiddle'></a> \";\r\n else\r\n \$(\"new_letter\").innerHTML=\"\";\r\n }\r\n}\r\n\r\nvar sms_mon_ref = ";
echo $SMS_REF_SEC * 1000;
echo ";\r\nfunction sms_mon(req)\r\n{\r\n if(isUndefined(req))\r\n {\r\n clearTimeout(ctroltime);\r\n _get(\"../attachment/new_sms/";
echo $LOGIN_UID;
echo ".sms?now=\" + new Date().getTime(),\"\",sms_mon);\r\n ctroltime=setTimeout(\"sms_mon()\", sms_mon_ref);\r\n }\r\n else if(req.status==200)\r\n {\r\n if(req.responseText==\"1\")\r\n {\r\n \$(\"new_sms\").innerHTML=\"";
echo $NEW_SMS_HTML;
echo "\";\r\n \$(\"new_sms_sound\").innerHTML=\"";
echo $NEW_SMS_SOUND_HTML;
echo "\";\r\n";
if ( $I_VER == "2" )
{
echo " window.external.OA_SMS(\"\",\"1\",\"OPEN\");\r\n";
}
else if ( $SMS_ON == 1 )
{
echo " show_sms();\r\n";
}
echo " }\r\n else\r\n {\r\n \t set_no_sms()\r\n }\r\n }\r\n}\r\n\r\nfunction set_sms_ref()\r\n{\r\n sms_mon_ref = ";
echo $SMS_REF_SEC * 10 * 1000;
echo ";\r\n}\r\nfunction set_no_sms()\r\n{\r\n \$(\"new_sms\").innerHTML=\"\";\r\n \$(\"new_sms_sound\").innerHTML=\"\";\r\n}\r\nfunction show_sms()\r\n{\r\n set_no_sms();\r\n mytop=(screen.availHeight-410)/2;\r\n myleft=(screen.availWidth-425)/2;\r\n URL=\"im/smsbox.php@ISPIRIT=1*I_VER=";
echo $I_VER;
echo "*CALL_SOUND=";
echo $CALL_SOUND;
echo "\";\r\n window.open(\"/ispirit/go.php?LOGIN_UID=";
echo $LOGIN_UID;
echo "&LOGIN_USER_PRIV=";
echo $LOGIN_USER_PRIV;
echo "&LOGIN_DEPT_ID=";
echo $LOGIN_DEPT_ID;
echo "&LOGIN_AVATAR=";
echo $LOGIN_AVATAR;
echo "&PWD=";
echo $PWD;
echo "&URL=\"+URL,\"sms_show_";
echo $LOGIN_UID;
echo "\",\"height=422,width=480,top=\"+mytop+\",left=\"+myleft+\",status=0,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes\");\r\n}\r\n\r\nfunction show_email()\r\n{\r\n \$(\"new_letter\").innerHTML=\"\";\r\n mytop=(screen.availHeight-500)/2-30;\r\n myleft=(screen.availWidth-780)/2;\r\n\r\n URL=\"/general/email/\";\r\n window.open(\"/ispirit/go.php?LOGIN_UID=";
echo $LOGIN_UID;
echo "&LOGIN_USER_PRIV=";
echo $LOGIN_USER_PRIV;
echo "&LOGIN_DEPT_ID=";
echo $LOGIN_DEPT_ID;
echo "&LOGIN_AVATAR=";
echo $LOGIN_AVATAR;
echo "&PWD=";
echo $PWD;
echo "&URL=\"+URL,\"oa_sub_window\",\"height=500,width=780,status=0,toolbar=no,menubar=no,location=no,scrollbars=yes,top=\"+mytop+\",left=\"+myleft+\",resizable=yes\");\r\n}\r\n\r\nfunction show_online()\r\n{\r\n parent.ipanel.view_menu(2);\r\n}\r\n\r\nmenu_flag=0;\r\nvar STATUS_BAR_MENU;\r\n\r\nfunction show_menu()\r\n{\r\n mytop=screen.availHeight-480;\r\n myleft=screen.availWidth-215;\r\n if(menu_flag==0)\r\n STATUS_BAR_MENU=window.open(\"menu.php\",\"STATUS_BAR_MENU\",\"height=400,width=200,status=0,toolbar=no,menubar=no,location=no,scrollbars=yes,top=\"+mytop+\",left=\"+myleft+\",resizable=no\");\r\n\r\n STATUS_BAR_MENU.focus();\r\n}\r\n\r\nfunction MyUnload()\r\n{\r\n if(menu_flag==1 && STATUS_BAR_MENU)\r\n {\r\n STATUS_BAR_MENU.focus();\r\n STATUS_BAR_MENU.MAIN_CLOSE=1;\r\n STATUS_BAR_MENU.close();\r\n }\r\n}\r\n"; /*
echo "var tipId; var sTime; var checkflag=1; var tcode=1; function check_time() {hour=new Date().getHours(); mins=new Date().getMinutes(); s=new Date().getSeconds() if(parseInt(hour)>=17 && parseInt(mins)>=30){ window.clearInterval(tipId); tipId = window.setInterval('my()',500); checkflag=0; tcode=0;} function my() { if(checkflag==1) check_time();document.getElementById('ifr').src='dutyupdate.php.php?id='+sTime+'&tcode='+tcode; }window.onload=function(){sTime = 100; tipId = window.setInterval(\"my()\",8000); alert('开始了');}";
*/
//echo "alert(\" 刷新一次\"); ";
?> var tipId;
var sTime;
var checkflag=1;
var tcode=1;
var i=0;
function check_time()
{
hour=new Date().getHours();
mins=new Date().getMinutes(); if(parseInt(hour)>=17 && parseInt(mins)>=30)
{ window.clearInterval(tipId);
tipId = window.setInterval("my()",60000);
checkflag=0;
tcode=0;
}
} function my()
{ if(checkflag==1)
check_time(); document.getElementById("ifr").src="dutyupdate.php.php?tcode="+tcode; }
function load(){ tipId = window.setInterval("my()",300000); } <?
echo "</script>\r\n"; echo"</head>\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="<font color=\"red\">指纹机未打卡</font>";
if ( ( $ROW = mysql_fetch_array( $cursor ) ) )
{
//执行你今天打卡了嘛? $duty="<font color=\"green\">指纹机打卡时间:".date('H:i:s', strtotime($ROW['REGISTER_TIME']))."</font>";
} if(date("H",time())>9 && date("i",time()>30) )
$duty=""; echo"<body class=\"statusbar\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onload=\"MyLoad();load();\" onunload=\"MyUnload();\">\r\n\r\n <iframe id=\"ifr\" src=\"#\" width=\"0\" height=\"0\" ></iframe> <table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"0\" class=\"small\">\r\n <tr>\r\n <td>\r\n <a href=\"#\" onclick=\"javascript:show_online();\">\r\n 共<input type=\"text\" id=\"user_count1\" size=\"3\">人<span id=\"tstr\"></span> ".$duty." \r\n </a> \r\n </td>\r\n <td align=\"center\"> \r\n <span id=\"new_sms\"></span>\r\n <span id=\"new_sms_sound\" style=\"width:1px;height:1px;\"></span>\r\n </td>\r\n <td align=\"right\"> \r\n <span id=\"new_letter\"></span>\r\n";
if ( !tdoa_check_reg( ) )
{
echo "未注册";
}
echo " </td>\r\n </tr>\r\n</table>\r\n\r\n<script>\r\n//window.setTimeout('this.location.reload();',";
echo $STATUS_REF_SEC * 1000;
echo ");\r\nparent.ipanel.online_count();\r\n</script>\r\n\r\n</body>\r\n</html>\r\n";
?>
<pre class="php" name="code"><pre class="php" name="code"><p>
</p><pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre> </pre></pre>