Working on the process for renew member and their employees.
return $accounts;
}
+ public function createMemberInvoiceWithEmployees( $invoice_data )
+ {
+ // Make sure the required parts of $invoice_data exists.
+ if ( !isset( $invoice_data['account_id'] )
+ || !isset( $invoice_data['amount'] )
+ || !isset( $invoice_data['due_date'] )
+ || !isset( $invoice_data['member_invoice'] )
+ || !isset( $invoice_data['employee_data'] )
+ || !isset( $invoice_data['employees'] )
+ ) {
+ return false;
+ }
+ // Create invoice.
+ $this->wpdb->insert(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'invoices',
+ array(
+ 'transaction_time' => date( 'Y-m-d H:i:s' ),
+ 'account' => $account_id,
+ 'amount_total' => $amount,
+ 'balance' => $amount,
+ 'due_date' => $due_date,
+ 'paid' => 0,
+ 'notes' => '',
+ 'recurring' => true,
+ 'recurrence' => 20
+ ),
+ array(
+ '%s', // transaction_time
+ '%d', // account
+ '%s', // amount
+ '%s', // balance
+ '%s', // due_date
+ '%s', // paid
+ '%s', // notes
+ '%s', // recurring
+ '%s', // recurrence
+ )
+ );
+ $invoice_id = $this->wpdb->insert_id;
+ if ( $invoice_id ) {
+ // Add line items for each employee.
+ foreach ( $employees as $ref_dest ) {
+ // Get the account from the ref_dest.
+ $line_account_id = $this->getAccountByRefDest( $ref_dest );
+ $this->wpdb->insert(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'line_items',
+ array(
+ 'invoice' => $invoice_id,
+ 'line_item_type' => $line_item,
+ 'name' => $_REQUEST['line_item_name'][$line_item],
+ 'amount' => $_REQUEST['line_item_amount'][$line_item],
+ 'quantity' => $_REQUEST['line_item_qty'][$line_item],
+ 'total' => (float)$_REQUEST['line_item_qty'][$line_item] * (float)$_REQUEST['line_item_amount'][$line_item],
+ 'created' => date('Y-m-d'),
+ 'first_due_date' => $_REQUEST['due_date'],
+ 'next_due_date' => $_REQUEST['due_date'],
+ 'recurring' => $invoiceType['recurring']['value'],
+ 'recurrence' => $invoiceType['recurrence']
+ ),
+ array(
+ '%d', // invoice
+ '%d', // line_item_type (invoiceType id)
+ '%s', // name
+ '%s', // amount
+ '%d', // quantity
+ '%d', // total
+ '%s', // created
+ '%s', // first_due_date
+ '%s', // next_due_date
+ '%d', // recurring
+ '%d', // recurrence
+ )
+ );
+
+ }
+ }
+ }
+
}
$member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID );
if ( $member_invoice_id ) {
$member_invoice = $BillingSupport->getInvoicTypeById( $member_invoice_id );
- // echo '<pre>$member_invoice: ' . print_r( $member_invoice, true ) . '</pre>';
}
$employees = $BillingSupport->getListOfAccountEmployees( $this->memberID );
// Get a list of this accounts employees. If they have any.
break;
+
+ case 'renewMembership':
+ $view = 'renewMembership';
+ $messages[] = '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+
+ $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID );
+ if ( $member_invoice_id ) {
+ $member_invoice = $BillingSupport->getInvoicTypeById( $member_invoice_id );
+ }
+ $messages[] = '<pre>$member_invoice: ' . print_r( $member_invoice, true ) . '</pre>';
+
+ $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID );
+ $messages[] = '<pre>$employees: ' . print_r( $employees, true ) . '</pre>';
+
+ $invoice_data = array(
+ 'account_id' => filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT ),
+ 'amount' => filter_var( $_REQUEST['total_renew_amount'], FILTER_VALIDATE_STRING ),
+ 'due_date' => date( 'Y-m-d' ),
+ 'member_invoice' => $member_invoice,
+ 'employee_data' => $employees,
+ 'employees' => $_REQUEST['employees']
+ );
+
+ // Create the invoice for this member.
+
+
+ break;
+
case 'account':
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php';
$Accounts = new GlmDataAccounts( $this->wpdb, $this->config );
$view = 'editAccount';
break;
+
case 'view':
$invoiceHtml = $BillingSupport->viewInvoice( $_REQUEST['id'] );
$view = 'viewInvoice';
break;
+
case 'createPayment':
$view = 'paymentProcess';
}
break;
+
case 'makepayment':
// Load DataClass for accounts.
<form action="{$thisUrl}?page={$thisPage}&glm_action=billing&option=makePayment" method="post">
<input type="hidden" name="page" value="{$thisPage}" />
<input type="hidden" name="glm_action" value="billing" />
- <input type="hidden" name="option" value="createPayment" />
+ <input type="hidden" name="option" value="renewMembership" />
<input type="hidden" name="member" value="{$memberID}" />
- <input type="hidden" name="account_id" value="{$account.fieldData.id}" />
+ <input type="hidden" name="account_id" value="{$account_data.id}" />
<input type="hidden" id="total_renew_amount" name="total_renew_amount" value="" />
<h4>Employees:</h4>
--- /dev/null
+{include file='admin/member/header.html'}
+{include file='admin/billing/memberBillingSubHeader.html'}
+
+{foreach $messages as $message}
+{$message}<br>
+{/foreach}
+
+{include file='admin/footer.html'}