function front_id($results) { $this->load->helper('settings'); //print preview of MR $this->load->library('fpdf'); $this->load->library('fpdi'); // initiate FPDI $pdf = new FPDI('L'); // add a page $pdf->AddPage(); // set the sourcefile $pagecount = $pdf->setSourceFile('pdf-report/id/front-id.pdf'); // import page 1 $tplIdx = $pdf->importPage(1); // use the imported page and place it at point 10,10 with a width of 100 mm $pdf->useTemplate($tplIdx); //367 // now write some text above the imported page $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', '', 9); $n = 1; foreach ($results as $result) { $s = new Employee_m(); $row = $s->get_by_id($result->employee_id); if ($n == 11) { //add new page $pdf->addPage(); for ($n = 1; $n <= 1; $n++) { $tplidx = $pdf->ImportPage(1); $pdf->useTemplate($tplIdx); //, 1, 1, 210 } $n = $n - 1; } //======================== START Column 1 ============================== $pic = 'pics/not_available.png'; $photo = 'pics/' . $row->employee_id . '.png'; if (file_exists($photo)) { $pic = 'pics/' . $row->employee_id . '.png'; } //signature $sign = 'pics/signatures/' . $row->employee_id . '.png'; $employee_id = $row->employee_id; $name = utf8_decode($row->fname . ' ' . $row->lname); $lblname = 'NAME'; $office = 'LAGUNA UNIVERSITY'; $position = $row->position; $fs = '11.5'; if (strlen($name) >= 22) { $fs = '9'; } //----------------------------- Row 1 ---------------------------------- if ($n == 1) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(18.5, 29); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 17.5, 31, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(18.5, 71); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(18.5, 74); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 20, 75, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(18.5, 83); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(18.5, 88); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(18.5, 94); $pdf->Cell(30, 0, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 2 ---------------------------------- if ($n == 2) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(76.5, 29); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 75.5, 31, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(76.5, 71); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(76.5, 74); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 78, 75, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(76.5, 83); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(76.5, 88); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(76.5, 94); $pdf->Cell(30, 0, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 3 ---------------------------------- if ($n == 3) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(134.5, 29); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 133.5, 31, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(134.5, 71); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(134.5, 74); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 136, 75, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(134.5, 83); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(134.5, 88); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(134.5, 94); $pdf->Cell(30, 0, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 4 ---------------------------------- if ($n == 4) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(192.5, 29); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 191.5, 31, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(192.5, 71); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(192.5, 74); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 194, 75, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(192.5, 83); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(192.5, 88); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(192.5, 94); $pdf->Cell(30, 0, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 5 ---------------------------------- if ($n == 5) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(250.5, 29); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 249.5, 31, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(250.5, 71); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(250.5, 74); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 252, 75, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(250.5, 83); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(250.5, 88); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(250.5, 94); $pdf->Cell(30, 0, strtoupper($position), '0', 0, 'C', false); } //======================== END Column 1 ============================== //======================== START Column 1 ============================== //----------------------------- Row 2 ---------------------------------- if ($n == 6) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(18.5, 129); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 17.5, 132, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(18.5, 172); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(18.5, 175); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 20, 176, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(18.5, 184); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(18.5, 188.5); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(18.5, 200); $pdf->Cell(30, -11, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 2 ---------------------------------- if ($n == 7) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(76.5, 129); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 75.5, 132, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(76.5, 172); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(76.5, 175); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 78, 176, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(76.5, 184); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(76.5, 188.5); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(76.5, 200); $pdf->Cell(30, -11, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 3 ---------------------------------- if ($n == 8) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(134.5, 129); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 133.5, 132, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(134.5, 172); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(134.5, 175); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 136, 176, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(134.5, 184); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(134.5, 188.5); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(134.5, 200); $pdf->Cell(30, -11, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 4 ---------------------------------- if ($n == 9) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(192.5, 129); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 191.5, 132, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(192.5, 172); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(192.5, 175); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 194, 176, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(192.5, 184); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(192.5, 188.5); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(192.5, 200); $pdf->Cell(30, -11, strtoupper($position), '0', 0, 'C', false); } //----------------------------- Row 5 ---------------------------------- if ($n == 10) { //Employee number $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('Arial', 'B', 9); $pdf->SetXY(250.5, 129); $pdf->Cell(30, 0, 'EMP No. ' . $employee_id, '0', 0, 'C', false); //Employee Photo 2x3 $pdf->image($pic, 249.5, 132, 32, 37); //x, y, w, h //Employee name $pdf->SetFont('Arial', 'B', $fs); $pdf->SetXY(250.5, 172); $pdf->Cell(30, 0, strtoupper($name), '0', 0, 'C', false); //label name $pdf->SetFont('Arial', '', 5); $pdf->SetXY(250.5, 175); $pdf->Cell(30, 0, $lblname, '0', 0, 'C', false); //Signature if (file_exists($sign)) { $pdf->image($sign, 252, 176, 25, 10); //x, y, w, h } //label signature $pdf->SetXY(250.5, 184); $pdf->Cell(30, 0, 'SIGNATURE', '0', 0, 'C', false); //Office $pdf->SetTextColor(255, 255, 255); //r, g ,b $pdf->SetFont('Arial', 'B', 13); $pdf->SetXY(250.5, 188.5); $pdf->Cell(30, 0, $office, '0', 0, 'C', false); //Position $pdf->SetTextColor(255, 255, 0); $pdf->SetFont('Arial', '', 10); $pdf->SetXY(250.5, 200); $pdf->Cell(30, -11, strtoupper($position), '0', 0, 'C', false); } $n++; //======================== END Column 2 ============================== } // Output $pdf->Output('pdf-report/front-id.pdf', 'F'); return 'pdf-report/front-id.pdf'; }
public function generatesExternalReport($id = -1) { /* * Loading libraries and helpers */ $this->load->library(array('rb', 'fpdf_gen')); $this->load->helper(array('date', 'utility')); /* * The request id is not set */ if ($id == -1) { echo "Parece que não foi especificado qual o id da Solicitação."; exit; } /* * Loading request */ $request = R::findOne('request', 'id=?', array($id)); /* * Request exists */ if ($request == null) { echo 'Parece que a solicitação não existe.'; exit; } /* * Creating PDF */ $pdf = new FPDI(); $pdf->addPage('L'); /* ********************************************************* * BEGIN - HEADER ********************************************************* */ $pdf->image(public_url('img/' . $this->config->item('system_report_logo')), 140, 5); $pdf->ln(14); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 0, utf8_decode($this->config->item('system_name')), 0, 0, 'C'); $pdf->Ln(5); $pdf->SetFont('Courier', '', 9); $pdf->Cell(0, 0, utf8_decode("SOLICITAÇÃO DE INFORMAÇÃO"), 0, 0, 'C'); /* ********************************************************* * END - HEADER ********************************************************* */ $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->SetDrawColor(217, 217, 217); $pdf->SetFillColor(217, 217, 217); $pdf->Cell(0, 10, utf8_decode(' DADOS DA SOLICITAÇÃO'), 'LRTB', 0, 'L', true); $pdf->Ln(10); $pdf->Cell(24, 10, utf8_decode(' PROTOCOLO: '), 'LTB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(110, 10, utf8_decode($request->protocol), 'TBR', 0, 'L', false); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(32, 10, utf8_decode(' SOLICITADA EM: '), 'TB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(111, 10, utf8_decode(mdate('%d/%m/%Y', strtotime($request->createdAt))), 'TBR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(24, 10, utf8_decode(' SITUAÇÃO: '), 'LB', 0, 'L', false); $pdf->SetFont('Courier', '', 9); $pdf->Cell(253, 10, utf8_decode(status_text($request->status)), 'TBR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' SOLICITAÇÃO: '), 'LR', 0, 'L', false); $pdf->Ln(8); $pdf->SetFont('Courier', '', 9); $pdf->MultiCell(0, 5, utf8_decode(' ' . $request->request), 'LR', 'L', false); $pdf->Cell(0, 4, '', 'LR', 0, 'L', false); $pdf->Ln(4); $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' TRÂMITAÇÃO'), 'LRTB', 0, 'L', true); $pdf->Ln(10); $pdf->SetFont('Courier', '', 9); $statuses = R::find('status', ' request_id = ? ORDER BY created_at ASC ', array($request->id)); if (!count($statuses)) { $pdf->Cell(0, 10, utf8_decode(' Nenhuma trâmitação ainda'), 'LRB', 0, 'L', false); } else { foreach ($statuses as $s) { $pdf->SetFont('Courier', 'B', 9); $pdf->Cell(0, 10, utf8_decode(' ' . status_text($s->type) . ' [' . date('d/m/Y', strtotime($s->createdAt)) . ']'), 'LR', 0, 'L', false); $pdf->Ln(10); $pdf->SetFont('Courier', '', 9); $pdf->MultiCell(0, 5, utf8_decode(' ' . $s->response), 'LRB', 'L', false); } } $pdf->Ln(10); $pdf->Output(); }