--- /dev/null
+.phpcs.xml.dist
+.travis.yml
+bin/
+phpunit.xml.dist
+tests/
public function getFullInvoiceData( $invoice_id )
{
$invoice = $this->getInvoiceById( $invoice_id );
+ if ( !$invoice ) {
+ return false;
+ }
return array(
'invoice' => $invoice,
'line_items' => $this->getLineItemsForInvoice( $invoice_id ),
<?php
+/**
+ * Gaslight Media Billing
+ * PDF Invoice generator
+ *
+ * PHP version 5.6
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersBilling
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/pdf-php/Cezpdf.php';
+/**
+ * This class extends the Cezpdf Ros PDF-PHP class
+ *
+ */
class GlmPDFInvoice extends Cezpdf
{
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ public $pdf_top_y = 680;
+ public $pdf_lft_col_x = 20;
+ public $pdf_rgt_col_x = 380;
+ public $pdf_bottom_y = 130;
+ public $pdf_font_size = 12;
+ public $pdf_header_font_1 = 24;
+ public $pdf_header_font_2 = 20;
+ public $color_white = array( 1, 1, 1 );
- public function __construct( $p, $o ) {
+ public function __construct( $config, $p, $o ) {
+ // Save plugin configuration object
+ $this->config = $config;
parent::__construct( $p, $o, 'none', array() );
}
- // Rectangle Callback function for Text output
+ /**
+ * Rectangle Callback function for Text output
+ *
+ * @param $info mixed Array of data for the content
+ */
public function rect( $info )
{
// this callback records all of the table of contents entries, it also places a destination marker there
}
}
+ /**
+ * createPdf
+ *
+ * @param $invoices array Invoices is an array of billing invoices.
+ *
+ * @return mixed
+ */
+ public function createPdf( $invoices )
+ {
+ $this->setupPages();
+
+ $totalPdfs = count( $invoices );
+ $pdfCounter = 0;
+
+ foreach ( $invoices as $fullInvoice ) {
+
+ $pdfCounter++;
+
+ $invoice = $fullInvoice['invoice'];
+ $account = $fullInvoice['account'];
+
+ $this->ezSetY( 745 );
+ $this->ezText( '<b>INVOICE</b>', $this->pdf_header_font_1, array( 'aright' => 550, 'justification' => 'right' ) );
+
+ $this->ezSetY( $this->pdf_top_y );
+
+ // Company Name
+ $companyNameSaveY = $this->ezText( '<b>' . $this->config['settings']['company_name'] . '</b>', $this->pdf_font_size );
+ // Company Address
+ $this->ezText(
+ sprintf(
+ "%s\n%s, %s %s",
+ $this->config['settings']['company_addr1'],
+ $this->config['settings']['company_city'],
+ $this->config['settings']['company_state'],
+ $this->config['settings']['company_zip']
+ ),
+ $this->pdf_font_size
+ );
+ // Company Phone
+ $this->ezText( $this->config['settings']['company_phone'], $this->pdf_font_size );
+ // Company Email
+ $endAddressSaveY = $this->ezText( $this->config['settings']['company_email'], $this->pdf_font_size );
+
+ // Right header for date and account #
+ $this->ezSetY( $companyNameSaveY );
+
+ // Add the Date of invoice and the member account number using ezTable.
+ $invoiceData = array(
+ array( 'header' => 'Date:', 'value' => date( 'm/d/Y', strtotime( $invoice['due_date'] ) ), 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ),
+ array( 'header' => 'Member Billing #:', 'value' => $account['account_number'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white )
+ );
+ $this->ezTable(
+ $invoiceData,
+ array( 'header' => '', 'value' => '' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 0,
+ 'showLines' => 0,
+ 'width' => 200,
+ 'xPos' => 350,
+ 'xOrientation' => 'right',
+ )
+ );
+
+ // Bill To header part.
+ $this->ezSetY( $endAddressSaveY );
+ $this->ezText( '', $this->pdf_font_size );
+ $this->ezText( '<b>Bill To:</b>', $this->pdf_header_font_2 );
+ // Billing Information.
+ $this->ezText(
+ sprintf(
+ "%s\n%s\n%s, %s %s",
+ $account['ref_name'],
+ $account['billing_addr1'],
+ $account['billing_city'],
+ $account['billing_state'],
+ $account['billing_zip']
+ ),
+ $this->pdf_font_size
+ );
+ $this->ezText( '', $this->pdf_font_size );
+
+ $invoiceLineItems = array();
+ // Line Items (charges).
+ $lineItems = $fullInvoice['line_items'];
+ $item = false;
+ foreach ( $lineItems as &$item ) {
+ $invoiceLineItems[] = array(
+ 'created' => date( 'm/d/Y', strtotime( $item['created'] ) ),
+ 'name' => $item['name'],
+ 'amount' => '$'.$item['amount'],
+ 'createdFill' => $this->color_white,
+ 'nameFill' => $this->color_white,
+ 'amountFill' => $this->color_white,
+ );
+ }
+ // Payments.
+ $payments = $fullInvoice['payments'];
+ $item = false;
+ foreach ( $payments as &$item ) {
+ $invoiceLineItems[] = array(
+ 'created' => date( 'm/d/Y', strtotime( $item['transaction_time'] ) ),
+ 'name' => 'Payment',
+ 'amount' => '-$'.$item['amount'],
+ 'createdFill' => $this->color_white,
+ 'nameFill' => $this->color_white,
+ 'amountFill' => $this->color_white,
+ );
+ }
+ $this->ezText( '', $this->pdf_font_size );
+ $this->ezText( '', $this->pdf_font_size );
+ $this->ezTable(
+ $invoiceLineItems,
+ array( 'created' => '<b>Date</b>', 'name' => '<b>Description</b>', 'amount' => '<b>Rate</b>' ),
+ '',
+ array(
+ 'showHeadings' => 1,
+ 'showLines' => 4,
+ 'width' => 560,
+ 'xPos' => 0,
+ 'xOrientation' => 'right',
+ 'cols' => array(
+ 'created' => array( 'width' => 100 ),
+ 'name' => array( 'width' => 380 ),
+ 'amount' => array( 'width' => 50, 'justification' => 'right' ),
+ ),
+ )
+ );
+ $invoiceTotal = array(
+ array(
+ 'created' => '',
+ 'name' => 'Total Amount Due',
+ 'amount' => '$'.$invoice['balance']
+ )
+ );
+ $this->ezTable(
+ $invoiceTotal,
+ array( 'created' => '<b>Date</b>', 'name' => '<b>Description</b>', 'amount' => '<b>Rate</b>' ),
+ '',
+ array(
+ 'showHeadings' => 0,
+ 'showLines' => 4,
+ 'width' => 560,
+ 'xPos' => 0,
+ 'xOrientation' => 'right',
+ 'cols' => array(
+ 'created' => array( 'width' => 100 ),
+ 'name' => array( 'width' => 380, 'justification' => 'right' ),
+ 'amount' => array( 'width' => 50, 'justification' => 'right' ),
+ ),
+ )
+ );
+
+ // Payment Terms
+ $this->ezSetY( 220 );
+ if ( $this->config['settings']['payment_terms'] ) {
+ $paymentTerms = array(
+ array(
+ 'terms' => $this->config['settings']['payment_terms']
+ )
+ );
+ $this->ezTable(
+ $paymentTerms,
+ array( 'terms' => '<b>Payment Terms</b>' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 1,
+ 'showLines' => 4,
+ 'width' => 530,
+ 'xPos' => 0,
+ 'xOrientation' => 'right',
+ )
+ );
+ }
+
+ // Footer section.
+ $this->ezSetY( 165 );
+ $this->ezText( 'Please return this coupon below with your payment', 10, array( 'justification' => 'center' ) );
+ // Draw a dashed line
+ $this->setLineStyle( 1, '', '', array( 5, 10 ) );
+ $this->line( 20, 150, 550, 150 );
+ $this->setLineStyle( 1, null, null, array() );
+ $this->ezSetY( 150 );
+ $this->setColor( 1, 0, 0 );
+ $this->ezText( 'Make checks payable to:', 10 );
+ $this->setColor( 0, 0, 0, 1 );
+ // Company Name
+ // Company Address
+ $this->ezText(
+ sprintf(
+ "%s\n%s, %s, %s %s\n%s - %s",
+ $this->config['settings']['company_name2'],
+ $this->config['settings']['company_addr1'],
+ $this->config['settings']['company_city'],
+ $this->config['settings']['company_state'],
+ $this->config['settings']['company_zip'],
+ $this->config['settings']['company_phone'],
+ $this->config['settings']['company_email']
+ ),
+ $this->pdf_font_size
+ );
+ $this->ezText( '', $this->pdf_font_size );
+ // Billing Information.
+ $this->ezText(
+ sprintf(
+ "%s\n%s\n%s, %s %s",
+ $account['ref_name'],
+ $account['billing_addr1'],
+ $account['billing_city'],
+ $account['billing_state'],
+ $account['billing_zip']
+ ),
+ $this->pdf_font_size
+ );
+ $barCodeText = $account['account_number'] . '-' . $invoice['id'];
+ // $barCodeText = $account['account_number'] . '-3013';
+ $code39RECT = $this->code39($barCodeText, 1, 30, 0, -5);
+ $barcode = '';
+ foreach ($code39RECT as $v) {
+ $barcode .= '<C:rect:'.implode(',', $v).'>';
+ // x position + width
+ if (($v['x'] + $v['b']) > $MAXcodeWidth) {
+ $MAXcodeWidth = $v['x'] + $v['b'];
+ }
+ }
+ $this->ezSetY( 130 );
+ // $this->ezText( $barcode, $this->pdf_font_size, array( 'aright' => 335, 'justification' => 'right' ) );
+ $barCode = array(
+ array( 'content' => $barcode ),
+ );
+ $this->ezTable(
+ $barCode,
+ array( 'content' => 'barcode' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 0,
+ 'showLines' => 0,
+ 'width' => 250,
+ 'xPos' => 300,
+ 'xOrientation' => 'right',
+ 'cols' => array(
+ 'content' => array( 'width' => 250 )
+ ),
+ )
+ );
+ $this->ezText( '', $this->pdf_font_size );
+ $paymentForm1 = array(
+ array( 'header' => '<b>Please Pay:</b>', 'value' => '$'.$invoice['balance'] ),
+ );
+ $newY = $this->ezTable(
+ $paymentForm1,
+ array( 'header' => 'Header', 'value' => 'Value' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 0,
+ 'showLines' => 0,
+ 'width' => 230,
+ 'xPos' => 320,
+ 'xOrientation' => 'right',
+ 'cols' => array( 'header' => array( 'width' => 120,'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
+ )
+ );
+ if ( $invoice['balance'] != '0.00' ) {
+ $paymentForm2 = array(
+ array(
+ 'header' => '<b>Payment Amount:</b>',
+ 'value' => '___________',
+ 'headerFill' => $this->color_white,
+ 'valueFill' => $this->color_white,
+ )
+ );
+ $newY = $this->ezTable(
+ $paymentForm2,
+ array( 'header' => 'Header', 'value' => 'Value' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 0,
+ 'showLines' => 0,
+ 'width' => 230,
+ 'xPos' => 320,
+ 'xOrientation' => 'right',
+ 'cols' => array( 'header' => array( 'width' => 120,'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
+ )
+ );
+ } else {
+ $newY = $this->ezText( '', $this->pdf_font_size );
+ $newY = $this->addText( 375, $newY, 14, '<b>NO PAYMENT REQUIRED</b>' );
+ }
+ $paymentForm3 = array(
+ array( 'header' => '<b>Member Billing #:</b>', 'value' => $account['account_number'] ),
+ );
+ $this->ezTable(
+ $paymentForm3,
+ array( 'header' => 'Header', 'value' => 'Value' ),
+ '',
+ array(
+ 'fontSize' => 12,
+ 'showHeadings' => 0,
+ 'showLines' => 0,
+ 'width' => 230,
+ 'xPos' => 320,
+ 'xOrientation' => 'right',
+ 'cols' => array( 'header' => array( 'width' => 120, 'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
+ )
+ );
+
+
+
+ if ( $pdfCounter < $totalPdfs ) {
+ $this->ezNewPage();
+ }
+ }
+
+ // Output PDF
+ $this->ezStream();
+
+ }
+
+ /**
+ * Setup the invoice graphic on top of all pages.
+ */
+ public function setupPages()
+ {
+ $this->allowedTags .= '|rect:.*?';
+ $this->setLineStyle( 1 );
+ $this->ezSetMargins( 20, 20, 20, 20 );
+ $this->selectFont( 'Helvetica' );
+
+ // Set header/footer of all pages
+ $all = $this->openObject();
+ $this->saveState();
+ $this->ezSetY( 775 );
+ if ( $this->config['settings']['company_logo'] ) {
+ $this->ezImage(
+ GLM_MEMBERS_PLUGIN_MEDIA_PATH . '/images/large/' . $this->config['settings']['company_logo'], // image
+ 0, // padding
+ 260, // width
+ 'none', // resize
+ 'left', // justification
+ '', // angle
+ '' // array border
+ );
+ }
+ $this->restoreState();
+ $this->closeObject();
+ $this->addObject( $all, 'all' );
+ }
+ function code39( $text, $barcodethinwidth = 2, $barcodeheight = 40, $xpos = 0, $ypos = 0 )
+ {
+ $barcodethickwidth = $barcodethinwidth * 3;
+ $codingmap = array(
+ '0' => '000110100', '1' => '100100001',
+ '2' => '001100001', '3' => '101100000', '4' => '000110001',
+ '5' => '100110000', '6' => '001110000', '7' => '000100101',
+ '8' => '100100100', '9' => '001100100', 'A' => '100001001',
+ 'B' => '001001001', 'C' => '101001000', 'D' => '000011001',
+ 'E' => '100011000', 'F' => '001011000', 'G' => '000001101',
+ 'H' => '100001100', 'I' => '001001100', 'J' => '000011100',
+ 'K' => '100000011', 'L' => '001000011', 'M' => '101000010',
+ 'N' => '000010011', 'O' => '100010010', 'P' => '001010010',
+ 'Q' => '000000111', 'R' => '100000110', 'S' => '001000110',
+ 'T' => '000010110', 'U' => '110000001', 'V' => '011000001',
+ 'W' => '111000000', 'X' => '010010001', 'Y' => '110010000',
+ 'Z' => '011010000', ' ' => '011000100', '$' => '010101000',
+ '%' => '000101010', '*' => '010010100', '+' => '010001010',
+ '-' => '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 );
+ // make unknown chars a '-';
+ 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 );
+ }
+ $xpos += $elementwidth;
+ }
+ $xpos += $barcodethinwidth;
+ }
+
+ return $rectangle;
+ }
+
}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Billing
+ * PDF Invoice generator
+ *
+ * PHP version 5.6
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersBilling
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/pdf-php/Cezpdf.php';
+
+/**
+ * This class extends the Cezpdf Ros PDF-PHP class
+ *
+ */
+class GlmPDFLabel extends Cezpdf
+{
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ public $pdf_top_y = 790;
+ public $pdf_bottom_y = 30;
+ public $pdf_font_size = 12;
+ public $pdf_header_font_1 = 24;
+ public $color_white = array( 1, 1, 1 );
+
+ public function __construct( $config, $p, $o ) {
+ // Save plugin configuration object
+ $this->config = $config;
+ parent::__construct( $p, $o, 'none', array() );
+ }
+
+ /**
+ * createPdf
+ *
+ * @param $invoices array Invoices is an array of billing invoices.
+ *
+ * @return mixed
+ */
+ public function createPdf( $invoices )
+ {
+ $this->setupPages();
+
+ $y = $this->pdf_top_y;
+ $this->ezSetY( $this->pdf_top_y );
+
+ $counter = 0;
+ foreach ( $invoices as $fullInvoice ) {
+
+ $invoice = $fullInvoice['invoice'];
+ $account = $fullInvoice['account'];
+
+ $counter++;
+ if ( $counter % 2 == 0 ) {
+ $y = $y += 45;
+ $this->ezSetY( $y );
+ $option = array(
+ 'aleft' => 330,
+ );
+ } else {
+ $y = $y -= 35;
+ $this->ezSetY( $y );
+ $option = '';
+ }
+
+ $y = $this->ezText(
+ sprintf(
+ "<b>%s</b>\n%s\n%s, %s %s",
+ $account['ref_name'],
+ $account['billing_addr1'],
+ $account['billing_city'],
+ $account['billing_state'],
+ $account['billing_zip']
+ ),
+ 12,
+ $option
+ );
+ if ( $y <= $this->pdf_bottom_y && $counter % 2 == 0 ) {
+ $this->ezNewPage();
+ $y =$this->pdf_top_y;
+ $this->ezSetY( $y );
+ }
+
+ }
+
+ // Output PDF
+ $this->ezStream();
+
+ }
+
+ /**
+ * Setup the invoice graphic on top of all pages.
+ */
+ public function setupPages()
+ {
+ // $this->allowedTags .= '|rect:.*?';
+ $this->setLineStyle( 1 );
+ $this->ezSetMargins( 20, 20, 20, 20 );
+ $this->selectFont( 'Helvetica' );
+
+ }
+}
echo 'failed to get invoice';
return false;
}
- // Get the account information.
- $account = $fullInvoice['account'];
- // PDF settings
- $this->pdf_top_y = 725;
- $this->pdf_width = 570;
- $this->line_height = 10;
- $this->pdf_lft_col_x = 20;
- $this->pdf_rgt_col_x = 380;
- $this->pdf_bottom_y = 130;
- $this->pdf_font_size = 12;
- $this->pdf_header_font_1 = 24;
- $this->pdf_header_font_2 = 20;
- $this->color_white = array( 1, 1, 1 );
- $this->color_red = array( 1, 0, 0 );
- $this->color_black = array( 0, 0, 0 );
+ $invoices = array( $fullInvoice );
// Create pdf object
- $pdf = new GlmPDFInvoice( 'a4', 'portrait' );
- $pdf->allowedTags .= '|rect:.*?';
- $pdf->setLineStyle( 1 );
- $pdf->ezSetMargins( 20, 20, 20, 20 );
- $pdf->selectFont( 'Helvetica' );
+ $pdf = new GlmPDFInvoice( $this->config, 'LETTER', 'portrait' );
+ $pdf->createPdf( $invoices );
- // Set header/footer of all pages
- $all = $pdf->openObject();
- $pdf->saveState();
- $pdf->ezSetY( 827 );
- if ( $this->config['settings']['company_logo'] ) {
- $pdf->ezImage(
- GLM_MEMBERS_PLUGIN_MEDIA_PATH . '/images/large/' . $this->config['settings']['company_logo'], // image
- 0, // padding
- 260, // width
- 'none', // resize
- 'left', // justification
- '', // angle
- '' // array border
- );
- }
- $pdf->restoreState();
- $pdf->closeObject();
- $pdf->addObject( $all, 'all' );
-
- $pdf->ezSetY( 785 );
- $pdf->ezText( '<b>INVOICE</b>', $this->pdf_header_font_1, array( 'aright' => 550, 'justification' => 'right' ) );
-
- $pdf->ezSetY( $this->pdf_top_y );
-
- // Company Name
- $companyNameSaveY = $pdf->ezText( '<b>' . $this->config['settings']['company_name'] . '</b>', $this->pdf_font_size );
- // Company Address
- $pdf->ezText(
- sprintf(
- "%s\n%s, %s %s",
- $this->config['settings']['company_addr1'],
- $this->config['settings']['company_city'],
- $this->config['settings']['company_state'],
- $this->config['settings']['company_zip']
- ),
- $this->pdf_font_size
- );
- // Company Phone
- $pdf->ezText( $this->config['settings']['company_phone'], $this->pdf_font_size );
- // Company Email
- $endAddressSaveY = $pdf->ezText( $this->config['settings']['company_email'], $this->pdf_font_size );
-
- // Right header for date and account #
- $pdf->ezSetY( $companyNameSaveY );
-
- // Add the Date of invoice and the member account number using ezTable.
- $invoiceData = array(
- array( 'header' => 'Date:', 'value' => date( 'm/d/Y', strtotime( $invoice['due_date'] ) ), 'headerFill' => $this->color_white, 'valueFill' => $this->color_white ),
- array( 'header' => 'Member Billing #:', 'value' => $account['account_number'], 'headerFill' => $this->color_white, 'valueFill' => $this->color_white )
- );
- $pdf->ezTable(
- $invoiceData,
- array( 'header' => '', 'value' => '' ),
- '',
- array(
- 'fontSize' => 12,
- 'showHeadings' => 0,
- 'showLines' => 0,
- 'width' => 200,
- 'xPos' => 350,
- 'xOrientation' => 'right',
- )
- );
-
- // Bill To header part.
- $pdf->ezSetY( $endAddressSaveY );
- $pdf->ezText( '', $this->pdf_font_size );
- $pdf->ezText( '<b>Bill To:</b>', $this->pdf_header_font_2 );
- // Billing Information.
- $pdf->ezText(
- sprintf(
- "%s\n%s\n%s, %s %s",
- $account['ref_name'],
- $account['billing_addr1'],
- $account['billing_city'],
- $account['billing_state'],
- $account['billing_zip']
- ),
- $this->pdf_font_size
- );
-
- $invoiceLineItems = array();
- // Line Items (charges).
- $lineItems = $fullInvoice['line_items'];
- $item = false;
- foreach ( $lineItems as &$item ) {
- $invoiceLineItems[] = array(
- 'created' => date( 'm/d/Y', strtotime( $item['created'] ) ),
- 'name' => $item['name'],
- 'amount' => $item['amount'],
- );
- }
- // Payments.
- $payments = $fullInvoice['payments'];
- $item = false;
- foreach ( $payments as &$item ) {
- $invoiceLineItems[] = array(
- 'created' => date( 'm/d/Y', strtotime( $item['transaction_time'] ) ),
- 'name' => 'Payment',
- 'amount' => '-'.$item['amount'],
- );
- }
- $pdf->ezText( '', $this->pdf_font_size );
- $pdf->ezText( '', $this->pdf_font_size );
- $pdf->ezTable(
- $invoiceLineItems,
- array( 'created' => '<b>Date</b>', 'name' => '<b>Description</b>', 'amount' => '<b>Rate</b>' ),
- '',
- array(
- 'showHeadings' => 1,
- 'showLines' => 4,
- 'width' => 560,
- 'xPos' => 0,
- 'xOrientation' => 'right',
- 'cols' => array(
- 'created' => array( 'width' => 100 ),
- 'name' => array( 'width' => 380 ),
- 'amount' => array( 'width' => 50, 'justification' => 'right' ),
- ),
- )
- );
- $invoiceTotal = array(
- array(
- 'created' => '',
- 'name' => 'Total Amount Due',
- 'amount' => $invoice['balance']
- )
- );
- $pdf->ezTable(
- $invoiceTotal,
- array( 'created' => '<b>Date</b>', 'name' => '<b>Description</b>', 'amount' => '<b>Rate</b>' ),
- '',
- array(
- 'showHeadings' => 0,
- 'showLines' => 4,
- 'width' => 560,
- 'xPos' => 0,
- 'xOrientation' => 'right',
- 'cols' => array(
- 'created' => array( 'width' => 100 ),
- 'name' => array( 'width' => 380, 'justification' => 'right' ),
- 'amount' => array( 'width' => 50, 'justification' => 'right' ),
- ),
- )
- );
-
- // Payment Terms
- $pdf->ezSetY( 220 );
- if ( $this->config['settings']['payment_terms'] ) {
- $paymentTerms = array(
- array(
- 'terms' => $this->config['settings']['payment_terms']
- )
- );
- $pdf->ezTable(
- $paymentTerms,
- array( 'terms' => '<b>Payment Terms</b>' ),
- '',
- array(
- 'fontSize' => 12,
- 'showHeadings' => 1,
- 'showLines' => 4,
- 'width' => 530,
- 'xPos' => 0,
- 'xOrientation' => 'right',
- )
- );
- }
-
- // Footer section.
- $pdf->ezSetY( 165 );
- $pdf->ezText( 'Please return this coupon below with your payment', 9, array( 'justification' => 'center' ) );
- // Draw a dashed line
- $pdf->setLineStyle( 1, '', '', array( 5, 10 ) );
- $pdf->line( 20, 150, 550, 150 );
- $pdf->setLineStyle( 1, null, null, array() );
- $pdf->ezSetY( 150 );
- $pdf->setColor( 1, 0, 0 );
- $pdf->ezText( 'Make checks payable to:', 9 );
- $pdf->setColor( 0, 0, 0, 1 );
- // Company Name
- // Company Address
- $pdf->ezText(
- sprintf(
- "%s\n%s, %s, %s %s\n%s - %s",
- $this->config['settings']['company_name2'],
- $this->config['settings']['company_addr1'],
- $this->config['settings']['company_city'],
- $this->config['settings']['company_state'],
- $this->config['settings']['company_zip'],
- $this->config['settings']['company_phone'],
- $this->config['settings']['company_email']
- ),
- $this->pdf_font_size
- );
- $pdf->ezText( '', $this->pdf_font_size );
- // Billing Information.
- $pdf->ezText(
- sprintf(
- "%s\n%s\n%s, %s %s",
- $account['ref_name'],
- $account['billing_addr1'],
- $account['billing_city'],
- $account['billing_state'],
- $account['billing_zip']
- ),
- $this->pdf_font_size
- );
- $barCodeText = $account['account_number'] . '-' . $invoice['id'];
- // $barCodeText = $account['account_number'] . '-3013';
- $code39RECT = $this->code39($barCodeText, 1, 30, 0, -5);
- $barcode = '';
- foreach ($code39RECT as $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( $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 );
- $paymentForm1 = array(
- array( 'header' => '<b>Please Pay:</b>', 'value' => $invoice['balance'] ),
- );
- $newY = $pdf->ezTable(
- $paymentForm1,
- array( 'header' => 'Header', 'value' => 'Value' ),
- '',
- array(
- 'fontSize' => 12,
- 'showHeadings' => 0,
- 'showLines' => 0,
- 'width' => 230,
- 'xPos' => 320,
- 'xOrientation' => 'right',
- 'cols' => array( 'header' => array( 'width' => 120,'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
- )
- );
- if ( $invoice['balance'] != '0.00' ) {
- $paymentForm2 = array(
- array(
- 'header' => '<b>Payment Amount:</b>',
- 'value' => '___________',
- 'headerFill' => $this->color_white,
- 'valueFill' => $this->color_white,
- )
- );
- $newY = $pdf->ezTable(
- $paymentForm2,
- array( 'header' => 'Header', 'value' => 'Value' ),
- '',
- array(
- 'fontSize' => 12,
- 'showHeadings' => 0,
- 'showLines' => 0,
- 'width' => 230,
- 'xPos' => 320,
- 'xOrientation' => 'right',
- 'cols' => array( 'header' => array( 'width' => 120,'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
- )
- );
- } else {
- $newY = $pdf->ezText( '', $this->pdf_font_size );
- $newY = $pdf->addText( 375, $newY, 14, '<b>NO PAYMENT REQUIRED</b>' );
- }
- $paymentForm3 = array(
- array( 'header' => '<b>Member Billing #:</b>', 'value' => $account['account_number'] ),
- );
- $pdf->ezTable(
- $paymentForm3,
- array( 'header' => 'Header', 'value' => 'Value' ),
- '',
- array(
- 'fontSize' => 12,
- 'showHeadings' => 0,
- 'showLines' => 0,
- 'width' => 230,
- 'xPos' => 320,
- 'xOrientation' => 'right',
- 'cols' => array( 'header' => array( 'width' => 120, 'justification' => 'right' ), 'value' => array( 'justification' => 'right' ) ),
- )
- );
-
- $pdf->ezStream();
}
wp_die();
}
- function code39( $text, $barcodethinwidth = 2, $barcodeheight = 40, $xpos = 0, $ypos = 0 )
- {
- $barcodethickwidth = $barcodethinwidth * 3;
- $codingmap = array(
- '0' => '000110100', '1' => '100100001',
- '2' => '001100001', '3' => '101100000', '4' => '000110001',
- '5' => '100110000', '6' => '001110000', '7' => '000100101',
- '8' => '100100100', '9' => '001100100', 'A' => '100001001',
- 'B' => '001001001', 'C' => '101001000', 'D' => '000011001',
- 'E' => '100011000', 'F' => '001011000', 'G' => '000001101',
- 'H' => '100001100', 'I' => '001001100', 'J' => '000011100',
- 'K' => '100000011', 'L' => '001000011', 'M' => '101000010',
- 'N' => '000010011', 'O' => '100010010', 'P' => '001010010',
- 'Q' => '000000111', 'R' => '100000110', 'S' => '001000110',
- 'T' => '000010110', 'U' => '110000001', 'V' => '011000001',
- 'W' => '111000000', 'X' => '010010001', 'Y' => '110010000',
- 'Z' => '011010000', ' ' => '011000100', '$' => '010101000',
- '%' => '000101010', '*' => '010010100', '+' => '010001010',
- '-' => '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 );
- // make unknown chars a '-';
- 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 );
- }
- $xpos += $elementwidth;
- }
- $xpos += $barcodethinwidth;
- }
-
- return $rectangle;
- }
-
}
*/
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
-require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/GlmPDFInvoice.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/GlmPDFLabel.php';
/**
* Steve Note
public function modelAction( $actionData = false ) {
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+ if ( isset( $_REQUEST['invoice_types'] ) ) {
- // Expect an array of member data with addresses.
-
- // PDF settings
- $this->pdf_top_y = 725;
- $this->pdf_width = 570;
- $this->line_height = 10;
- $this->pdf_lft_col_x = 20;
- $this->pdf_rgt_col_x = 380;
- $this->pdf_bottom_y = 130;
- $this->pdf_font_size = 12;
- $this->pdf_header_font_1 = 24;
- $this->pdf_header_font_2 = 20;
- $this->color_white = array( 1, 1, 1 );
- $this->color_red = array( 1, 0, 0 );
- $this->color_black = array( 0, 0, 0 );
-
- // Create pdf object
- $pdf = new GlmPDFInvoice( 'a4', 'portrait' );
- $pdf->allowedTags .= '|rect:.*?';
- $pdf->setLineStyle( 1 );
- $pdf->ezSetMargins( 20, 20, 20, 20 );
- $pdf->selectFont( 'Helvetica' );
-
- $Invoice = new GlmDataInvoices( $this->wpdb, $this->config );
- $invoices = $Invoice->getList();
-
- // echo '<pre>$invoices: ' . print_r( $invoices, true ) . '</pre>';
-
- $y = 830;
- $pdf->ezSetY( $y );
-
- $counter = 0;
- foreach ( $invoices as $invoice ) {
- $counter++;
- if ( $counter % 2 == 0 ) {
- $y = $y += 40;
- $pdf->ezSetY( $y );
- $option = array(
- 'aleft' => 330,
- );
- } else {
- $y = $y -= 30;
- $pdf->ezSetY( $y );
- $option = '';
- }
+ $invoiceTypes = $_REQUEST['invoice_types'];
+ $wParts[] = " T.invoice_type IN (" . implode(',', $invoiceTypes) . ") ";
+
+ }
+
+ if ( isset( $_REQUEST['counties'] ) ) {
+
+ $countiesSelected = $_REQUEST['counties'];
+ $wParts[] = "T.billing_county IN (" . implode(',', $countiesSelected ) . ")";
+
+ }
- // echo '<pre>$invoice: ' . print_r( $invoice['account']['value'], true ) . '</pre>';
- // Get account
- $account = $BillingSupport->getAccountById( $invoice['account']['value'] );
- // echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
- $y = $pdf->ezText(
- sprintf(
- "<b>%s</b>\n%s\n%s, %s %s",
- $account['ref_name'],
- $account['billing_addr1'],
- $account['billing_city'],
- $account['billing_state'],
- $account['billing_zip']
- ),
- 12,
- $option
- );
- if ( $y <= 80 && $counter % 2 == 0 ) {
- $pdf->ezNewPage();
- $y = 830;
- $pdf->ezSetY( $y );
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+
+ // $where used in all places.
+ $where = implode( ' AND ', $wParts );
+
+ // Get all invoices
+ $invoiceData = $this->wpdb->get_results(
+ "SELECT I.id
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
+ LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts T ON (T.id = I.account)
+ WHERE $where
+ ORDER BY T.ref_name",
+ ARRAY_A
+ );
+ // echo '<pre>$invoiceData: ' . print_r( $invoiceData, true ) . '</pre>';
+ foreach ( $invoiceData as $inv ) {
+ $fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
+ if ( $fullInvoice ) {
+ $invoices[] = $fullInvoice;
}
}
- $pdf->ezStream();
+ $pdf = new GlmPDFLabel( $this->config, 'LETTER', 'portrait' );
+ $pdf->createPdf( $invoices );
wp_die();
}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * PDF Output by admin-ajax
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_PATH . '/lib/GlmPDFInvoice.php';
+
+/**
+ * Steve Note
+ *
+ * You can get to this using the following URL.
+ *
+ *
+ {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=printInvoices
+ *
+ * You should be able to do this as POST or GET and should be able to add and read additional parameters.
+ * I added a "mystuff" parameter to the URL above and it does output from the code in the
+ * modelAction() function below.
+ *
+ * To add another model under models/admin/ajax all you need to do is create it and add it to the
+ * setup/validActions.php file.
+ *
+ */
+
+/**
+ * This class handles the work of creating new invoices based on.
+ * 1) Member Type of member matching a paid invoiceType
+ * 2) Member renewal date past
+ * 3) Member has Billing Account
+ * 4) Member has no active Invoice
+ * 5) Renewal date is within the next 30 Days
+ *
+ */
+class GlmMembersAdmin_ajax_printInvoices
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ public function modelAction( $actionData = false ) {
+
+ $wParts = array( 'true' );
+
+ // $invoices
+ $invoices = array();
+
+ // Create Billing Support Object.
+ $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+
+ if ( isset( $_REQUEST['invoice_types'] ) ) {
+
+ $invoiceTypes = $_REQUEST['invoice_types'];
+ $wParts[] = " T.invoice_type IN (" . implode(',', $invoiceTypes) . ") ";
+
+ }
+
+ if ( isset( $_REQUEST['counties'] ) ) {
+
+ $countiesSelected = $_REQUEST['counties'];
+ $wParts[] = "T.billing_county IN (" . implode(',', $countiesSelected ) . ")";
+
+ }
+
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+
+ // $where used in all places.
+ $where = implode( ' AND ', $wParts );
+
+ // Get all invoices
+ $invoiceData = $this->wpdb->get_results(
+ "SELECT I.id
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
+ LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts T ON (T.id = I.account)
+ WHERE $where
+ ORDER BY T.ref_name",
+ ARRAY_A
+ );
+ // echo '<pre>$invoiceData: ' . print_r( $invoiceData, true ) . '</pre>';
+ foreach ( $invoiceData as $inv ) {
+ $fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
+ if ( $fullInvoice ) {
+ $invoices[] = $fullInvoice;
+ }
+ }
+ // Create pdf object
+ $pdf = new GlmPDFInvoice( $this->config, 'LETTER', 'portrait' );
+ $pdf->createPdf( $invoices );
+
+ wp_die();
+ }
+
+}
$numbDisplayed = false;
$lastDisplayed = false;
$totalAccounts = false;
+ $option2 = false;
// Get any provided option
if ( isset( $_REQUEST['option'] ) ) {
}
- // $where used in all places.
- $where = implode( ' AND ', $wParts );
-
if ( isset( $_REQUEST['submitType'] ) ) {
$option2 = filter_var( $_REQUEST['submitType'], FILTER_SANITIZE_STRING );
- switch( $option2 ) {
- case 'Create Invoices':
+ }
+
+ // Do selected option
+ switch ($option) {
+
+ case 'printInvoices':
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+ break;
+
+ case 'createLabels':
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+ break;
+
+ case 'createInvoices':
+ $view = 'invoicing';
+
+ if ( $option2 ) {
$accounts = $Accounts->getSimpleAccountList( $where );
// echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
foreach ( $accounts as $account ) {
)
);
}
-
- break;
- case 'Print Invoices':
- break;
- case 'Send Invoices':
- break;
- default:
- break;
}
- }
-
- // Do selected option
- switch ($option) {
+ break;
case 'list':
default:
$view = 'invoicing';
+ break;
- // Check if Counties is enabled and fetch counties
- if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {
- // Grab counties
- $counties = $this->wpdb->get_results(
- "SELECT *
- FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
- ORDER BY name",
- ARRAY_A
- );
- }
+ }
+
+ // $where used in all places.
+ $where = implode( ' AND ', $wParts );
- $paymentTypes = $BillingSupport->getAllInvoiceTypes();
+ // Check if Counties is enabled and fetch counties
+ if ( isset( $this->config['settings']['enable_counties'] ) && $this->config['settings']['enable_counties'] ) {
+ // Grab counties
+ $counties = $this->wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "counties
+ ORDER BY name",
+ ARRAY_A
+ );
+ }
+ $paymentTypes = $BillingSupport->getAllInvoiceTypes();
- if (isset($_REQUEST['pageSelect'])) {
- // If request is for Next
- if ($_REQUEST['pageSelect'][0] == 'N') {
- $newStart = $_REQUEST['nextStart'] - 0;
- // Otherwise it must be Previous
- } else {
- $newStart = $_REQUEST['prevStart'] - 0;
- }
+ if (isset($_REQUEST['pageSelect'])) {
+ // If request is for Next
+ if ($_REQUEST['pageSelect'][0] == 'N') {
+ $newStart = $_REQUEST['nextStart'] - 0;
- if ($newStart > 0) {
- $start = $newStart;
- }
- }
- $orderBy = 'member_name';
- $Accounts->paymentTypes = true;
- $Accounts->balanceDue = true;
- $accountsResult = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
- $totalAccounts = $Accounts->getStats( $where );
- $Accounts->paymentTypes = false;
- $Accounts->balanceDue = false;
- // Get paging results
- $numbDisplayed = $accountsResult['returned'];
- $lastDisplayed = $accountsResult['last'];
- if ( $start == 1 ) {
- $prevStart = false;
+ // Otherwise it must be Previous
} else {
- $prevStart = $start - $limit;
- if ( $start < 1 ) {
- $start = 1;
- }
- }
- if ( $accountsResult['returned'] == $limit ) {
- $nextStart = $start + $limit;
+ $newStart = $_REQUEST['prevStart'] - 0;
}
- // since we're doing paging, we have to break out just the accounts data
- $accounts = $accountsResult['list'];
- // echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
- if ( count( $accounts ) > 0 ) {
- $haveAccounts = true;
+ if ($newStart > 0) {
+ $start = $newStart;
}
+ }
+ $orderBy = 'member_name';
+ $Accounts->paymentTypes = true;
+ $Accounts->balanceDue = true;
+ $accountsResult = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
+ $totalAccounts = $Accounts->getStats( $where );
+ $Accounts->paymentTypes = false;
+ $Accounts->balanceDue = false;
+ // Get paging results
+ $numbDisplayed = $accountsResult['returned'];
+ $lastDisplayed = $accountsResult['last'];
+ if ( $start == 1 ) {
+ $prevStart = false;
+ } else {
+ $prevStart = $start - $limit;
+ if ( $start < 1 ) {
+ $start = 1;
+ }
+ }
+ if ( $accountsResult['returned'] == $limit ) {
+ $nextStart = $start + $limit;
+ }
- break;
-
+ // since we're doing paging, we have to break out just the accounts data
+ $accounts = $accountsResult['list'];
+ // echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
+ if ( count( $accounts ) > 0 ) {
+ $haveAccounts = true;
}
+
$templateData = array(
'option' => $option,
'paymentTypes' => $paymentTypes,
'invoiceTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'createNewInvoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'createPDFInvoice' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+ 'printInvoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'createPDFLabels' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'accountsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'paymentsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
{include file='admin/billing/header.html'}
-{* include file='admin/billing/invoicingSubHeader.html' *}
-
<h2>Invoicing</h2>
-<form action="{$thisUrl}?page={$thisPage}" method="post">
+{include file='admin/billing/invoicingSubHeader.html'}
+
+<form id="invoicing-form" action="{$thisUrl}?page={$thisPage}" method="get">
+ <input type="hidden" name="page" value="{$thisPage}">
<input type="hidden" name="glm_action" value="invoicing">
- <input type="hidden" name="option" value="list">
+ <input type="hidden" name="option" value="{$option}">
<input type="hidden" name="prevStart" value="{$prevStart}">
<input type="hidden" name="nextStart" value="{$nextStart}">
<input type="hidden" name="limit" value="{$limit}">
{/if}
<div style="width:400px; height: 30px;">
+
<input type="submit" value="Filter">
- <input type="submit" name="submitType" value="Create Invoices">
+
+ {if $option == 'createInvoices'}
+ <input type="submit" name="submitType" value="Create Invoices" onClick="return( confirm( 'Are you Sure?' ) );">
+ {elseif $option == 'printInvoices'}
+ <input id="print-invoices" type="submit" name="submitType" value="Print Invoices">
+ {elseif $option == 'createLabels'}
+ <input id="create-labels" type="submit" name="submitType" value="Create Labels">
+ {/if}
+
+
</div>
</div>
</thead>
{foreach $accounts as $t}
<tr>
- <td> {$t.member_name} </td>
+ <td>
+ <a href="{$adminUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$t.ref_dest}">
+ {$t.member_name}
+ </a>
+ </td>
<td> {$t.account_number} </td>
<td> {$t.payment_type} </td>
<td> {$t.balance_due|string_format:"%.2f"} </td>
</form>
+<script>
+jQuery(document).ready(function($) {
+ $('#print-invoices').on( 'click', function(e){
+ e.preventDefault();
+ var formData = $('#invoicing-form select').serialize();
+ console.log( 'Form Data:', formData );
+ window.location = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=printInvoices&' + formData;
+ } );
+ $('#create-labels').on( 'click', function(e){
+ e.preventDefault();
+ var formData = $('#invoicing-form select').serialize();
+ console.log( 'Form Data:', formData );
+ window.location = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFLabels&' + formData;
+ } );
+});
+</script>
+
{include file='admin/footer.html'}
--- /dev/null
+<h2 class="nav-tab-wrapper">
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoicing&option=createInvoices" class="nav-tab{if $option==createInvoices} nav-tab-active{/if}">Create Invoices</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoicing&option=printInvoices" class="nav-tab{if $option==printInvoices} nav-tab-active{/if}">Print Invoices</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoicing&option=createLabels" class="nav-tab{if $option==createLabels} nav-tab-active{/if}">Create Labels</a>
+</h2>
<tr>
<th style="text-align: right;" {if $notification.fieldRequired.message}class="glm-required"{/if}>Message:</th>
<td {if $notification.fieldFail.message}class="glm-form-bad-input" data-tabid="glm-message"{/if}>
- {php}
- wp_editor('{$notification.fieldData.message|escape:quotes}', 'glm_descr', array(
- 'media_buttons' => false,
- 'textarea_name' => 'message',
- 'editor_height' => 200,
- ));
- {/php}
+ {wp_editor(
+ $notification.fieldData.message|escape:quotes,
+ 'glm_descr',
+ json_decode('{
+ "media_buttons": false,
+ "quicktags": false,
+ "textarea_name": "message",
+ "editor_height": 200
+ }', true)
+ )}
{if $notification.fieldFail.message}<p>{$notification.fieldFail.message}</p>{/if}
</td>
</tr>