--- /dev/null
+<?php
+/**
+ * GLM Member-DB WordPress Add-On Plugin
+ * Data Class Management
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package GLM Member-DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * GlmDataBillingManagement class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package GLM Member DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ * Exp $
+ */
+class GlmDataTransactions extends GlmDataAbstract
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Data Table Name
+ *
+ * @var $table
+ * @access public
+ */
+ public $table;
+ /**
+ * Field definitions
+ *
+ * 'type' is type of field as defined by the application
+ * text Regular text field
+ * pointer Pointer to an entry in another table
+ * 'filters' is the filter name for a particular filter ID in PHP filter
+ * functions
+ * See PHP filter_id()
+ *
+ * 'use' is when to use the field
+ * l = List
+ * g = Get
+ * n = New
+ * i = Insert
+ * e = Edit
+ * u = Update
+ * d = Delete
+ * a = All
+ *
+ * @var $ini
+ * @access public
+ */
+ public $fields = false;
+
+ /**
+ * Constructor
+ *
+ * @param object $d database connection
+ * @param array $config Configuration array
+ * @param bool $limitedEdit Flag to say indicate limited edit requested
+ *
+ * @return void
+ * @access public
+ */
+ public function __construct($wpdb, $config, $limitedEdit = false)
+ {
+
+ // If this class is not being extended along with existing $wpdb and $config
+ if (!$this->wpdb) {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ }
+
+ /*
+ * Table Name
+ */
+ $this->table = GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'transactions';
+
+ /*
+ * Table Data Fields
+ */
+
+ $this->fields = array (
+
+ 'id' => array (
+ 'field' => 'id',
+ 'type' => 'integer',
+ 'view_only' => true,
+ 'use' => 'a',
+ ),
+
+ // Transaction Type
+ 'type' => array(
+ 'field' => 'type',
+ 'type' => 'text',
+ 'use' => 'a',
+ ),
+
+ // Id of Transaction Type
+ 'type_id' => array(
+ 'field' => 'type_id',
+ 'type' => 'text',
+ 'use' => 'a',
+ ),
+
+ // Account ref to accounts table
+ 'account' => array(
+ 'field' => 'account',
+ 'type' => 'pointer',
+ 'p_table' => GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
+ 'p_field' => 'ref_dest',
+ 'p_orderby' => 'ref_name',
+ 'p_blank' => true,
+ 'force_list' => false,
+ 'required' => false,
+ 'use' => 'a'
+ ),
+
+ // Transaction time
+ 'transaction_time' => array(
+ 'field' => 'transaction_time',
+ 'type' => 'datetime',
+ 'use' => 'a',
+ ),
+
+ // Current Invoice Total
+ 'current_invoice_total' => array(
+ 'field' => 'current_invoice_total',
+ 'type' => 'text',
+ 'use' => 'a',
+ ),
+
+ // Current Payment Total
+ 'current_payment_total' => array(
+ 'field' => 'current_payment_total',
+ 'type' => 'text',
+ 'use' => 'a',
+ ),
+ );
+
+
+ }
+
+ /*
+ * Entry Post Processing Call-Back Method
+ *
+ * Perform post-processing for all result entries.
+ *
+ * In this case we're using it to append an array of category
+ * data to each member result and also sort by member name.
+ *
+ * @param array $r Array of field result data for a single entry
+ * @param string $a Action being performed (l, i, g, ...)
+ *
+ * @return object Class object
+ *
+ */
+ public function entryPostProcessing($r, $a)
+ {
+ return $r;
+ }
+
+
+}
// $barCodeText = $account['account_number'] . '-3013';
$code39RECT = $this->code39($barCodeText, 1, 30, 0, -5);
$barcode = '';
+ $MAXcodeWidth = 0;
foreach ($code39RECT as $v) {
$barcode .= '<C:rect:'.implode(',', $v).'>';
// x position + width
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Transactions List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
+
+// Load Contacts data class
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataTransactions.php';
+
+class GlmMembersAdmin_billing_reports extends GlmDataTransactions
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+ /**
+ * Transactions ID
+ *
+ * @var $account_id
+ * @access public
+ */
+ public $account_id = false;
+
+ /**
+ * Constructor
+ *
+ * This constructor performs the work for this model. This model returns
+ * an array containing the following.
+ *
+ * 'status'
+ *
+ * True if successful and false if there was a fatal failure.
+ *
+ * 'view'
+ *
+ * A suggested view name that the controller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ * @wpdb object WordPress database object
+ *
+ * @return array Array containing status, suggested view, and any data
+ */
+ public function __construct ( $wpdb, $config )
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ /*
+ * Run constructor for the Contacts data class
+ *
+ * Note, the third parameter is a flag that indicates to the Contacts
+ * data class that it should flag a group of fields as 'view_only'.
+ */
+ parent::__construct( false, false, true );
+
+ }
+
+ public function modelAction($actionData = false)
+ {
+
+ $haveAccounts = false;
+ $option = 'list';
+ $view = 'reports';
+ $wParts = array( 'true' );
+ $paymentTypes = false;
+ $counties = false;
+ $accounts = false;
+ $paging = true;
+ $prevStart = false;
+ $nextStart = false;
+ $start = 1;
+ $limit = 20; // Set to the number of listings per page
+ $numbDisplayed = false;
+ $lastDisplayed = false;
+ $totalAccounts = false;
+ $option2 = false;
+
+ // Get any provided option
+ if ( isset( $_REQUEST['option'] ) ) {
+ $option = $_REQUEST['option'];
+ }
+
+ $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+ $Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
+
+ // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+
+ 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['submitType'] ) ) {
+
+ $option2 = filter_var( $_REQUEST['submitType'], FILTER_SANITIZE_STRING );
+
+ }
+
+ // Do selected option
+ switch ($option) {
+
+ case 'list':
+ default:
+ $view = 'reports';
+ break;
+
+ }
+
+ // $where used in all places.
+ $where = implode( ' AND ', $wParts );
+
+ // 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 ($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;
+ }
+
+ // 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,
+ 'counties' => $counties,
+ 'accounts' => $accounts,
+ 'paging' => $paging,
+ 'prevStart' => $prevStart,
+ 'nextStart' => $nextStart,
+ 'start' => $start = 1,
+ 'limit' => $limit,
+ 'haveAccounts' => $haveAccounts,
+ 'numbDisplayed' => $numbDisplayed,
+ 'lastDisplayed' => $lastDisplayed,
+ 'totalAccounts' => $totalAccounts,
+ );
+
+ // Return status, any suggested view, and any data to controller
+ return array(
+ 'status' => true,
+ 'modelRedirect' => false,
+ 'view' => "admin/billing/$view.html",
+ 'data' => $templateData
+ );
+
+ }
+
+}
'payments' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'accounts' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'invoicing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+ 'reports' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'logs' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'contact' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
),
<a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=payments" class="nav-tab{if $thisAction==payments} nav-tab-active{/if}">Payments</a>
<a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=accounts" class="nav-tab{if $thisAction==accounts} nav-tab-active{/if}">Accounts</a>
<a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=invoicing" class="nav-tab{if $thisAction==invoicing} nav-tab-active{/if}">Invoicing</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports" class="nav-tab{if $thisAction==reports} nav-tab-active{/if}">Reports</a>
<a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=logs" class="nav-tab{if $thisAction==logs} nav-tab-active{/if}">Logs</a>
</h2>
<div id="glm-admin-content-container">
</span>
<br>
<span class="glm-nowrap">
- <input type="checkbox" name="filterUnpaid"{if $smarty.request.filterUnpaid} checked{/if}>
+ <input type="checkbox" name="filterUnpaid"{if isset($smarty.request.filterUnpaid) && $smarty.request.filterUnpaid} checked{/if}>
<b>Show only Unpaid Invoices</b>
</span>
<br>
--- /dev/null
+{include file='admin/billing/header.html'}
+<h2>Invoicing</h2>
+{include file='admin/billing/reportsSubHeader.html'}
+<form id="reports-form" action="{$thisUrl}?page={$thisPage}" method="get">
+ <input type="hidden" name="page" value="{$thisPage}">
+ <input type="hidden" name="glm_action" value="reports">
+ <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 $option == 'reportGenerator'}
+ <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>
+ {/foreach}
+ </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'}
+ <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>
+ {/if}
+ <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>
+ <tr>
+ <th> Member Name </th>
+ <th> Account Number </th>
+ <th> Payment Type </th>
+ <th> Balance Due </th>
+ </tr>
+ </thead>
+ {foreach $accounts as $t}
+ <tr>
+ <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>
+ </tr>
+ {/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){
+ e.preventDefault();
+ var formData = $('#reports-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 = $('#reports-form select, input.labelOption').serialize();
+ console.log( 'Form Data:', 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'}
--- /dev/null
+<h2 class="nav-tab-wrapper">
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=openAccounts" class="nav-tab{if $option==openAccounts} nav-tab-active{/if}">Open Accounts</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=cloasedAccounts" class="nav-tab{if $option==cloasedAccounts} nav-tab-active{/if}">Closed Accounts</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=accountsByAge" class="nav-tab{if $option==accountsByAge} nav-tab-active{/if}">Accounts By Age</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=reportGenerator" class="nav-tab{if $option==reportGenerator} nav-tab-active{/if}">Report Generator</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=noAccounts" class="nav-tab{if $option==noAccounts} nav-tab-active{/if}">No Accounts</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-billing&glm_action=reports&option=allAccounts" class="nav-tab{if $option==allAccounts} nav-tab-active{/if}">All Accounts</a>
+</h2>
</div>
</div>
- {if $account.fieldData.payment_profile_card}
+ {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card}
<div class="glm-billing-field glm-billing-credit">
<div class="glm-billing-input">
<label>