* Plugin Name: GLM Members Billing
* Plugin URI: http://www.gaslightmedia.com/
* Description: This is glmAssociate Billing Module
- * Version: 1.0.26
+ * Version: 1.0.27
* Author: Gaslight Media
* Author URI: http://www.gaslightmedia.com/
* License: GPL2
* @package glmMembersBillingAddOn
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.0.26
+ * @version 1.0.27
*/
/*
* so that we're sure the other add-ons see an up to date
* version from this plugin.
*/
-define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.26');
+define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '1.0.27');
define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.26');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
$employees = $BillingSupport->getListOfAccountEmployees( $this->memberID );
+ if ( isset( $employees ) && !empty( $employees ) ) {
+ // Check if an employee was removed (deleted)
+ foreach ( $employees as $employee_id => $employee ) {
+ if ( !isset( $_REQUEST['employees'][$employee['employee']] ) ) {
+ $this->wpdb->delete(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'employees',
+ array( 'id' => $employee_id ),
+ array( '%d' )
+ );
+ }
+ // Remove the employee from the $employees array
+ unset( $employees[$employee_id] );
+ }
+ }
+ // If there's employees data then add them to this account
+ if ( isset($accountID) && $accountID && isset( $_REQUEST['employees'] ) && is_array( $_REQUEST['employees'] ) && !empty( $_REQUEST['employees'] ) ) {
+ $this->wpdb->update(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'accounts',
+ array( 'boss' => 1 ),
+ array( 'id' => $accountID ),
+ array( '%s' ),
+ array( '%d' )
+ );
+ foreach ( $_REQUEST['employees'] as $employee_id => $hasKey ) {
+ // Should check to see if there's one added with account and employee first
+ $emp_id = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "employees
+ WHERE account = %d
+ AND employee = %d",
+ $accountID,
+ $employee_id
+ )
+ );
+ if ( !$emp_id ) {
+ $this->wpdb->insert(
+ GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'employees',
+ array(
+ 'account' => $accountID,
+ 'employee' => $employee_id,
+ ),
+ array(
+ '%d',
+ '%d'
+ )
+ );
+ }
+ }
+ }
+ // Reset employees
+ $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID );
+
$invoice_data = array(
'account_id' => $accountID,
'renew_type_id' => filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ),
break;
case 'pay_by_check':
break;
+
+ case 'mark_paid':
+ $_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' );
+ $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] );
+ // Mark this invoice as paid
+ // Create new payment.
+ $payment_id = $BillingSupport->createPayment( $accountID, $_REQUEST['total_renew_amount'], 'Marked Paid' );
+
+ // Record the payment.
+ $BillingSupport->recordPayment( $payment_id, $accountID, $_REQUEST['total_renew_amount'], $invoices );
+
+ // Set the contact_role for the member contact so they can login now.
+ if ( $account_id ) {
+ $BillingSupport->setMemberAccountActive( $account_id );
+ }
+ // Set the contact_role (employees) for the member contact so they can login now.
+ if ( isset( $employees ) && is_array( $employees ) && !empty( $employees ) ) {
+ foreach ( $employees as $emp_account_id ) {
+ $BillingSupport->setMemberAccountActive( $emp_account_id );
+ }
+ }
+ break;
}
// If there's no error reported then show the invoice