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


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

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

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

// // IHF INSERT HOLIDAY STATUS
// $mysql = "insert ignore into attendance (fdeptcode,fattndept,fattndate,femplcode,fattnstat,fupdtuser,fattnremk,fupdttime)
// select em.fdeptcode,em.fdeptcode,subdate(current_date,1),em.femplcode,if(dayname(subdate(current_date,1))='Sunday','WO','HD') as fattnstat,
// 'AUTO' as fupdtuser,'' as fattnremk, now() as fupdttime 
// from masempl em
// inner join masholiday hd on em.fdeptcode = hd.fdeptcode and hd.fholidate=subdate(current_date,1) 
// where fempltype='p' and femplstat='T' and fattnentr='T' and ifnull(em.fdeptcode,'') = 'IHF';";
// $myres = mysqli_query($mycon, $mysql);


// //IHF ABSENT / WEEKLY OFF STATUS
// $mysql = "insert ignore into attendance (fdeptcode,fattndept,fattndate,femplcode,fattnstat,fupdtuser,fattnremk,fupdttime)
// select em.fdeptcode,em.fdeptcode,subdate(current_date,1),em.femplcode,if(dayname(subdate(current_date,1))='Sunday','WO','AB') as fattnstat,
// 'AUTO' as fupdtuser,'' as fattnremk, now() as fupdttime from masempl em
// left join attendance at on em.femplcode = at.femplcode and fattndate = subdate(current_date,1)
// where fempltype='p' and femplstat='T' and fattnentr='T' and ifnull(em.fdeptcode,'') = 'IHF' and at.femplcode is null;";
// $myres = mysqli_query($mycon, $mysql);


// //IHF ABSENT REPORT
// $mysql = "select date_format(ad.fattndate,'%d/%m/%Y') as lattndate,ad.fattndate,dp.fdeptcode,dp.fdeptname,dp.fdeptshrt,
// em.femplcode,femplname,fempldesn,ad.fattnstat
// from attendance ad
// inner join masempl em on ad.femplcode = em.femplcode and em.femplstat='T' and em.fattnentr='T' and em.fempltype='P'
// inner join masdesn ds on em.fempldesn = ds.fempldesn and em.fempldesn like '%'
// inner join masdept dp on ad.fdeptcode = dp.fdeptcode 
// inner join masattn_stat ap on ad.fattnstat = ap.fattnstat and ad.fdeptcode = ap.fdeptcode 
// where ad.fdeptcode like '%' and ad.fattnstat in ('AB','CL') and ifnull(em.fdeptcode,'')='IHF'
// and ad.fattndate = subdate(current_date,1) order by fattndate,fdeptname,femplname";
// $myres = mysqli_query($mycon, $mysql);
// $mycnt = mysqli_num_rows($myres);
// if ($mycnt != 0) {
//     $line_no = 0;
//     $i = 1;
//     require_once("fpdf/fpdf.php");
//     $pdf = new FPDF('P', 'mm', 'A4');
//     $pdf->SetMargins(15, 10);
//     $pdf->SetFont('Arial', '', 9);
//     while ($myrow = mysqli_fetch_assoc($myres)) {
//         if ($line_no == 0 || $line_no % 36 == 0) {
//             $pdf->AddPage();
//             $pdf->SetFont('Arial', 'B', 10);
//             $pdf->Cell(0, 7, "IHF, BENGALURU", 0, 1, "C");
//             $line_no++;
//             $pdf->Cell(0, 7, "LEAVE / ABSENT LIST " . $myrow['lattndate'], 0, 1, "C");

//             $pdf->SetFont('Arial', 'B', 9);
//             $pdf->Cell(10, 7, "Sl. No.", 1, 0, "C");
//             $pdf->Cell(25, 7, "Client", 1, 0, "C");
//             $pdf->Cell(80, 7, "Employee Name", 1, 0, "C");
//             $pdf->Cell(50, 7, "Designation", 1, 0, "C");
//             $pdf->Cell(20, 7, "Remarks", 1, 1, "C");

//             $line_no++;
//         }
//         $pdf->SetFont('Arial', '', 9);
//         $pdf->Cell(10, 7, "{$i}", 1, 0, "C");
//         $pdf->Cell(25, 7, "[{$myrow['fdeptcode']}] {$myrow['fdeptshrt']}", 1, 0, "C");
//         $pdf->Cell(80, 7, "[{$myrow['femplcode']}] {$myrow['femplname']}", 1, 0, "L");
//         $pdf->Cell(50, 7, "{$myrow['fempldesn']}", 1, 0, "L");
//         $pdf->Cell(20, 7, "{$myrow['fattnstat']}", 1, 0, "C");
//         $i++;
//         $pdf->ln();
//         $line_no++;
//     }
//     $mail_fil1 = "reports/attendance_absent_report.pdf";
//     $pdf->output($mail_fil1, 'F');
// }

// IHF SUMMARY REPORT
$mysql = "select dp.fdeptcode,dp.fdepttype,dp.fdeptname,dp.fdeptshrt,count(*) as ltotalem,
sum(case when ap.fattntype in ('pr','hw') then 1 else 0 end) as ltotalpr,
sum(case when ap.fattntype='ab' then 1 else 0 end) as ltotalab,
sum(case when ap.fattntype='cl' then 1 else 0 end) as ltotalcl, 
sum(case when ap.fattntype='hd' then 1 else 0 end) as ltotalhd,
sum(case when ad.femplcode is null then 1 else 0 end) as ltotalpd,fholidesc 
from masdept dp
inner join masempl em on dp.fdeptcode = em.fdeptcode and em.femplstat='T' and ifnull(em.fdeleted,'F')<>'T' 
left join attendance ad on em.femplcode = ad.femplcode and ad.fattndate = subdate(current_date,1)
left join masattn_stat ap on dp.fdeptcode = ap.fdeptcode and ad.fattnstat = ap.fattnstat
left join masholiday hl on dp.fdeptcode = hl.fdeptcode and fholidate = subdate(current_date,1)
where ifnull(dp.fdeptcode,'')='IHF'
group by dp.fdeptcode order by dp.fdepttype desc, dp.fdeptname";
$myres = mysqli_query($mycon, $mysql);
if (mysqli_num_rows($myres) == 0) {
    $mail_text = "
    <div style='background-color:#CCC;padding:10px; max-width:1034px; aligh:center;'>
    <table cellpadding='5' cellspacing='0' border='1' align='center' style='border:1px solid #BBB;border-collapse: collapse;background-color:#FFF;min-width:1024px;'>
    <tr>
    <th colspan=99> No attendance details found on " . date('d/m/Y',strtotime("-1 days")) . "</th>
    </tr></table></div>";
}else{
    $mail_text = "
    <div style='background-color:#CCC;padding:10px; max-width:1034px; aligh:center;'>
    <table cellpadding='5' cellspacing='0' border='1' align='center' style='border:1px solid #BBB;border-collapse: collapse;background-color:#FFF;min-width:1024px;'>
    <tr>
    <th colspan=99> Attendance Summary - " . date('d/m/Y',strtotime("-1 days")) . "</th>
    </tr>
    <tr>
    <th width='4%' align='center'>#</th>
    <th width='50%'align='center'>Location</th>
    <th width='6%' align='center'>Total</th>
    <th width='6%' align='center'>Present</th>
    <th width='6%' align='center'>Leave</th>
    <th width='6%' align='center'>Absent</th>
    <th width='6%' align='center'>Holiday</th>
    <th width='15%' align='center'>Remarks</th>
    </tr>";
    $i = 1;
    $totalem = 0;
    $totalpr = 0;
    $totalab = 0;
    $totalcl = 0;
    $totalhd = 0;
    $totalwo = 0;
    while ($myrow = mysqli_fetch_assoc($myres)) {
        $mail_text .= "<tr>
        <td align='center'> $i</td>
        <td align='left'  >[$myrow[fdeptcode]] $myrow[fdeptname]</td>
        <td align='center'> $myrow[ltotalem]</td>
        <td align='center'> $myrow[ltotalpr]</td>
        <td align='center'> $myrow[ltotalcl]</td>
        <td align='center'> $myrow[ltotalab]</td>
        <td align='center'> $myrow[ltotalhd]</td>
        <td align='center'> $myrow[fholidesc]</td>
        </tr>";
        $i++;
        $totalem = $totalem + $myrow['ltotalem'];
        $totalpr = $totalpr + $myrow['ltotalpr'];
        $totalcl = $totalcl + $myrow['ltotalcl'];
        $totalab = $totalab + $myrow['ltotalab'];
        $totalhd = $totalhd + $myrow['ltotalhd'];
    }
    $mail_text .= "<tr style='font-weight:bold;'>
    <td align='center' colspan=2>Total</td>
    <td align='center'>$totalem</td>
    <td align='center'>$totalpr</td>
    <td align='center'>$totalcl</td>
    <td align='center'>$totalab</td>
    <td align='center'>$totalhd</td>
    <td align='center'></td>
    </tr></table>";

    $mysql = "select concat('[',em.femplcode,'] ',femplname) as lemplname,
    fattnstat,ad.flogitime,ad.flogotime,if(ad.femplcode is null,'Attn. Pending','') as lattnremk 
    from masempl em
    inner join masdept dp on em.fdeptcode = dp.fdeptcode and dp.fdeptcode in ('','ihf') 
    left join attendance ad on em.femplcode = ad.femplcode and fattndate=subdate(current_date, 1) 
    where em.femplstat='T' and ifnull(em.fdeleted,'F')<>'T' order by em.fdeptcode,em.femplname;";
    $myres = mysqli_query($mycon, $mysql);

    $mail_text .= "<table cellpadding='5' cellspacing='0' border='1' align='center' style='border:1px solid #BBB;border-collapse: collapse;background-color:#FFF;min-width:1024px;'>
    <tr>
    <th colspan=99> Attendance List - " . date('d/m/Y',strtotime("-1 days")) . "</th>
    </tr>
    <tr>
    <th width='4%' align='center'>#</th>
    <th width='50%'align='center'>Empl. Name</th>
    <th width='10%' align='center'>Status</th>
    <th width='10%' align='center'>Log In Time</th>
    <th width='10%' align='center'>Log Out Time</th>
    <th width='15%' align='center'>Remarks</th>
    </tr>";
    $i = 1;
    $totalem = 0;
    $totalpr = 0;
    $totalab = 0;
    $totalcl = 0;
    $totalhd = 0;
    $totalwo = 0;
    while ($myrow = mysqli_fetch_assoc($myres)) {
        $mail_text .= "<tr>
        <td align='center'> $i</td>
        <td align='left'  > $myrow[lemplname]</td>
        <td align='center'> $myrow[fattnstat]</td>
        <td align='center'> $myrow[flogitime]</td>
        <td align='center'> $myrow[flogotime]</td>
        <td align='center'> $myrow[lattnremk]</td>
        </tr>";
        $i++;
    }
    $mail_text .= "</table>";
    $mail_text .= "</div>";
}

$mail_main = "hnagaraj@hotmail.com";
$mail_copy = "shsubramanya@gmail.com";
$mail_bccy = "";
$mail_subj = "Attendance Status - ".date('d/m/Y',strtotime("-1 days"))." [Indian Home Foods]" ;
$mail_file = $mail_fil1 . ',' . $mail_fil2;
$resp_stat = send_mail($mail_main, $mail_copy, $mail_bccy, $mail_subj, $mail_text, $mail_file);