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 : 18.226.187.224


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

<?php
include("sys_session.php");
include("sys_mainphp.php");
include("sys_connect.php");
include("api_sendmail.php");

$resp_stat = "";
$resp_file = "";
$mail_main = "";
$mail_copy = "";
$mail_bccy = "";
$mail_subj = "";
$mail_file = "";
$mail_text = "";

//GRV STATUS
$mysql = "select dp.fdeptcode,dp.fdepttype,dp.fdeptname,count(*) as 'ftotlrecv',
sum(case when ifnull(fgrvstatus,'')='R' then 1 else 0 end) as 'ftotlrepl',
sum(case when ifnull(fgrvstatus,'')='C' then 1 else 0 end) as 'ftotlcomp',
sum(case when ifnull(fgrvstatus,'')='A' then 1 else 0 end) as 'ftotlactv',
sum(case when ifnull(fgrvstatus,'')='' then 1 else 0 end) as 'ftotlpend',
sum(case when date_format(fgrvdate,'%Y-%m-%d')=current_date then 1 else 0 end) as 'fdaterecv',
sum(case when ifnull(fgrvstatus,'')='R' and date_format(fgrvdate,'%Y-%m-%d')=current_date then 1 else 0 end) as 'fdaterepl',
sum(case when ifnull(fgrvstatus,'')='C' and date_format(fgrvdate,'%Y-%m-%d')=current_date then 1 else 0 end) as 'fdatecomp',
sum(case when ifnull(fgrvstatus,'')='A' and date_format(fgrvdate,'%Y-%m-%d')=current_date then 1 else 0 end) as 'fdateactv'
from logisys3_grv.grvhead gh
inner join masdept dp on gh.funivcode = dp.fdeptcode and dp.fdeptstat='T'
group by gh.funivcode
order by dp.fdepttype desc, dp.fdeptcode;";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) == 0) {
    $mail_text = "
    <div style='background-color:#CCC; float:left; padding:10px;'>
    <table cellpadding='5' cellspacing='0' border='1' align='center' style='border:1px solid #BBB;border-collapse: collapse;background-color:#FFF;width:1024px;'>
    <tr>
    <th colspan=99>No details found on " . date('d/m/Y') . "</th>
    </tr></table>
    </div>";
} else {
    $mail_text = "
    <div style='background-color:#CCC; float:left; padding:10px;'>
    <table cellpadding='5' cellspacing='0' border='1' align='center' style='border:1px solid #BBB;border-collapse: collapse;background-color:#FFF;width:1024px;'>
    <tr style='color:#0000FF;'>
    <th colspan=99> Grievance Status - " . date('d/m/Y') . "</th>
    </tr>
    <tr style='color:#0000FF;'>
    <th width='4%' align='center' rowspan=2>#</th>
    <th width='6%' align='center' rowspan=2>Type</th>
    <th width='30%'align='center' rowspan=2>Client</th>
    <th width='30%' align='center' colspan=5>Total</th>
    <th width='30%' align='center' colspan=4>" . date('d/m/Y') . "</th>
    </tr>
    <tr style='color:#0000FF;'>   
    <th width='6%' align='center'>Received</th>
    <th width='6%' align='center'>Closed</th>
    <th width='6%' align='center'>Replied</th>
    <th width='6%' align='center'>Active</th>
    <th width='6%' align='center'>Pending</th>
    
    <th width='7%' align='center'>Received</th>
    <th width='7%' align='center'>Closed</th>
    <th width='7%' align='center'>Replied</th>
    <th width='7%' align='center'>Active</th>
    </tr>";
    $i = 1;
    $totl_recv = 0;
    $totl_repl = 0;
    $totl_comp = 0;
    $totl_actv = 0;
    $totl_pend = 0;

    $date_recv = 0;
    $date_repl = 0;
    $date_comp = 0;
    $date_actv = 0;

    while ($myrow = mysqli_fetch_assoc($myres)) {
        $mail_text .= "<tr>
        <td align='center'> $i</td>
        <td align='center'> $myrow[fdepttype]</td>
        <td align='left'  > [$myrow[fdeptcode]] $myrow[fdeptname]</td>
        <td align='center'> $myrow[ftotlrecv]</td>
        <td align='center'> $myrow[ftotlcomp]</td>
        <td align='center'> $myrow[ftotlrepl]</td>
        <td align='center'> $myrow[ftotlactv]</td>
        <td align='center'> $myrow[ftotlpend]</td>

        <td align='center'> $myrow[fdaterecv]</td>
        <td align='center'> $myrow[fdatecomp]</td>
        <td align='center'> $myrow[fdaterepl]</td>
        <td align='center'> $myrow[fdateactv]</td>
        </tr>";
        $i++;
        $totl_recv = $totl_recv + $myrow['ftotlrecv'];
        $totl_comp = $totl_comp + $myrow['ftotlcomp'];
        $totl_repl = $totl_repl + $myrow['ftotlrepl'];
        $totl_actv = $totl_actv + $myrow['ftotlactv'];
        $totl_pend = $totl_pend + $myrow['ftotlpend'];

        $date_recv = $date_recv + $myrow['fdaterecv'];
        $date_comp = $date_comp + $myrow['fdatecomp'];
        $date_repl = $date_repl + $myrow['fdaterepl'];
        $date_actv = $date_actv + $myrow['fdateactv'];
    }
    $mail_text .= "<tr style='font-weight:bold;'>
    <td align='center' colspan=3>Total</td>
    <td align='center'>$totl_recv</td>
    <td align='center'>$totl_comp</td>
    <td align='center'>$totl_repl</td>
    <td align='center'>$totl_actv</td>
    <td align='center'>$totl_pend</td>

    <td align='center'>$date_recv</td>
    <td align='center'>$date_comp</td>
    <td align='center'>$date_repl</td>
    <td align='center'>$date_actv</td>
    </tr>";
    $mail_text .= "</table></div>";
}

$mysql = "select group_concat(femplmail) as mail_copy from masempl em 
inner join masdesn ds on em.fempldesn = ds.fempldesn and fmailupdt='T' 
where femplstat='t' and ifnull(femplmail,'')<>'' and ifnull(em.fdeleted,'F')<>'T' and femplcode<>'1001' and ifnull(em.fdeptcode,'') not in ('DEP','IHF')";
$myres = mysqli_query($mycon, $mysql);
while ($myrow = mysqli_fetch_assoc($myres)) {
    $mail_copy = $myrow['mail_copy'];
}

$mail_main = "hr@logisys.org";
$mail_bccy = "";
$mail_subj = "Grievance Status - " . date("d/m/Y");
$mail_file = "";
$resp_stat = send_mail($mail_main, $mail_copy, $mail_bccy, $mail_subj, $mail_text, $mail_file);