Correcting link for Dashboard to billing
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 15 May 2018 13:54:26 +0000 (09:54 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 15 May 2018 13:54:26 +0000 (09:54 -0400)
show pay invoice page if they have an invoice.

models/admin/dashboard/billing.php

index a3473e1..b7e8aa9 100644 (file)
@@ -128,8 +128,24 @@ class GlmMembersAdmin_dashboard_billing //extends GlmDataBilling
                 $billing_label = 'Billing Account Info';
                 break;
             case 'Pending':
-                $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew';
-                $billing_label = 'Renewal Membership';
+                // If they're pending check if they have an unpaid renewal invoice created.
+                $invoice_id = $this->wpdb->get_var(
+                    $this->wpdb->prepare(
+                        "SELECT id
+                           FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices
+                          WHERE account = %d
+                            AND paid <> true
+                            AND renewal = true",
+                        $accountID
+                    )
+                );
+                if ( $invoice_id ) {
+                    $billing_link = 'glm_action=billing&member=' . $memberID . '&option=makepayment';
+                    $billing_label = 'Pay Invoice';
+                } else {
+                    $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew';
+                    $billing_label = 'Renewal Membership';
+                }
                 break;
             case 'Expired':
                 $billing_link = 'glm_action=billing&member=' . $memberID . '&option=renew';