Update the pdf to bring in the member address.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 21 Nov 2016 18:20:18 +0000 (13:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 21 Nov 2016 18:20:18 +0000 (13:20 -0500)
If member assigned to the coupon. Then output address in the pdf version
of the coupon.

models/admin/ajax/pdfCoupons.php
models/front/coupons/list.php
views/front/coupons/list.html

index 3f1334f..cc1e464 100644 (file)
@@ -73,6 +73,32 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons
 
         $coupons = $this->getList( $where );
 
+        if ( isset( $coupons ) && !empty( $coupons ) ) {
+            foreach ( $coupons as &$coupon ) {
+                $coupon['address'] = '';
+                include_once  GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
+                $address    = array();
+                $memberData = new GlmDataMemberInfo( $this->wpdb, $this->config );
+                $mInfo      = $memberData->getActiveInfoForMember( (int)$coupon['ref_dest_id'] );
+                if ( $mInfo['addr1'] ) {
+                    $address[] = $mInfo['addr1'];
+                }
+                if ( $mInfo['city'] ) {
+                    $address[] = $mInfo['city'];
+                }
+                if ( $mInfo['state'] ) {
+                    $address[] = $mInfo['state'];
+                }
+                if ( $mInfo['zip'] ) {
+                    $address[] = $mInfo['zip'];
+                }
+                $coupon['address'] = implode( ',', $address );
+            }
+        }
+
+        //echo '<pre>$coupons: ' . print_r( $coupons, true ) . '</pre>';
+        //exit;
+
         $pdf = new glmCoupon('a4', 'portrait');
         $pdf->selectFont(GLM_MEMBERS_COUPONS_PLUGIN_PATH . "/fonts/Helvetica.afm");
         $pdf->ezSetMargins(90, 30, 30, 35);
index b9b4b6b..279a5ad 100644 (file)
@@ -69,9 +69,13 @@ class GlmMembersFront_coupons_list extends GlmDataCoupons
                     foreach ( $coupon['categories'] as $category ) {
                         $categories[$category['name']][] = $coupon;
                     }
+                } else {
+                    $categories['1-category'][] = $coupon;
                 }
             }
         }
+        // sort them by category name
+        ksort( $categories );
 
 
         // Compile template data
index 0996735..24a4738 100644 (file)
@@ -6,7 +6,11 @@
         <input type="submit" value="Print Selected" name="printSel" class="button success glm_coupon_print">
         {if $categories}
         {foreach $categories as $catName => $coupons}
-                <h2>{$catName}</h2>
+            {if $catName != '1-category'}
+            <h2>{$catName}</h2>
+            {else}
+            <br style="clear:both;">
+            {/if}
                 <div class="coupon-row">
                 {if $coupons}
                     {foreach $coupons as $coupon}