From: Steve Sutton Date: Sun, 2 Dec 2018 14:12:06 +0000 (-0500) Subject: Adding more items to the invoice. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=dde353d8c89b93c12e8c505abbe9d111f1542ecf;p=WP-Plugins%2Fglm-member-db-billing.git Adding more items to the invoice. Added: Barcode Amount due and payment amount, member account number. --- diff --git a/lib/GlmPDFInvoice.php b/lib/GlmPDFInvoice.php index 879706e..8c8b403 100644 --- a/lib/GlmPDFInvoice.php +++ b/lib/GlmPDFInvoice.php @@ -10,15 +10,15 @@ class GlmPDFInvoice extends Cezpdf } // Rectangle Callback function for Text output - public function rect($info) + public function rect( $info ) { // this callback records all of the table of contents entries, it also places a destination marker there // so that it can be linked too // parameters $tmp = $info['p']; - $r = explode(',', $tmp); - if (count($r) >= 4) { - $this->filledRectangle($info['x'] + $r[0], $info['y'] + $r[1], $r[2], $r[3]); + $r = explode( ',', $tmp ); + if ( count ($r ) >= 4 ) { + $this->filledRectangle( $info['x'] + $r[0], $info['y'] + $r[1], $r[2], $r[3] ); } } diff --git a/models/admin/ajax/createPDFInvoice.php b/models/admin/ajax/createPDFInvoice.php index 32abb6a..77b4f91 100644 --- a/models/admin/ajax/createPDFInvoice.php +++ b/models/admin/ajax/createPDFInvoice.php @@ -234,6 +234,7 @@ class GlmMembersAdmin_ajax_createPDFInvoice array( 'terms' => 'Payment Terms' ), '', array( + 'fontSize' => 12, 'showHeadings' => 1, 'showLines' => 4, 'width' => 530, @@ -283,17 +284,63 @@ class GlmMembersAdmin_ajax_createPDFInvoice $this->pdf_font_size ); $barCodeText = $account['account_number'] . '-' . $invoice['id']; + // $barCodeText = $account['account_number'] . '-3013'; $code39RECT = $this->code39($barCodeText, 1, 30, 0, -5); - $const = ''; + $barcode = ''; foreach ($code39RECT as $v) { - $const .= ''; + $barcode .= ''; // x position + width if (($v['x'] + $v['b']) > $MAXcodeWidth) { $MAXcodeWidth = $v['x'] + $v['b']; } } $pdf->ezSetY( 130 ); - $pdf->ezText( $const, $this->pdf_font_size, array( 'right' => 220, 'justification' => 'right' ) ); + // $pdf->ezText( $barcode, $this->pdf_font_size, array( 'aright' => 335, 'justification' => 'right' ) ); + $barCode = array( + array( 'content' => $barcode ), + ); + $pdf->ezTable( + $barCode, + array( 'content' => 'barcode' ), + '', + array( + 'fontSize' => 12, + 'showHeadings' => 0, + 'showLines' => 0, + 'width' => 250, + 'xPos' => 300, + 'xOrientation' => 'right', + 'cols' => array( + 'content' => array( 'width' => 250 ) + ), + ) + ); + $pdf->ezText( '', $this->pdf_font_size ); + $paymentForm = array( + array( 'header' => 'Please Pay:', 'value' => $invoice['balance'] ), + array( + 'header' => 'Payment Amount:', + 'value' => '___________', + 'headerFill' => $this->color_white, + 'valueFill' => $this->color_white, + + ), + array( 'header' => 'Member Billing #:', 'value' => $account['account_number'] ), + ); + $pdf->ezTable( + $paymentForm, + array( 'header' => 'Header', 'value' => 'Value' ), + '', + array( + 'fontSize' => 12, + 'showHeadings' => 0, + 'showLines' => 0, + 'width' => 230, + 'xPos' => 320, + 'xOrientation' => 'right', + 'cols' => array( 'header' => array( 'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ), + ) + ); $pdf->ezStream(); } @@ -301,10 +348,11 @@ class GlmMembersAdmin_ajax_createPDFInvoice wp_die(); } - function code39($text, $barcodethinwidth = 2, $barcodeheight = 40, $xpos = 0, $ypos = 0) + function code39( $text, $barcodethinwidth = 2, $barcodeheight = 40, $xpos = 0, $ypos = 0 ) { $barcodethickwidth = $barcodethinwidth * 3; - $codingmap = array('0' => '000110100', '1' => '100100001', + $codingmap = array( + '0' => '000110100', '1' => '100100001', '2' => '001100001', '3' => '101100000', '4' => '000110001', '5' => '100110000', '6' => '001110000', '7' => '000100101', '8' => '100100100', '9' => '001100100', 'A' => '100001001', @@ -318,23 +366,22 @@ class GlmMembersAdmin_ajax_createPDFInvoice 'W' => '111000000', 'X' => '010010001', 'Y' => '110010000', 'Z' => '011010000', ' ' => '011000100', '$' => '010101000', '%' => '000101010', '*' => '010010100', '+' => '010001010', - '-' => '010000101', '.' => '110000100', '/' => '010100010', ); - $text = strtoupper($text); + '-' => '010000101', '.' => '110000100', '/' => '010100010', + ); + $text = strtoupper( $text ); $text = "*$text*"; // add start/stop chars. - $textlen = strlen($text); - $barcodewidth = ($textlen) * (7 * $barcodethinwidth + 3 * $barcodethickwidth) - $barcodethinwidth; - for ($idx = 0; $idx < $textlen; ++$idx) { - $char = substr($text, $idx, 1); + $textlen = strlen( $text ); + $barcodewidth = ( $textlen ) * ( 7 * $barcodethinwidth + 3 * $barcodethickwidth ) - $barcodethinwidth; + for ( $idx = 0; $idx < $textlen; ++$idx ) { + $char = substr( $text, $idx, 1 ); // make unknown chars a '-'; - if (!isset($codingmap[$char])) { + if ( !isset( $codingmap[$char] ) ) { $char = '-'; } - for ($baridx = 0; $baridx <= 8; ++$baridx) { - $elementwidth = (substr($codingmap[$char], $baridx, 1)) ? - $barcodethickwidth - : $barcodethinwidth; - if (($baridx + 1) % 2) { - $rectangle[] = array('x' => $xpos, 'y' => $ypos, 'b' => $elementwidth, 'h' => $barcodeheight); + for ( $baridx = 0; $baridx <= 8; ++$baridx ) { + $elementwidth = ( substr( $codingmap[$char], $baridx, 1 ) ) ? $barcodethickwidth : $barcodethinwidth; + if ( ( $baridx + 1 ) % 2 ) { + $rectangle[] = array( 'x' => $xpos, 'y' => $ypos, 'b' => $elementwidth, 'h' => $barcodeheight ); } $xpos += $elementwidth; } diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 8b607b1..bd4172d 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -85,7 +85,10 @@ {$t.amount_total} {$t.balance} {if $t.paid.value} {else}Pay Invoice{/if} - View + + View + Print + Delete {/foreach}