0.65, 'colW'=>3.4, 'colSpacing'=>0.4); $layout['left'] = array('marginL'=>0.65, 'colW'=>3.4); $layout['right'] = array('marginL'=>4.45, 'colW'=>3.4); $font = array(); $font['category'] = array ('family'=>'ArialBlack', 'style'=>'', 'size'=>13, 'color'=>'#ba3e46'); $font['catDesc'] = array ('family'=>'Arial', 'style'=>'', 'size'=>10); $font['item'] = array ('family'=>'PalatinoLinotype', 'style'=>'', 'size'=>12, 'color'=>'#b7484d'); $font['itemDesc'] = array ('family'=>'PalatinoLinotype', 'style'=>'', 'size'=>11); require (FPDF_PATH.'fpdf.php'); $pdf = new FPDF('P', 'in', 'Letter'); $pdf->AddFont('Arial','', 'arial.php'); $pdf->AddFont('ArialBlack','', 'ariblk.php'); $pdf->AddFont('PalatinoLinotype','','pala.php'); $pdf->SetMargins (0, 0, 0); $pdf->SetAutoPageBreak (FALSE); $pdfz = new FPDF('P', 'in', 'Letter'); // sandbox to determine multicell heights $pdfz->AddFont('Arial','', 'arial.php'); $pdfz->AddFont('ArialBlack','', 'ariblk.php'); $pdfz->AddFont('PalatinoLinotype','','pala.php'); $pdf->AddPage(); ////print header //$imgW = 1.375; //$pdf->Image('images/printHeader.jpg', 0.75, $marginT+0.125, 7.0); // //$pdf->SetY(1.7); $pdf->SetY($marginT); $yTop = $pdf->GetY(); foreach ($meals as $meal) { if ($meal['name']=='Drinks') { foreach ($meal['categories'] as $category) { if (in_array($category['idCategory'],array(99,100,101,102,103,104))) { switch ($category['idCategory']) { case 99: // MARGARITAS case 101: // CERVEZAS $column = 'left'; printCategory($pdf, $column, $category['name']); foreach ($category['items'] as $keyItem=>$item) { if ($item['special'] <> '1') { if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'item'); $pdf->SetX ($layout[$column]['marginL']); $pdf->Cell($layout[$column]['colW'], ($font['item']['size']+2)/72, $item['name'], 0, 1, 'C'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, (stripslashes($item['desc'])."\n".$item['prices'][0]['price']), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); } } if ($category['idCategory']==101) { $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/72); setFont ($pdf, 'item'); $pdf->SetX ($layout[$column]['marginL']); $pdf->Cell($layout[$column]['colW'], ($font['item']['size']+2)/72, 'Juices', 0, 1, 'C'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, ('Fresh Limeade $3.50'."\n".'Cranberry or Orange $2'), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); setFont ($pdf, 'item'); $pdf->SetX ($layout[$column]['marginL']); $pdf->Cell($layout[$column]['colW'], ($font['item']['size']+2)/72, 'Tea, Coffee', 0, 1, 'C'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, ('Hot or Iced'."\n".'Also Decaf Coffee or Manzanilla Tea'."\n".'$1.50'), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); setFont ($pdf, 'item'); $pdf->SetX ($layout[$column]['marginL']); $pdf->Cell($layout[$column]['colW'], ($font['item']['size']+2)/72, 'Bottled Water', 0, 1, 'C'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, ('S. Pelegrino liter $4.50'), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); printCategory($pdf, $column, 'FULL BAR'); } break; case 100: // TEQUILAS $column = 'left'; printCategory($pdf, $column, $category['name'], $category['desc']); foreach ($category['items'] as $keyItem=>$item) { if ($item['special'] <> '1') { if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'item'); $wItem = $pdf->GetStringWidth($item['name'].' '); setFont ($pdf, 'itemDesc'); $sDesc = (($item['desc']!='')?($item['desc'].' '):'').$item['prices'][0]['price']; $wDesc = $pdf->GetStringWidth($sDesc); $x = $layout[$column]['marginL'] + ($layout[$column]['colW'] - $wItem - $wDesc)/2.0; setFont ($pdf, 'item'); $pdf->SetX ($x); $pdf->Cell($wItem, ($font['item']['size']+2)/72, $item['name'], 0, 0, 'L'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($x + $wItem); $pdf->MultiCell ($wDesc+0.2, ($font['itemDesc']['size']+2)/72, $sDesc, 0, 'L'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); } } break; case 102: // VINO BLANCO $pdf->SetY($yTop); case 103: // VINO TINTO $column = 'right'; printCategory($pdf, $column, $category['name']); foreach ($category['items'] as $keyItem=>$item) { if ($item['special'] <> '1') { if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'item'); $pdf->SetX ($layout[$column]['marginL']); $pdf->Cell($layout[$column]['colW'], ($font['item']['size']+2)/72, $item['name'], 0, 1, 'C'); $iPrice = 0; $desc = ''; foreach ($item['prices'] as $price) { $iPrice++; if (is_numeric($price['price'])) $price['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($price['price']))); $desc .= (($iPrice > 1) ? ', ' : '') .(($price['desc'] != '') ? htmlentities(stripslashes($price['desc'])) : '') .' '.htmlentities($price['price']); } setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, (str_replace('',"'",stripslashes($item['desc'])).' '.trim($desc)), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); } } if ($category['idCategory']==103) { printCategory($pdf, $column, 'SANGRIA ROJA'); setFont ($pdf, 'itemDesc'); $pdf->SetX ($layout[$column]['marginL']); $pdf->MultiCell ($layout[$column]['colW'], ($font['itemDesc']['size']+2)/72, ('Carafe (3 glasses) $10'."\n".'Large carafe $20'), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); } break; /* case 101: // CERVEZAS echo '

'.htmlentities(stripslashes($category['name'])) .(($category['desc'] != '') ? ('
'.nl2br(htmlentities(stripslashes($category['desc']))).'
') : '').'

'."\n"; foreach ($category['items'] as $item) { if ($item['special'] <> '1') { if (is_numeric($item['prices'][0]['price'])) $item['prices'][0]['price'] = sprintf("$%01.2f", floatval($item['prices'][0]['price'])); echo '

'.htmlentities(stripslashes($item['name'])).'

' .'

'.nl2br(htmlentities(stripslashes($item['desc']))).'
' .htmlentities($item['prices'][0]['price']).'

'; } } // zzz uncoded items cervezas echo ' '."\n"; echo ' ' .' ' .' ' .'

Full Bar

' .'  ' .'

'."\n"; break; case 102: echo ' '."\n"; case 103: // VINO BLANCO y VINO TINTO echo '

'.htmlentities(stripslashes($category['name'])) .(($category['desc'] != '') ? ('
'.nl2br(htmlentities(stripslashes($category['desc']))).'
') : '').'

'."\n"; foreach ($category['items'] as $item) { if ($item['special'] <> '1') { echo '

'.htmlentities(stripslashes($item['name'])).'
' .''.nl2br(htmlentities(stripslashes($item['desc']))); $iPrice = 0; foreach ($item['prices'] as $price) { $iPrice++; if (is_numeric($price['price'])) $price['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($price['price']))); echo (($iPrice > 1) ? ', ' : '') .(($price['desc'] != '') ? htmlentities(stripslashes($price['desc'])) : '') .' '.htmlentities($price['price']); } echo '

'; } } echo '

 

'."\n"; break; case 104: // SANGRIA ROJA echo '

'.htmlentities(stripslashes($category['name'])) .(($category['desc'] != '') ? ('
'.nl2br(htmlentities(stripslashes($category['desc']))).'
') : '').'

'."\n" .'

'."\n"; foreach ($category['items'] as $item) { if ($item['special'] <> '1') { $iPrice = 0; foreach ($item['prices'] as $price) { $iPrice++; if (is_numeric($price['price'])) $price['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($price['price']))); echo (($iPrice > 1) ? "
\n" : '') .(($price['desc'] != '') ? htmlentities(stripslashes($price['desc'])) : '') .' '.htmlentities($price['price']); } echo '

'; } } break; */ } } } } } $pdf->Output(); function setFont (&$pdf, $class) { global $font; $pdf->SetFont($font[$class]['family'], $font[$class]['style'], $font[$class]['size']); if ($font[$class]['color'] != '') { $pdf->SetTextColor(hexdec(substr($font[$class]['color'],1,2)), hexdec(substr($font[$class]['color'],3,2)), hexdec(substr($font[$class]['color'],5,2))); } else { $pdf->SetTextColor(0); } } function printItem (&$pdf, $item, $x, $colW) { global $font; $y = $pdf->GetY(); setFont ($pdf, 'item'); $pdf->SetX ($x); $pdf->Cell($colW, ($font['item']['size']+2)/72, $item['name']); // leave space in the item description MultiCell for the item name (different font/color) $w1 = $pdf->GetStringWidth(stripslashes($item['name'])); $numSpaces = 0; setFont ($pdf, 'itemDesc'); while ($pdf->GetStringWidth(str_repeat(' ',$numSpaces)) < $w1) { $numSpaces++; } if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'itemDesc'); $pdf->SetXY ($x, $y); $pdf->MultiCell ($colW, ($font['itemDesc']['size']+2)/72, (str_repeat(' ',++$numSpaces).str_replace("\n",' ',stripslashes($item['desc'])).' '.$item['prices'][0]['price']), 0, 'L'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); return $pdf->GetY(); } function printCategory (&$pdf, $column, $catName, $catDesc='') { global $font, $layout; $pdf->SetY($pdf->GetY()+$font['category']['size']/72); $pdf->SetX ($layout[$column]['marginL']); setFont ($pdf, 'category'); $pdf->MultiCell ($layout[$column]['colW'], $font['category']['size']/72, strtoupper($catName), 0, 'C'); if ($catDesc != '') { $pdf->SetY($pdf->GetY()+$font['category']['size']/144); $pdf->SetX ($layout[$column]['marginL']); setFont ($pdf, 'catDesc'); $pdf->MultiCell ($layout[$column]['colW'], $font['catDesc']['size']/72, $catDesc, 0, 'C'); $pdf->SetY($pdf->GetY()+$font['catDesc']['size']/72); } else { $pdf->SetY($pdf->GetY()+$font['category']['size']/72); } } /* // Create an AFM file from a TTF require ('includes/fpdf/font/makefont/makefont.php'); MakeFont('includes/fpdf/font/fonts/gothicb.ttf','includes/fpdf/font/fonts/gothicb.afm'); MakeFont('includes/fpdf/font/fonts/gothicbi.ttf','includes/fpdf/font/fonts/gothicbi.afm'); MakeFont('includes/fpdf/font/fonts/gothici.ttf','includes/fpdf/font/fonts/gothici.afm'); */ ?>