--- /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
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataInvoices.php';
+
+/**
+ * This class performs the work of handling images passed to it via
+ * an AJAX call that goes through the WorPress AJAX Handler.
+ *
+ */
+class GlmMembersAdmin_ajax_invoices extends GlmDataInvoices
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This constructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for data class
+ parent::__construct(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This model checks to see if the credentials passed in are correct.
+ *
+ * This model action does not return, it simply does it's work then calls die();
+ *
+ * @param $actionData
+ *
+ * Output JSON string as response and does not return
+ */
+ public function modelAction( $actionData = false )
+ {
+ $return = false;
+
+ $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING );
+ trigger_error( print_r( $_REQUEST, E_USER_NOTICE ) );
+
+ switch ( $option ) {
+ case 'list':
+ default:
+ $account = filter_var( $_REQUEST['account'], FILTER_VALIDATE_INT );
+ $invoices = $this->getList( "T.paid <> true AND T.account = $account" );
+ $return = array();
+ foreach ( $invoices as $invoice ) {
+ $return[] = array(
+ 'id' => $invoice['id'],
+ 'transaction_time' => $invoice['transaction_time'],
+ 'balance' => $invoice['balance'],
+ 'due_date' => $invoice['due_date']
+ );
+ }
+
+ break;
+ }
+
+ header( 'Content-type:application/json;charset=utf-8', true );
+ echo json_encode( $return, true );
+ exit();
+ }
+}
$view = 'editPayment';
// Need to get the accounts
$Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
- $accounts = $Accounts->getSimpleAccountList();
+
+ // Get only accounts that have invoices
+ $accounts = $Accounts->getSimpleAccountList(
+ "T.id IN ( SELECT DISTINCT account
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+ WHERE paid <> true )"
+ );
break;
case 'insert':
'setupQueue' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'runQueue' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'account' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
+ 'invoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'invoiceTypes' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'createNewInvoices' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
'accountsListExport' => GLM_MEMBERS_BILLING_PLUGIN_SLUG,
{
label: "{$m.ref_name|unescape:'html'|replace:'"':''}",
value: "{$m.ref_name|unescape:'html'|replace:'"':''}",
- id: '{$m.id}',
- anniversary: '{$m.next_anniversary_date}'
+ id: '{$m.id}'
},
{/foreach}
];
change: function( event, ui ) {
// If not in select option then empty the field
$(this).val((ui.item ? ui.item.label : ""));
- // Update the anniversary date
- $('#invoice_due_date').val( ui.item.anniversary );
},
});
// Setup autocomplete for the non member input.
availableAccountMembers.push( {
label: obj.name,
value: obj.name,
- id: obj.id,
- anniversary: obj.ann
+ id: obj.id
} );
}
// console.log( 'availableAccountMembers', availableAccountMembers );
data: {
name: customFieldName.val(),
amount: customFieldAmount.val(),
- parent: customFieldParent.val()
+ parent: customFieldParent.val(),
+ member_type: 0
},
encode: true,
dataType: 'json'
dateFormat: 'mm/dd/yy'
});
- /**
- * Change event listener for member account select.
- * When the member account is selected it should set the
- * invoice due_date to the current year based on the anniversary date.
- * Todo: Update this for the changes for adding in the autocomplete.
- */
- $('#member-account').change(function(){
- $('#invoice_due_date').val( $(this).find('option:selected').data('anniversary') );
- });
-
// Flash certain elements for a short time after display
$(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
{if $paymentInsertError}<span class="glm-notice glm-flash-updated">Notification Insert Error</span>{/if}
{if $paymentAdded}<span class="glm-notice glm-flash-updated">Notification Added</span>{/if}
-<div id="billing-payment-form">
+<div id="billing-payment-form" class="glm-billing-form">
<form action="{$thisUrl}?page={$thisPage}&glm_action=payments" method="post">
{if $payment_id}
<input type="hidden" name="option" value="update">
{else}
<input type="hidden" name="option" value="insert">
{/if}
- <div class="glm-row">
- <div class="glm-columns glm-small-12 glm-large-8">
-
- <div class="glm-row">
- <div class="glm-columns glm-small-12 glm-large-3 glm-required">
- Member Account
+ <div class="glm-billing-field">
+ <div class="glm-billing-label glm-required">
+ Lookup Member Invoices By Account
+ </div>
+ <div class="glm-billing-input">
+ <input id="member-account" name="account" type="hidden" name="filterAccounts" />
+ <input id="account_name" name="member_account" />
+ </div>
+ </div>
+ <div class="glm-billing-field">
+ <div class="glm-billing-label glm-required">
+ Select Invoices
</div>
- <div class="glm-columns glm-small-12 glm-large-9">
- <select name="account" required>
- <option value="">Select an Account</option>
- {foreach $accounts as $account}
- <option value="{$account.id}">{$account.ref_name}</option>
- {/foreach}
- </select>
+ <div class="glm-billing-input">
</div>
</div>
- <div class="glm-row">
- <div class="glm-columns glm-small-12 glm-large-3 glm-required">
+ <div class="glm-billing-field">
+ <div class="glm-billing-label glm-required">
Amount
</div>
- <div class="glm-columns glm-small-12 glm-large-9">
- <input type="text" name="amount" required>
+ <div class="glm-billing-input">
+ <div id="total_amount"></div>
+ <input type="text" id="total_payment_amount" type="hidden" name="amount" required>
</div>
</div>
- <div class="glm-row">
- <div class="glm-columns glm-small-12 glm-large-3">
+ <div class="glm-billing-field">
+ <div class="glm-billing-label glm-required">
Notes
</div>
- <div class="glm-columns glm-small-12 glm-large-9">
+ <div class="glm-billing-input">
<textarea name="notes"></textarea>
</div>
</div>
- </div>
- </div>
- <div class="glm-row">
- <div class="glm-columns glm-small-12 glm-large-8">
- <input class="button button-primary" type="submit" value="{if $payment_id}Save{else}Create{/if} Payment">
- </div>
- </div>
+ <input class="button button-primary" type="submit" value="{if $payment_id}Save{else}Create{/if} Payment">
</form>
</div>
<script>
jQuery(document).ready(function($){
+ var availableAccounts = [
+ {foreach $accounts as $m}
+ { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' },
+ {/foreach}
+ ]
+
+ // Setup autocomplete
+ $('#account_name').autocomplete({
+ source: availableAccounts,
+ select: function( event, ui ){
+ $('#member-account').val( ui.item.id );
+ $.ajax({
+ url: '{$ajaxUrl}',
+ cache: false,
+ data: {
+ action: 'glm_members_admin_ajax',
+ glm_action: 'invoices',
+ account: ui.item.id
+ },
+ success: function( results ) {
+ console.log( results );
+ },
+ });
+ },
+ change: function( event, ui) {
+ if( ui.item == null ) {
+ $('#member-account').val( '' );
+ }
+ },
+ });
+
// Flash certain elements for a short time after display
$(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);