From 4ea1f6cd725e71a122aab168ee1646c8d050f4d2 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 9 Dec 2016 15:53:14 -0500 Subject: [PATCH] Fixing printing issue with coupons. Put the print coupon id's into the sql so we only get the ones they selected at first. --- models/admin/ajax/pdfCoupons.php | 55 +++++++++++---------------- views/front/coupons/memberDetail.html | 8 ++-- 2 files changed, 27 insertions(+), 36 deletions(-) diff --git a/models/admin/ajax/pdfCoupons.php b/models/admin/ajax/pdfCoupons.php index 71f1490..167c859 100644 --- a/models/admin/ajax/pdfCoupons.php +++ b/models/admin/ajax/pdfCoupons.php @@ -67,7 +67,7 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons */ public function modelAction( $actionData = false ) { - $coupons = $categories = array(); + $coupons = $categories = $printCoupons = array(); $where = "current_date BETWEEN T.start_date AND T.end_date AND T.status = 10"; @@ -75,6 +75,16 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons $where .= " AND T.ref_dest = " . $_REQUEST['member']; } + // check to see if Print selected is on + if (isset($_REQUEST['printSel']) && $_REQUEST['printSel']) { + $printAll = false; + foreach ($_REQUEST as $posted => $value) { + if (preg_match('%coupon-id-(\d+)%', $posted, $matches)) { + $printCoupons[] = $matches[1]; + } + } + $where .= " AND T.id in (" . implode( ',', $printCoupons) . ")"; + } $coupons = $this->getList( $where ); if ( isset( $coupons ) && !empty( $coupons ) ) { @@ -91,7 +101,7 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons $address[] = $mInfo['city']; } if ( $mInfo['state'] ) { - $address[] = $mInfo['state']; + $address[] = $mInfo['state']['name']; } if ( $mInfo['zip'] ) { $address[] = $mInfo['zip']; @@ -100,9 +110,6 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons } } - //echo '
$coupons: ' . print_r( $coupons, true ) . '
'; - //exit; - $pdf = new glmCoupon('a4', 'portrait'); $pdf->selectFont(GLM_MEMBERS_COUPONS_PLUGIN_PATH . "/fonts/Helvetica.afm"); $pdf->ezSetMargins(90, 30, 30, 35); @@ -116,41 +123,23 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons $pdf->closeObject(); $pdf->addObject($all, 'all'); $coupon_lft_opt = array( - 'left' => 5, - 'right' => 280, - 'justification'=>'left' + 'left' => 5, + 'right' => 280, + 'justification' =>'left' ); $coupon_rgt_opt = array( - 'left' => 290, - 'justification'=>'left' + 'left' => 290, + 'justification' =>'left' ); - // check to see if Print selected is on - $printIds = array(); - if (isset($_REQUEST['printSel']) && $_REQUEST['printSel']) { - $printAll = false; - foreach ($_REQUEST as $posted => $value) { - if (preg_match('%coupon-id-(\d+)%', $posted, $matches)) { - //echo '
' . print_r($matches, true) . '
'; - $printIds[$matches[1]] = $matches[1]; - } - } - } else { - $printAll = true; - } - $minY = $y // y is verticle position starting at lower left hand corner + $minY = $y // y is vertical position starting at lower left hand corner = 800; $x = 20; // x is horizontal position starting at lover left hand corner $coupon_width = 265; // $mycount = $count = 1; // $options = $coupon_lft_opt; - foreach ( $coupons as $coupon ) { - if ( !$printAll && !in_array( $coupon['id'], $printIds ) ) { - continue; - } else if ( !$printAll && in_array( $coupon['id'], $printIds ) ) { - unset( $printIds[$coupon['id']] ); - } + foreach ( $coupons as &$coupon ) { $reset = $y; $val = array(); $val['header'] = iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon['name']); @@ -212,13 +201,13 @@ class GlmMembersAdmin_ajax_pdfCoupons extends GlmDataCoupons } if ($y < 180 || ($mycount % 8 == 0)) { $pdf->ezNewPage(); - $y = 800; + $y = 800; $minY = $y; } } else { $minY = $y; - $y = $reset; - $x = 300; + $y = $reset; + $x = 300; } $count++; $mycount++; diff --git a/views/front/coupons/memberDetail.html b/views/front/coupons/memberDetail.html index 8ed9fba..b5ac829 100644 --- a/views/front/coupons/memberDetail.html +++ b/views/front/coupons/memberDetail.html @@ -1,9 +1,11 @@
Coupons
-
+
+ - - + + {if $categories} {foreach $categories as $catName => $coupons} {if $catName != '1-category'} -- 2.17.1