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, 30,10, 'PNG','wwww.autohubgroup.com'); } /* function Footer(){ $this->SetY(-25); $this->Image('../images/ahg_logo.png'); } */ } include_once("../../../cfg/conn.php"); include ("../functions/users.php"); if(isset($_GET['groupID'])){ $sourceID = $_GET['source']; $groupID = $_GET['groupID']; //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']; $uFName = $uow['first_name']; $uLName = $uow['last_name']; } } $userFName = $uFName . " " . $uLName; if($uowaccStat == 0){ include '../accessDenied.php'; exit(); } if($uowdeleted == 1){ include '../accessDenied.php'; exit(); } $periodText ="KRA's / KPI SUMMARY LIST"; //echo $deptID ."-". $opsIDpdf; //END OF CHECKPOINT=============================================================================== //END OF CHECKPOINT=============================================================================== } $getName = "SELECT * FROM pms_sub_group WHERE id = $groupID LIMIT 1"; $getMyName = mysqli_query($conn,$getName); while($nRow = mysqli_fetch_array($getMyName)){ $compName=$nRow['sub_group_name']; } //$sql ="SELECT * FROM `kra_position_tbl` WHERE `pms_unit_id`='$unitID' AND `deleted`=0 ORDER BY `kra_name` ASC"; $sql = "SELECT kra_division_tbl.`id` AS kraID, kra_division_tbl.`weight` AS kraWeight, kra_division_tbl.`kra_name` AS kraName, kpi_maindivision.kra_id AS kpiKraID, kpi_maindivision.kpi_name AS kpiName, kpi_maindivision.kpi_weight AS kpiWeight, kpi_maindivision.kpi_target AS kpiTarget FROM kra_division_tbl JOIN kpi_maindivision ON kpi_maindivision.kra_id = kra_division_tbl.id WHERE kra_division_tbl.deleted=0 AND `pms_sub_group_id`='$groupID'"; $pdf = new PDF('P','mm',array(350,230)); //$pdf = new FPDF('L','mm',array(350,230)); //set margins $pdf->SetMargins(10,20,10); $pdf->AddPage('L'); //L = Land Scape, P = Portrait //set column size in array format $width_cell = array(10,120,15,145,15,25); $height =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',12); $pdf->MultiCell(0,3,'',0,0,true); $pdf->MultiCell(0,6,$compName,0,0,true); $pdf->SetFont('Arial','B',10); $pdf->MultiCell(0,7,$periodText,0,0,'C',true); $pdf->SetFont('Arial','B',7); $pdf->MultiCell(0,5,"",0,0,true); $pdf->SetFillColor(240, 240, 240,90); //use for header bgcolor $pdf->SetTextColor(0,0,0,90); $pdf->SetLineWidth(0); $pdf->SetDrawColor(0,0,25); //header start $pdf->Cell($width_cell[0],$height,'NO',1,0,'C',true); $pdf->Cell($width_cell[1],$height,'KRA NAME',1,0,'L',true); $pdf->Cell($width_cell[2],$height,'WEIGHT',1,0,'C',true); $pdf->Cell($width_cell[3],$height,'KPI NAME',1,0,'L',true); $pdf->Cell($width_cell[4],$height,'WEIGHT',1,0,'C',true); $pdf->Cell($width_cell[5],$height,'TARGET',1,0,'C',true); $pdf->SetFillColor(255,255,255); //use for body bgcolor $fill=false; //$pdf->Cell(400,200,'Hello Arnel'); $getData = mysqli_query($conn,$sql); $statRow = mysqli_num_rows($getData); $kraTitle = ''; $count=0; if($statRow > 0){ while($drow = mysqli_fetch_array($getData)){ $kraID=$drow['kraID']; $target = $drow['kpiTarget']; if (preg_match('/%/', $target)) { $myKPITarget = $drow['kpiTarget']; }else{ $myKPITarget = number_format($target,0,'.',','); } $pdf->MultiCell(0,$height,"",0,'P',false); //setup row padding if($kraTitle == $kraID){ $pdf->Cell($width_cell[0],$height,"",1,0,'C',$fill); $pdf->Cell($width_cell[1],$height,"",1,0,'L',$fill); $pdf->Cell($width_cell[2],$height,"",1,0,'L',$fill); $pdf->Cell($width_cell[3],$height,$drow['kpiName'],1,0,'L',$fill); $pdf->Cell($width_cell[4],$height,$drow['kpiWeight'],1,0,'C',$fill); $pdf->Cell($width_cell[5],$height,$myKPITarget,1,0,'C',$fill); }else{ $count = $count + 1; $pdf->Cell($width_cell[0],$height,$count,1,0,'C',$fill); $pdf->Cell($width_cell[1],$height,$drow['kraName'],1,0,'L',$fill); $pdf->Cell($width_cell[2],$height,$drow['kraWeight'],1,0,'C',$fill); $pdf->Cell($width_cell[3],$height,$drow['kpiName'],1,0,'L',$fill); $pdf->Cell($width_cell[4],$height,$drow['kpiWeight'],1,0,'C',$fill); $pdf->Cell($width_cell[5],$height,$myKPITarget,1,0,'C',$fill); } $fill =!$fill; // use code to put alternate color between rows $kraTitle=$kraID; } $pdf->MultiCell(1,20,"",0,'L',false); //setup row padding (border, padding top,) $pdf->Cell(100,0,"_____________________________",0,1,'L',false); $pdf->Cell(100,8,$userFName.' / '. $prfDateX ,0,0,'L',false); } $pdf->Output('groupKRA.php','I'); ?>