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.40.234
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/attendance.php |
<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$resp_mesg = "";
$resp_stat = "";
$resp_file = "";
if ($_POST["load_data"] == 'dept_detl') {
if ($type_id == 'ADMIN') {
$mysql = "select * from masdept where fdeptstat='T' and fattnenbl='T' order by fdeptname";
} else {
$mysql = "select * from masdept d
inner join masdept_user u on d.fdeptcode = u.fdeptcode and fusercode='$user_id'
where d.fdeptstat='T' and d.fattnenbl='T' order by fdeptname";
}
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) > 1) {
echo "<option value='%'>ALL [CLIENTS]</option>";
}
while ($myrow = mysqli_fetch_assoc($myres)) {
echo "<option value='$myrow[fdeptcode]'>$myrow[fdeptname] [$myrow[fdeptcode]]</option>";
}
}
if ($_POST["load_data"] == 'mark_detl') {
$dept_code = $_POST['dept_code'];
$mysql1 = "select distinct fattnstat,fstatdesc,fstatordr from masattn_stat where fdeptcode like '$dept_code' and ifnull(fdeleted,'F')<>'T' order by fstatordr,fstatdesc";
$myres1 = mysqli_query($mycon, $mysql1);
echo "<option value=0>NONE</option>";
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
echo "<option value='$myrow1[fattnstat]'>$myrow1[fstatdesc]</option>";
}
}
if ($_POST["load_data"] == 'view_data') {
$i = 1;
$dept_code = $_POST['dept_code'];
$attn_date = $_POST['attn_date'];
$attn_mark = $_POST['attn_mark'];
$i = 1;
if ($type_id == 'ADMIN') {
$mysql1 = "select e.fdeptcode as fdeptcode,d.fdeptshrt,e.femplcode as femplcode,femplname,fempldesn,a.fattndate as fattndate,a.fattnstat as fattnstat,
a.flogitime as flogitime,a.flogotime as flogotime,a.ftrvlamnt as ftrvlamnt,t.flogitime as flogitim2,t.flogotime as flogotim2,t.ftrvlamnt as ftrvlamn2,
a.fovertime as fovertime,a.fcodepack as fcodepack,a.fattnremk as fattnremk
from masempl e
left join masdept d on e.fdeptcode = d.fdeptcode
left join masattn_stat t on e.fdeptcode = t.fdeptcode and fattnstat='$attn_mark'
left join attendance a on e.femplcode = a.femplcode and e.fdeptcode=a.fdeptcode and a.fattndate=str_to_date('$attn_date','%d/%m/%Y')
where e.femplstat='T' and e.fempltype='T' and e.fattnentr='T' and d.fdeptstat='T' and d.fattnenbl='T' and d.fdeptcode like '$dept_code'
order by d.fdepttype desc,d.fdeptcode,e.femplname";
} else {
$mysql1 = "select e.fdeptcode as fdeptcode,d.fdeptshrt,e.femplcode as femplcode,femplname,fempldesn,a.fattndate as fattndate,a.fattnstat as fattnstat,
a.flogitime as flogitime,a.flogotime as flogotime,a.ftrvlamnt as ftrvlamnt,t.flogitime as flogitim2,t.flogotime as flogotim2,t.ftrvlamnt as ftrvlamn2,
a.fovertime as fovertime,a.fcodepack as fcodepack,a.fattnremk as fattnremk
from masempl e
left join masdept d on e.fdeptcode = d.fdeptcode
left join masattn_stat t on e.fdeptcode = t.fdeptcode and fattnstat='$attn_mark'
left join attendance a on e.femplcode = a.femplcode and e.fdeptcode=a.fdeptcode and a.fattndate=str_to_date('$attn_date','%d/%m/%Y')
inner join masdept_user u on e.fdeptcode = u.fdeptcode and u.fusercode='$user_id'
where e.femplstat='T' and e.fempltype='T' and e.fattnentr='T' and d.fdeptstat='T' and d.fattnenbl='T' and d.fdeptcode like '$dept_code'
order by d.fdepttype desc,d.fdeptcode,e.femplname";
}
$myres1 = mysqli_query($mycon, $mysql1);
echo "<table id=table_attn class=table_list border=1>";
echo "<tr>";
echo "<th width=3%> # </th>";
echo "<th width=7%> Client </th>";
echo "<th width=15%> Employee Name </th>";
echo "<th width=15%> Designation </th>";
echo "<th width=8%> Status </th>";
echo "<th width=15% colspan='3'> Login </th>";
echo "<th width=15% colspan='3'> Log Out </th>";
echo "<th width=5%> T.A.</th>";
echo "<th width=5%> Over Time</th>";
echo "<th width=5%> Code Pack.</th>";
echo "<th width=7%> Remarks </th>";
echo "</tr>";
while ($myrow1 = mysqli_fetch_assoc($myres1)) {
$defa_logi_hour = substr($myrow1['flogitim2'], 0, 2);
$defa_logi_mins = substr($myrow1['flogitim2'], 3, 2);
$defa_logi_secs = substr($myrow1['flogitim2'], 6, 2);
$defa_trvl_amnt = number_format($myrow1['ftrvlamn2'], 2, '.', '');
$dept_code = $myrow1['fdeptcode'];
$empl_code = $myrow1['femplcode'];
$attn_stat = $myrow1['fattnstat'];
$logi_hour = substr($myrow1['flogitime'], 0, 2);
$logi_mins = substr($myrow1['flogitime'], 3, 2);
$logi_secs = substr($myrow1['flogitime'], 6, 2);
$trvl_amnt = $myrow1['ftrvlamnt'];
$over_time = $myrow1['fovertime'];
$code_pack = $myrow1['fcodepack'];
$attn_remk = $myrow1['fattnremk'];
if ($logi_time == 0) {
$logi_hour = $defa_logi_hour;
$logi_mins = $defa_logi_mins;
$logi_secs = $defa_logi_secs;
}
if ($trvl_amnt == 0) {
$trvl_amnt = $defa_trvl_amnt;
}
if ($over_time == 0) {
$over_time = '0';
}
if ($code_pack == 0) {
$code_pack = '0';
}
if ($attn_mark != '0') {
$attn_stat = $attn_mark;
}
echo "<tr style='height:20px;'>";
echo "<input type=hidden name='txtattndate[]' id='txtattndate' value='$attn_date'>";
echo "<input type=hidden name='txtdeptcode[]' id='txtdeptcode' value='$myrow1[fdeptcode]'>";
echo "<input type=hidden name='txtemplcode[]' id='txtemplcode' value='$myrow1[femplcode]'>";
echo "<td align=center>$i</td>";
echo "<td align=center>$myrow1[fdeptcode]-$myrow1[fdeptshrt]</td>";
echo "<td align=left> $myrow1[femplname]</td>";
echo "<td align=left> $myrow1[fempldesn]</td>";
echo "<td align=left>";
echo "<select id=txtattnstat[] name=txtattnstat[] class='form-control' style='width:100%;' onChange='display_values(this);'>";
echo "<option value=0>--Select--</option>";
$mysql2 = "select * from masattn_stat where fdeptcode='$dept_code' and ifnull(fdeleted,'F')='F' order by fdeptcode,fstatordr,fstatdesc";
$myres2 = mysqli_query($mycon, $mysql2);
while ($myrow2 = mysqli_fetch_assoc($myres2)) {
$stat_dept_code = $myrow2['fdeptcode'];
$stat_attn_stat = $myrow2['fattnstat'];
$stat_trvl_amnt = $myrow2['ftrvlamnt'];
$stat_logi_hour = substr($myrow2['flogitime'], 0, 2);
$stat_logi_mins = substr($myrow2['flogitime'], 3, 2);
$stat_logi_secs = substr($myrow2['flogitime'], 6, 2);
$val = $stat_dept_code . '*' . $stat_attn_stat . '*' . $stat_logi_hour . '*' . $stat_logi_mins . '*' . $stat_logi_secs . '*' . $stat_trvl_amnt . '*';
$sel = (strtoupper($attn_stat) == strtoupper($stat_attn_stat) ? "selected" : "");
echo "<option value='$val' $sel>" . $myrow2['fstatdesc'] . "</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogihour[] name=txtlogihour[] class='form-control' style='width:100%;'>";
echo "<option value=0>Hrs.</option>";
for ($k = 0; $k <= 23; $k++) {
$hrs = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($hrs == $logi_hour ? "selected='selected'" : "");
echo "<option value='$hrs' $sel>$hrs Hrs.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogimins[] name=txtlogimins[] class='form-control' style='width:100%;'>";
echo "<option value=0>Min.</option>";
for ($k = 0; $k <= 59; $k++) {
$min = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($min == $logi_mins ? "selected='selected'" : "");
echo "<option value='$min' $sel>$min Min.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogisecs[] name=txtlogisecs[] class='form-control' style='width:100%;'>";
echo "<option value=0>Sec.</option>";
for ($k = 0; $k <= 60; $k++) {
$sec = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($sec == $logi_secs ? "selected='selected'" : "");
echo "<option value='$sec' $sel>$sec Sec.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogohour[] name=txtlogohour[] class='form-control' style='width:100%;'>";
echo "<option value=0>Hrs.</option>";
for ($k = 0; $k <= 23; $k++) {
$hrs = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($hrs == $logo_hour ? "selected='selected'" : "");
echo "<option value='$hrs' $sel>$hrs Hrs.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogomins[] name=txtlogomins[] class='form-control' style='width:100%;'>";
echo "<option value=0>Min.</option>";
for ($k = 0; $k <= 59; $k++) {
$min = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($min == $logo_mins ? "selected='selected'" : "");
echo "<option value='$min' $sel>$min Mins.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<select id=txtlogosecs[] name=txtlogosecs[] class='form-control' style='width:100%;'>";
echo "<option value=0>Sec.</option>";
for ($k = 0; $k <= 60; $k++) {
$sec = str_pad($k, 2, '0', STR_PAD_LEFT);
$sel = ($sec == $logo_secs ? "selected='selected'" : "");
echo "<option value='$sec' $sel>$sec Sec.</option>";
}
echo "</select>";
echo "</td>";
echo "<td align=left>";
echo "<input type=text id=txttrvlamnt[] name=txttrvlamnt[] class='form-control' value='$trvl_amnt' maxlength=6 style='text-align:right;' onKeyDown='return decimals_only(event);'/>";
echo "</td>";
echo "<td align=left>";
echo "<input type=text id=txtovertime[] name=txtovertime[] class='form-control' value='$over_time' maxlength=4 style='text-align:center;' onKeyDown='return decimals_only(event);'/>";
echo "</td>";
echo "<td align=left>";
echo "<input type=text id=txtcodepack[] name=txtcodepack[] class='form-control' value='$code_pack' maxlength=3 style='text-align:center;' onKeyDown='return numbers_only(event);'/>";
echo "</td>";
echo "<td align=left>";
echo "<input type=text id=txtattnremk[] name=txtattnremk[] class='form-control' value='$attn_remk' maxlength=50 onBlur='validate_row(this);'/>";
echo "</td>";
echo "</tr>";
$i++;
}
echo "</table>";
}
if ($_POST["load_data"] == 'save_data') {
$dept_cod2 = "";
$attn_date = $_POST['attn_date'];
$dept_code = $_POST['dept_code'];
$empl_code = $_POST['empl_code'];
$attn_stat = $_POST['attn_stat'];
$logi_hour = $_POST['logi_hour'];
$logi_mins = $_POST['logi_mins'];
$logi_secs = $_POST['logi_secs'];
$logo_hour = $_POST['logo_hour'];
$logo_mins = $_POST['logo_mins'];
$logo_secs = $_POST['logo_secs'];
$trvl_amnt = $_POST['trvl_amnt'];
$over_time = $_POST['over_time'];
$code_pack = $_POST['code_pack'];
$attn_remk = $_POST['attn_remk'];
for ($i = 0; $i < sizeof($dept_code); $i++) {
$mysql = "delete from attendance where fdeptcode='$dept_code[$i]' 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[1];
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;
$code_pack[$i] = 0;
} else {
$logi_time[$i] = $logi_hour[$i] . ":" . $logi_mins[$i] . ":" . $logi_secs[$i];
$logo_time[$i] = $logo_hour[$i] . ":" . $logo_mins[$i] . ":" . $logo_secs[$i];
}
$mysql = "insert into attendance (fdeptcode, fattndate, femplcode, fattnstat, flogitime, flogotime, ftrvlamnt, fovertime,
fcodepack, fattnremk, fupdtuser, fupdttime) values('$dept_code[$i]', str_to_date('$attn_date','%d/%m/%Y'), '$empl_code[$i]',
'$attn_stat3', '$logi_time[$i]', '$logo_time[$i]', '$trvl_amnt[$i]', '$over_time[$i]', '$code_pack[$i]', '$attn_remk[$i]',
'$user_id', now())";
$myres = mysqli_query($mycon, $mysql);
$mysql = "update masdept dp,attendance at set
at.flogidiff=timediff(at.flogitime,dp.flogitime),
at.flogodiff=timediff(at.flogotime,dp.flogotime),
at.fworkhour=timediff(at.flogotime,at.flogitime)
where at.fdeptcode=dp.fdeptcode and at.fdeptcode='$dept_code[$i]' and at.fattndate=str_to_date('$attn_date','%d/%m/%Y') and at.fattnstat='PR'";
$myres = mysqli_query($mycon, $mysql);
if ($dept_cod2 != $dept_code[$i]) {
set_user_logs($dept_id, $user_id, 'ATTN', 'ATTENDANCE UPDATED: ' . $attn_date . ' - ' . $dept_code[$i]);
$dept_cod2 = $dept_code[$i];
}
}
$resp_mesg = "Attendance updated!";
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}
|