Update from usntable branch.
[fa-stable.git] / reporting / rep209.php
index 9015a1b2564b35525de8bca02450a0f504e00788..b6b88a4572ee85b310b3493d5109b019c5594441 100644 (file)
@@ -9,7 +9,9 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$page_security = 2;
+
+$page_security = $_POST['PARAM_0'] == $_POST['PARAM_1'] ?
+       'SA_SUPPTRANSVIEW' : 'SA_SUPPBULKREP';
 // ----------------------------------------------------------------
 // $ Revision: 2.0 $
 // Creator:    Joe Hunt
@@ -60,9 +62,8 @@ function print_po()
        $from = $_POST['PARAM_0'];
        $to = $_POST['PARAM_1'];
        $currency = $_POST['PARAM_2'];
-       $bankaccount = $_POST['PARAM_3'];
-       $email = $_POST['PARAM_4'];
-       $comments = $_POST['PARAM_5'];
+       $email = $_POST['PARAM_3'];
+       $comments = $_POST['PARAM_4'];
 
        if ($from == null)
                $from = 0;
@@ -75,10 +76,8 @@ function print_po()
        // $headers in doctext.inc
        $aligns = array('left', 'left', 'left', 'right', 'left', 'right', 'right');
 
-       $params = array('comments' => $comments,
-                                       'bankaccount' => $bankaccount);
+       $params = array('comments' => $comments);
 
-       $baccount = get_bank_account($params['bankaccount']);
        $cur = get_company_Pref('curr_default');
 
        if ($email == 0)
@@ -92,6 +91,8 @@ function print_po()
        for ($i = $from; $i <= $to; $i++)
        {
                $myrow = get_po($i);
+               $baccount = get_default_bank_account($myrow['curr_code']);
+               $params['bankaccount'] = $baccount['id'];
 
                if ($email == 1)
                {