Updating create labels.
authorSteve Sutton <steve@gaslightmedia.com>
Sun, 12 May 2019 16:36:32 +0000 (12:36 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Sun, 12 May 2019 16:36:32 +0000 (12:36 -0400)
Labels should be grabbing the account data and creating labels even if
they don't have invoices.

lib/GlmPDFLabel.php
models/admin/ajax/createPDFLabels.php
models/admin/billing/invoicing.php
models/admin/management/importBillingData.php
models/admin/management/verifyBillingData.php
views/admin/dashboard/billing.html

index dd71e44..6197734 100644 (file)
@@ -45,20 +45,20 @@ class GlmPDFLabel extends Cezpdf
      *
      * Printing for Avery 5161 labels.
      *
-     * @param $invoices array Invoices is an array of billing invoices.
+     * @param $accounts array Accounts is an array of billing accounts.
      *
      * @return mixed
      */
-    public function createPdf( $invoices, $noContactNames = false )
+    public function createPdf( $accounts, $noContactNames = false )
     {
 
         $addresses = array();
 
-        if ( $invoices ) {
+        if ( $accounts && is_array( $accounts ) && !empty( $accounts ) ) {
             $columnCount = 0;
             $rowCount    = 0;
-            foreach ( $invoices as $invData ) {
-                $account = $invData['account'];
+            foreach ( $accounts as $account ) {
+                // $account = $invData['account'];
                 $columnCount++;
                 $colName = ( $columnCount % 2 == 0 ) ? 'col2' : 'col1';
                 $addressLine = '';
index fc00f47..15d8feb 100644 (file)
@@ -95,34 +95,49 @@ class GlmMembersAdmin_ajax_createPDFLabels
                   FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX  . "invoices
                  WHERE paid <> true ) ";
         } else {
-            $wParts[] = " T.id IN (
-                SELECT account
-                  FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX  . "invoices) ";
+            // $wParts[] = " T.id IN (
+            //     SELECT account
+            //       FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX  . "invoices) ";
         }
-        $wParts[] = " ( T.usmail_invoice OR T.fax_invoice ) ";
+        $wParts[] = " ( T.usmail_invoice = true OR T.fax_invoice = true ) ";
 
         // $where used in all places.
         $where = implode( ' AND ', $wParts );
+        // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
 
         // Get all invoices
-        $invoiceData = $this->wpdb->get_results(
-            "SELECT I.id
-               FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
-                    LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts T ON (T.id = I.account)
-              WHERE $where
-            ORDER BY T.ref_name",
-            ARRAY_A
-        );
+        // $invoiceData = $this->wpdb->get_results(
+        //     "SELECT I.id
+        //        FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoices I
+        //             LEFT OUTER JOIN " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts T ON (T.id = I.account)
+        //       WHERE $where
+        //     ORDER BY T.ref_name",
+        //     ARRAY_A
+        // );
         // echo '<pre>$invoiceData: ' . print_r( $invoiceData, true ) . '</pre>';
-        foreach ( $invoiceData as $inv ) {
-            $fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
-            if ( $fullInvoice ) {
-                $invoices[] = $fullInvoice;
-            }
-        }
+
+        // Need to get accounts not invoices
+        $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
+        $Accounts       = new GlmDataAccounts( $this->wpdb, $this->config );
+
+        $orderBy                = 'ref_name';
+        $Accounts->paymentTypes = true;
+        $Accounts->balanceDue   = true;
+        $accounts               = $Accounts->getList( $where, $orderBy );
+        $Accounts->paymentTypes = false;
+        $Accounts->balanceDue   = false;
+
+        // echo '<pre>$accounts: ' . print_r( $accounts, true ) . '</pre>';
+        // exit;
+        // foreach ( $invoiceData as $inv ) {
+        //     $fullInvoice = $BillingSupport->getFullInvoiceData( $inv['id'] );
+        //     if ( $fullInvoice ) {
+        //         $invoices[] = $fullInvoice;
+        //     }
+        // }
 
         $pdf = new GlmPDFLabel( $this->config, 'LETTER', 'portrait' );
-        $pdf->createPdf( $invoices, $noContactNames );
+        $pdf->createPdf( $accounts, $noContactNames );
 
         wp_die();
     }
index 0b9e619..154418e 100644 (file)
@@ -116,7 +116,7 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
         $Accounts       = new GlmDataAccounts( $this->wpdb, $this->config );
 
         // Not paid query
-        $notPaid = "( paid <> true OR paid IS NULL )";
+        $notPaid = "( paid <> true ) AND balance != 0.00";
 
         if ( isset( $_REQUEST['invoice_types'] ) ) {
             $invoiceTypes = $_REQUEST['invoice_types'];
@@ -270,7 +270,6 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
 
         $paymentTypes = $BillingSupport->getAllInvoiceTypes();
 
-
         if (isset($_REQUEST['pageSelect'])) {
             // If request is for Next
             if ($_REQUEST['pageSelect'][0] == 'N') {
@@ -285,13 +284,14 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
                 $start = $newStart;
             }
         }
-        $orderBy                = 'member_name';
+        $orderBy                = 'ref_name';
         $Accounts->paymentTypes = true;
         $Accounts->balanceDue   = true;
         $accountsResult         = $Accounts->getList( $where, $orderBy, true, 'id', $start, $limit );
         $totalAccounts          = $Accounts->getStats( $where );
         $Accounts->paymentTypes = false;
         $Accounts->balanceDue   = false;
+
         // Get paging results
         $numbDisplayed = $accountsResult['returned'];
         $lastDisplayed = $accountsResult['last'];
@@ -314,8 +314,6 @@ class GlmMembersAdmin_billing_invoicing //extends GlmDataAccounts
             $haveAccounts = true;
         }
 
-
-
         $templateData = array(
             'option'             => $option,
             'paymentTypes'       => $paymentTypes,
index b6f9dc0..5191399 100644 (file)
@@ -7,7 +7,7 @@ require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
 $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
 
 $limit = 10;
-$dbConn = 'pgsql: host=ds5 dbname=uptravel user=postgres';
+$dbConn = 'pgsql: host=ds5.gaslightmedia.com dbname=uptravel user=postgres';
 // $dbConn = 'pgsql: dbname=uptravel user=postgres';
 // Connect to their live database.
 $dbh = new PDO(
index a1c1ee8..82cbf1f 100644 (file)
@@ -6,7 +6,7 @@
 require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
 $BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
 // Connect to their live database.
-$dbConn = 'pgsql: host=ds5 dbname=uptravel user=postgres';
+$dbConn = 'pgsql: host=ds5.gaslightmedia.com dbname=uptravel user=postgres';
 // $dbConn = 'pgsql: dbname=uptravel user=postgres';
 $dbh = new PDO(
     $dbConn,
index cf2da4c..dc213c0 100644 (file)
@@ -4,8 +4,22 @@
         Billing Dashboard
         </h2>
         <div class="glm-widget-content">
-            Membership Status: {$account_status}
-            <a href="{$thisUrl}?page={$thisPage}&{$billing_link}">{$billing_label}</a>
+            {if $settings.member_types_enabled}
+                Membership Status: {$account_status}
+                <a href="{$thisUrl}?page={$thisPage}&{$billing_link}">{$billing_label}</a>
+            {else}
+            <ul>
+                <li>
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=account" class="">Billing Info</a>
+                </li>
+                <li>
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}" class="">All Statements</a>
+                </li>
+                <li>
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=billing&member={$memberID}&option=makepayment" class="">Pay Invoices</a>
+                </li>
+            </ul>
+            {/if}
 
         </div>
     </div>