From 3ae4fdfdc87a6a41f2f844562c739d55a7b3147c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 12 Dec 2018 16:53:26 -0500 Subject: [PATCH] Creating the report section Adding report section for uptravel --- classes/data/dataTransactions.php | 190 +++++++++++++++++ lib/GlmPDFInvoice.php | 1 + models/admin/billing/reports.php | 237 ++++++++++++++++++++++ setup/validActions.php | 1 + views/admin/billing/header.html | 1 + views/admin/billing/invoices.html | 2 +- views/admin/billing/reports.html | 124 +++++++++++ views/admin/billing/reportsSubHeader.html | 8 + views/common/billing/paymentForm.html | 2 +- 9 files changed, 564 insertions(+), 2 deletions(-) create mode 100644 classes/data/dataTransactions.php create mode 100644 models/admin/billing/reports.php create mode 100644 views/admin/billing/reports.html create mode 100644 views/admin/billing/reportsSubHeader.html diff --git a/classes/data/dataTransactions.php b/classes/data/dataTransactions.php new file mode 100644 index 0000000..ee89fe0 --- /dev/null +++ b/classes/data/dataTransactions.php @@ -0,0 +1,190 @@ + + * @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 + * @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; + } + + +} diff --git a/lib/GlmPDFInvoice.php b/lib/GlmPDFInvoice.php index e12fa2e..61f0949 100644 --- a/lib/GlmPDFInvoice.php +++ b/lib/GlmPDFInvoice.php @@ -280,6 +280,7 @@ class GlmPDFInvoice extends Cezpdf // $barCodeText = $account['account_number'] . '-3013'; $code39RECT = $this->code39($barCodeText, 1, 30, 0, -5); $barcode = ''; + $MAXcodeWidth = 0; foreach ($code39RECT as $v) { $barcode .= ''; // x position + width diff --git a/models/admin/billing/reports.php b/models/admin/billing/reports.php new file mode 100644 index 0000000..d208984 --- /dev/null +++ b/models/admin/billing/reports.php @@ -0,0 +1,237 @@ + + * @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 '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + + 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 '
$accounts: ' . print_r( $accounts, true ) . '
'; + 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 + ); + + } + +} diff --git a/setup/validActions.php b/setup/validActions.php index 783dcf9..6c8111a 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -90,6 +90,7 @@ $glmMembersBillingAddOnValidActions = array( '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, ), diff --git a/views/admin/billing/header.html b/views/admin/billing/header.html index f4ff6d7..a013938 100644 --- a/views/admin/billing/header.html +++ b/views/admin/billing/header.html @@ -6,6 +6,7 @@ Payments Accounts Invoicing + Reports Logs
diff --git a/views/admin/billing/invoices.html b/views/admin/billing/invoices.html index 07d8196..c5a139a 100644 --- a/views/admin/billing/invoices.html +++ b/views/admin/billing/invoices.html @@ -27,7 +27,7 @@
- + Show only Unpaid Invoices
diff --git a/views/admin/billing/reports.html b/views/admin/billing/reports.html new file mode 100644 index 0000000..5f38cea --- /dev/null +++ b/views/admin/billing/reports.html @@ -0,0 +1,124 @@ +{include file='admin/billing/header.html'} +

Invoicing

+{include file='admin/billing/reportsSubHeader.html'} +
+ + + + + + + {if $option == 'reportGenerator'} +
+ {if $paymentTypes} +
+
+ +
+ {/if} + {if $counties} +
+
+ +
+ {/if} + {if $option == 'createLabels'} +
+
+ + + +
+ {/if} +
+ + {if $option == 'createInvoices'} + + {elseif $option == 'printInvoices'} + + {elseif $option == 'createLabels'} + + {/if} +
+
+ {/if} +
+
+

Total found: {$totalAccounts}

+ {* Paging *} + {if $paging} + + + {/if} +
+
+ + + + + + + + + + {foreach $accounts as $t} + + + + + + + {/foreach} +
Member Name Account Number Payment Type Balance Due
+ + {$t.member_name} + + {$t.account_number} {$t.payment_type} {$t.balance_due|string_format:"%.2f"}
+
+ {* Paging *} + {if $paging} + + + {/if} +
+ +{include file='admin/footer.html'} diff --git a/views/admin/billing/reportsSubHeader.html b/views/admin/billing/reportsSubHeader.html new file mode 100644 index 0000000..2f743b5 --- /dev/null +++ b/views/admin/billing/reportsSubHeader.html @@ -0,0 +1,8 @@ + diff --git a/views/common/billing/paymentForm.html b/views/common/billing/paymentForm.html index fc8e8c0..e0e0d06 100644 --- a/views/common/billing/paymentForm.html +++ b/views/common/billing/paymentForm.html @@ -84,7 +84,7 @@
- {if $account.fieldData.payment_profile_card} + {if isset( $account.fieldData.payment_profile_card ) && $account.fieldData.payment_profile_card}