Compare commits
2 Commits
c830d3f90c
...
0923f5e0e0
| Author | SHA1 | Date | |
|---|---|---|---|
| 0923f5e0e0 | |||
| 822c2e8af9 |
@ -100,6 +100,10 @@ class LogController
|
|||||||
if($rs){
|
if($rs){
|
||||||
echo "start time : ".date("Y-m-d H:i:s")."\n";
|
echo "start time : ".date("Y-m-d H:i:s")."\n";
|
||||||
while($rw=$rs->fetch()){
|
while($rw=$rs->fetch()){
|
||||||
|
$swhereshiftcode="";
|
||||||
|
if($rw['shiftcode']&&$rw['idxdept']==22){
|
||||||
|
$swhereshiftcode="and shiftcode='".$rw['shiftcode']."'";
|
||||||
|
}
|
||||||
if($rw['idxdept']==30){ // === only call center department
|
if($rw['idxdept']==30){ // === only call center department
|
||||||
if($rw['attendancename']=='IN'){
|
if($rw['attendancename']=='IN'){
|
||||||
$qry="insert into tbl_attendancelist
|
$qry="insert into tbl_attendancelist
|
||||||
@ -108,13 +112,13 @@ class LogController
|
|||||||
officename='".$rw['officename']."',idxdept='".$rw['idxdept']."',divisiname='".$rw['divisiname']."',
|
officename='".$rw['officename']."',idxdept='".$rw['idxdept']."',divisiname='".$rw['divisiname']."',
|
||||||
serviconame='".$rw['serviconame']."',dates='".$rw['dates']."',checkin='".$rw['datestimes']."',
|
serviconame='".$rw['serviconame']."',dates='".$rw['dates']."',checkin='".$rw['datestimes']."',
|
||||||
islates='".$rw['islates']."',months='".$rw['months']."',years='".$rw['years']."',
|
islates='".$rw['islates']."',months='".$rw['months']."',years='".$rw['years']."',
|
||||||
shiftcode='".$rw['shiftcode']."',lateperemployee='".$rw['lateperemployee']."',
|
shiftcode='".$rw['shiftcode']."',lateperemployee='".$rw['lateperemployee']."',lateperemployeer2='".$rw['lateperemployeer2']."',
|
||||||
deviceidcheckin='".$rw['deviceidcheckin']."',deviceidcheckout='".$rw['deviceidcheckout']."',
|
deviceidcheckin='".$rw['deviceidcheckin']."',
|
||||||
iby='svc',idt='".$rw['datestimes']."'";
|
iby='svc',idt='".$rw['datestimes']."'";
|
||||||
|
|
||||||
$qrychk="select _idx from tbl_attendancelist
|
$qrychk="select _idx from tbl_attendancelist
|
||||||
where idxemployee='".$rw['idxemployee']."' and cast(dates as date)=cast('".date("Y-m-d",strtotime($rw['dates']))."' as date)
|
where idxemployee='".$rw['idxemployee']."' and cast(dates as date)=cast('".date("Y-m-d",strtotime($rw['dates']))."' as date)
|
||||||
and isdeleted=0 order by _idx desc limit 1";
|
$swhereshiftcode and isdeleted=0 order by _idx desc limit 1";
|
||||||
if($this->fn_rowisexists($qrychk)){
|
if($this->fn_rowisexists($qrychk)){
|
||||||
$qry="";
|
$qry="";
|
||||||
}
|
}
|
||||||
@ -125,7 +129,7 @@ class LogController
|
|||||||
$qrychk="select _idx from tbl_attendancelist
|
$qrychk="select _idx from tbl_attendancelist
|
||||||
where idxemployee='".$rw['idxemployee']."'
|
where idxemployee='".$rw['idxemployee']."'
|
||||||
and cast(checkin as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
and cast(checkin as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
||||||
and (checkout is null)
|
$swhereshiftcode and (checkout is null)
|
||||||
and isdeleted=0 order by _idx desc limit 1";
|
and isdeleted=0 order by _idx desc limit 1";
|
||||||
// echo $qrychk;//return false;
|
// echo $qrychk;//return false;
|
||||||
|
|
||||||
@ -133,13 +137,13 @@ class LogController
|
|||||||
if($_idx){
|
if($_idx){
|
||||||
$qry="update tbl_attendancelist
|
$qry="update tbl_attendancelist
|
||||||
set checkout='".$rw['datestimes']."',deviceidcheckout='".$rw['deviceidcheckout']."'
|
set checkout='".$rw['datestimes']."',deviceidcheckout='".$rw['deviceidcheckout']."'
|
||||||
where _idx='$_idx' ";
|
where _idx='$_idx' and UNIX_TIMESTAMP('".date("Y-m-d H:i:s",strtotime($rw['datestimes']))."')>UNIX_TIMESTAMP(checkin)";
|
||||||
$qryduration="update tbl_attendancelist
|
$qryduration="update tbl_attendancelist
|
||||||
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
||||||
where _idx='$_idx'";
|
where _idx='$_idx'";
|
||||||
$qrychk="select _idx from tbl_attendancelist
|
$qrychk="select _idx from tbl_attendancelist
|
||||||
where cast(checkout as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
where cast(checkout as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
||||||
and idxemployee='".$rw['idxemployee']."' and isdeleted=0
|
$swhereshiftcode and idxemployee='".$rw['idxemployee']."' and isdeleted=0
|
||||||
order by _idx desc limit 1";
|
order by _idx desc limit 1";
|
||||||
if($this->fn_rowisexists($qrychk)){
|
if($this->fn_rowisexists($qrychk)){
|
||||||
$qry="";$qryduration="";
|
$qry="";$qryduration="";
|
||||||
@ -152,19 +156,21 @@ class LogController
|
|||||||
$qrychk="select _idx from tbl_attendancelist
|
$qrychk="select _idx from tbl_attendancelist
|
||||||
where idxemployee='".$rw['idxemployee']."'
|
where idxemployee='".$rw['idxemployee']."'
|
||||||
and cast(checkin as date)=date_sub('".date("Y-m-d",strtotime($rw['datestimes']))."', INTERVAL 1 day) and checkout is null
|
and cast(checkin as date)=date_sub('".date("Y-m-d",strtotime($rw['datestimes']))."', INTERVAL 1 day) and checkout is null
|
||||||
and isdeleted=0 order by _idx desc limit 1";
|
$swhereshiftcode and isdeleted=0 order by _idx desc limit 1";
|
||||||
|
|
||||||
// echo $qrychk;return false;
|
// echo $qrychk;return false;
|
||||||
$_idx=$this->fn_getfieldvalue("_idx",$qrychk);
|
$_idx=$this->fn_getfieldvalue("_idx",$qrychk);
|
||||||
if($_idx){
|
if($_idx){
|
||||||
$qry="update tbl_attendancelist set checkout='".$rw['datestimes']."' where _idx='$_idx' and checkout is null";
|
$qry="update tbl_attendancelist
|
||||||
|
set checkout='".$rw['datestimes']."',deviceidcheckout='".$rw['deviceidcheckout']."'
|
||||||
|
where _idx='$_idx' and (UNIX_TIMESTAMP('".date("Y-m-d H:i:s",strtotime($rw['datestimes']))."')>UNIX_TIMESTAMP(checkin)) and checkout is null";
|
||||||
// $qry="update tbl_attendancelist set checkout='".$rw['datestimes']."' where _idx='$_idx'";
|
// $qry="update tbl_attendancelist set checkout='".$rw['datestimes']."' where _idx='$_idx'";
|
||||||
$qryduration="update tbl_attendancelist
|
$qryduration="update tbl_attendancelist
|
||||||
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
||||||
where _idx='$_idx'";
|
where _idx='$_idx'";
|
||||||
$qrychk="select _idx from tbl_attendancelist
|
$qrychk="select _idx from tbl_attendancelist
|
||||||
where cast(checkout as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
where cast(checkout as date)=cast('".date("Y-m-d",strtotime($rw['datestimes']))."' as date)
|
||||||
and idxemployee='".$rw['idxemployee']."' and isdeleted=0
|
$swhereshiftcode and idxemployee='".$rw['idxemployee']."' and isdeleted=0
|
||||||
order by _idx desc limit 1";
|
order by _idx desc limit 1";
|
||||||
if($this->fn_rowisexists($qrychk)){
|
if($this->fn_rowisexists($qrychk)){
|
||||||
$qry="";$qryduration="";
|
$qry="";$qryduration="";
|
||||||
@ -192,7 +198,7 @@ class LogController
|
|||||||
else{ // === Non call center dept
|
else{ // === Non call center dept
|
||||||
if($rw['attendancename']=='IN'){$attfield="checkin='".$rw['datestimes']."',";}
|
if($rw['attendancename']=='IN'){$attfield="checkin='".$rw['datestimes']."',";}
|
||||||
if($rw['attendancename']=='R1'){$attfield="R1='".$rw['datestimes']."',";}
|
if($rw['attendancename']=='R1'){$attfield="R1='".$rw['datestimes']."',";}
|
||||||
if($rw['attendancename']=='R2'){$attfield="R2='".$rw['datestimes']."',";}
|
if($rw['attendancename']=='R2'){$attfield="R2='".$rw['datestimes']."',lateperemployeer2='".$rw['lateperemployeer2']."',";}
|
||||||
if($rw['attendancename']=='OUT'){$attfield="checkout='".$rw['datestimes']."',";}
|
if($rw['attendancename']=='OUT'){$attfield="checkout='".$rw['datestimes']."',";}
|
||||||
|
|
||||||
$qry="insert into tbl_attendancelist
|
$qry="insert into tbl_attendancelist
|
||||||
@ -201,36 +207,48 @@ class LogController
|
|||||||
officename='".$rw['officename']."',idxdept='".$rw['idxdept']."',divisiname='".$rw['divisiname']."',
|
officename='".$rw['officename']."',idxdept='".$rw['idxdept']."',divisiname='".$rw['divisiname']."',
|
||||||
serviconame='".$rw['serviconame']."',dates='".$rw['dates']."',".$attfield."
|
serviconame='".$rw['serviconame']."',dates='".$rw['dates']."',".$attfield."
|
||||||
islates='".$rw['islates']."',months='".$rw['months']."',years='".$rw['years']."',
|
islates='".$rw['islates']."',months='".$rw['months']."',years='".$rw['years']."',
|
||||||
shiftcode='".$rw['shiftcode']."',lateperemployee='".$rw['lateperemployee']."',
|
shiftcode='".$rw['shiftcode']."',lateperemployee='".$rw['lateperemployee']."',lateperemployeer2='".$rw['lateperemployeer2']."',
|
||||||
deviceidcheckin='".$rw['deviceidcheckin']."',deviceidcheckout='".$rw['deviceidcheckout']."',
|
deviceidcheckin='".$rw['deviceidcheckin']."',
|
||||||
iby='svc',idt='".$rw['datestimes']."'";
|
iby='svc',idt='".$rw['datestimes']."'";
|
||||||
|
|
||||||
$qrychk="select _idx,checkin,checkout,lateperemployee from tbl_attendancelist
|
$qrychk="select _idx,checkin,checkout,lateperemployee from tbl_attendancelist
|
||||||
where idxemployee='".$rw['idxemployee']."' and cast(dates as date)=cast('".date("Y-m-d",strtotime($rw['dates']))."' as date) and isdeleted=0 order by _idx desc limit 1";
|
where idxemployee='".$rw['idxemployee']."' and cast(dates as date)=cast('".date("Y-m-d",strtotime($rw['dates']))."' as date)
|
||||||
|
$swhereshiftcode and isdeleted=0 order by _idx desc limit 1";
|
||||||
if($this->fn_rowisexists($qrychk)){
|
if($this->fn_rowisexists($qrychk)){
|
||||||
|
// $_idx=$this->fn_getfieldvalue("_idx",$qrychk);
|
||||||
$sp=$this->fn_getfieldsvalues("_idx,checkin,checkout,lateperemployee", $qrychk);
|
$sp=$this->fn_getfieldsvalues("_idx,checkin,checkout,lateperemployee", $qrychk);
|
||||||
$_idx=$sp[0];$checkin=$sp[1];$checkout=$sp[2];$lateperemployee=$sp[3];
|
$_idx=$sp[0];$checkin=$sp[1];$checkout=$sp[2];$lateperemployee=$sp[3];
|
||||||
$laterperemployeefield="";
|
$laterperemployeefield="";
|
||||||
|
|
||||||
if(!$lateperemployee){
|
// if(!$lateperemployee){
|
||||||
$laterperemployeefield="lateperemployee='".$rw['lateperemployee']."',";
|
// $laterperemployeefield="lateperemployee='".$rw['lateperemployee']."',";
|
||||||
}
|
// }
|
||||||
|
|
||||||
$qry="update tbl_attendancelist
|
$qry="update tbl_attendancelist
|
||||||
set ".$attfield.$laterperemployeefield."uby='svc',udt='".$rw['datestimes']."'
|
set ".$attfield.$laterperemployeefield."uby='svc',udt='".$rw['datestimes']."'
|
||||||
where _idx='$_idx'";
|
where _idx='$_idx'";
|
||||||
if($rw['attendancename']=='IN'&&$checkin!=null){
|
if($rw['attendancename']=='IN'&&$checkin!=null){
|
||||||
$qry="update tbl_attendancelist
|
$qry="update tbl_attendancelist
|
||||||
set uby='svc',udt='".$rw['datestimes']."'
|
set uby='svc',udt='".$rw['datestimes']."'
|
||||||
where _idx='$_idx'";
|
where _idx='$_idx'";
|
||||||
}
|
}
|
||||||
if($rw['attendancename']=='OUT'){
|
if($rw['attendancename']=='OUT'){
|
||||||
$qry="update tbl_attendancelist
|
$qry="update tbl_attendancelist
|
||||||
set ".$attfield."uby='svc',udt='".$rw['datestimes']."',deviceidcheckout='".$rw['deviceidcheckout']."'
|
set ".$attfield."uby='svc',udt='".$rw['datestimes']."',deviceidcheckout='".$rw['deviceidcheckout']."'
|
||||||
where _idx='$_idx' and UNIX_TIMESTAMP('".date("Y-m-d H:i:s",strtotime($rw['datestimes']))."')>UNIX_TIMESTAMP(checkin)";
|
where _idx='$_idx' and UNIX_TIMESTAMP('".date("Y-m-d H:i:s",strtotime($rw['datestimes']))."')>UNIX_TIMESTAMP(checkin)";
|
||||||
$qryduration="update tbl_attendancelist
|
|
||||||
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
$idxdept=$rw['idxdept'];
|
||||||
where _idx='$_idx'";
|
if($idxdept==33||$idxdept==34||$idxdept==30||$idxdept==22){
|
||||||
|
$qryduration="update tbl_attendancelist
|
||||||
|
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,checkout))
|
||||||
|
where _idx='$_idx'";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$qryduration="update tbl_attendancelist
|
||||||
|
set duration=SEC_TO_TIME(TIMESTAMPDIFF(SECOND,checkin,R1)+TIMESTAMPDIFF(SECOND,R2,checkout))
|
||||||
|
where _idx='$_idx'";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user