Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.128.205.137
<?php
$dept_code = "LOGS";
$attn_date = date("Y-m-d");
$mysql = "";
$mysql.= "select * from masempl where fdeptcode='$dept_code' and femplstat='T' and fdeleted<>'T' and faltrcode<>'' order by faltrcode";
$myres = mysqli_query($mycon,$mysql);
$mycnt = mysqli_num_rows($myres);
if($mycnt!=0)
{
while($myrow = mysqli_fetch_assoc($myres))
{
$empl_code=$myrow['femplcode'];
$altr_code=$myrow['faltrcode'];
$mysql2 = "select faltrcode, min(ftime) as llogitime, max(ftime) as llogotime from attendancedet ";
$mysql2.= "where fattndate='$attn_date' and faltrcode='$altr_code' order by faltrcode,ftime ";
$myres2 = mysqli_query($mycon,$mysql2);
while($myrow2 = mysqli_fetch_assoc($myres2))
{
if($myrow2['faltrcode']=="")
{
$attn_stat = "AB";
$logi_time = "00:00:00";
$logi_diff = "00:00:00";
$logo_time = "00:00:00";
$logo_diff = "00:00:00";
$work_hour = "00:00:00";
}
else
{
$attn_stat = "PR";
$logi_time = date("i:s", strtotime($myrow2['llogitime']));
$logi_diff = "00:00:00";
$logo_time = date("i:s", strtotime($myrow2['llogotime']));
$logo_diff = "00:00:00";
$work_hour = "00:00:00";
if($logi_time==$logo_time)
{
$logo_time="00:00:00";
$logo_diff="00:00:00";
}
}
}
$mysql3 = "";
$mysql3.= "select * from attendance where fattndate='$attn_date' and femplcode='$empl_code'";
$myres3 = mysqli_query($mycon,$mysql3);
$mycnt3 = mysqli_num_rows($myres3);
if($mycnt3==0)
{
$mysql4 = "";
$mysql4.= "insert into attendance (fdeptcode,femplcode,fattndate,fattnstat,flogitime,flogidiff,flogotime,flogodiff,";
$mysql4.= "fworkhour,fupdtuser,fupdttime) values('$dept_code','$empl_code','$attn_date','$attn_stat',";
$mysql4.= "'$logi_time','$logi_diff','$logo_time','$logo_diff','$work_hour','$user_id',now())";
$myres4 = mysqli_query($mycon,$mysql4);
}
else
{
$mysql4 = "";
$mysql4.= "update attendance set fattnstat='$attn_stat',flogitime='$logi_time',flogidiff='$logi_diff',flogotime='$logo_time',";
$mysql4.= "flogodiff='$logo_diff',fworkhour='$work_hour',fupdtuser='$user_id',fupdttime=now() ";
$mysql4.= "where fattndate='$attn_date' and femplcode='$empl_code'";
$myres4 = mysqli_query($mycon,$mysql4);
}
}
$mysql = "";
$mysql.= "update masattnstat,attendance set ";
$mysql.= "attendance.flogidiff=timediff(attendance.flogitime,masattnstat.flogitime),";
$mysql.= "attendance.flogodiff=timediff(attendance.flogotime,masattnstat.flogotime),";
$mysql.= "attendance.fworkhour=timediff(attendance.flogotime,attendance.flogitime) ";
$mysql.= "where attendance.fdeptcode=masattnstat.fdeptcode and attendance.fattnstat=masattnstat.fattnstat ";
$mysql.= "and attendance.fdeptcode='$dept_code' and attendance.fattndate='$attn_date'";
$myres=mysqli_query($mycon,$mysql);
}
?>
|