diff --git a/source/php/Summary.php b/source/php/Summary.php index 7c62aed..65040f9 100644 --- a/source/php/Summary.php +++ b/source/php/Summary.php @@ -100,14 +100,13 @@ public function emailSummary($email, $interval) if ($this->getCachedResult($interval) !== false) { $report = $this->getCachedResult($interval); } else { - $report = self::$resultCache[$interval] = $this->renderReport($from, $to, true); + [$rendered, $hasContent] = $this->renderReport($from, $to, true); + $report = self::$resultCache[$interval] = $rendered; } - + //Send non empty reports - if (!empty($report)) { - + if (!empty($report) && !empty($hasContent)) { $report = '' . $report . ''; - wp_mail( $email, __('Feedback summary', 'customer-feedback') . ' (' . get_option('blogname') . ')', @@ -116,7 +115,7 @@ public function emailSummary($email, $interval) 'Content-Type: text/html; charset=UTF-8', 'From: ' . get_option('admin_email') ) - ); + ); } } @@ -173,7 +172,7 @@ public function renderReport($from = null, $to = null, $return = false) } // Get data from dates - $data = $this->getDataBetween($from, $to); + [$data, $hasContent] = $this->getDataBetween($from, $to); // Get question $mainQuestion = __('Did the information on this page help you?', 'customer-feedback'); @@ -190,7 +189,7 @@ public function renderReport($from = null, $to = null, $return = false) if ($return) { ob_start(); include CUSTOMERFEEDBACK_TEMPLATE_PATH . '/summary-view.php'; - return ob_get_clean(); + return [ob_get_clean(), $hasContent]; } else { include CUSTOMERFEEDBACK_TEMPLATE_PATH . '/summary-view.php'; } @@ -258,7 +257,7 @@ public function getDataBetween($from = null, $to = null) 'pending' => $pending ); - return $data; + return [$data, (!empty($yesno) || !empty($yesnoPercent) || !empty($pending))]; } /**