From 74d962f7a82f2fd9543bf35faaa5026403b98cee Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Wed, 28 Sep 2011 21:19:25 +0200 Subject: [PATCH] Fixed range selection for bulk document printing to avoid unexpected blank page when from/to selectors are mistakenly swapped. --- reporting/rep107.php | 10 +++++----- reporting/rep110.php | 10 +++++----- reporting/rep112.php | 14 +++++++------- reporting/rep113.php | 10 +++++----- reporting/rep210.php | 10 +++++----- reporting/rep409.php | 10 ++++------ 6 files changed, 31 insertions(+), 33 deletions(-) diff --git a/reporting/rep107.php b/reporting/rep107.php index 99c58a51..620117f7 100644 --- a/reporting/rep107.php +++ b/reporting/rep107.php @@ -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; diff --git a/reporting/rep110.php b/reporting/rep110.php index ad19c6b1..cadfc522 100644 --- a/reporting/rep110.php +++ b/reporting/rep110.php @@ -44,14 +44,14 @@ function print_deliveries() $packing_slip = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; - 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); @@ -74,7 +74,7 @@ function print_deliveries() $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_CUSTDELIVERY, $i)) continue; diff --git a/reporting/rep112.php b/reporting/rep112.php index d2e06c09..f04ee1d7 100644 --- a/reporting/rep112.php +++ b/reporting/rep112.php @@ -71,14 +71,14 @@ function print_receipts() $currency = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; - 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, 85, 150, 225, 275, 360, 450, 515); @@ -95,10 +95,10 @@ function print_receipts() $rep->Font(); $rep->Info($params, $cols, null, $aligns); - for ($i = $fno[0]; $i <= $tno[0]; $i++) + for ($i = $from; $i <= $to; $i++) { - if ($fno[0] == $tno[0]) - $types = array($fno[1]); + if ($from == $to) + $types = array($from); else $types = array(ST_BANKDEPOSIT, ST_CUSTPAYMENT); foreach ($types as $j) diff --git a/reporting/rep113.php b/reporting/rep113.php index 8fb6fd02..916032b8 100644 --- a/reporting/rep113.php +++ b/reporting/rep113.php @@ -43,14 +43,14 @@ function print_credits() $paylink = $_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], $fto[0]); + $to = max($fno[0], $fto[0]); $cols = array(4, 60, 225, 300, 325, 385, 450, 515); @@ -70,7 +70,7 @@ function print_credits() $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_CUSTCREDIT, $i)) continue; diff --git a/reporting/rep210.php b/reporting/rep210.php index 072e8d90..1b80b72e 100644 --- a/reporting/rep210.php +++ b/reporting/rep210.php @@ -71,14 +71,14 @@ function print_remittances() $email = $_POST['PARAM_3']; $comments = $_POST['PARAM_4']; - 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, 85, 150, 225, 275, 360, 450, 515); @@ -98,7 +98,7 @@ function print_remittances() $rep->Info($params, $cols, null, $aligns); } - for ($i = $fno[0]; $i <= $tno[0]; $i++) + for ($i = $from; $i <= $to; $i++) { if ($fno[0] == $tno[0]) $types = array($fno[1]); diff --git a/reporting/rep409.php b/reporting/rep409.php index 2974d647..a4d41c70 100644 --- a/reporting/rep409.php +++ b/reporting/rep409.php @@ -37,14 +37,12 @@ function print_workorders() $email = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; - if ($from == null) - $from = 0; - if ($to == null) - $to = 0; - $dec = user_price_dec(); + if (!$from || !$to) return; $fno = explode("-", $from); $tno = explode("-", $to); + $from = min($fno[0], $tno[0]); + $to = max($fno[0], $tno[0]); $cols = array(4, 60, 190, 255, 320, 385, 450, 515); @@ -64,7 +62,7 @@ function print_workorders() $rep->Info($params, $cols, null, $aligns); } - for ($i = $fno[0]; $i <= $tno[0]; $i++) + for ($i = $from; $i <= $to; $i++) { $myrow = get_work_order($i); if ($myrow === false) -- 2.30.2