From: Steve Sutton Date: Thu, 7 Dec 2017 21:50:21 +0000 (-0500) Subject: WIP adding account form for member billing tab X-Git-Tag: v1.0.0^2~203 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=102043bb58f1a4625a840c6d17181d4f2a762554;p=WP-Plugins%2Fglm-member-db-billing.git WIP adding account form for member billing tab Working on getting the member billing tab with management of the account. If the member doesn't have an account it can add one. If there's one already there it updates it. --- diff --git a/classes/data/dataAccounts.php b/classes/data/dataAccounts.php index 41181cd..4ce220a 100644 --- a/classes/data/dataAccounts.php +++ b/classes/data/dataAccounts.php @@ -124,36 +124,41 @@ class GlmDataAccounts extends GlmDataAbstract 'p_orderby' => 'name', 'p_blank' => true, 'force_list' => true, - 'required' => false, + 'required' => true, 'use' => 'a' ), // Name of red_dest 'ref_name' => array( - 'field' => 'ref_name', - 'type' => 'text', - 'use' => 'a', + 'field' => 'ref_name', + 'type' => 'text', + 'use' => 'a', + 'required' => true, ), // Anniversary Date 'anniversary_date' => array( - 'field' => 'anniversary_date', - 'type' => 'date', - 'use' => 'a', + 'field' => 'anniversary_date', + 'type' => 'date', + 'use' => 'a', + 'default' => '', + 'required' => true, ), // Payment Data 'payment_data' => array( - 'field' => 'payment_data', - 'type' => 'text', - 'use' => 'a', + 'field' => 'payment_data', + 'type' => 'text', + 'use' => 'a', + 'required' => false, ), // Email 'email' => array( - 'field' => 'email', - 'type' => 'text', - 'use' => 'a', + 'field' => 'email', + 'type' => 'text', + 'use' => 'a', + 'required' => true, ), ); diff --git a/classes/data/dataInvoices.php b/classes/data/dataInvoices.php index a9a295f..e1ede13 100644 --- a/classes/data/dataInvoices.php +++ b/classes/data/dataInvoices.php @@ -208,12 +208,10 @@ class GlmDataInvoices extends GlmDataAbstract public function entryPostProcessing($r, $a) { $sql = " - SELECT M.name - FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members M, - " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I, - " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts A - WHERE A.ref_dest = M.id - AND I.account = A.id"; + SELECT A.ref_name + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I + LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts A + ON ( I.account = A.id )"; $r['member_name'] = $this->wpdb->get_var( $sql ); return $r; } diff --git a/index.php b/index.php index f6d22f2..7ac5744 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.1'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.2'); // 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'); diff --git a/models/admin/billing/index.php b/models/admin/billing/index.php index 7ffd2ba..047721b 100644 --- a/models/admin/billing/index.php +++ b/models/admin/billing/index.php @@ -36,10 +36,10 @@ class GlmMembersAdmin_billing_index // extends GlmDataBilling /** * Billing ID * - * @var $billingID + * @var $memberID * @access public */ - public $billingID = false; + public $memberID = false; /** * Constructor @@ -88,10 +88,24 @@ class GlmMembersAdmin_billing_index // extends GlmDataBilling public function modelAction($actionData = false) { // Initialize Variables Here - $numbPending = 0; - $namesList = false; - $haveCategories = false; - $numberPending = 0; + $numbPending = 0; + $namesList = false; + $haveCategories = false; + $numberPending = 0; + $fromMemberMenu = false; + $this->memberID = false; + $memberData = false; + $memberName = false; + $haveMember = false; + $haveAccount = false; + $option = 'list'; + $view = 'index'; + $account = false; + $accountID = 0; + $accountUpdated = false; + $accountUpdateError = false; + $accountAdded = false; + $accountInsertError = false; // For lockedToMember $lockedToMember = false; @@ -118,17 +132,114 @@ class GlmMembersAdmin_billing_index // extends GlmDataBilling $lockedWhere .= ' AND '; } + if ( defined( 'GLM_MEMBERS_BILLING_MEMBER_MENU' ) && GLM_MEMBERS_BILLING_MEMBER_MENU ) { + $fromMemberMenu = true; + + if ( isset( $_REQUEST['member'] ) ) { + $this->memberID = $_REQUEST['member']; + } + } + + require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMembers.php'; + $this->Members = new GlmDataMembers( $this->wpdb, $this->config ); + + if ( $this->memberID ) { + $memberData = $this->Members->getEntry( $this->memberID ); + } + + if ( isset( $memberData ) && is_array( $memberData ) && $memberData['id'] > 0 ) { + $haveMember = true; + $memberName = $memberData['name']; + } + + if ( isset( $_REQUEST['option'] ) ) { + $option = $_REQUEST['option']; + } + + switch ( $option ) { + case 'account': + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); + + // Check to see if we're adding an account or editing one. + if ( isset( $_REQUEST['ref_name'] ) ) { + $_REQUEST['anniversary_date'] = date('Y-m-d', strtotime($_REQUEST['anniversary_date'])); + // echo '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; + // if there's no id then add account + if ( !isset( $_REQUEST['id'] ) ) { + $account = $Accounts->insertEntry(); + if ( !$account['status'] ) { + $accountInsertError = true; + } else { + $accountAdded = true; + } + } else { + $account = $Accounts->updateEntry( $_REQUEST['id'] ); + if ( !$account['status'] ) { + $accountUpdateError = true; + } else { + $accountUpdated = true; + } + } + } + + // Need to see if there's an account for this member. + $accountID = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE ref_dest = %d", + $this->memberID + ) + ); + if ( !$account ) { + if ( $accountID ) { + $account = $Accounts->editEntry( $accountID ); + $haveAccount = true; + } else { + $accountID = 0; + $account = $Accounts->newEntry(); + // Set the ref_name from memberData + $account['fieldData']['ref_name'] = $memberData['name']; + $haveAccount = false; + } + } else { + $haveAccount = true; + // echo '
$account: ' . print_r( $account, true ) . '
'; + } + + // echo '
$account: ' . print_r( $account, true ) . '
'; + $view = 'editAccount'; + break; + case 'list': + break; + } + // Compile template data $templateData = array( - 'lockedToMember' => $lockedToMember, - 'numberPending' => $numberPending, + 'accountID' => $accountID, + 'option' => $option, + 'fromMemberMenu' => ( defined('GLM_MEMBERS_BILLING_MEMBER_MENU' ) ? true: false ), + 'lockedToMember' => $lockedToMember, + 'numberPending' => $numberPending, + 'memberID' => $this->memberID, + 'haveMember' => $haveMember, + 'haveAccount' => $haveAccount, + 'memberData' => $memberData, + 'memberName' => $memberName, + 'account' => $account, + 'accountUpdated' => $accountUpdated, + 'accountUpdateError' => $accountUpdateError, + 'accountAdded' => $accountAdded, + 'accountInsertError' => $accountInsertError, ); + // echo '
$templateData: ' . print_r( $templateData, true ) . '
'; // Return status, any suggested view, and any data to controller return array( 'status' => true, 'modelRedirect' => false, - 'view' => 'admin/billing/index.html', + 'view' => 'admin/billing/'.$view.'.html', 'data' => $templateData ); diff --git a/models/admin/billing/invoices.php b/models/admin/billing/invoices.php index dbe8b15..df78b8b 100644 --- a/models/admin/billing/invoices.php +++ b/models/admin/billing/invoices.php @@ -322,7 +322,7 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices } unset($invoicesResult); - // echo '
$invoices: ' . print_r( $invoices, true ) . '
'; + echo '
$invoices: ' . print_r( $invoices, true ) . '
'; foreach ( $invoices as $invoice ) { // $this->generateInvoiceTotal( $invoice['id'] ); diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php new file mode 100644 index 0000000..35752dc --- /dev/null +++ b/models/admin/member/billing.php @@ -0,0 +1,108 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release admin.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Inform the billing code that we're working from the member area +define('GLM_MEMBERS_BILLING_MEMBER_MENU', true); + +// Load the events index +require GLM_MEMBERS_BILLING_PLUGIN_PATH."/models/admin/billing/index.php"; + +class GlmMembersAdmin_member_billing extends GlmMembersAdmin_billing_index +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Billing List + * + * @var $billing + * @access public + */ + public $billing = false; + /** + * Contact Info + * + * @var $contactInfo + * @access public + */ + public $contactInfo = false; + /** + * Member ID + * + * @var $memberID + * @access public + */ + public $memberID = false; + /** + * Contact ID + * + * @var $contactID + * @access public + */ + public $contactID = false; + + + /* + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * 'view' + * + * A suggested view name that the contoller 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 members data class + parent::__construct($wpdb, $config); + + } + +} diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 99827b5..261a5cc 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -46,19 +46,7 @@ if ( current_user_can( 'glm_members_members' ) ) { return $addOnTabs; } ); - // add_filter( 'glm-member-db-add-tab-for-settings', - // function( $addOnTabs ) { - // $newTabs = array( - // array( - // 'text' => 'Payment Types', - // 'menu' => 'settings', - // 'action' => 'paymentTypes', - // ) - // ); - // $addOnTabs = array_merge( $addOnTabs, $newTabs ); - // return $addOnTabs; - // } - // ); + add_filter( 'glm-member-db-add-tab-for-billing', function( $addOnTabs ){ $newTabs = array( @@ -71,4 +59,19 @@ if ( current_user_can( 'glm_members_members' ) ) { ); } ); + + add_filter( + 'glm-member-db-add-tab-for-member', + function( $addOnTabs ){ + $newTabs = array( + array( + 'text' => 'Billing', + 'menu' => 'billing', + 'action' => 'billing' + ) + ); + $addOnTabs = array_merge( $addOnTabs, $newTabs ); + return $addOnTabs; + } + ); } diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql deleted file mode 100644 index 82a1761..0000000 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ /dev/null @@ -1,166 +0,0 @@ --- Gaslight Media Billing Module --- File Created: 11/08/2017 --- Database Version: 0.0.1 --- 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 - 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 - 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 - 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 - 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) -); - ----- - --- 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 ) -; diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql new file mode 100644 index 0000000..06d4a23 --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.2.sql @@ -0,0 +1,167 @@ +-- Gaslight Media Billing Module +-- File Created: 11/08/2017 +-- Database Version: 0.0.1 +-- 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 + 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 + 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 + 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 + invoice INT NOT NULL, -- ref to an invoice 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) +); + +---- + +-- 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 ) +; diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 1ab11c9..40efb5c 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -15,5 +15,6 @@ $glmMembersBillingDbVersions = array( '0.0.1' => array('version' => '0.0.1', 'tables' => 10), + '0.0.2' => array('version' => '0.0.2', 'tables' => 10), ); diff --git a/setup/databaseScripts/update_database_V0.0.1.sql b/setup/databaseScripts/update_database_V0.0.1.sql new file mode 100644 index 0000000..ed54969 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.1.sql @@ -0,0 +1,9 @@ +-- Gaslight Media Billing Database +-- File Created: 12/07/2017 +-- Database Version: 0.0.2 +-- +-- To permit each query below to be executed separately, +-- all queries must be separeted by a line with four dashes + +-- Add new field for payments table +ALTER TABLE {prefix}payments ADD invoice INT NOT NULL; -- ref to invoice table diff --git a/setup/validActions.php b/setup/validActions.php index 378389d..926a4ad 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -69,6 +69,9 @@ $glmMembersBillingAddOnValidActions = array( 'list' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, 'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, ), + 'member' => array( + 'billing' => GLM_MEMBERS_BILLING_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) diff --git a/views/admin/billing/editAccount.html b/views/admin/billing/editAccount.html new file mode 100644 index 0000000..770596f --- /dev/null +++ b/views/admin/billing/editAccount.html @@ -0,0 +1,69 @@ +{if $fromMemberMenu} + {include file='admin/member/header.html'} + {include file='admin/billing/memberBillingSubHeader.html'} +{else} + {include file='admin/billing/header.html'} +{/if} + +{if $accountUpdated}Account Updated{/if} +{if $accountUpdateError}Account Update Error{/if} +{if $accountInsertError}Account Insert Error{/if} +{if $accountAdded}Account Added{/if} + +
+ + + + + + + {if $accountID} + + {/if} + + + + + + + + + + + + + + + + + + + + + + + +
Name + + {if $account.fieldFail.ref_name}

{$account.fieldFail.ref_name}

{/if}
+
Anniversary Date + + {if $account.fieldFail.anniversary_date}

{$account.fieldFail.anniversary_date}

{/if}
+
Billing Email + + {if $account.fieldFail.email}

{$account.fieldFail.email}

{/if}
+
+ +
+
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/billing/index.html b/views/admin/billing/index.html index af2773d..0f74edc 100644 --- a/views/admin/billing/index.html +++ b/views/admin/billing/index.html @@ -1,4 +1,9 @@ -{include file='admin/billing/header.html'} +{if $fromMemberMenu} + {include file='admin/member/header.html'} + {include file='admin/billing/memberBillingSubHeader.html'} +{else} + {include file='admin/billing/header.html'} +{/if} diff --git a/views/admin/billing/memberBillingSubHeader.html b/views/admin/billing/memberBillingSubHeader.html new file mode 100644 index 0000000..851366b --- /dev/null +++ b/views/admin/billing/memberBillingSubHeader.html @@ -0,0 +1,6 @@ +