PHP 7.4 Bugs in some reports.
[fa-stable.git] / reporting / rep710.php
index 06485b2c2b20b828c103703bf93ab236763cad15..9db53e60b46324e6c7d9fea9705f3063f2392a88 100644 (file)
@@ -62,12 +62,14 @@ function print_audit_trail()
     $systype = $_POST['PARAM_2'];
     $user = $_POST['PARAM_3'];
     $comments = $_POST['PARAM_4'];
-       $destination = $_POST['PARAM_5'];
+       $orientation = $_POST['PARAM_5'];
+       $destination = $_POST['PARAM_6'];
        if ($destination)
                include_once($path_to_root . "/reporting/includes/excel_report.inc");
        else
                include_once($path_to_root . "/reporting/includes/pdf_report.inc");
 
+       $orientation = ($orientation ? 'L' : 'P');
     $dec = user_price_dec();
 
     $cols = array(0, 60, 120, 180, 240, 340, 400, 460, 520);
@@ -78,13 +80,15 @@ function print_audit_trail()
     $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right');
 
        $usr = get_user($user);
-       $user_id = $usr['user_id'];
+       $user_id = isset($usr['user_id']) ? $usr['user_id'] : "";
     $params =   array(         0 => $comments,
                                    1 => array('text' => _('Period'), 'from' => $from,'to' => $to),
                        2 => array('text' => _('Type'), 'from' => ($systype != -1 ? $systypes_array[$systype] : _('All')), 'to' => ''),
                        3 => array('text' => _('User'), 'from' => ($user != -1 ? $user_id : _('All')), 'to' => ''));
 
-    $rep = new FrontReport(_('Audit Trail'), "AuditTrail", user_pagesize());
+    $rep = new FrontReport(_('Audit Trail'), "AuditTrail", user_pagesize(), 9, $orientation);
+    if ($orientation == 'L')
+       recalculate_cols($cols);
 
     $rep->Font();
     $rep->Info($params, $cols, $headers, $aligns);
@@ -92,6 +96,7 @@ function print_audit_trail()
 
     $trans = getTransactions($from, $to, $systype, $user);
 
+       $tot_amount = 0;
     while ($myrow=db_fetch($trans))
     {
         $rep->TextCol(0, 1, sql2date(date("Y-m-d", $myrow['unix_stamp'])));
@@ -108,12 +113,19 @@ function print_audit_trail()
         else
                $action = _('Closed');
         $rep->TextCol(6, 7, $action);
-        if ($myrow['amount'] != null)
+        if ($myrow['amount'] != null) {
                $rep->AmountCol(7, 8, $myrow['amount'], $dec);
+                       if ($systype != -1)
+                               $tot_amount += $myrow['amount'];
+               }
         $rep->NewLine(1, 2);
     }
     $rep->Line($rep->row  + 4);
+       if ($systype != -1) {
+        $rep->NewLine(1, 2);
+        $rep->TextCol(6, 7, _('Total'));
+               $rep->AmountCol(7, 8, $tot_amount, $dec);
+       }
     $rep->End();
 }
 
-?>
\ No newline at end of file