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.145.109.231
<?php
include("sys_session.php");
include("sys_mainphp.php");
$load_data=$_POST["load_data"];
$resp_mesg="";
$resp_stat="";
$resp_file="";
if($load_data=='dept_detl')
{
include("sys_connect.php");
if($type_id=='ADMIN')
{
$mysql="select * from masdept where fdeptstat='T' order by fdeptname";
}
elseif($type_id=='CHIEF')
{
$mysql="select * from masdept where fdeptstat='T' and fdepthead='$empl_id' order by fdeptname";
}
else
{
$mysql="select * from masdept where fdeptstat='T' and fdeptcode='$dept_id' order by fdeptname";
}
$myres=mysqli_query($mycon,$mysql);
if(mysqli_num_rows($myres)>1)
{
echo "<option value=0>--Select--</option>";
}
while($row = mysqli_fetch_assoc($myres))
{
echo "<option value='$row[fdeptcode]'>$row[fdeptname]</option>";
}
}
if($load_data=='mark_detl')
{
$dept_code=$_POST['dept_code'];
include("sys_connect.php");
$mysql1="select * from masattnstat where fdeptcode='$dept_code' and ifnull(fdeleted,'F')='F' order by fdeptcode,fstatordr,fstatdesc";
$myres1=mysqli_query($mycon,$mysql1);
echo "<option value=0>NONE</option>";
while($row1 = @mysqli_fetch_assoc($myres1))
{
echo "<option value='$row1[fattnstat]'>$row1[fstatdesc]</option>";
}
}
if($load_data=='view_data')
{
$i=1;
$dept_code=$_POST['dept_code'];
$attn_date=$_POST['attn_date'];
$attn_mark=$_POST['attn_mark'];
echo "<table id=table_attn class=table_list border=1>";
echo "<tr>";
echo "<th width=4%> # </th>";
echo "<th width=18%> Employee Name </th>";
echo "<th width=18%> Designation </th>";
echo "<th width=12%> Status </th>";
echo "<th width=10%> Login Time </th>";
echo "<th width=10%> Logout Time </th>";
echo "<th width=8%> T.A. Amt. </th>";
echo "<th width=8%> O.T./Packets</th>";
echo "<th width=10%> Remarks </th>";
echo "</tr>";
$logi_sett="0";
$logo_sett="0";
$trvl_sett="0.00";
include("sys_connect.php");
$mysqlx="select * from masattnstat where fdeptcode='$dept_code' and fattnstat='$attn_mark' and ifnull(fdeleted,'F')='F'";
$myresx=mysqli_query($mycon,$mysqlx);
while($rowx = @mysqli_fetch_assoc($myresx))
{
$logi_sett=$rowx['flogitime'];
$logo_sett=$rowx['flogotime'];
$trvl_sett=$rowx['ftrvlamnt'];
}
$mysql1 ="";
$mysql1.="select masempl.*,masdesn.* from masempl,masdesn where masempl.fdesncode=masdesn.fdesncode and fdeptcode='$dept_code' ";
$mysql1.="and replace(fjoindate,'0000-00-00', str_to_date('$attn_date','%d-%m-%Y')) <= str_to_date('$attn_date','%d-%m-%Y') ";
$mysql1.="and replace(ftermdate,'0000-00-00', str_to_date('$attn_date','%d-%m-%Y')) >= str_to_date('$attn_date','%d-%m-%Y') ";
$mysql1.="and ifnull(masempl.femplstat,'F')='T' and ifnull(masempl.fattnentr,'F')='T' and ifnull(masempl.fdeleted,'F')<>'T' ";
$mysql1.="order by fdeptcode,fdesnordr,masdesn.fdesncode,fempltype,femplname";
$myres1=mysqli_query($mycon,$mysql1);
$i=1;
while($row1 = @mysqli_fetch_assoc($myres1))
{
$empl_code=$row1['femplcode'];
echo "<tr style='height:20px;'>";
echo "<input type=hidden name='txtemplcode[]' id='txtemplcode' value=$row1[femplcode]>";
$attn_stat="0";
$logi_time="0";
$logo_time="0";
$trvl_amnt="0.00";
$over_time="0";
$attn_remk="";
$mysql2="select * from attendance where femplcode='$empl_code' and fattndate=str_to_date('$attn_date','%d-%m-%Y')";
$myres2=mysqli_query($mycon,$mysql2);
while($row2 = @mysqli_fetch_assoc($myres2))
{
$attn_stat=$row2['fattnstat'];
$logi_time=$row2['flogitime'];
$logo_time=$row2['flogotime'];
$trvl_amnt=$row2['ftrvlamnt'];
$over_time=$row2['fovertime'];
$attn_remk=$row2['fattnremk'];
}
if($logi_time==0)
{$logi_time=$logi_sett;}
if($logo_time==0 && (date('H:i')>=date('H:i',strtotime($logo_sett))))
{$logo_time=$logo_sett;}
if($trvl_amnt==0)
{$trvl_amnt=$trvl_sett;}
if($attn_mark!='0')
{$attn_stat=$attn_mark;}
$desn_name=get_desn_name($row1['fdesncode']);
echo "<td width=4% align=center>$i</td>";
echo "<td width=18% align=left>$row1[femplname]</td>";
echo "<td width=18% align=left>$desn_name</td>";
echo "<td width=12% align=left>";
echo "<select id=txtattnstat[] name=txtattnstat[] class='form-control' style='width:100%;' onChange=display_values(this);>";
echo "<option value=0>--Select--</option>";
$mysql="select * from masattnstat where fdeptcode like '$dept_code' and ifnull(fdeleted,'F')='F' order by fdeptcode,fstatordr,fstatdesc";
$myres=mysqli_query($mycon,$mysql);
while($row = @mysqli_fetch_assoc($myres))
{
?>
<option value="<?php echo $row['fattnstat']."*".$row['flogitime']."*".$row['flogotime']."*".$row['ftrvlamnt']."*";?>" <?php if (strtoupper(@$attn_stat)==strtoupper($row['fattnstat'])){echo 'selected="selected"';}?>><?php echo $row['fstatdesc'];?></option>
<?php
}
echo "</select>";
echo "</td>";
echo "<td width=10% align=left>";
echo "<select id=txtlogitime[] name=txtlogitime[] class='form-control' style='width:100%;'>";
echo "<option value=0>--Select--</option>";
$mysql="select * from mastime order by ftimecode";
$myres=mysqli_query($mycon,$mysql);
while($row = @mysqli_fetch_assoc($myres))
{
?>
<option value="<?php echo $row['ftimecode'];?>" <?php if (@$logi_time==$row['ftimecode']){echo 'selected="selected"';}?>><?php echo $row['ftimedesc'];?></option>
<?php
}
echo "</select>";
echo "</td>";
echo "<td width=10% align=left>";
echo "<select id=txtlogotime[] name=txtlogotime[] class='form-control' style='width:100%;'>";
echo "<option value=0>--Select--</option>";
echo $mysql="select * from mastime where ftimecode>'$logi_time' order by ftimecode";
$myres=mysqli_query($mycon,$mysql);
while($row = @mysqli_fetch_assoc($myres))
{
?>
<option value="<?php echo $row['ftimecode'];?>" <?php if ($logo_time==$row['ftimecode']){echo 'selected="selected"';}?>><?php echo $row['ftimedesc'];?></option>
<?php
}
echo "</select>";
echo "</td>";
echo "<td width=8% align=left>";
echo "<input type=text id=txttrvlamnt[] name=txttrvlamnt[] class='form-control' value='$trvl_amnt' maxlength=5 style='width:100%;text-align:right;' onKeyDown='return decimals_only(event);'/>";
echo "</td>";
echo "<td width=8% align=left>";
echo "<input type=text id=txtovertime[] name=txtovertime[] class='form-control' value='$over_time' maxlength=3 style='width:100%; text-align:center;' onKeyDown='return numbers_only(event);'/>";
echo "</td>";
echo "<td width=10% align=left>";
echo "<input type=text id=txtattnremk[] name=txtattnremk[] class='form-control' value='$attn_remk' onBlur='validate_row(this);' style=;width:100%;'/>";
echo "</td>";
echo "</tr>";
$i++;
}
echo "</table>";
}
if($load_data=='save_data')
{
$dept_code=$_POST['dept_code'];
$attn_date=$_POST['attn_date'];
$empl_code=$_POST['empl_code'];
$attn_stat=$_POST['attn_stat'];
$logi_time=$_POST['logi_time'];
$logo_time=$_POST['logo_time'];
$trvl_amnt=$_POST['trvl_amnt'];
$over_time=$_POST['over_time'];
$attn_remk=$_POST['attn_remk'];
include("sys_connect.php");
$mysql="delete from attendance where fdeptcode='$dept_code' and fattndate=str_to_date('$attn_date','%d-%m-%Y')";
$myres=mysqli_query($mycon,$mysql);
for ($i = 0; $i < sizeof($empl_code); $i++)
{
$attn_stat1=$attn_stat[$i];
$attn_stat2=explode("*",$attn_stat1);
$attn_stat3=$attn_stat2[0];
if($attn_stat=='ab'||$attn_stat=='cl'||$attn_stat=='hd'||$attn_stat=='ia')
{
$logi_time[$i]=0;
$logo_time[$i]=0;
$trvl_amnt[$i]=0;
$over_time[$i]=0;
}
$mysql = "";
$mysql.= "insert into attendance (fdeptcode, fattndate, femplcode, fattnstat, flogitime, flogotime, ftrvlamnt, fovertime, ";
$mysql.= "fattnremk, fupdtuser, fupdttime) values('$dept_code', str_to_date('$attn_date','%d-%m-%Y'), '$empl_code[$i]', ";
$mysql.= "'$attn_stat3', '$logi_time[$i]', '$logo_time[$i]', '$trvl_amnt[$i]', '$over_time[$i]', '$attn_remk[$i]', ";
$mysql.= "'$user_id', now())";
$myres=mysqli_query($mycon,$mysql);
$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=str_to_date('$attn_date','%d-%m-%Y')";
$myres=mysqli_query($mycon,$mysql);
}
$mysql="insert into sys_logs_user (fdeptcode,flogstype,fusercode,flogsdate,flogsipad,flogsmcad,fremarks,fdeleted) values('$dept_id','ATTN','$user_id',now(),'$useripad','$usermcad','ATTENDANCE UPDATED - $attn_date : $dept_code','F')";
$myres=mysqli_query($mycon,$mysql);
$resp_mesg="Attendance updated!";
echo json_encode(array("mesg"=>$resp_mesg, "stat"=>$resp_stat, "file"=>$resp_file));
}
?>
|