public function getPerfReportsPdf()
 {
     $deptL = Session::get('deptpdf');
     $sem = Session::get('sempdf');
     $year = Session::get('yearpdf');
     if ($deptL == 'All') {
         $deptL = '*';
     }
     //------------------------------
     if ($sem == 'All') {
         $sem = '*';
     }
     $users = 'Performance';
     $matchThese = array();
     //If user chooses from dropdown
     if ($deptL != "*") {
         //If true insert this to variable
         $matchThese = array_add($matchThese, 'dept_id', $deptL);
         /***********Add Array*****************/
         //If user chooses from dropdown
         if ($sem != "*") {
             //If true insert this to variable
             $matchThese = array_add($matchThese, 'semester', $sem);
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
         } else {
             //===========Else of Semester
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 //===========Else of Year
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
             $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
         }
         /***********End Add Array*****************/
     } else {
         //===========Else of Department
         /*************Add Array***************/
         if ($sem != "*") {
             //If true insert this to variable
             $matchThese = array_add($matchThese, 'semester', $sem);
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             }
         } else {
             //===========Else of Semester
             if ($year != "All") {
                 $matchThese = array_add($matchThese, 'year', $year);
                 $query = $users::where($matchThese)->orderBy('overall', 'desc')->get();
             } else {
                 //===========Else of Year
                 $query = $users::all();
             }
         }
         /************End Add Array****************/
     }
     Fpdf::AddPage();
     Fpdf::PageNo();
     Fpdf::AliasNbPages();
     Fpdf::Image('img/dap.jpg', 10, 5, 150);
     Fpdf::Ln(5);
     Fpdf::SetFont('Arial', 'B', 8);
     Fpdf::Cell(300, 20, 'Date Generated: ' . date("Y/m/d"), 0, 2, 'C', 0);
     Fpdf::Cell(30, 10, 'Performance Results', 0, 2, 'C', 0);
     if ($deptL == '*') {
         Fpdf::Cell(22, 10, 'Department: All', 0, 2, 'C', 0);
     } else {
         $filterDepartment = Department::where('id', $deptL)->first();
         Fpdf::Cell(30, 10, 'Department: ' . $filterDepartment->name, 0, 2, 'C', 0);
     }
     //------------------------------
     if ($sem == '*') {
         Fpdf::Cell(22, 10, 'Semester: All', 0, 2, 'C', 0);
     } else {
         Fpdf::Cell(30, 10, 'Semester: ' . $sem, 0, 2, 'C', 0);
     }
     if ($year == 'All') {
         Fpdf::Cell(30, 10, 'Year: All', 0, 2, 'C', 0);
     } else {
         Fpdf::Cell(30, 10, 'Year: ' . $year, 0, 2, 'C', 0);
     }
     Fpdf::SetFont('Arial', 'B', 5.5);
     Fpdf::Cell(5, 5, 'Id', 1, 0, 'C', 0);
     Fpdf::Cell(24.5, 5, 'Employee Name', 1, 0, 'C', 0);
     Fpdf::Cell(24.5, 5, 'Department', 1, 0, 'C', 0);
     Fpdf::SetFillColor(51, 51, 225);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(25, 5, 'Utilities', 1, 0, 'C', true);
     Fpdf::Cell(25, 5, 'Quality of Work', 1, 0, 'C', true);
     Fpdf::Cell(30, 5, 'Potential for future performance', 1, 0, 'C', true);
     Fpdf::SetFillColor(96, 96, 96);
     Fpdf::Cell(25, 5, 'Overall Rating', 1, 0, 'C', true);
     Fpdf::Cell(15, 5, 'Semester', 1, 0, 'C', 0);
     Fpdf::Cell(16, 5, 'Year', 1, 0, 'C', 0);
     Fpdf::Ln();
     foreach ($query as $perf) {
         Fpdf::Cell(5, 5, $perf->user->id, 1, 0, 'C', 0);
         Fpdf::Cell(24.5, 5, $perf->user->formatName(':ln, :fn :mi'), 1, 0, 'C', 0);
         $department = Department::where('id', $perf->dept_id)->first();
         Fpdf::Cell(24.5, 5, $department->name, 1, 0, 'C', 0);
         Fpdf::SetFillColor(204, 229, 225);
         Fpdf::Cell(5, 5, $perf->utilities, 1, 0, 'C', true);
         Fpdf::Cell(20, 5, $perf->equivalent('utilities')->description, 1, 0, 'C', true);
         Fpdf::Cell(5, 5, $perf->workQuality, 1, 0, 'C', true);
         Fpdf::Cell(20, 5, $perf->equivalent('workQuality')->description, 1, 0, 'C', true);
         Fpdf::Cell(5, 5, $perf->potential, 1, 0, 'C', true);
         Fpdf::Cell(25, 5, $perf->equivalent('potential')->description, 1, 0, 'C', true);
         $u = $perf->utilities;
         $qow = $perf->workQuality;
         $pffp = $perf->potential;
         $overall = number_format(($u + $qow + $pffp) / 3, 2);
         $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first();
         $overpercent = number_format($overall / 6 * 100, 2);
         Fpdf::SetFillColor(192, 192, 192);
         Fpdf::Cell(20, 5, $overall, 1, 0, 'C', true);
         Fpdf::Cell(5, 5, $rating->adjectival, 1, 0, 'C', true);
         Fpdf::Cell(15, 5, $perf->semester, 1, 0, 'C', 0);
         Fpdf::Cell(16, 5, $perf->year, 1, 0, 'C', 0);
         Fpdf::Ln();
     }
     Fpdf::SetY(-30.5);
     Fpdf::SetFont('Arial', 'I', 6);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(0, 10, 'Page ' . Fpdf::PageNo() . "/{nb}", 0, 0, 'C');
     Fpdf::Output();
     exit;
     Session::forget('deptpdf');
     Session::forget('sempdf');
     Session::forget('yearpdf');
 }
Beispiel #2
0
 /**
  * Generate lembar disposisi menggunakan FPDF.
  */
 public static function generate_lembar_disposisi($input)
 {
     $pdf = new Fpdf();
     /**
      * TODO:
      * Ubah posisi y dari perhitungan manual menjadi menggunakan GetY SetY
      */
     $pdf->SetLineWidth(0.01);
     // 0.01mm
     // specify margin variables, dalam unit milimeter
     $margin_left = 5;
     $margin_top = 10;
     $margin_right = 10;
     $pdf->SetMargins($margin_left, $margin_top, $margin_right);
     $pdf->AddPage();
     $pdf->Image(URL::to_asset('img/logo.png'), $margin_left, $margin_top, 0, 25);
     // specify height variables
     $h1 = 6;
     $h2 = 1.5 * $h1;
     $h3 = 2 * $h1;
     /**
      * Bagian Header
      */
     $span1 = 30;
     $span2 = 40;
     $span3 = 50;
     $span4 = 60;
     /* line 1 */
     $pdf->SetFont('Times', 'B', 16);
     $pdf->Cell($span1, $h1, '');
     $pdf->Cell(160, $h1, 'Direktorat Jenderal Pajak', 0, 0, 'C');
     $pdf->Ln();
     /* line 2 */
     $pdf->SetFont('Times', 'B', 12);
     $pdf->Cell($span1, $h1, '');
     $pdf->Cell(160, $h1, strtoupper($input->nama_kpp), 0, 0, 'C');
     $pdf->Ln();
     /* line 3 */
     $pdf->Cell($span1, $h1, '');
     $pdf->Cell(160, $h1, $input->nama_seksi, 0, 0, 'C');
     $line_x1 = $margin_left + $span1;
     $line_y1 = $margin_top + 3 * $h1;
     $line_x2 = 210 - $margin_right;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 4 */
     $pdf->SetFont('Times', '', 14);
     $pdf->Cell($span1, $h3, '');
     $pdf->Cell(160, $h3, 'LEMBAR DISPOSISI', 0, 0, 'C');
     $line_x1 = $margin_left + $span1 + 10;
     $line_y1 = $margin_top + 3 * $h1 + $h2;
     $line_x2 = 210 - $margin_right - 10;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 5, blank line */
     $pdf->Cell(210 - $margin_left - $margin_right, $h3, '');
     $pdf->Ln();
     /**
      * variable font size
      */
     $font_size = 10;
     /* line 6 */
     // output label left
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Tanggal Diterima:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->Cell($span4 + 10, $h2, Printpdf::full_tanggal($input->tgl_diterima));
     // divider
     $pdf->Cell(10, $h2, '');
     //output label right
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Nomor Agenda:');
     $pdf->SetFont('Arial', '', $font_size);
     // cek apakah nomor Agenda otomatis akan ikut dicetak?
     $tampilkan_nomor_agenda = Konfigurasi::find(8)->config_value;
     if ($tampilkan_nomor_agenda == 1) {
         $pdf->Cell($span4 + 5 - $margin_right, $h2, $input->nomor_agenda_seksi);
     } else {
         $pdf->Cell($span4 + 5 - $margin_right, $h2, '');
     }
     // border-bottom dibuat secara manual agar posisinya bisa diatur dan tidak
     // dipengaruhi cell height
     // underline content left
     $line_x1 = $margin_left + $span1;
     $line_y1 = $margin_top + 4 * $h1 + 2 * $h3 + 1;
     $line_x2 = $line_x1 + $span4 + 10;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     // underline content right
     $line_x1 = 210 - $margin_right - ($span4 + 5 - $margin_right);
     $line_y1 = $line_y1;
     $line_x2 = 210 - $margin_right;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 7 */
     // output label left
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Nomor Surat:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->Cell($span4 + 10, $h2, $input->nomor_surat);
     // divider
     $pdf->Cell(10, $h2, '');
     //output label right
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'No. Agenda Sekre:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->Cell($span4 + 5 - $margin_right, $h2, $input->nomor_agenda_sekre);
     // underline content left
     $line_x1 = $margin_left + $span1;
     $line_y1 = $line_y1 + $h2;
     $line_x2 = $line_x1 + $span4 + 10;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     // underline content right
     $line_x1 = 210 - $margin_right - ($span4 + 5 - $margin_right);
     $line_y1 = $line_y1;
     $line_x2 = 210 - $margin_right;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 8 */
     // output label left
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Tanggal Surat:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->Cell($span4 + 10, $h2, Printpdf::full_tanggal($input->tgl_surat));
     // underline content left
     $line_x1 = $margin_left + $span1;
     $line_y1 = $line_y1 + $h2;
     $line_x2 = $line_x1 + $span4 + 10;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 9 */
     // output label left
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Nama Pengirim:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->Cell(210 - $margin_right - $margin_left - $span1, $h2, strtoupper($input->pengirim));
     // underline content left
     $line_x1 = $margin_left + $span1;
     $line_y1 = $line_y1 + $h2;
     $line_x2 = 210 - $margin_right;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 10 */
     // output label left
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($span1, $h2, 'Perihal:');
     $pdf->SetFont('Arial', '', $font_size);
     $pdf->drawTextBox(strtoupper($input->hal), 210 - $margin_right - $margin_left - $span1, $h3 + $h1 / 2, 'L', 'T', 0, $h1 / 2);
     // underline content left
     $line_x1 = $margin_left + $span1;
     $line_y1 = $line_y1 + $h3 + $h1 / 2 + 1;
     $line_x2 = 210 - $margin_right;
     $line_y2 = $line_y1;
     $pdf->Line($line_x1, $line_y1, $line_x2, $line_y2);
     $pdf->Ln();
     /* line 11 */
     $pdf->SetFont('Times', '', $font_size);
     $y = $line_y1 + $h3;
     $pdf->SetY($y);
     $pdf->SetStyle("em", "Times", "I", 0, "0,0,0");
     $pdf->SetStyle("p", "Times", "N", $font_size, "0,0,0", 0);
     $pdf->SetStyle("content", "Arial", "", 0, "0,0,0");
     $pdf->SetStyle("strong", "Times", "B", 0, "0,0,0");
     $pdf->WriteTag(210 - $margin_left - $margin_right, $h1, '<p>PERHATIAN: <em>Dilarang memisahkan sehelai surat pun dari berkas yang telah disusun.</em></p>', 0, 'C');
     /**
      * line 12
      * print daftar disposisi, daftar sifat, daftar petunjuk
      */
     // set to correct y position
     $pdf->SetY($y + $h1);
     // create 3 column
     $spacer = 1;
     $box_width = (210 - $margin_left - $margin_right - 2) / 2;
     // box_width akan dipakai untuk dua kolom
     $checkbox_width = 8;
     $box_text_width = $box_width - $checkbox_width;
     // save y position
     $save_y_position = $pdf->GetY();
     // print right box first
     $pdf->Cell($box_width + $spacer, $h1, '');
     // padding-left hack :)
     $pdf->SetFont('Times', 'B', $font_size);
     $pdf->Cell($box_width, $h1, 'Ditujukan kepada:', 'LTR');
     $pdf->Ln();
     /* iterasi */
     foreach ($input->daftar_disposisi as $row) {
         if ($row->aktif) {
             // padding-left hack :)
             $pdf->Cell($box_width + $spacer, $h1, '');
             // draw checkbox
             Printpdf::draw_checkbox($pdf, in_array($row->id, $input->disposisi), $font_size, $h1, $checkbox_width);
             // print daftar nama
             $pdf->SetFont('Times', '', $font_size);
             $pdf->Cell($box_text_width, $h1, $row->nama, 'R');
             $pdf->Ln();
         }
     }
     // print daftar disposisi lain-lain
     if (!empty($input->lain_lain)) {
         // padding-left
         $pdf->Cell($box_width + $spacer, $h1, '');
         // draw checkbox
         Printpdf::draw_checkbox($pdf, true, $font_size, $h1, $checkbox_width);
         // print lain-lain
         $pdf->SetFont('Times', '', $font_size);
         $pdf->Cell($box_text_width, $h1, $input->lain_lain, 'R');
         $pdf->Ln();
     }
     // bottom space and border
     $pdf->Cell($box_width + $spacer, $h1, '');
     $pdf->Cell($box_width, $h1 / 2, '', 'RLB');
     $pdf->Ln();
     // save y position untuk reset posisi box catatan
     $catatan_box_y_position_1 = $pdf->GetY();
     // reset y position, print left box
     $pdf->SetY($save_y_position);
     $pdf->SetFont('Times', 'B', $font_size);
     $pdf->Cell($box_width, $h1, 'Sifat:', 'LTR');
     $pdf->Ln();
     /* iterasi */
     $pdf->SetFont('Times', '', $font_size);
     foreach ($input->daftar_sifat as $key => $value) {
         // draw checkbox
         Printpdf::draw_checkbox($pdf, in_array($key, $input->sifat), $font_size, $h1, $checkbox_width);
         // print daftar sifat
         $pdf->SetFont('Times', '', $font_size);
         $pdf->Cell($box_text_width, $h1, $value, 'R');
         $pdf->Cell($spacer, $h1, '', '');
         $pdf->Ln();
     }
     // continue print left box
     $pdf->SetFont('Times', 'B', $font_size);
     $pdf->Cell($box_width, $h1, 'Petunjuk:', 'LR');
     $pdf->Ln();
     /* iterasi */
     $pdf->SetFont('Times', '', $font_size);
     foreach ($input->daftar_petunjuk as $row) {
         // draw checkbox
         Printpdf::draw_checkbox($pdf, in_array($row->id, $input->petunjuk), $font_size, $h1, $checkbox_width);
         // print daftar petunjuk
         $pdf->SetFont('Times', '', $font_size);
         $pdf->Cell($box_text_width, $h1, $row->petunjuk, 'R');
         $pdf->Cell($spacer, $h1, '', '');
         $pdf->Ln();
     }
     // copy
     $dots = '........';
     if ($input->copy > 0) {
         $copy = '  ' . $input->copy . '  ';
         Printpdf::draw_checkbox($pdf, true, $font_size, $h1, $checkbox_width);
     } else {
         $copy = $dots;
         Printpdf::draw_checkbox($pdf, false, $font_size, $h1, $checkbox_width);
     }
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell($box_text_width, $h1, 'Perbanyak: ' . $copy . ' kali,  Asli ke: ' . $dots, 'R');
     $pdf->Ln();
     // bottom border
     $pdf->Cell($box_width, $h1 / 2, '', 'RLB');
     $pdf->Ln();
     // save y position untuk reset posisi box catatan
     $catatan_box_y_position_2 = $pdf->GetY();
     /* line 13 */
     // adjust y position
     $y = $catatan_box_y_position_1 > $catatan_box_y_position_2 ? $catatan_box_y_position_1 : $catatan_box_y_position_2;
     $pdf->SetY($y + 1);
     // print box catatan
     $pdf->SetFont('Times', 'U', $font_size);
     $pdf->Cell(0, $h1, 'CATATAN:', 'LTR');
     $pdf->Ln();
     // save y position
     $y = $pdf->GetY();
     // print text catatan
     $pdf->SetFont('Arial', '', $font_size - 1);
     $pdf->drawTextBox(strtoupper($input->catatan), 210 - $margin_right - $margin_left, 'L', 'T', 1, $h1 / 2);
     // reset position, draw fake border
     $pdf->SetY($y);
     $pdf->Cell(0, $h3, '', 'LBR');
     $pdf->Ln();
     /* line 14 */
     // adjust y position
     $y = $pdf->GetY();
     $pdf->SetY($y + 2);
     // print field tambahan
     $pdf->SetFont('Times', '', $font_size);
     $pdf->Cell(0, 5, 'PENGELOLAAN PADA SEKSI TERKAIT:');
     $pdf->Ln();
     /* line 15 */
     // dua kolom hal yang sama
     $half_width = (210 - $margin_left - $margin_right) / 2;
     $hw = $half_width;
     $padding_right = 20;
     $pdf->SetFont('Times', 'B', $font_size);
     $pdf->Cell($half_width, 7, 'Diteruskan ke:');
     $pdf->Cell($half_width, 7, 'Diteruskan ke:');
     $pdf->Ln();
     $s1 = '1. Seksi: ';
     $s2 = '2. Diterima Seksi: ';
     $s3 = '3. Selesai diproses: ';
     $dot1 = str_repeat('.', 71);
     $dot2 = str_repeat('.', 56);
     $dot3 = str_repeat('.', 54);
     $w1 = $pdf->GetStringWidth($s1);
     $w2 = $pdf->GetStringWidth($s2);
     $w3 = $pdf->GetStringWidth($s3);
     $pdf->SetFont('Times', '', $font_size);
     // print text dengan dotted yang right-aligned
     $pdf->Cell($hw - ($hw - $w1) - $padding_right, 4, $s1);
     $pdf->Cell($hw - $w1, 4, $dot1, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Cell($hw - ($hw - $w1) - $padding_right, 4, $s1);
     $pdf->Cell($hw - $w1, 4, $dot1, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Ln();
     $pdf->Cell($hw - ($hw - $w2) - $padding_right, 4, $s2);
     $pdf->Cell($hw - $w2, 4, $dot2, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Cell($hw - ($hw - $w2) - $padding_right, 4, $s2);
     $pdf->Cell($hw - $w2, 4, $dot2, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Ln();
     $pdf->Cell($hw - ($hw - $w3) - $padding_right, 4, $s3);
     $pdf->Cell($hw - $w3, 4, $dot3, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Cell($hw - ($hw - $w3) - $padding_right, 4, $s3);
     $pdf->Cell($hw - $w3, 4, $dot3, 0, '', 'R');
     $pdf->Cell($padding_right, 4, '');
     $pdf->Ln();
     // generate pdf ke folder 'public' subfolder 'pdf'
     $file_name = 'print' . time() . '.pdf';
     $output_path = Printpdf::pdf_folder_path() . $file_name;
     $pdf->Output($output_path, 'F');
     return $file_name;
 }
 public function getLeavesListPdf($id)
 {
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Employee Management Admin', 'action' => 'printed Leave balances of All employees.']);
     if ($id == "*") {
         $users = User::all();
     } else {
         $users = User::where('department_id', $id)->get();
     }
     Fpdf::AddPage();
     Fpdf::Image('img/dap.jpg', 40, 0, 150);
     Fpdf::Ln(35);
     Fpdf::SetFont('Arial', 'B', 11);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(300, 20, 'Date Generated: ' . date("F j, Y"), 0, 2, 'C', 0);
     Fpdf::Cell(18, 7, 'Leave List', 0, 2, 'C', 0);
     Fpdf::SetFont('Arial', 'B', 7);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(18, 7, 'ID', 1);
     Fpdf::Cell(24, 7, 'Name', 1);
     Fpdf::Cell(30, 7, 'Department', 1);
     Fpdf::Cell(9, 7, 'VL', 1);
     Fpdf::Cell(9, 7, 'SL', 1);
     Fpdf::Cell(9, 7, 'PL', 1);
     Fpdf::Cell(9, 7, 'ML', 1);
     Fpdf::Cell(9, 7, 'BL', 1);
     Fpdf::Ln();
     Fpdf::SetFont('Arial', '', 7);
     foreach ($users as $user) {
         Fpdf::Cell(18, 7, $user->id, 1);
         Fpdf::Cell(24, 7, $user->firstname, 1);
         Fpdf::Cell(30, 7, $user->department->name, 1);
         $leaves = LeaveBalance::where('user_id', $user->id)->get();
         foreach ($leaves as $leave) {
             Fpdf::Cell(9, 7, $leave->balance, 1);
         }
         Fpdf::Ln();
     }
     Fpdf::SetY(-35);
     Fpdf::AliasNbPages('{nb}');
     Fpdf::SetFont('Arial', 'I', 10);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(0, 10, 'Page ' . Fpdf::PageNo() . '/{nb}', 0, 0, 'C');
     Fpdf::Output();
     exit;
 }
 public function getViewResultsPdf($id)
 {
     $result = Performance::find($id);
     $perf = Performance::find($id);
     $user = Performance::find($id);
     $rating = Performance::find($id);
     $u = $perf->utilities;
     $qow = $perf->workQuality;
     $pffp = $perf->potential;
     $overall = number_format(($u + $qow + $pffp) / 3, 2);
     $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first();
     $overpercent = number_format($overall / 6 * 100, 2);
     $department = Department::where('id', $perf->dept_id)->first();
     Fpdf::AddPage();
     Fpdf::PageNo();
     Fpdf::AliasNbPages('{nb}');
     Fpdf::Image('img/dap.jpg', 40, 0, 150);
     Fpdf::Ln(30);
     Fpdf::SetFont('Arial', 'B', 11);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(300, 20, 'Date Generated: ' . date("F j, Y"), 0, 2, 'C', 0);
     Fpdf::SetFont('Arial', 'B', 15);
     Fpdf::Cell(0, 0, 'Performance Evaluation', 0, 1, 'L', 0);
     Fpdf::Ln(8);
     Fpdf::SetFont('Arial', 'B', 11);
     Fpdf::Cell(0, 0, 'Name: ' . $perf->user->formatName(':ln, :fn :mn'), 0, 1, 'L', 0);
     Fpdf::Ln(8);
     Fpdf::Cell(0, 0, 'Department: ' . $department->name, 0, 1, 'L', 0);
     Fpdf::Ln(8);
     Fpdf::Cell(0, 0, 'Semester: ' . $perf->semester, 0, 1, 'L', 0);
     Fpdf::Ln(10);
     Fpdf::SetFont('Arial', '', 20);
     Fpdf::SetDrawColor(224, 224, 224);
     Fpdf::SetFillColor(51, 51, 225);
     Fpdf::SetTextColor(255, 255, 255);
     Fpdf::Cell(110, 10, 'Utilities', 1, 1, 'C', true);
     Fpdf::SetFont('Arial', 'B', 7);
     Fpdf::SetFillColor(204, 229, 225);
     Fpdf::SetTextColor(96, 96, 96);
     Fpdf::Cell(50, 10, 'Intra-group Involvements', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->util1, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util1')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util1')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Inter-group Involvements', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->util2, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util2')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util2')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Committee Work', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->util3, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util3')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('util3')->description, 1, 1, 'C', 0);
     Fpdf::SetTextColor(204, 0, 0);
     Fpdf::Cell(50, 10, 'Average Rating', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->util_overall, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('utilities')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('utilities')->description, 1, 1, 'C', 0);
     //Quality of work table
     Fpdf::Ln(10);
     Fpdf::SetFont('Arial', '', 20);
     Fpdf::SetDrawColor(224, 224, 224);
     Fpdf::SetFillColor(51, 51, 225);
     Fpdf::SetTextColor(255, 255, 255);
     Fpdf::Cell(110, 10, 'Quality of Work', 1, 2, 'C', true);
     Fpdf::SetFont('Arial', 'B', 7);
     Fpdf::SetFillColor(204, 229, 225);
     Fpdf::SetTextColor(96, 96, 96);
     Fpdf::Cell(50, 10, 'Relevance to Project/unit objectives', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow1, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow1')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow1')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Timeliness', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow2, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow2')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow2')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Thoroughness', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow3, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow3')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow3')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'High-Rate', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow4, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow4')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow4')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Accuracy', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow5, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow5')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow5')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Foresight', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow6, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow6')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow6')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Neatness and Presentability', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow7, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow7')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow7')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Cost-effectiveness', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow8, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow8')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow8')->description, 1, 1, 'C', 0);
     Fpdf::SetTextColor(204, 0, 0);
     Fpdf::Cell(50, 10, 'Average Rating', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->qow_overall, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow_overall')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('qow_overall')->description, 1, 1, 'C', 0);
     //Potential for Future Performance table
     Fpdf::Ln(10);
     Fpdf::SetFont('Arial', '', 20);
     Fpdf::SetDrawColor(224, 224, 224);
     Fpdf::SetFillColor(51, 51, 225);
     Fpdf::SetTextColor(255, 255, 255);
     Fpdf::Cell(110, 10, 'Potential for Future Performance', 1, 2, 'C', true);
     Fpdf::SetFont('Arial', 'B', 7);
     Fpdf::SetFillColor(204, 229, 225);
     Fpdf::SetTextColor(96, 96, 96);
     Fpdf::Cell(50, 10, 'Appropriate Expertise', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp1, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp1')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp1')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Professional Interest', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp2, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp2')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp2')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Ability to Learn', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp3, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp3')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp3')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Professional Integrity ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp4, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp4')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp4')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Work standards ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp5, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp5')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp5')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Innovativeness ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp6, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp6')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp6')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Maturity ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp7, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp7')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp7')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Collaboration ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp8, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp8')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp8')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Initiative', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp9, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp9')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp9')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Responsiveness', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp10, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp10')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp10')->description, 1, 1, 'C', 0);
     Fpdf::Cell(50, 10, 'Adaptability and Consistent track record ', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp11, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp11')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp11')->description, 1, 1, 'C', 0);
     Fpdf::SetTextColor(204, 0, 0);
     Fpdf::Cell(50, 10, 'Average Rating', 1, 0, 'C', true);
     Fpdf::Cell(20, 10, $result->pffp_overall, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp_overall')->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(20, 10, $perf->equivalent('pffp_overall')->description, 1, 1, 'C', 0);
     //Overall Rating table
     Fpdf::Ln(10);
     Fpdf::SetFont('Arial', '', 20);
     Fpdf::SetDrawColor(224, 224, 224);
     Fpdf::SetFillColor(51, 51, 225);
     Fpdf::SetTextColor(255, 255, 255);
     Fpdf::Cell(140, 10, 'Overall Rating', 1, 2, 'C', true);
     Fpdf::SetFont('Arial', 'B', 7);
     Fpdf::SetFillColor(204, 229, 225);
     Fpdf::SetTextColor(96, 96, 96);
     Fpdf::Cell(30, 10, 'Superior Remarks', 1, 0, 'C', true);
     Fpdf::Cell(110, 10, $perf->comments, 1, 1, 'C', 0);
     Fpdf::Cell(30, 10, 'Overall rating', 1, 0, 'C', true);
     Fpdf::Cell(30, 10, $result->overall, 1, 0, 'C', 0);
     Fpdf::Cell(30, 10, $rating->adjectival, 1, 0, 'C', 0);
     Fpdf::Cell(50, 10, $rating->description, 1, 0, 'C', 0);
     Fpdf::SetY(-35);
     Fpdf::AliasNbPages('{nb}');
     Fpdf::SetFont('Arial', 'I', 10);
     Fpdf::SetTextColor(0, 0, 0);
     Fpdf::Cell(0, 10, 'Page ' . Fpdf::PageNo() . '/{nb}', 0, 0, 'C');
     Fpdf::Output();
     exit;
 }