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


Current Path : /var/www/html/oums/src/
Upload File :
Current File : /var/www/html/oums/src/work_entry_report_work_done_stat.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'];
$empl_code = $_POST['empl_code'];
$work_type = $_POST['work_type'];
$work_dat1 = $_POST['work_dat1'];
$work_dat2 = $_POST['work_dat2'];

$mysql = "";
$mysql .= "select * from workentry where fdeptcode='$dept_code' and femplcode like '$empl_code' ";
$mysql .= "and fworkdate between str_to_date('$work_dat1','%d/%m/%Y') and str_to_date('$work_dat2','%d/%m/%Y') ";
$mysql .= "and fworktype like '$work_type' and fclntcode like '$_POST[clnt_code]' order by fworkdate";
$myres = mysqli_query($mycon, $mysql);
$mycnt = mysqli_num_rows($myres);

if ($mycnt == 0) {
    $resp_stat = "F";
    $resp_mesg = "No records found!";
} else {
    require("fpdf/fpdf.php");
    $pdf = new FPDF('P', 'mm', 'A4');
    $pdf->AliasNbPages();

    $i = 1;
    $work_date = "";
    $line_no = 0;

    $header_dept_name = get_dept_name($dept_code);
    $header_empl_name = get_empl_name($empl_code);

    while ($myrow = mysqli_fetch_assoc($myres)) {
        if ($work_date != date('d/m/Y', strtotime($myrow['fworkdate'])) || $empl_code != $myrow['femplcode']) {
            $work_date = date('d/m/Y', strtotime($myrow['fworkdate']));
            $empl_code = $myrow['femplcode'];
            $pdf->AddPage();
            $pdf->SetMargins(10, 10);
            $pdf->SetFont('Arial', 'B', 10);
            $pdf->Cell(0, 7, "WORK DONE STATEMENT (DATEWISE)", 0, 1, "C");
            $line_no++;
            $pdf->Cell(190, 7, "Client : {$header_dept_name}", 1, 1, "L");
            $line_no++;
            $pdf->Cell(100, 7, "Employee Range: {$header_empl_name}", 1, 0, "L");
            $pdf->Cell(90, 7, "Date Range: {$work_dat1} to {$work_dat2}", 1, 0, "R");
            $pdf->ln();
            $line_no++;
            $pdf->ln();
            $line_no++;
        }

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

        $work_date = date('d/m/Y', strtotime($myrow['fworkdate']));
        $empl_code = $myrow['femplcode'];
        $empl_name = get_empl_name($empl_code);

        $clnt_code = $myrow['fclntcode'];
        $clnt_name = get_clnt_name($clnt_code);

        $work_type = $myrow['fworktype'];
        $type_desc = get_type_desc($work_type);

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

        // $pdf->Cell(10,7,"{$i}",1,0,"C");
        $pdf->Cell(30, 7, "Name: ", 1, 0, "L");
        $pdf->Cell(100, 7, "{$empl_name}", 1, 0, "L");
        $pdf->Cell(30, 7, "Date: ", 1, 0, "L");
        $pdf->Cell(30, 7, "{$work_date}", 1, 0, "L");
        $pdf->ln();
        $line_no++;

        $pdf->Cell(30, 7, "Type: ", 1, 0, "L");
        $pdf->Cell(100, 7, "{$type_desc}", 1, 0, "L");
        $pdf->Cell(30, 7, "Planned?: ", 1, 0, "L");
        if ($myrow['fworkplan'] == 'T') {
            $pdf->Cell(30, 7, "Yes", 1, 0, "L");
        } else {
            $pdf->Cell(30, 7, "No", 1, 0, "L");
        }
        $pdf->ln();
        $line_no++;

        // $pdf->Cell(10,7,"",1,0,"C");
        $pdf->Cell(30, 7, "Client: ", 1, 0, "L");
        $pdf->Cell(100, 7, "{$clnt_name}", 1, 0, "L");
        $pdf->Cell(30, 7, "Place of Work: ", 1, 0, "L");
        $pdf->Cell(30, 7, "{$myrow['fworkplce']}", 1, 0, "L");
        $pdf->ln();
        $line_no++;

        // $pdf->Cell(10,7,"",1,0,"C");
        $pdf->Cell(30, 7, "Work Title:", 1, 0, "L");
        $pdf->Cell(160, 7, "{$myrow['fworkname']}", 1, 0, "L");
        $pdf->ln();
        $line_no++;


        $x = $pdf->GetX();
        $y = $pdf->GetY();
        // $pdf->MultiCell(10,7,"",1,1);			
        // $pdf->SetXY($x + 10, $y);	
        // $pdf->MultiCell(30,7,"Work Details",1,1);			

        $pdf->SetXY($x, $y);
        $pdf->MultiCell(190, 7, "{$myrow['fworkdetl']}", 1, 1);

        // $pdf->Cell(10,7,"",1,0,"C");
        // $pdf->Cell(30,7,"Work Details:",1,0,"L");								
        // $pdf->Cell(240,7,"{$myrow[fworkdetl]}",1,0,"L");								
        // $pdf->ln();$line_no++;

        // $pdf->Cell(10,7,"",1,0,"C");
        $pdf->Cell(30, 7, "Remarks:", 1, 0, "L");
        $pdf->Cell(160, 7, "{$myrow['fworkremk']}", 1, 0, "L");
        $pdf->ln();
        $line_no++;

        // $pdf->Cell(10,7,"",1,0,"C");
        $pdf->Cell(30, 7, "Status:", 1, 0, "L");
        $pdf->Cell(160, 7, "{$myrow['fworkstat']}", 1, 0, "L");
        $pdf->ln();
        $line_no++;
        $pdf->ln();
        $line_no++;
        $i++;
    }
    $resp_file = 'reports/report_work_done_stat.pdf';
    $pdf->output($resp_file, 'F');
}
echo json_encode(array("mesg" => $resp_mesg, "stat" => $resp_stat, "file" => $resp_file));