SetFillColor(153,204,255); // Draw rectangle line $k = 16; for ($i = 1; $i < 10; $i++){ $this->Rect(8,$k,63,29.4,'FD'); $this->Rect(73.5,$k,63,29.4,'FD'); $this->Rect(139,$k,63,29.4,'FD'); $k = $k + 29.4; } } // Split long hotel name function splitName($longname, $col_st, $b){ $cnt_name = strlen($longname); if ($cnt_name > 41 ){ $name = explode(" ", $longname); for ($i = 0; $i < count($name); $i++){ $hotel_name .= $name[$i]." "; //echo $hotel_name."-"; if (strlen($hotel_name) > 41){ //echo "
"; $this->Ln(); $hotel_name = ""; //echo $name[$i]." "; $this->SetXY($col_st,$b); $this->Write(4,$name[$i]." "); $st = 4; $this->st = $st; }else { //echo $name[$i]." "; $this->Write(4,$name[$i]." "); } } }else { //echo $v['name']."
"; $this->Write(3,$longname); $st = 0; $this->st = $st; } return $st; } // Decode html mnemonic, utf decode for special simbol in languages function decoder($text){ $text = utf8_decode(html_entity_decode($text, ENT_QUOTES)); return $text; } // Print text on tickets function printText ($hostel){ $a = 18; $b = 22; $c = 26; $d = 31; for ($i = 0; $i < count($hostel); $i += 3){ // Write static text $this->SetXY(10,$a); $this->SetFont('Arial','U',6); $this->Write(4,$this->decoder('FRANKFURT HOSTEL KAISERST. 74 60329 FRANKFURT')); // Write text $this->SetXY(10,$b); $this->SetFont('Arial','',8); $col_st = 10; $this->splitName($this->decoder($hostel[$i]['name']),$col_st, $c); $this->Ln(); $this->SetXY(10,$c+$this->st); $this->Write(4,$this->decoder($hostel[$i]['street'])); $this->Ln(); $this->SetXY(10,$d+$this->st); $this->SetFont('Arial','B',12); $this->Write(5,getCountrycode($hostel[$i]['country']).'-'.$this->decoder($hostel[$i]['zip'])); $this->SetFont('Arial','',8); $this->Write(5,' '.$this->decoder($hostel[$i]['city'])); $this->Ln(); $this->SetXY(10,$e+$this->st); $this->Write(5,getCountry($hostel[$i]['country'])); // Write static text $this->SetXY(76,$a); $this->SetFont('Arial','U',6); $this->Write(4,$this->decoder('FRANKFURT HOSTEL KAISERST. 74 60329 FRANKFURT')); $this->SetXY(76,$b); $this->SetFont('Arial','',8); //$this->Write(5,$hostel[$i+1]['name']); $col_st = 76; $this->splitName($this->decoder($hostel[$i+1]['name']),$col_st, $c); $this->Ln(); $this->SetXY(76,$c+$this->st); $this->Write(4,utf8_decode($hostel[$i+1]['street'])); $this->Ln(); $this->SetXY(76,$d+$this->st); $this->SetFont('Arial','B',12); $this->Write(5,getCountrycode($hostel[$i+1]['country']).'-'.$this->decoder($hostel[$i+1]['zip'])); $this->SetFont('Arial','',8); $this->Write(5,' '.$this->decoder($hostel[$i+1]['city'])); $this->Ln(); $this->SetXY(76,$e+$this->st); $this->Write(5,getCountry($hostel[$i+1]['country'])); // Write static text $this->SetXY(141,$a); $this->SetFont('Arial','U',6); $this->Write(4,$this->decoder('FRANKFURT HOSTEL KAISERST. 74 60329 FRANKFURT')); $this->SetXY(141,$b); $this->SetFont('Arial','',8); //$this->Write(5,$hostel[$i+2]['name']); $col_st = 141; $this->splitName($this->decoder($hostel[$i+2]['name']),$col_st, $c); $this->Ln(); $this->SetXY(141,$c+$this->st); $this->Write(4,utf8_decode($hostel[$i+2]['street'])); $this->Ln(); $this->SetXY(141,$d+$this->st); $this->SetFont('Arial','B',12); $this->Write(5,getCountrycode($hostel[$i+2]['country']).'-'.$this->decoder($hostel[$i+2]['zip'])); $this->SetFont('Arial','',8); $this->Write(5,' '.$this->decoder($hostel[$i+2]['city'])); $this->Ln(); $this->SetXY(141,$e+$this->st); $this->Write(5,getCountry($hostel[$i+2]['country'])); $a = $a + 29.4; $b = $b + 29.4; $c = $c + 29.4; $d = $d + 29.4; $e = $e + 29.4; } } } $pdf = new PDF(); $pages = ceil(count($idhostel)/27); for ($p = 1; $p < ($pages+1); $p++){ if (count($idhostel) > 27) $to = 27; else $to = count($idhostel); for ($i = 0; $i < $to; $i++){ $sql = "SELECT name, street, zip, city, country FROM fe_hostels WHERE idhostel='".array_shift($idhostel)."'"; $result = DB::getRow($sql); $hostel[] = $result; } // Debug info //echo "page: ".$p."
"; //print_r($hostel); //echo "
"; // Add new page to pdf document $pdf->AddPage(); // Draw rectangle //$pdf->pageRect(); // Write text on tickets $pdf->printText($hostel); // Clean hostel array for next page unset($hostel); } // Put pdf file $pdf->Output("", "D"); ?>