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


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

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

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

$dept_code = $_POST['dept_code'];
$attn_dat1 = $_POST['attn_dat1'];
$attn_dat2 = $_POST['attn_dat2'];

$mysql = "select attendance.fdeptcode,attendance.femplcode,femplname,
	fattndate,attendance.fattnstat,fstatdesc,attendance.flogitime,attendance.flogotime,
	flogidiff,flogodiff,fworkhour from attendance,masempl,masattn_stat,masdesn where 
	attendance.fdeptcode='$dept_code' and fattndate between str_to_date('$attn_dat1','%d/%m/%Y') 
	and str_to_date('$attn_dat2','%d/%m/%Y') and attendance.femplcode=masempl.femplcode 
	and attendance.fattnstat=masattn_stat.fattnstat and attendance.fdeptcode=masattn_stat.fdeptcode 	
	and masempl.fempldesn=masdesn.fempldesn order by fattndate,fempltype,fdesnordr,femplname";

$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);
if ($mycnt == 0) {
    $resp_mesg = "No details found!";
    $resp_stat = "F";
} else {
    $resp_stat = "T";
    $dept_code = "";
    $line_no = 0;
    $i = 1;

    require_once("fpdf/fpdf.php");
    $pdf = new FPDF('P', 'mm', 'A4');
    $pdf->SetMargins(15, 15);
    $pdf->SetFont('Arial', '', 9);
    while ($myrow = mysqli_fetch_assoc($myres)) {
        if ($attn_date <> $myrow['fattndate']) {
            $line_no = 0;
            $i = 1;
        }

        if ($line_no == 0 || $line_no % 36 == 0) {
            $attn_date = $myrow['fattndate'];
            $dept_code = $myrow['fdeptcode'];
            $rept_date = date('d/m/Y', strtotime($attn_date));
            $header_dept_code = $dept_code;
            $header_dept_name = get_dept_name($dept_code);

            $pdf->AddPage();
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Cell(0, 7, "LOGISYS, BANGALORE", 0, 1, "C");
            $line_no++;
            $pdf->Cell(0, 7, "ATTENDANCE REPORT (DATEWISE)", 0, 1, "C");
            $line_no++;
            $pdf->Cell(95, 7, "Department Name: {$header_dept_name}", 0, 0, "L");
            $pdf->Cell(90, 7, "Date: {$rept_date}", 0, 0, "R");
            $pdf->ln();
            $line_no++;

            $pdf->SetFont('Arial', 'B', 9);

            $x = $pdf->GetX();
            $y = $pdf->GetY();
            $pdf->MultiCell(10, 7, "Sl. No.", 1, "C");

            $pdf->SetXY($x + 10, $y);
            $pdf->MultiCell(15, 7, "Empl. Code", 1, "C");

            $pdf->SetXY($x + 25, $y);
            $pdf->MultiCell(50, 14, "Employee Name", 1, "C");

            $pdf->SetXY($x + 75, $y);
            $pdf->MultiCell(25, 14, "Status", 1, "C");

            $pdf->SetXY($x + 100, $y);
            $pdf->MultiCell(35, 7, "Log In", 1, "C");

            $pdf->SetXY($x + 100, $y + 7);
            $pdf->MultiCell(15, 7, "Time", 1, "C");

            $pdf->SetXY($x + 115, $y + 7);
            $pdf->MultiCell(20, 7, "Remarks", 1, "C");

            $pdf->SetXY($x + 135, $y);
            $pdf->MultiCell(35, 7, "Log Out", 1, "C");

            $pdf->SetXY($x + 135, $y + 7);
            $pdf->MultiCell(15, 7, "Time", 1, "C");

            $pdf->SetXY($x + 150, $y + 7);
            $pdf->MultiCell(20, 7, "Remarks", 1, "C");

            $pdf->SetXY($x + 170, $y);
            $pdf->MultiCell(15, 7, "Work Hours", 1, "C");

            $line_no++;
        }
        $empl_code = $myrow['femplcode'];
        $pdf->SetFont('Arial', '', 9);
        $pdf->Cell(10, 7, "{$i}", 1, 0, "C");
        $pdf->Cell(15, 7, "{$myrow['femplcode']}", 1, 0, "C");
        $pdf->Cell(50, 7, "{$myrow['femplname']}", 1, 0, "L");
        $pdf->Cell(25, 7, "{$myrow['fstatdesc']}", 1, 0, "C");
        $attn_stat = strtolower($myrow['fattnstat']);
        if ($attn_stat == "ab" || $attn_stat == "cl" || $attn_stat == "hd" || $attn_stat == "wo") {
            $pdf->Cell(15, 7, "-", 1, 0, "C");
            $pdf->Cell(20, 7, "-", 1, 0, "C");
            $pdf->Cell(15, 7, "-", 1, 0, "C");
            $pdf->Cell(20, 7, "-", 1, 0, "C");
            $pdf->Cell(15, 7, "-", 1, 0, "C");
        } else {
            $logi_time = $myrow['flogitime'];
            $logi_diff = $myrow['flogidiff'];

            $pdf->Cell(15, 7, "{$logi_time}", 1, 0, "C");
            if ($logi_diff > "00:00:00") {
                $pdf->Cell(20, 7, "{$logi_diff} delay", 1, 0, "C");
            } elseif ($logi_diff < "00:00:00") {
                $pdf->Cell(20, 7, "{$logi_diff} early", 1, 0, "C");
            } else {
                $pdf->Cell(20, 7, "-", 1, 0, "C");
            }

            $logo_time = $myrow['flogotime'];
            $logo_diff = $myrow['flogodiff'];

            if ($logo_time == "00:00:00") {
                $pdf->Cell(15, 7, "-", 1, 0, "C");
                $pdf->Cell(20, 7, "Pending", 1, 0, "C");
            } else {
                if ($logo_diff > "00:00:00") {
                    $pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
                    $pdf->Cell(20, 7, "{$logo_diff} late", 1, 0, "C");
                } elseif ($logo_diff < "00:00:00") {
                    $pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
                    $pdf->Cell(20, 7, "{$logo_diff} early", 1, 0, "C");
                } elseif ($logo_diff == "00:00:00") {
                    $pdf->Cell(15, 7, "{$logo_time}", 1, 0, "C");
                    $pdf->Cell(20, 7, "-", 1, 0, "C");
                } else {
                    $pdf->Cell(15, 7, "-", 1, 0, "C");
                    $pdf->Cell(20, 7, "-", 1, 0, "C");
                }
            }

            $work_hour = $myrow['fworkhour'];
            if ($work_hour > "00:00:00") {
                $pdf->Cell(15, 7, "{$work_hour}", 1, 0, "C");
            } else {
                $pdf->Cell(15, 7, "-", 1, 0, "C");
            }
        }
        $i++;
        $pdf->ln();
        $line_no++;
    }
    $resp_file = "reports/attendance_report_datewise.pdf";
    $pdf->output($resp_file, 'F');
}

echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));