function commerce_billy_pdf_html in Commerce Billy 7
Helper function that returns the generated HTML for the invoice PDFs.
Parameters
object[] $orders: Array of order objects.
3 calls to commerce_billy_pdf_html()
- commerce_billy_pdf in modules/
commerce_billy_pdf/ commerce_billy_pdf.module - Page callback for invoice PDF.
- commerce_billy_pdf_html_page in modules/
commerce_billy_pdf/ commerce_billy_pdf.module - Page callback for the HTML version of the invoice.
- commerce_billy_pdf_print_invoices in modules/
commerce_billy_pdf/ commerce_billy_pdf.module - Callback to generate a PDF.
File
- modules/
commerce_billy_pdf/ commerce_billy_pdf.module, line 166 - Commerce Billy module file.
Code
function commerce_billy_pdf_html($orders) {
// Backwards compatibilty: also accept a single order object.
if (is_object($orders)) {
$orders = array(
$orders,
);
}
foreach ($orders as $order) {
$vars['viewed_orders'][] = entity_view('commerce_order', array(
$order->order_id => $order,
), 'pdf', NULL, TRUE);
// Add a credit memo.
if ($order->status == 'canceled') {
$vars['viewed_orders'][] = entity_view('commerce_order', array(
$order->order_id => $order,
), 'canceled', NULL, TRUE);
}
}
$css_files = variable_get('commerce_billy_pdf_css_files', array(
drupal_get_path('module', 'commerce_billy_pdf') . '/css/pdf.css',
));
if (variable_get('commerce_billy_pdf_converter', 'dompdf') == 'wkhtmltopdf') {
$css_files[] = drupal_get_path('module', 'commerce_billy_pdf') . '/css/pdf_wkhtmltopdf.css';
}
$vars['inline_css'] = "";
foreach ($css_files as $file) {
$vars['inline_css'] .= file_get_contents($file);
}
return theme('commerce_billy_pdf_page', $vars);
}