Invoice labels now printing.
Invoice labels now export csv file.
Adding todo.txt to keep track on work.
public $config;
public $pdf_top_y = 765;
public $pdf_bottom_y = 30;
- public $pdf_font_size = 11;
+ public $pdf_font_size = 10;
public $pdf_header_font_1 = 24;
public $color_white = array( 1, 1, 1 );
public $label_width = 270;
*
* @return mixed
*/
- public function createPdf( $invoices )
+ public function createPdf( $invoices, $noContactNames = false )
{
+
$addresses = array();
if ( $invoices ) {
foreach ( $invoices as $invData ) {
$account = $invData['account'];
$columnCount++;
- if ( $columnCount % 2 == 0 ) {
- $addresses[$rowCount][0]['col2'] = sprintf(
- "%s\n%s\n%s, %s %s\n",
- '<b>'.$account['ref_name'].'</b>',
- $account['billing_addr1'],
- $account['billing_city'],
- $account['billing_state'],
- $account['billing_zip']
+ $colName = ( $columnCount % 2 == 0 ) ? 'col2' : 'col1';
+ $addressLine = '';
+ if ( $noContactNames || ( !$noContactNames && !$account['billing_contact_name'] ) ) {
+ $addressLine = $account['billing_addr1'];
+ } else if ( $account['billing_contact_name'] ) {
+ $addressLine = sprintf(
+ "%s\n%s",
+ $account['billing_contact_name'],
+ $account['billing_addr1']
);
+ }
+ $addresses[$rowCount][0][$colName] = sprintf(
+ "%s\n%s\n%s, %s %s\n",
+ '<b>'.$account['ref_name'].'</b>',
+ $addressLine,
+ $account['billing_city'],
+ $account['billing_state'],
+ $account['billing_zip']
+ );
+ if ( $columnCount % 2 == 0 ) {
$rowCount++;
$columnCount = 0;
- } else {
- $addresses[$rowCount][0]['col1'] = sprintf(
- "%s\n%s\n%s, %s %s\n",
- '<b>'.$account['ref_name'].'</b>',
- $account['billing_addr1'],
- $account['billing_city'],
- $account['billing_state'],
- $account['billing_zip']
- );
}
}
}
+ // var_dump( $addresses[15][0]['col2'] );
// echo '<pre>$addresses: ' . print_r( $addresses, true ) . '</pre>';
// exit;
--- /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';
+
+/**
+ * Steve Note
+ *
+ * You can get to this using the following URL.
+ *
+ *
+ {host}/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=runQueue
+ *
+ * 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_createCSVLabels
+{
+
+ /**
+ * 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 ) {
+
+ $addresses = array();
+ $fileHeaders = array(
+ 'Name',
+ 'Contact',
+ 'Address',
+ 'City',
+ 'State',
+ 'ZIP',
+ );
+
+ $noContactNames = false;
+ if ( isset( $_REQUEST['no_contact_name'] ) && filter_var( $_REQUEST['no_contact_name'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $noContactNames = true;
+ }
+
+ $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 ) . ")";
+ }
+ if ( isset( $_REQUEST['only_payment_due'] ) && filter_var( $_REQUEST['only_payment_due'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ } else {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices) ";
+ }
+ $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
+ );
+ foreach ( $invoiceData as $inv ) {
+ $fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
+ if ( $fullInvoice ) {
+ $invoices[] = $fullInvoice;
+ }
+ }
+
+ // Pull out only the address nifo for the file export.
+ if ( $invoices && is_array( $invoices ) && !empty( $invoices ) ) {
+ foreach ( $invoices as $invData ) {
+ $account = $invData['account'];
+ $addresses[] = array(
+ 'Name' => $account['ref_name'],
+ 'Contact' => ( $noContactNames ) ? '' : $account['billing_contact_name'],
+ 'Address' => $account['billing_addr1'],
+ 'City' => $account['billing_city'],
+ 'State' => $account['billing_state'],
+ 'ZIP' => $account['billing_zip'],
+ );
+ }
+ }
+
+ $fp = fopen( 'php://output', 'w' );
+ fputcsv( $fp, $fileHeaders, ',', '"' );
+ foreach ( $addresses as $address ) {
+ fputcsv( $fp, $address, ',', '"' );
+ }
+
+ // Setup headers for forcing a file download.
+ if (ini_get('zlib.output_compression')) {
+ ini_set('zlib.output_compression', 'Off');
+ }
+ header("Content-Type: application/force-download\n");
+ /* Correction for the stupid MSIE thing */
+ $fileName = 'memberLabels-'.date('m-d-Y').'.csv';
+ if (strstr(getenv('HTTP_USER_AGENT'), 'MSIE')) {
+ header("Content-Disposition: inline; filename=\"$fileName\"");
+ } else {
+ header("Content-Disposition: attachment; filename=\"$fileName\"");
+ }
+ fclose( $fp );
+
+ wp_die();
+ }
+
+}
public function modelAction( $actionData = false ) {
+ $noContactNames = false;
+ if ( isset( $_REQUEST['no_contact_name'] ) && filter_var( $_REQUEST['no_contact_name'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $noContactNames = true;
+ }
+
$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 ) ";
+ if ( isset( $_REQUEST['only_payment_due'] ) && filter_var( $_REQUEST['only_payment_due'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ } else {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices) ";
+ }
$wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
// $where used in all places.
}
$pdf = new GlmPDFLabel( $this->config, 'LETTER', 'portrait' );
- $pdf->createPdf( $invoices );
+ $pdf->createPdf( $invoices, $noContactNames );
wp_die();
}
break;
case 'createLabels':
- $wParts[] = " T.id IN (
- SELECT account
- FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
- WHERE paid <> true ) ";
+ if ( isset( $_REQUEST['only_payment_due'] ) && filter_var( $_REQUEST['only_payment_due'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true ) ";
+ } else {
+ $wParts[] = " T.id IN (
+ SELECT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices) ";
+ }
$wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
break;
'createPDFInvoice' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'printInvoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'createPDFLabels' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+ 'createCSVLabels' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'accountsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'paymentsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'billingFlagExpiredUsers' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
--- /dev/null
+Uptra additions for Billing
+
+Additional features that need to be added to our billing plugin.
+
+Invoice type payment type with Dynamic amount. See how this was used.
+
+QIF (quickbooks) export?
+qcode entry for payment type (numeric)
+
+Invoicing:
+[x] Create Invoices (batch)
+[x] - Filter by county and category or member type
+[x] -Print Invoices (batch)
+[x] -- Filter by county and category or member type
+[x]-Create labels
+[ ] -Send Email (invoices)
+
+Reports:
+-Open Accounts
+-Closed Accounts
+-Account by Age
+-Report Generator
+-No Accounts
+-All Accounts
+
+[x] Make Payment:(might already be done)
+Donna used the payment form from the member edit section.
+
+NOTES:
+Update the account list pages so they show what number and total results are being shown.
+Maybe sortable by the headers.
+[x] Column for boss/employees should check the employee option from management first.
{include file='admin/billing/header.html'}
-
<h2>Invoicing</h2>
-
{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="{$option}">
<input type="hidden" name="prevStart" value="{$prevStart}">
<input type="hidden" name="nextStart" value="{$nextStart}">
<input type="hidden" name="limit" value="{$limit}">
-
<div class="glm-admin-table-inner">
{if $paymentTypes}
<div style="width:200px;float:left;">
-
<label>Payment Types:</label><br>
-
<select multiple size="10" name="invoice_types[]">
{foreach $paymentTypes as $paymentType}
<option value="{$paymentType.id}"{if isset($smarty.request.invoice_types) && in_array( $paymentType.id, $smarty.request.invoice_types )} selected{/if}>{$paymentType.name}</option>
</select>
</div>
{/if}
-
{if $counties}
<div style="width:200px;float:left;">
-
<label>Counties:</label><br>
-
<select multiple size="10" name="counties[]">
{foreach $counties as $county}
<option value="{$county.id}"{if isset($smarty.request.counties) && in_array( $county.id, $smarty.request.counties )} selected{/if}>{$county.name}</option>
{/foreach}
</select>
-
</div>
{/if}
-
+ {if $option == 'createLabels'}
+ <div style="width:300px;float:left;">
+ <br>
+ <label>
+ <input class="labelOption" type="checkbox" name="only_payment_due"{if isset($smarty.request.only_payment_due) && $smarty.request.only_payment_due} checked{/if}>
+ Only Payments Due<br>
+ </label>
+ <label>
+ <input id="exportCSV" type="checkbox" name="export_file"{if isset($smarty.request.export_file) && $smarty.request.export_file} checked{/if}>
+ Export as CSV File<br>
+ </label>
+ <label>
+ <input class="labelOption" type="checkbox" name="no_contact_name"{if isset($smarty.request.no_contact_name) && $smarty.request.no_contact_name} checked{/if}>
+ Remove Member Billing Contact<br>
+ </label>
+ </div>
+ {/if}
<div style="width:400px; height: 30px;">
-
<input type="submit" value="Filter">
-
{if $option == 'createInvoices'}
<input type="submit" name="submitType" value="Create Invoices" onClick="return( confirm( 'Are you Sure?' ) );">
{elseif $option == 'printInvoices'}
{elseif $option == 'createLabels'}
<input id="create-labels" type="submit" name="submitType" value="Create Labels">
{/if}
-
-
</div>
-
</div>
<br clear="all">
<br clear="all">
<p>Total found: {$totalAccounts}</p>
-
{* Paging *}
{if $paging}
<input type="Submit" name="pageSelect" value="Previous {$limit} Accounts" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
<input type="Submit" name="pageSelect" value="Next {$limit} Accounts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}
-
<br clear="all">
-
<div id="account-list">
<table class="wp-list-table widefat fixed posts glm-admin-table">
<thead>
{/foreach}
</table>
</div>
-
{* Paging *}
{if $paging}
<input type="submit" name="pageSelect" value="Previous {$limit} Accounts" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
<input type="submit" name="pageSelect" value="Next {$limit} Accounts" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
{/if}
-
</form>
-
<script>
jQuery(document).ready(function($) {
$('#print-invoices').on( 'click', function(e){
} );
$('#create-labels').on( 'click', function(e){
e.preventDefault();
- var formData = $('#invoicing-form select').serialize();
+ var formData = $('#invoicing-form select, input.labelOption').serialize();
console.log( 'Form Data:', formData );
- window.location = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFLabels&' + formData;
+ // Check if the Export as CSV file was checked.
+ if ( $('#exportCSV:checked').length ) {
+ console.log( 'exportCSV: ON' );
+ window.location = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createCSVLabels&' + formData;
+ } else {
+ console.log( 'exportCSV: OFF' );
+ window.location = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFLabels&' + formData;
+ }
} );
});
</script>
-
{include file='admin/footer.html'}