format("Y-m-d");
//https://www.youtube.com/watch?v=gNH6NNyhJLk
//https://www.youtube.com/watch?v=EYYZFRRdR6A PDF with MySQL database
$count = 0;
require ('./fpdf.php');
class PDF extends FPDF{
function Header(){
$this->Image('../images/ahg_logo.png',10,5, 25,10, 'PNG','wwww.autohubgroup.com');
}
/* function Footer(){
$this->SetY(-25);
$this->Image('../images/ahg_logo.png');
} */
}
$myUID = $_GET['userID'];
$unitID = $_GET['unitID'];
$sourceID = $_GET['userID'];
$sem = $_GET['sem'];
$unitName = $_GET['unitName'];
$rptYear = $_GET['year'];
if($sem == 1){
$semester = "1st Semester";
}else if($sem == 2){
$semester = "2nd Semester";
}else{
$semester = "1st & 2nd Semester";
}
$unitNamen = $unitName . " - PCP Compliance Report" ." (". $rptYear .")";
include_once("../../../cfg/conn.php");
include ("../functions/users.php");
$roleID=0;
if(isset($_GET['s'])){
//START OF CHECKPOINT===============================================================================
//START OF CHECKPOINT===============================================================================
//==========CHECK IF USER EXIST IN THE RECORD AND MATCH ALL INFORMATION IN THE LICNK =========
$chkUser = "SELECT * FROM `pms_employee_data` WHERE `id`='$sourceID' AND `deleted` = 0";
$qCU=mysqli_query($conn,$chkUser);
$countUser = mysqli_num_rows($qCU);
if($countUser == 0){
include '../accessDenied.php';
exit();
}else{
while($uow=mysqli_fetch_array($qCU)){
$uowaccStat = $uow['account_status'];
$uowdeleted = $uow['deleted'];
}
}
if($uowaccStat == 0){
include '../accessDenied.php';
exit();
}
if($uowdeleted == 1){
include '../accessDenied.php';
exit();
}
//==========CHECK IF EMPLOYEE EXIST IN RECORD AND MATCH ALL INFORMATION IN THE LICNK =========
$chkPoint = "SELECT `last_name`, `first_name`,`account_status`,`deleted` FROM `pms_employee_data` WHERE `id`='$empID'";
$qChk=mysqli_query($conn,$chkPoint);
$ckhRow = mysqli_num_rows($qChk);
If($ckhRow > 0){
while($row=mysqli_fetch_array($qChk)){
$lastName = $row['last_name'];
$firstName = $row['first_name'];
$accStat = $row['account_status'];
$deleted = $row['deleted'];
}
}else{
echo "

";
include '../accessDenied.php';
exit();
}
//END OF CHECKPOINT===============================================================================
//END OF CHECKPOINT===============================================================================
}
$getName = "SELECT * FROM pms_employee_data WHERE id = $myUID LIMIT 1";
$getMyName = mysqli_query($conn,$getName);
while($nRow = mysqli_fetch_array($getMyName)){
$fname=$nRow['first_name'];
$lname=$nRow['last_name'];
$compID=$nRow['comp_id'];
$myFName = $fname ." ". $lname;
}
$compName = getCompanyNameSub($compID)[0];
$sql ="SELECT * FROM `pms_employee_data` WHERE `sub_group_id`='$unitID' AND `deleted`=0 ORDER BY `last_name` ASC";
$pdf = new PDF();
//set margins
$pdf->SetMargins(10,20,10);
$pdf->AddPage('P'); //L = Land Scape, P = Portrait
//set column size in array format
$width_cell = array(20,110,30,30); //275
$height_cell= 7;
//set Image
//$pdf->Image('../images/ahg_logo.png',10,5, 25,10, 'PNG','wwww.autohubgroup.com');
//background color
$pdf->SetFillColor(255,255,255); //use for report title bgcolor
$pdf->SetFont('Arial','B',10 );
$pdf->MultiCell(0,5,$compName,0,1,0,true);
$pdf->SetFont('Arial','',10 );
$pdf->MultiCell(0,5,$unitNamen,0,1,0,true);
$pdf->MultiCell(0,5,"",0,0,true);
$pdf->SetFont('Arial','',8);
$pdf->SetFillColor(0,0,0,90); //use for header bgcolor
$pdf->SetTextColor(255,255,255,90);
$pdf->SetLineWidth(0);
$pdf->SetDrawColor(0,0,25);
//header start
$pdf->Cell($width_cell[0],$height_cell,'NO',1,0,'L',true);
$pdf->Cell($width_cell[1],$height_cell,'EMPLOYEE NAME',1,0,'L',true);
$pdf->Cell($width_cell[2],$height_cell,'1ST SEM',1,0,'C',true);
$pdf->Cell($width_cell[3],$height_cell,'2ND SEM',1,0,'C',true);
$pdf->SetFillColor(255,255,255,0); //use for header bgcolor
$pdf->SetTextColor(0,0,0,90);
$fill=false;
//$pdf->Cell(400,200,'Hello Arnel');
$getData = mysqli_query($conn,$sql);
$statRow = mysqli_num_rows($getData);
$semA = 0;
$semB = 0;
$count = 0;
$achvRateTotal=0;
$wPointTotal =0;
$kraWeightTotal=0;
$kraWeightT=0;
while($row = mysqli_fetch_array($getData)){
$marCount = 0;
$janMarData="";
$count = $count + 1;
$pdf->MultiCell(0,$height_cell,"",0,'P',false); //setup row padding
$activeEmp = $row['id'];
$pdf->Cell($width_cell[0],$height_cell,$count,1,0,'C',$fill);
$pdf->Cell($width_cell[1],$height_cell,$row['last_name'].", ".$row['first_name'],1,0,'L',$fill); //getEmployeeKRAName($kraID)[0]
for($x = 1; $x <=2; $x++){
//$myNewX = str_pad($x, 2, "0", STR_PAD_LEFT);
if($x == 1){
$myPeriod='1ST';
}else{
$myPeriod='2ND';
}
$pcp = "SELECT `date_posted` FROM `pcp_headers` WHERE `year`='$rptYear' AND `employee_id`='$activeEmp' AND `date_posted`!='' AND `period`='$myPeriod' LIMIT 1";
$qPcp = mysqli_query($conn,$pcp);
$qRow = mysqli_num_rows($qPcp);
if($qRow > 0){
$marCount = $marCount + 1;
while($mar = mysqli_fetch_array($qPcp)){
$janMar = explode(" ",$mar['date_posted']);
$janMarData = $janMar[0];
$pdf->Cell($width_cell[3],$height_cell,$janMarData,1,0,'C',$fill);
if($x == 1){
$semA = $semA + 1;
}else{
$semB = $semB + 1;
}
}
}else{
$pdf->Cell($width_cell[3],$height_cell,"-",1,0,'C',$fill);
}
}
}
if($count > 0 ){
$semAS = number_format((($semA/$count) * 100),2,'.','')."%";
$semBS = number_format((($semB/$count) * 100),2,'.','')."%";
$semBY = number_format(((($semA + $semB) / $count) * 100),2,'.','')."%";
}else{
$semAS ="0.0%";
$semBS = "0.0%";
$semBY = "0.0%";
}
$pdf->MultiCell(0,$height_cell,"",0,'P',false);
$pdf->Cell(130,$height_cell,"COMPLIANCE PER SEMESTER ",0,0,'R',$fill);
$pdf->Cell($width_cell[2],$height_cell,$semAS,1,0,'C',$fill);
$pdf->Cell($width_cell[3],$height_cell,$semBS,1,0,'C',$fill);
$pdf->MultiCell(0,$height_cell,"",0,'P',false);
$pdf->Cell(130,$height_cell,"COMPLIANCE RATE PER YEARLY ",0,0,'R',$fill);
$pdf->Cell(60,$height_cell,$semBY ,1,0,'C',$fill);
$pdf->SetFillColor(255,255,255,10); //use for header bgcolor
$pdf->SetTextColor(0,0,0,90);
$pdf->MultiCell(1,25,"",0,'L',false); //setup row padding
$pdf->Cell(100,0,"_____________________________",0,1,'L',false);
$pdf->Cell(100,8,$myFName .' / '. $prfDateX ,0,0,'L',false);
$pdf->Output('pcpCompliance_'.$unitName.'.pdf','I');
?>