function web_invoice_mark_as_cancelled($invoice_id) { global $wpdb; $counter = 0; // Check to see if array is passed or single. if (is_array($invoice_id)) { foreach ($invoice_id as $single_invoice_id) { if (!web_invoice_paid_status($single_invoice_id)) { continue; } $counter++; web_invoice_update_invoice_meta($single_invoice_id, 'paid_status', 'cancelled'); web_invoice_update_log($single_invoice_id, 'paid', "Invoice marked as cancelled"); do_action('web_invoice_mark_as_cancel', $single_invoice_id); } return $counter . " invoice(s) marked as cancelled."; } else { if (web_invoice_paid_status($single_invoice_id)) { $counter++; web_invoice_update_invoice_meta($invoice_id, 'paid_status', 'cancelled'); web_invoice_update_log($invoice_id, 'paid', "Invoice marked as cancelled"); do_action('web_invoice_mark_as_cancel', $invoice_id); return $counter . " invoice marked as cancelled."; } else { return "No invoices marked as cancelled."; } } }
function web_invoice_generate_pdf_content($invoice_id) { global $post, $web_invoice_print; $web_invoice_print = true; $invoice = new Web_Invoice_GetInfo($invoice_id); $lines = preg_split("/\n/", get_option('web_invoice_business_address')); $lines_recepient = preg_split("/\n/", $invoice->recipient('streetaddress')); $lc = max(count($lines_recepient), count($lines)); ob_start(); ?> <style type="text/css"> .noprint { display: none; } #invoice_page { width: 500px; margin: 0 auto; font-size: 11px; font-family: 'Trebuchet MS','Lucida Grande',Verdana,Tahoma,Arial; } th { text-align: left; font-size: 13px; padding: 5px; } td { font-size: 12px; vertical-align: top; padding: 5px; } tr td { background-color: #fefefe; } tr.alt_row td { background-color: #eee; } span.description_text { color: #333; font-size: 0.8em; } tr.web_invoice_bottom_line { font-size: 1.1em; font-weight: bold; } table { width: 100%; } h2 { font-size: 1.1em; } h1 { text-align: center; } p { margin: 5px 0px; } div.clear { clear: both; } #invoice_client_info { width: 100%; text-align: right; padding-top: -<?php print ($lc + 3) * 20 + 7; ?> px; } #invoice_business_info { width: 100%; text-align: left; height: <?php print ($lc + 3) * 15 + 7; ?> px; } </style> <?php do_action('web_invoice_front_top', $invoice_id); print '<div class="clear"></div>'; //If this is not recurring invoice, show regular message if (!($recurring = web_invoice_recurring($invoice_id))) { web_invoice_show_invoice_overview($invoice_id); } // Show this if recurring if ($recurring) { web_invoice_show_recurring_info($invoice_id); } if (web_invoice_paid_status($invoice_id)) { web_invoice_show_already_paid($invoice_id); do_action('web_invoice_front_paid', $invoice_id); } else { //Show Billing Information web_invoice_show_billing_information($invoice_id); do_action('web_invoice_front_unpaid', $invoice_id); } do_action('web_invoice_front_bottom', $invoice_id); ?> <script type="text/php"> if ( isset($pdf) ) { $font = Font_Metrics::get_font("verdana", "bold"); $font_light = Font_Metrics::get_font("verdana"); $pdf->page_text(52, 810, "Powered by Web Invoice ".WEB_INVOICE_VERSION_NUM, $font_light, 10, array(0,0,0)); $pdf->page_text(510, 810, "Page {PAGE_NUM} of {PAGE_COUNT}", $font, 10, array(0,0,0)); } </script> <?php $content = ob_get_contents(); ob_clean(); return $content; }