<?php
+
include_once GLM_COUPON_PLUGIN_PATH_DIR . '/lib/class.pdf.php';
include_once GLM_COUPON_PLUGIN_PATH_DIR . '/lib/class.ezpdf.php';
class Creport extends Cezpdf
$mycount = $count = 1; //
$options = $coupon_lft_opt;
-//echo '<pre>' . print_r($coupons, true) . '</pre>';
-//exit;
-foreach ($coupons as $coupon) {
- if (!$printAll && !in_array($coupon->ID, $printIds)) {
- continue;
- }
- $reset = $y;
- $val = array();
- $val['header'] = iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->post_title);
- $val['description'] = iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->post_content);
- $header = ($coupon->glm_coupons_member) ? "<b>" . iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->glm_coupons_member) . "</b>\n" : '';
- $header .= "<b>".$val['header']."</b>\n";
- $descr = preg_replace(
- "/<br>|<br \/>/i",
- "\n",
- strip_tags(substr($val['description'], 0, 600))
- )."\n";
- $url = preg_replace('/http:\/\//i', '', $coupon->glm_coupons_url);
- $expire = '<b>Expires: '.date("n/j/Y", $coupon->glm_coupons_expdate).'</b>';
- if ($count == 2) {
- $reset = $y;
- $options = $coupon_rgt_opt;
- $header_options = $options;
- $header_options['justification'] = 'center';
- $img_align = 'right';
- } elseif ($count == 1) {
- $options = $coupon_lft_opt;
- $header_options = $options;
- $header_options['justification'] = 'center';
- $img_align = 'left';
- }
- $pdf->setLineStyle(1, '', '', array(5, 5, 5, 5));
- $pdf->setColor(0, 0, 0, 1);
- $pdf->setStrokeColor(0, 0, 0, 1);
- $pdf->line($x, $y, $x + $coupon_width , $y); // make line for the top of coupon
- $pdf->ezSetY($y);
- $y = $pdf->ezText("\n".$header, 12, $header_options);
- $y = $pdf->ezText($descr, 10, $options);
- if (isset($coupon->glm_coupons_address) && $coupon->glm_coupons_address) {
- $y = $pdf->ezText($coupon->glm_coupons_address, 9, $header_options);
- }
- if (isset($phone) && $phone) {
- $y = $pdf->ezText($phone, 9, $header_options);
- }
- if (isset($url) && $url) {
- $y = $pdf->ezText($url, 9, $header_options);
- }
- $y = $pdf->ezText("\n".$expire."\n", 9, $options);
- // bottom footer
- $pdf->saveState();
- $pdf->setLineStyle(1, null, null, array());
- $pdf->line($x, $y, $x + $coupon_width, $y); // make line for bottom
- $y = $pdf->ezText( "<b>" . get_bloginfo('name') . "</b> - <b>" . home_url() . "</b>\n", 8, $options );
- $pdf->restoreState();
- $pdf->line($x, $y, $x + $coupon_width, $y); // make line for bottom
- $pdf->line($x + $coupon_width, $reset, $x + $coupon_width, $y); // make right
- $pdf->line($x, $reset, $x, $y); // make left
- if ($count == 2 && $mycount != count($coupons)) {
- $x = 20;
- $count = 0;
- if ($minY <= $y) {
- $y = $minY - 5;
- } else {
- $y = $y - 5;
+foreach ( $categories as $catName => $coupons ) {
+ foreach ($coupons as $coupon) {
+ if (!$printAll && !in_array($coupon->ID, $printIds)) {
+ continue;
+ }
+ $reset = $y;
+ $val = array();
+ $val['header'] = iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->post_title);
+ $val['description'] = iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->post_content);
+ $header = ($coupon->glm_coupons_member) ? "<b>" . iconv('UTF-8', 'ISO-8859-1//IGNORE', $coupon->glm_coupons_member) . "</b>\n" : '';
+ $header .= "<b>".$val['header']."</b>\n";
+ $descr = preg_replace(
+ "/<br>|<br \/>/i",
+ "\n",
+ strip_tags(substr($val['description'], 0, 600))
+ )."\n";
+ $url = preg_replace('/http:\/\//i', '', $coupon->glm_coupons_url);
+ $expire = '<b>Expires: '.date("n/j/Y", $coupon->glm_coupons_expdate).'</b>';
+ if ($count == 2) {
+ $reset = $y;
+ $options = $coupon_rgt_opt;
+ $header_options = $options;
+ $header_options['justification'] = 'center';
+ $img_align = 'right';
+ } elseif ($count == 1) {
+ $options = $coupon_lft_opt;
+ $header_options = $options;
+ $header_options['justification'] = 'center';
+ $img_align = 'left';
+ }
+ $pdf->setLineStyle(1, '', '', array(5, 5, 5, 5));
+ $pdf->setColor(0, 0, 0, 1);
+ $pdf->setStrokeColor(0, 0, 0, 1);
+ $pdf->line($x, $y, $x + $coupon_width , $y); // make line for the top of coupon
+ $pdf->ezSetY($y);
+ $y = $pdf->ezText("\n".$header, 12, $header_options);
+ $y = $pdf->ezText($descr, 10, $options);
+ if (isset($coupon->glm_coupons_address) && $coupon->glm_coupons_address) {
+ $y = $pdf->ezText($coupon->glm_coupons_address, 9, $header_options);
}
- if ($y < 180 || ($mycount % 8 == 0)) {
- $pdf->ezNewPage();
- $y = 800;
+ if (isset($phone) && $phone) {
+ $y = $pdf->ezText($phone, 9, $header_options);
+ }
+ if (isset($url) && $url) {
+ $y = $pdf->ezText($url, 9, $header_options);
+ }
+ $y = $pdf->ezText("\n".$expire."\n", 9, $options);
+ // bottom footer
+ $pdf->saveState();
+ $pdf->setLineStyle(1, null, null, array());
+ $pdf->line($x, $y, $x + $coupon_width, $y); // make line for bottom
+ $y = $pdf->ezText( "<b>" . get_bloginfo('name') . "</b> - <b>" . home_url() . "</b>\n", 8, $options );
+ $pdf->restoreState();
+ $pdf->line($x, $y, $x + $coupon_width, $y); // make line for bottom
+ $pdf->line($x + $coupon_width, $reset, $x + $coupon_width, $y); // make right
+ $pdf->line($x, $reset, $x, $y); // make left
+ if ($count == 2 && $mycount != count($coupons)) {
+ $x = 20;
+ $count = 0;
+ if ($minY <= $y) {
+ $y = $minY - 5;
+ } else {
+ $y = $y - 5;
+ }
+ if ($y < 180 || ($mycount % 8 == 0)) {
+ $pdf->ezNewPage();
+ $y = 800;
+ $minY = $y;
+ }
+ } else {
$minY = $y;
+ $y = $reset;
+ $x = 300;
}
- } else {
- $minY = $y;
- $y = $reset;
- $x = 300;
+ $count++;
+ $mycount++;
}
- $count++;
- $mycount++;
}
$pdf->stream();
exit;