From 11d087d51963f36f5f07f1f74e45c560fd146525 Mon Sep 17 00:00:00 2001
From: ChangezKhan <mynameischangezkhan@gmail.com>
Date: Fri, 20 Jul 2018 20:30:36 +0530
Subject: [PATCH 1/4] Fixed #5856 - Multiple pages PDF from reports when Total
 of field is selected

---
 modules/AOR_Reports/AOR_Report.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/AOR_Reports/AOR_Report.php b/modules/AOR_Reports/AOR_Report.php
index f09efb8bb1..e9f9406a24 100755
--- a/modules/AOR_Reports/AOR_Report.php
+++ b/modules/AOR_Reports/AOR_Report.php
@@ -903,7 +903,7 @@ class AOR_Report extends Basic
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
 
         $showTotal = false;
-        $html = '';
+        $html = '<table>';
         $html .= "<thead class='fc-head'>";
         $html .= "<tr>";
         foreach ($fields as $label => $field) {
@@ -940,7 +940,7 @@ class AOR_Report extends Basic
             return '';
         }
 
-        $html .= "</body><tr class='oddListRowS1'>";
+        $html .= "<tbody><tr class='oddListRowS1'>";
         foreach ($fields as $label => $field) {
             if (!$field['display']) {
                 continue;
@@ -988,7 +988,7 @@ class AOR_Report extends Basic
             }
         }
         $html .= '</tr>';
-        $html .= '</body>';
+        $html .= '</tbody></table>';
 
         return $html;
     }

From e2d901d15f93dc6a2b484d2a712d6ba5d272f4dd Mon Sep 17 00:00:00 2001
From: ChangezKhan <mynameischangezkhan@gmail.com>
Date: Sat, 21 Jul 2018 22:11:23 +0530
Subject: [PATCH 2/4] Fixed #5856 - Multiple pages PDF from reports when Total
 of field is selected

---
 modules/AOR_Reports/AOR_Report.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/AOR_Reports/AOR_Report.php b/modules/AOR_Reports/AOR_Report.php
index e9f9406a24..fd46926941 100755
--- a/modules/AOR_Reports/AOR_Report.php
+++ b/modules/AOR_Reports/AOR_Report.php
@@ -903,7 +903,7 @@ class AOR_Report extends Basic
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
 
         $showTotal = false;
-        $html = '<table>';
+        $html = '</table><table>';
         $html .= "<thead class='fc-head'>";
         $html .= "<tr>";
         foreach ($fields as $label => $field) {
@@ -929,7 +929,7 @@ class AOR_Report extends Basic
             if ($fieldTotal) {
                 $showTotal = true;
                 $totalLabel = $field['label'] . ' ' . $appListStringsAorTotalOptionsFieldTotal;
-                $html .= "<th>{$totalLabel}</td>";
+                $html .= "<th>{$totalLabel}</th>";
             } else {
                 $html .= '<th></th>';
             }
@@ -988,7 +988,7 @@ class AOR_Report extends Basic
             }
         }
         $html .= '</tr>';
-        $html .= '</tbody></table>';
+        $html .= '</tbody>';
 
         return $html;
     }

From 85f6d6d71029888240f371187d0b95633a063616 Mon Sep 17 00:00:00 2001
From: ChangezKhan <mynameischangezkhan@gmail.com>
Date: Tue, 31 Jul 2018 18:56:49 +0530
Subject: [PATCH 3/4] Fixed #5856 - Multiple pages PDF from reports when Total
 of field is selected

---
 modules/AOR_Reports/AOR_Report.php | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/modules/AOR_Reports/AOR_Report.php b/modules/AOR_Reports/AOR_Report.php
index fd46926941..696dfe1ba3 100755
--- a/modules/AOR_Reports/AOR_Report.php
+++ b/modules/AOR_Reports/AOR_Report.php
@@ -815,11 +815,11 @@ class AOR_Report extends Basic
 
             $row_class = $row_class == 'oddListRowS1' ? 'evenListRowS1' : 'oddListRowS1';
         }
-        $html .= "</tbody>";
+        $html .= "</tbody></table>";
 
         $html .= $this->getTotalHTML($fields, $totals);
 
-        $html .= '</table></div>';
+        $html .= '</div>';
 
         $html .= "    <script type=\"text/javascript\">
                             groupedReportToggler = {
@@ -903,7 +903,7 @@ class AOR_Report extends Basic
         $currency->retrieve($GLOBALS['current_user']->getPreference('currency'));
 
         $showTotal = false;
-        $html = '</table><table>';
+        $html = '<table>';
         $html .= "<thead class='fc-head'>";
         $html .= "<tr>";
         foreach ($fields as $label => $field) {
@@ -988,7 +988,7 @@ class AOR_Report extends Basic
             }
         }
         $html .= '</tr>';
-        $html .= '</tbody>';
+        $html .= '</tbody></table>';
 
         return $html;
     }

From 827d1ba428fe3f965ad8808e38a6fc5626fbb24f Mon Sep 17 00:00:00 2001
From: ChangezKhan <mynameischangezkhan@gmail.com>
Date: Tue, 31 Jul 2018 19:22:00 +0530
Subject: [PATCH 4/4] Fixed #5856 - Multiple pages PDF from reports when Total
 of field is selected

---
 tests/unit/modules/AOR_Reports/AOR_ReportTest.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/unit/modules/AOR_Reports/AOR_ReportTest.php b/tests/unit/modules/AOR_Reports/AOR_ReportTest.php
index 9b16e1ba9e..d4f22af30a 100644
--- a/tests/unit/modules/AOR_Reports/AOR_ReportTest.php
+++ b/tests/unit/modules/AOR_Reports/AOR_ReportTest.php
@@ -264,7 +264,7 @@ class AOR_ReportTest extends SuiteCRM\StateCheckerPHPUnitTestCaseAbstract
         //execute the method with required data preset and verify it returns expected result
         $fields = array('label' => array('display' => 1, 'total' => 'SUM', 'label' => 'total'));
         $totals = array('label' => array(10, 20, 30));
-        $expected = "<thead class='fc-head'><tr><th>total Sum</td></tr></thead></body><tr class='oddListRowS1'><td>60</td></tr></body>";
+        $expected = "<table><thead class='fc-head'><tr><th>total Sum</th></tr></thead><tbody><tr class='oddListRowS1'><td>60</td></tr></tbody></table>";
 
         $aor_Report = new AOR_Report();
         $actual = $aor_Report->getTotalHTML($fields, $totals);