Working on adding another table for the billing plugin.
Adding table to record the payment amounts that get applied to an invoice.
This way When I show the invoice I can show the payments made to that invoice.
* Record the Payment in the transaction table. Need to also go through the invoices
* and marked them as paid if amount is equal or greater than the invoice amount.
*
+ * Also need to record the payment to the invoice_payments
+ * table so we know which payment was applied to the invoice.
+ *
* @param mixed $invoice_id Id of the Invoice record
* @param mixed $payment Total amount of the Payment
-
+ *
* @access public
* @return void
*/
if ( $payment == $invoice['balance'] ) {
// Mark this as paid then
$this->updateInvoiceBalance( $invoice['id'], (float)0.00 );
+ // Record the payment to the invoice_payments table
+ $this->recordInvoicePayment( $invoice['id'], $payment_id, $invoice['balance'] );
// $payment is used up so break from the foreach loop
break;
} else if ( $payment > $invoice['balance'] ) {
$this->updateInvoiceBalance( $invoice['id'], (float)0.00 );
$payment -= $invoice['balance'];
+ // Record the payment to the invoice_payments table
+ $this->recordInvoicePayment( $invoice['id'], $payment_id, $invoice['balance'] );
} else if ( $invoice['balance'] > $payment ) {
// Update the balance of the invoice
$balance = (float)$balance - (float)$payment;
$this->updateInvoiceBalance( $invoice['id'], (float)$balance );
+ // Record the payment to the invoice_payments table
+ $this->recordInvoicePayment( $invoice['id'], $payment_id, (float)$payment );
// $payment is used up so break from the foreach loop
break;
}
);
}
+ /**
+ * recordInvoicePayment
+ *
+ * Record the payment to the invoice_payment table.
+ *
+ * @param mixed $invoice Invoice Id
+ * @param mixed $payment Payment Id
+ * @param mixed $amount Amount of payment
+ *
+ * @access public
+ * @return void
+ */
+ public function recordInvoicePayment( $invoice, $payment, $amount )
+ {
+ $this->wpdb->insert(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'invoice_payments',
+ array(
+ 'invoice' => $invoice,
+ 'payment' => $payment,
+ 'amount' => $amount,
+ 'transaction_time' => date('Y-m-d H:i;s'),
+ ),
+ array(
+ '%d',
+ '%d',
+ '%s',
+ '%s',
+ )
+ );
+ }
+
/**
* updateInvoiceBalance
*
+ * Update the balance amount for the invoice.
+ *
* @param mixed $invoice_id Id for the invoice
* @param mixed $balance New balance amount
*
public function updateInvoiceBalance( $invoice_id, $balance )
{
// if the balance is 0.00 then set paid to true
- $this->markInvoiceAsPaid( $invoice_id );
+ if ( $balance === 0.00 ) {
+ $this->markInvoiceAsPaid( $invoice_id );
+ }
$this->wpdb->update(
GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'invoices',
array( 'balance' => $balance ),
);
}
+ /**
+ * getInvoicePaymentsByInvoiceId
+ *
+ * Get all records from the invoice_payment table for an invoice.
+ *
+ * @param mixed $invoice Invoice Id.
+ *
+ * @access public
+ * @return void
+ */
+ public function getInvoicePaymentsByInvoiceId( $invoice )
+ {
+ return $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT *
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_payments
+ WHERE invoice = %d",
+ $invoice
+ ),
+ ARRAY_A
+ );
+ }
/**
* getBalanceDueByAccount
return $balance_due;
}
-
/**
* viewInvoice
*
// echo '<pre>$this->config: ' . print_r( $this->config, true ) . '</pre>';
$account = $this->getAccountById( $invoice['account'] );
// echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
+ $payments = $this->getInvoicePaymentsByInvoiceId( $invoice_id );
+ // echo '<pre>$payments: ' . print_r( $payments, true ) . '</pre>';
$templateData = array(
'settings' => $this->config['settings'],
'invoice' => $invoice,
'line_items' => $line_items,
'account' => $account,
+ 'payments' => $payments,
);
$invoiceHtml = $this->generateInvoiceHtml( $templateData, 'admin/billing/invoiceStore.html' );
return $invoiceHtml;
}
- public function getMemberInfo()
- {
-
- }
-
/**
* getLineItemsForInvoice
*
* version from this plugin.
*/
define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.5');
+define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.6');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
define('GLM_MEMBERS_BILLING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
break;
case 'view':
- // Now we have a total for the invoice we can record the transaction
+ // Call in the support class
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
$invoiceHtml = $BillingSupport->viewInvoice( $_REQUEST['id'] );
// echo '<pre>$account: ' . print_r( $account, true ) . '</pre>';
$view = 'editAccount';
+ break;
+ case 'view':
+ // Call in the support class
+ $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+
+ $invoiceHtml = $BillingSupport->viewInvoice( $_REQUEST['id'] );
+
+ // Set the file name for the view file.
+ $view = 'viewInvoice';
+
break;
case 'list':
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config);
'account_data' => $account_data,
'balance_due' => $balance_due,
'transaction_types' => $this->config['transaction_type'],
+ 'invoiceHtml' => $invoiceHtml,
);
// Return status, any suggested view, and any data to controller.
+++ /dev/null
--- Gaslight Media Billing Module
--- File Created: 11/08/2017
--- Database Version: 0.0.3
--- Database Creation Script
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
---
--- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
---
-
--- Billing Accounts
-CREATE TABLE {prefix}accounts (
- id INT NOT NULL AUTO_INCREMENT,
- ref_dest INT NOT NULL, -- reference to member id
- ref_name TINYTEXT NOT NULL, -- Name of reference member
- billing_addr1 TINYTEXT NULL, -- Billing Address 1
- billing_addr2 TINYTEXT NULL, -- Billing Address 2
- billing_city TINYTEXT NULL, -- Billing City
- billing_state TINYTEXT NULL, -- Billing State
- billing_zip TINYTEXT NULL, -- Billing Zip
- billing_phone TINYTEXT NULL, -- Billing Phone
- anniversary_date DATE NOT NULL, -- anniversary date - used for main invoice generation
- payment_data TEXT NULL, -- stored payment data
- email TINYTEXT NULL, -- billing email
- PRIMARY KEY (id)
-);
-
-----
-
--- transactions
-CREATE TABLE {prefix}transactions (
- id INT NOT NULL AUTO_INCREMENT,
- type INT NOT NULL, -- type of transaction (payment,invoice,etc)
- type_id INT NOT NULL, -- reference to type id
- account INT NOT NULL, -- reference to account id
- transaction_time DATETIME NOT NULL, -- datetime for the transaction
- current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total
- current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total
- PRIMARY KEY (id)
-);
-
-----
-
--- Invoices
-CREATE TABLE {prefix}invoices (
- id INT NOT NULL AUTO_INCREMENT,
- transaction_time DATETIME NOT NULL, -- datetime for the invoice
- account INT NOT NULL, -- ref to account id
- amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice
- balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice
- due_date DATE NOT NULL, -- Due date for this invoice
- paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid
- notes TINYTEXT, -- notes for this invoice
- recurring BOOLEAN DEFAULT '0', -- true/false if recurring
- recurrence INT NULL DEFAULT 0, -- recurrence type
- PRIMARY KEY (id)
-);
-
-----
-
--- Line Item Types
-CREATE TABLE {prefix}invoice_types (
- id INT NOT NULL AUTO_INCREMENT,
- name TINYTEXT NOT NULL, -- name
- parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent
- amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount
- recurring BOOLEAN DEFAULT '0', -- true/false if recurring
- recurrence INT NULL DEFAULT 0, -- recurrence type
- PRIMARY KEY (id)
-);
-
-----
-
--- Line Items
-CREATE TABLE {prefix}line_items (
- id INT NOT NULL AUTO_INCREMENT,
- invoice INT NOT NULL, -- reference to invoice
- line_item_type INT NOT NULL, -- reference to line item type
- name TEXT NOT NULL, -- line item name
- amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item
- quantity INT DEFAULT 1, -- quantity
- total DECIMAL(8,2) DEFAULT '0.00', -- line item total
- recurring BOOLEAN DEFAULT '0', -- true/false if recurring
- recurrence INT NULL DEFAULT 0, -- recurrence type
- PRIMARY KEY (id)
-);
-
-----
-
--- payments
-CREATE TABLE {prefix}payments (
- id INT NOT NULL AUTO_INCREMENT,
- transaction_time DATETIME NOT NULL, -- datetime of payment
- account INT NOT NULL, -- ref to account table
- amount DECIMAL(8, 2) NOT NULL, -- payment amount
- payment_method TINYTEXT NOT NULL, -- payment method
- payment_data TINYTEXT NULL, -- additional payment info
- PRIMARY KEY (id)
-);
-
-----
-
--- pdfs
-CREATE TABLE {prefix}pdfs (
- id INT NOT NULL AUTO_INCREMENT,
- ref_type INT NOT NULL, -- reference type
- ref_dest INT NOT NULL, -- reference types id
- pdf MEDIUMTEXT NOT NULL, -- saved pdf
- PRIMARY KEY (id)
-);
-
-----
-
--- Notification Types
-CREATE TABLE {prefix}notification_types (
- id INT NOT NULL AUTO_INCREMENT,
- name TINYTEXT NOT NULL, -- name
- from_header TINYTEXT NOT NULL, -- from headers
- replyto TINYTEXT NULL, -- reply-to headers
- subject TINYTEXT NOT NULL, -- Subject
- message TEXT NOT NULL, -- Message
- send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date
- send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action
- send_action INT NULL DEFAULT 0, -- (create invoice or receive payment)
- send_date_number INT NULL DEFAULT 0, -- number to apply to send by date
- send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years)
- send_date_when INT NULL DEFAULT 0, -- (before or after)
- PRIMARY KEY (id)
-);
-
-----
-
--- Notifications
-CREATE TABLE {prefix}notifications (
- id INT NOT NULL AUTO_INCREMENT,
- notification_type INT NOT NULL, -- ref to notification type
- account INT NOT NULL, -- ref to account
- from_replyto TINYTEXT NOT NULL, -- from reply-to header
- subject TEXT NOT NULL, -- subject
- message TEXT NOT NULL, -- message
- date_sent DATETIME NOT NULL, -- Date the notice was sent
- email_sent TINYTEXT NOT NULL, -- email used
- PRIMARY KEY (id)
-);
-
-----
-
--- Gateway Settings
-CREATE TABLE {prefix}gateway_settings (
- id INT NOT NULL AUTO_INCREMENT,
- name TEXT NOT NULL,
- login_id TINYTEXT NOT NULL,
- transaction_key TINYTEXT NOT NULL,
- PRIMARY KEY (id)
-);
-
-----
-
--- Settings
-CREATE TABLE {prefix}settings (
- id INT NOT NULL AUTO_INCREMENT,
- company_logo TINYTEXT NULL,
- company_logo_height INT NULL,
- company_name TINYTEXT NULL,
- company_name2 TINYTEXT NULL,
- company_addr1 TINYTEXT NULL,
- company_addr2 TINYTEXT NULL,
- company_city TINYTEXT NULL,
- company_state TINYTEXT NULL,
- company_zip TINYTEXT NULL,
- company_phone TINYTEXT NULL,
- company_email TINYTEXT NULL,
- company_url TINYTEXT NULL,
- PRIMARY KEY (id)
-);
-
-----
-
--- Set default billing Settings entry
-INSERT INTO {prefix}settings
- ( id )
- VALUES
- ( 1 );
-
-----
-
--- Management
-CREATE TABLE {prefix}management (
- id INT NOT NULL AUTO_INCREMENT,
- payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini
- proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini
- cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini
- -- Authorize.net Credentials
- authorize_net_login TINYTEXT NULL,
- authorize_net_key TINYTEXT NULL,
- authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini
- authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net
- authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail
- -- Merchant Solutions Credentials
- merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials
- merchant_solutions_merchantpin TINYTEXT NULL,
- merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini
- merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email
- merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail
- PRIMARY KEY (id)
-);
-
-----
-
--- Set default billing Management entry
-INSERT INTO {prefix}management
- ( id )
- VALUES
- ( 1 );
--- /dev/null
+-- Gaslight Media Billing Module
+-- File Created: 11/08/2017
+-- Database Version: 0.0.3
+-- Database Creation Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+--
+-- **** BE SURE TO ALSO UPDATE drop_database_Vxxx.sql FILE WHEN CHANGING TABLES ****
+--
+
+-- Billing Accounts
+CREATE TABLE {prefix}accounts (
+ id INT NOT NULL AUTO_INCREMENT,
+ ref_dest INT NOT NULL, -- reference to member id
+ ref_name TINYTEXT NOT NULL, -- Name of reference member
+ billing_addr1 TINYTEXT NULL, -- Billing Address 1
+ billing_addr2 TINYTEXT NULL, -- Billing Address 2
+ billing_city TINYTEXT NULL, -- Billing City
+ billing_state TINYTEXT NULL, -- Billing State
+ billing_zip TINYTEXT NULL, -- Billing Zip
+ billing_phone TINYTEXT NULL, -- Billing Phone
+ anniversary_date DATE NOT NULL, -- anniversary date - used for main invoice generation
+ payment_data TEXT NULL, -- stored payment data
+ email TINYTEXT NULL, -- billing email
+ PRIMARY KEY (id)
+);
+
+----
+
+-- transactions
+CREATE TABLE {prefix}transactions (
+ id INT NOT NULL AUTO_INCREMENT,
+ type INT NOT NULL, -- type of transaction (payment,invoice,etc)
+ type_id INT NOT NULL, -- reference to type id
+ account INT NOT NULL, -- reference to account id
+ transaction_time DATETIME NOT NULL, -- datetime for the transaction
+ current_invoice_total DECIMAL(8, 2) NOT NULL, -- invoice total
+ current_payment_total DECIMAL(8, 2) NOT NULL, -- payment total
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Invoices
+CREATE TABLE {prefix}invoices (
+ id INT NOT NULL AUTO_INCREMENT,
+ transaction_time DATETIME NOT NULL, -- datetime for the invoice
+ account INT NOT NULL, -- ref to account id
+ amount_total DECIMAL(8, 2) NOT NULL, -- total amount for invoice
+ balance DECIMAL(8, 2) NOT NULL, -- balance for this invoice
+ due_date DATE NOT NULL, -- Due date for this invoice
+ paid BOOLEAN DEFAULT '0', -- true/false if invoice is paid
+ notes TINYTEXT, -- notes for this invoice
+ recurring BOOLEAN DEFAULT '0', -- true/false if recurring
+ recurrence INT NULL DEFAULT 0, -- recurrence type
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Line Item Types
+CREATE TABLE {prefix}invoice_types (
+ id INT NOT NULL AUTO_INCREMENT,
+ name TINYTEXT NOT NULL, -- name
+ parent INT NOT NULL DEFAULT 0, -- 0 if top level otherwise ref to another line_item_type as it's parent
+ amount DECIMAL(8,2) NOT NULL DEFAULT '0.00', -- amount
+ recurring BOOLEAN DEFAULT '0', -- true/false if recurring
+ recurrence INT NULL DEFAULT 0, -- recurrence type
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Line Items
+CREATE TABLE {prefix}line_items (
+ id INT NOT NULL AUTO_INCREMENT,
+ invoice INT NOT NULL, -- reference to invoice
+ line_item_type INT NOT NULL, -- reference to line item type
+ name TEXT NOT NULL, -- line item name
+ amount DECIMAL(8,2) DEFAULT '0.00', -- line item amount per item
+ quantity INT DEFAULT 1, -- quantity
+ total DECIMAL(8,2) DEFAULT '0.00', -- line item total
+ recurring BOOLEAN DEFAULT '0', -- true/false if recurring
+ recurrence INT NULL DEFAULT 0, -- recurrence type
+ PRIMARY KEY (id)
+);
+
+----
+
+-- payments
+CREATE TABLE {prefix}payments (
+ id INT NOT NULL AUTO_INCREMENT,
+ transaction_time DATETIME NOT NULL, -- datetime of payment
+ account INT NOT NULL, -- ref to account table
+ amount DECIMAL(8, 2) NOT NULL, -- payment amount
+ payment_method TINYTEXT NOT NULL, -- payment method
+ payment_data TINYTEXT NULL, -- additional payment info
+ PRIMARY KEY (id)
+);
+
+----
+
+-- pdfs
+CREATE TABLE {prefix}pdfs (
+ id INT NOT NULL AUTO_INCREMENT,
+ ref_type INT NOT NULL, -- reference type
+ ref_dest INT NOT NULL, -- reference types id
+ pdf MEDIUMTEXT NOT NULL, -- saved pdf
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Notification Types
+CREATE TABLE {prefix}notification_types (
+ id INT NOT NULL AUTO_INCREMENT,
+ name TINYTEXT NOT NULL, -- name
+ from_header TINYTEXT NOT NULL, -- from headers
+ replyto TINYTEXT NULL, -- reply-to headers
+ subject TINYTEXT NOT NULL, -- Subject
+ message TEXT NOT NULL, -- Message
+ send_by_date BOOLEAN NULL DEFAULT '0', -- true/false send by date based on due date
+ send_by_action BOOLEAN NULL DEFAULT '0', -- send notice based on an action
+ send_action INT NULL DEFAULT 0, -- (create invoice or receive payment)
+ send_date_number INT NULL DEFAULT 0, -- number to apply to send by date
+ send_date_period INT NULL DEFAULT 0, -- (days,weeks,months,years)
+ send_date_when INT NULL DEFAULT 0, -- (before or after)
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Notifications
+CREATE TABLE {prefix}notifications (
+ id INT NOT NULL AUTO_INCREMENT,
+ notification_type INT NOT NULL, -- ref to notification type
+ account INT NOT NULL, -- ref to account
+ from_replyto TINYTEXT NOT NULL, -- from reply-to header
+ subject TEXT NOT NULL, -- subject
+ message TEXT NOT NULL, -- message
+ date_sent DATETIME NOT NULL, -- Date the notice was sent
+ email_sent TINYTEXT NOT NULL, -- email used
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Gateway Settings
+CREATE TABLE {prefix}gateway_settings (
+ id INT NOT NULL AUTO_INCREMENT,
+ name TEXT NOT NULL,
+ login_id TINYTEXT NOT NULL,
+ transaction_key TINYTEXT NOT NULL,
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Invoice Payments
+CREATE TABLE {prefix}invoice_payments (
+ id INT NOT NULL AUTO_INCREMENT,
+ invoice INT NOT NULL, -- reference to invoice id
+ payment INT NOT NULL, -- reference to payment id
+ amount DECIMAL(8, 2) NOT NULL, -- payment amount
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Settings
+CREATE TABLE {prefix}settings (
+ id INT NOT NULL AUTO_INCREMENT,
+ company_logo TINYTEXT NULL,
+ company_logo_height INT NULL,
+ company_name TINYTEXT NULL,
+ company_name2 TINYTEXT NULL,
+ company_addr1 TINYTEXT NULL,
+ company_addr2 TINYTEXT NULL,
+ company_city TINYTEXT NULL,
+ company_state TINYTEXT NULL,
+ company_zip TINYTEXT NULL,
+ company_phone TINYTEXT NULL,
+ company_email TINYTEXT NULL,
+ company_url TINYTEXT NULL,
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default billing Settings entry
+INSERT INTO {prefix}settings
+ ( id )
+ VALUES
+ ( 1 );
+
+----
+
+-- Management
+CREATE TABLE {prefix}management (
+ id INT NOT NULL AUTO_INCREMENT,
+ payment_methods SMALLINT NULL, -- Payment methods available for all registrations - Bitmap - see payment_method in plugin.ini
+ proc_methods SMALLINT NULL, -- Creadit Cart payment processing methods available - Bitmap - see proc_method in plugin.ini
+ cc_accepts SMALLINT NULL, -- Credit Cards Accepted - Bitmap - See credit_card in plugin.ini
+ -- Authorize.net Credentials
+ authorize_net_login TINYTEXT NULL,
+ authorize_net_key TINYTEXT NULL,
+ authorize_net_test TINYINT NULL, -- Authorize.net test mode - List - see proc_test_mode in plugin.ini
+ authorize_net_conf BOOLEAN NULL, -- Flag to send payment confirmation Email from Authorize.net
+ authorize_net_merchant_email TINYTEXT NULL, -- E-Mail Authorize.net will send copy of confirmation E-Mail
+ -- Merchant Solutions Credentials
+ merchant_solutions_acctid TINYTEXT NULL, -- Merchant Solutions credentials
+ merchant_solutions_merchantpin TINYTEXT NULL,
+ merchant_solutions_test TINYINT NULL, -- Merchant Solutions test mode - List - see proc_test_mode in plugin.ini
+ merchant_solutions_conf BOOLEAN NULL, -- Flag to send payment confirmation Email
+ merchant_solutions_merchant_email TINYTEXT NULL, -- Merchant Solutions will send copy of confirmation E-Mail
+ PRIMARY KEY (id)
+);
+
+----
+
+-- Set default billing Management entry
+INSERT INTO {prefix}management
+ ( id )
+ VALUES
+ ( 1 );
'0.0.3' => array('version' => '0.0.3', 'tables' => 12),
'0.0.4' => array('version' => '0.0.4', 'tables' => 12),
'0.0.5' => array('version' => '0.0.5', 'tables' => 12),
+ '0.0.6' => array('version' => '0.0.6', 'tables' => 13),
);
--- /dev/null
+-- Gaslight Media Billing Database
+-- File Created: 12/22/2017
+-- Database Version: 0.0.6
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- Invoice Payments
+CREATE TABLE {prefix}invoice_payments (
+ id INT NOT NULL AUTO_INCREMENT,
+ transaction_time DATETIME NOT NULL, -- datetime for the invoice
+ invoice INT NOT NULL, -- reference to invoice id
+ payment INT NOT NULL, -- reference to payment id
+ amount DECIMAL(8, 2) NOT NULL, -- payment amount
+ PRIMARY KEY (id)
+);
-<html>
- <head>
- <style>
- #container-table {
- /* border: solid lightgrey 1px; */
- font-size: 16px;
- }
- #container-table .line-items {
- border-collapse: collapse;
- }
- #container-table .line-items tr {
- /* border: solid green 1px; */
- }
- #container-table .line-items tr td {
- /* border: solid green 1px; */
- }
- @media print{
- @page {
- size: A4;
- margin: 0.5cm;
- }
- .wrap > h2 {
- display: none;
- }
- .nav-tab-wrapper, #adminmenu, #adminmenuback, #adminmenuwrap,
- .update-nag, .glm-copyright, #wpfooter
- {
- display: none;
- }
- body {
- background-color: none;
- }
- #glm-admin-content-container {
- margin: 0;
- border: 0 !important;
- background-color: none;
- }
- #container-table {
- width: 90%;
- page-break-after: avoid;
- page-break-inside: avoid;
- }
- #wpcontent, #wrap {
- margin: 0;
- page-break-after: avoid;
- page-break-inside: avoid;
- }
- }
- </style>
- </head>
- <body>
- <table id="container-table" width="600" cellspacing="0" cellpadding="0">
- <tr>
- <td>{if $settings.company_logo}<img src="{$glmPluginMediaUrl}/images/medium/{$settings.company_logo}">{/if}</td>
- <td width="160">
- <h1>INVOICE</h1>
- <!-- Invoice date/memberbilling# --></td>
- </tr>
- <tr>
- <td>
- <!-- Billing Invoice Settings -->
- <b>{$settings.company_name}</b></b><br>
- {if $settings.company_name2}{$settings.company_name2}<br>{/if}
- {if $settings.company_addr1}{$settings.company_addr1}<br>{/if}
- {if $settings.company_addr2}{$settings.company_addr2}<br>{/if}
- {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}<br>{/if}
- {if $settings.company_phone}{$settings.company_phone}<br>{/if}
- {if $settings.company_email}{$settings.company_email}<br>{/if}
- </td>
- <td width="150" valign="top">
- <table width="100%">
- <tr>
- <th align="right"> Date: </th>
- <td align="right"> {$invoice.transaction_time|date_format:"%D"} </td>
- </tr>
- <tr>
- <th align="right"> Account #: </th>
- <td align="right"> {$account.id} </td>
- </tr>
- <tr>
- <th align="right"> Invoice #: </th>
- <td align="right"> {$invoice.id} </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr><td colspan="2"></td></tr>
- <tr>
- <td colspan="2">
- <h4>Bill To:</h4>
- {if $account.billing_name2}{$account.billing_name2}<br>{/if}
- {if $account.billing_addr1}{$account.billing_addr1}<br>{/if}
- {if $account.billing_addr2}{$account.billing_addr2}<br>{/if}
- {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}<br>{/if}
- {if $account.billing_phone}{$account.billing_phone}<br>{/if}
+<style>
+#container-table {
+ /* border: solid lightgrey 1px; */
+ font-size: 16px;
+}
+#container-table .line-items {
+ border-collapse: collapse;
+}
+#container-table .line-items tr {
+ /* border: solid green 1px; */
+}
+#container-table .line-items tr td {
+ /* border: solid green 1px; */
+}
+@media print{
+ @page {
+ size: A4;
+ margin: 0.5cm;
+ }
+ .wrap > h2,.nav-tab-wrapper, #adminmenu, #adminmenuback, #adminmenuwrap,
+ .update-nag, .glm-copyright, #wpfooter, a.button.button-primary
+ {
+ display: none;
+ }
+ body {
+ background-color: none;
+ }
+ #glm-admin-content-container {
+ margin: 0;
+ border: 0 !important;
+ background-color: none;
+ }
+ #container-table {
+ width: 90%;
+ page-break-after: avoid;
+ page-break-inside: avoid;
+ }
+ #wpcontent, #wrap {
+ margin: 0;
+ page-break-after: avoid;
+ page-break-inside: avoid;
+ }
+}
+</style>
+<table id="container-table" width="600" cellspacing="0" cellpadding="0">
+ <tr>
+ <td>{if $settings.company_logo}<img src="{$glmPluginMediaUrl}/images/medium/{$settings.company_logo}">{/if}</td>
+ <td width="160" align="right">
+ <h1>INVOICE</h1>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <!-- Billing Invoice Settings -->
+ <b>{$settings.company_name}</b></b><br>
+ {if $settings.company_name2}{$settings.company_name2}<br>{/if}
+ {if $settings.company_addr1}{$settings.company_addr1}<br>{/if}
+ {if $settings.company_addr2}{$settings.company_addr2}<br>{/if}
+ {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}<br>{/if}
+ {if $settings.company_phone}{$settings.company_phone}<br>{/if}
+ {if $settings.company_email}{$settings.company_email}<br>{/if}
+ </td>
+ <td width="150" valign="top">
+ <table width="100%">
+ <tr>
+ <th align="right"> Date: </th>
+ <td align="right"> {$invoice.transaction_time|date_format:"%D"} </td>
+ </tr>
+ <tr>
+ <th align="right"> Account #: </th>
+ <td align="right"> {$account.id} </td>
+ </tr>
+ <tr>
+ <th align="right"> Invoice #: </th>
+ <td align="right"> {$invoice.id} </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr><td colspan="2"></td></tr>
+ <tr>
+ <td colspan="2">
+ <h4>Bill To:</h4>
+ {if $account.ref_name}{$account.ref_name}<br>{/if}
+ {if $account.billing_addr1}{$account.billing_addr1}<br>{/if}
+ {if $account.billing_addr2}{$account.billing_addr2}<br>{/if}
+ {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}<br>{/if}
+ {if $account.billing_phone}{$account.billing_phone}<br>{/if}
- <!-- Billing Settings -->
- </td>
- </tr>
- <tr><td colspan="2"> </td></tr>
- <tr>
- <td colspan="2">
- <table class="line-items" width="100%">
- <thead>
+ <!-- Billing Settings -->
+ </td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <td colspan="2">
+ <table class="line-items" width="100%">
+ <thead>
+ <tr>
+ <th align="left">Date</th>
+ <th align="left">Qty</th>
+ <th> </th>
+ <th align="left">Description</th>
+ <th align="right">Rate</th>
+ <th align="right">Amount</th>
+ </tr>
+ <tr>
+ <td colspan="6"><hr></td>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach $line_items as $item}
+ <tr>
+ <td align="left" width="70">{$invoice.transaction_time|date_format:"%D"}</td>
+ <td align="right" width="20">{$item.quantity}</td>
+ <td align="right" width="10"> </td>
+ <td align="left">{$item.name}</td>
+ <td align="right" width="60">${$item.amount|string_format:"%.2f"}</td>
+ <td align="right" width="60">${$item.total|string_format:"%.2f"}</td>
+ </tr>
+ {/foreach}
+ {foreach $payments as $payment}
+ <tr>
+ <td align="left" width="70">{$payment.transaction_time|date_format:"%D"}</td>
+ <td align="right" width="20"> </td>
+ <td align="right" width="10"> </td>
+ <td align="left">Payment</td>
+ <td align="right" width="60"> </td>
+ <td align="right" width="60">- ${$payment.amount|string_format:"%.2f"}</td>
+ </tr>
+ {/foreach}
+ <tr><td colspan="6"><hr></td></tr>
+ <tr>
+ <td colspan="5" align="right">Total Amount Due</td>
+ <td width="70" align="right">${$invoice.balance|string_format:"%.2f"}</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <th colspan="2" align="left">
+ Payment Terms:
+ </th>
+ </tr>
+ <tr><td colspan="2"><hr></td></tr>
+ <tr>
+ <td colspan="2">
+ Membership dues need to be paid by October 1st.
+ </td>
+ </tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <td colspan="2" align="center" style="font-size: 12px;">Please return Coupon Below with Payment</td>
+ </tr>
+ <tr><td colspan="2"><hr></td></tr>
+ <tr>
+ <td colspan="2">
+ <table width="100%">
+ <tr>
+ <td>
+ <span style="color:red">Make checks payable to:</span><br>
+ {$settings.company_name}<br>
+ {if $settings.company_name2}{$settings.company_name2}<br>{/if}
+ {if $settings.company_addr1}{$settings.company_addr1},{/if}
+ {if $settings.company_addr2}{$settings.company_addr2},{/if}
+ {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}<br>{/if}
+ {if $settings.company_phone}{$settings.company_phone} -{/if}
+ {if $settings.company_email}{$settings.company_email}<br>{/if}
+ <br><br>
+ {if $account.ref_name}{$account.ref_name}<br>{/if}
+ {if $account.billing_addr1}{$account.billing_addr1}<br>{/if}
+ {if $account.billing_addr2}{$account.billing_addr2}<br>{/if}
+ {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}<br>{/if}
+ {if $account.billing_phone}{$account.billing_phone}<br>{/if}
+ </td>
+ <td width="220" valign="top">
+ <table>
<tr>
- <th align="left">Date</th>
- <th align="left">Qty</th>
- <th> </th>
- <th align="left">Description</th>
- <th align="right">Rate</th>
- <th align="right">Amount</th>
+ <th align="right">Please Pay:</th>
+ <td align="right">${$invoice.balance|string_format:"%.2f"}</td>
</tr>
<tr>
- <td colspan="6"><hr></td>
+ <th align="right">Payment Amount:</th>
+ <td align="right"><input type="text" size="5"></td>
</tr>
- </thead>
- <tbody>
- {foreach $line_items as $item}
- <tr>
- <td align="left" width="70">{$invoice.transaction_time|date_format:"%D"}</td>
- <td align="right" width="20">{$item.quantity}</td>
- <td align="right" width="10"> </td>
- <td align="left">{$item.name}</td>
- <td align="right" width="60">${$item.amount|string_format:"%.2f"}</td>
- <td align="right" width="60">${$item.total|string_format:"%.2f"}</td>
- </tr>
- {/foreach}
- <tr><td colspan="6"><hr></td></tr>
<tr>
- <td colspan="5" align="right">Total Amount</td>
- <td width="70" align="right">${$invoice.balance|string_format:"%.2f"}</td>
+ <th align="right"> Account #: </th>
+ <td align="right"> {$account.id} </td>
</tr>
- </tbody>
- </table>
- </td>
- </tr>
- <tr><td colspan="2"> </td></tr>
- <tr>
- <th colspan="2" align="left">
- Payment Terms:
- </th>
- </tr>
- <tr><td colspan="2"><hr></td></tr>
- <tr>
- <td colspan="2">
- Membership dues need to be paid by October 1st.
- </td>
- </tr>
- <tr><td colspan="2"> </td></tr>
- <tr>
- <td colspan="2" align="center" style="font-size: 12px;">Please return Coupon Below with Payment</td>
- </tr>
- <tr><td colspan="2"><hr></td></tr>
- <tr>
- <td colspan="2">
- <table width="100%">
- <tr>
- <td>
- <span style="color:red">Make checks payable to:</span><br>
- {$settings.company_name}<br>
- {if $settings.company_name2}{$settings.company_name2}<br>{/if}
- {if $settings.company_addr1}{$settings.company_addr1},{/if}
- {if $settings.company_addr2}{$settings.company_addr2},{/if}
- {if $settings.company_city}{$settings.company_city} {$settings.company_state}, {$settings.company_zip}<br>{/if}
- {if $settings.company_phone}{$settings.company_phone} -{/if}
- {if $settings.company_email}{$settings.company_email}<br>{/if}
- <br><br>
- {if $account.billing_name2}{$account.billing_name2}<br>{/if}
- {if $account.billing_addr1}{$account.billing_addr1}<br>{/if}
- {if $account.billing_addr2}{$account.billing_addr2}<br>{/if}
- {if $account.billing_city}{$account.billing_city} {$account.billing_state}, {$account.billing_zip}<br>{/if}
- {if $account.billing_phone}{$account.billing_phone}<br>{/if}
- </td>
- <td width="220" valign="top">
- <table>
- <tr>
- <th align="right">Please Pay:</th>
- <td align="right">${$invoice.balance|string_format:"%.2f"}</td>
- </tr>
- <tr>
- <th align="right">Payment Amount:</th>
- <td align="right"><input type="text" size="5"></td>
- </tr>
- <tr>
- <th align="right"> Account #: </th>
- <td align="right"> {$account.id} </td>
- </tr>
- <tr>
- <th align="right"> Invoice #: </th>
- <td align="right"> {$invoice.id} </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
-</html>
+ <tr>
+ <th align="right"> Invoice #: </th>
+ <td align="right"> {$invoice.id} </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
<th>Due Date</th>
<th>Type</th>
<th>Amount</th>
+ <th> </th>
</tr>
</thead>
<tbody>
<td>{$transaction.transaction_data.due_date|date_format:"%D"}</td>
<td>{$transaction_types[$transaction.type]}</td>
<td>${$transaction.transaction_data.amount_total}</td>
+ <td> <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=view&member={$memberID}&id={$transaction.type_id}">View / Make Payment</a> </td>
{elseif $transaction.type == '20'}
<td>{$transaction.transaction_data.transaction_time|date_format:"%D"}</td>
<td></td>
<td>{$transaction_types[$transaction.type]}</td>
<td>${$transaction.transaction_data.amount}</td>
+ <td> </td>
{/if}
</tr>
{$alt = $alt + 1}
-{include file='admin/billing/header.html'}
-
-{include file='admin/billing/subHeader.html'}
+{if $fromMemberMenu}
+ {include file='admin/member/header.html'}
+ {include file='admin/billing/memberBillingSubHeader.html'}
+ <form action="" method="post">
+{else}
+ {include file='admin/billing/header.html'}
+ {include file='admin/billing/subHeader.html'}
+{/if}
{$invoiceHtml}
+{if $fromMemberMenu}
+ <a class="button button-primary" href="#">Make a Payment</a>
+ </form>
+{else}
+{/if}
{include file='admin/footer.html'}