1177: Print single receipt fails
[fa-stable.git] / reporting / rep107.php
index e5a832cc44899ab46c3c2ac084ee636178aff766..620117f775f595b0dfe62d7acd9f1b6b4f3923ff 100644 (file)
@@ -43,14 +43,14 @@ function print_invoices()
        $pay_service = $_POST['PARAM_4'];
        $comments = $_POST['PARAM_5'];
 
-       if ($from == null)
-               $from = 0;
-       if ($to == null)
-               $to = 0;
+       if (!$from || !$to) return;
+
        $dec = user_price_dec();
 
        $fno = explode("-", $from);
        $tno = explode("-", $to);
+       $from = min($fno[0], $tno[0]);
+       $to = max($fno[0], $tno[0]);
 
        $cols = array(4, 60, 225, 300, 325, 385, 450, 515);
 
@@ -69,7 +69,7 @@ function print_invoices()
                $rep->Font();
                $rep->Info($params, $cols, null, $aligns);
        }
-       for ($i = $fno[0]; $i <= $tno[0]; $i++)
+       for ($i = $from; $i <= $to; $i++)
        {
                        if (!exists_customer_trans(ST_SALESINVOICE, $i))
                                continue;
@@ -202,7 +202,7 @@ function print_invoices()
                        $rep->Font();
                        if ($email == 1)
                        {
-                               $rep->End($email, '', $myrow, ST_SALESINVOICE);
+                               $rep->End($email);
                        }
        }
        if ($email == 0)