Adding more items to the invoice.
authorSteve Sutton <ssutton@gmail.com>
Sun, 2 Dec 2018 14:12:06 +0000 (09:12 -0500)
committerSteve Sutton <ssutton@gmail.com>
Sun, 2 Dec 2018 14:15:55 +0000 (09:15 -0500)
Added:
Barcode
Amount due and payment amount, member account number.

lib/GlmPDFInvoice.php
models/admin/ajax/createPDFInvoice.php
views/admin/billing/invoices.html

index 879706e..8c8b403 100644 (file)
@@ -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] );
         }
     }
 
index 32abb6a..77b4f91 100644 (file)
@@ -234,6 +234,7 @@ class GlmMembersAdmin_ajax_createPDFInvoice
                     array( 'terms' => '<b>Payment Terms</b>' ),
                     '',
                     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 .= '<C:rect:'.implode(',', $v).'>';
+                $barcode .= '<C:rect:'.implode(',', $v).'>';
                 // 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' => '<b>Please Pay:</b>', 'value' => $invoice['balance'] ),
+                array(
+                    'header'     => '<b>Payment Amount:</b>',
+                    'value'      => '___________',
+                    'headerFill' => $this->color_white,
+                    'valueFill'  => $this->color_white,
+
+                ),
+                array( 'header' => '<b>Member Billing #:</b>', '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;
             }
index 8b607b1..bd4172d 100644 (file)
                     <td> {$t.amount_total} </td>
                     <td> {$t.balance} </td>
                     <td> {if $t.paid.value}&nbsp;{else}<a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&option=makepayment&member={$t.member_id}">Pay Invoice</a>{/if} </td>
-                    <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=invoices&option=view&id={$t.id}">View</a> </td>
+                    <td>
+                        <a href="{$thisUrl}?page={$thisPage}&glm_action=invoices&option=view&id={$t.id}">View</a>
+                        <a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFInvoice&id={$t.id}">Print</a>
+                    </td>
                     <td> <a onClick="return confirm('This will delete the invoice. This cannot be undone. Are you Sure?');" href="{$thisUrl}?page={$thisPage}&glm_action=invoices&option=delete&invoice_id={$t.id}">Delete</a> </td>
                 </tr>
             {/foreach}