From: <Ex...@us...> - 2012-01-30 01:15:30
|
Revision: 4851 http://web-erp.svn.sourceforge.net/web-erp/?rev=4851&view=rev Author: ExsonQu Date: 2012-01-30 01:15:22 +0000 (Mon, 30 Jan 2012) Log Message: ----------- Fix for $_SESSION overwritten problem with $identifier variable and minor html modification Modified Paths: -------------- trunk/Payments.php Modified: trunk/Payments.php =================================================================== --- trunk/Payments.php 2012-01-29 09:42:44 UTC (rev 4850) +++ trunk/Payments.php 2012-01-30 01:15:22 UTC (rev 4851) @@ -16,15 +16,20 @@ include('includes/footer.inc'); exit(); } - +if (empty($_GET['identifier'])){ + /*unique session identifier to ensure that there is no conflict with other order enty session on the same machine */ + $identifier=date('U'); +}else{ + $identifier=$_GET['identifier'];//edit GLItems +} if (isset($_GET['NewPayment']) AND $_GET['NewPayment']=='Yes'){ - unset($_SESSION['PaymentDetail']->GLItems); - unset($_SESSION['PaymentDetail']); + unset($_SESSION['PaymentDetail' . $identifier]->GLItems); + unset($_SESSION['PaymentDetail' . $identifier]); } -if (!isset($_SESSION['PaymentDetail'])){ - $_SESSION['PaymentDetail'] = new Payment; - $_SESSION['PaymentDetail']->GLItemCounter = 1; +if (!isset($_SESSION['PaymentDetail' . $identifier])){ + $_SESSION['PaymentDetail' . $identifier] = new Payment; + $_SESSION['PaymentDetail' . $identifier]->GLItemCounter = 1; } if ((isset($_POST['UpdateHeader']) @@ -49,10 +54,10 @@ if (isset($_GET['SupplierID'])){ /*The page was called with a supplierID check it is valid and default the inputs for Supplier Name and currency of payment */ - unset($_SESSION['PaymentDetail']->GLItems); - unset($_SESSION['PaymentDetail']); - $_SESSION['PaymentDetail'] = new Payment; - $_SESSION['PaymentDetail']->GLItemCounter = 1; + unset($_SESSION['PaymentDetail' . $identifier]->GLItems); + unset($_SESSION['PaymentDetail' . $identifier]); + $_SESSION['PaymentDetail' . $identifier] = new Payment; + $_SESSION['PaymentDetail' . $identifier]->GLItemCounter = 1; $SQL= "SELECT suppname, @@ -75,16 +80,16 @@ } else { $myrow = DB_fetch_array($Result); if ($myrow['factorcompanyid'] == 0) { - $_SESSION['PaymentDetail']->SuppName = $myrow['suppname']; - $_SESSION['PaymentDetail']->Address1 = $myrow['address1']; - $_SESSION['PaymentDetail']->Address2 = $myrow['address2']; - $_SESSION['PaymentDetail']->Address3 = $myrow['address3']; - $_SESSION['PaymentDetail']->Address4 = $myrow['address4']; - $_SESSION['PaymentDetail']->Address5 = $myrow['address5']; - $_SESSION['PaymentDetail']->Address6 = $myrow['address6']; - $_SESSION['PaymentDetail']->SupplierID = $_GET['SupplierID']; - $_SESSION['PaymentDetail']->Currency = $myrow['currcode']; - $_POST['Currency'] = $_SESSION['PaymentDetail']->Currency; + $_SESSION['PaymentDetail' . $identifier]->SuppName = $myrow['suppname']; + $_SESSION['PaymentDetail' . $identifier]->Address1 = $myrow['address1']; + $_SESSION['PaymentDetail' . $identifier]->Address2 = $myrow['address2']; + $_SESSION['PaymentDetail' . $identifier]->Address3 = $myrow['address3']; + $_SESSION['PaymentDetail' . $identifier]->Address4 = $myrow['address4']; + $_SESSION['PaymentDetail' . $identifier]->Address5 = $myrow['address5']; + $_SESSION['PaymentDetail' . $identifier]->Address6 = $myrow['address6']; + $_SESSION['PaymentDetail' . $identifier]->SupplierID = $_GET['SupplierID']; + $_SESSION['PaymentDetail' . $identifier]->Currency = $myrow['currcode']; + $_POST['Currency'] = $_SESSION['PaymentDetail' . $identifier]->Currency; } else { $factorsql= "SELECT coyname, @@ -99,23 +104,23 @@ $FactorResult = DB_query($factorsql, $db); $myfactorrow = DB_fetch_array($FactorResult); - $_SESSION['PaymentDetail']->SuppName = $myrow['suppname'] . ' ' . _('care of') . ' ' . $myfactorrow['coyname']; - $_SESSION['PaymentDetail']->Address1 = $myfactorrow['address1']; - $_SESSION['PaymentDetail']->Address2 = $myfactorrow['address2']; - $_SESSION['PaymentDetail']->Address3 = $myfactorrow['address3']; - $_SESSION['PaymentDetail']->Address4 = $myfactorrow['address4']; - $_SESSION['PaymentDetail']->Address5 = $myfactorrow['address5']; - $_SESSION['PaymentDetail']->Address6 = $myfactorrow['address6']; - $_SESSION['PaymentDetail']->SupplierID = $_GET['SupplierID']; - $_SESSION['PaymentDetail']->Currency = $myrow['currcode']; - $_POST['Currency'] = $_SESSION['PaymentDetail']->Currency; + $_SESSION['PaymentDetail' . $identifier]->SuppName = $myrow['suppname'] . ' ' . _('care of') . ' ' . $myfactorrow['coyname']; + $_SESSION['PaymentDetail' . $identifier]->Address1 = $myfactorrow['address1']; + $_SESSION['PaymentDetail' . $identifier]->Address2 = $myfactorrow['address2']; + $_SESSION['PaymentDetail' . $identifier]->Address3 = $myfactorrow['address3']; + $_SESSION['PaymentDetail' . $identifier]->Address4 = $myfactorrow['address4']; + $_SESSION['PaymentDetail' . $identifier]->Address5 = $myfactorrow['address5']; + $_SESSION['PaymentDetail' . $identifier]->Address6 = $myfactorrow['address6']; + $_SESSION['PaymentDetail' . $identifier]->SupplierID = $_GET['SupplierID']; + $_SESSION['PaymentDetail' . $identifier]->Currency = $myrow['currcode']; + $_POST['Currency'] = $_SESSION['PaymentDetail' . $identifier]->Currency; } } } if (isset($_POST['BankAccount']) AND $_POST['BankAccount']!=''){ - $_SESSION['PaymentDetail']->Account=$_POST['BankAccount']; + $_SESSION['PaymentDetail' . $identifier]->Account=$_POST['BankAccount']; /*Get the bank account currency and set that too */ $ErrMsg = _('Could not get the currency of the bank account'); $result = DB_query("SELECT currcode, @@ -127,41 +132,41 @@ $ErrMsg); $myrow = DB_fetch_array($result); - $_SESSION['PaymentDetail']->AccountCurrency=$myrow['currcode']; - $_SESSION['PaymentDetail']->CurrDecimalPlaces=$myrow['decimalplaces']; + $_SESSION['PaymentDetail' . $identifier]->AccountCurrency=$myrow['currcode']; + $_SESSION['PaymentDetail' . $identifier]->CurrDecimalPlaces=$myrow['decimalplaces']; } else { - $_SESSION['PaymentDetail']->AccountCurrency =$_SESSION['CompanyRecord']['currencydefault']; - $_SESSION['PaymentDetail']->CurrDecimalPlaces=$_SESSION['CompanyRecord']['decimalplaces']; + $_SESSION['PaymentDetail' . $identifier]->AccountCurrency =$_SESSION['CompanyRecord']['currencydefault']; + $_SESSION['PaymentDetail' . $identifier]->CurrDecimalPlaces=$_SESSION['CompanyRecord']['decimalplaces']; } if (isset($_POST['DatePaid']) AND $_POST['DatePaid']!='' AND Is_Date($_POST['DatePaid'])){ - $_SESSION['PaymentDetail']->DatePaid=$_POST['DatePaid']; + $_SESSION['PaymentDetail' . $identifier]->DatePaid=$_POST['DatePaid']; } if (isset($_POST['ExRate']) AND $_POST['ExRate']!=''){ - $_SESSION['PaymentDetail']->ExRate=filter_number_format($_POST['ExRate']); //ex rate between payment currency and account currency + $_SESSION['PaymentDetail' . $identifier]->ExRate=filter_number_format($_POST['ExRate']); //ex rate between payment currency and account currency } if (isset($_POST['FunctionalExRate']) AND $_POST['FunctionalExRate']!=''){ - $_SESSION['PaymentDetail']->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); //ex rate between payment currency and account currency + $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); //ex rate between payment currency and account currency } if (isset($_POST['Paymenttype']) AND $_POST['Paymenttype']!=''){ - $_SESSION['PaymentDetail']->Paymenttype = $_POST['Paymenttype']; + $_SESSION['PaymentDetail' . $identifier]->Paymenttype = $_POST['Paymenttype']; } if (isset($_POST['Currency']) AND $_POST['Currency']!=''){ - $_SESSION['PaymentDetail']->Currency=$_POST['Currency']; //payment currency + $_SESSION['PaymentDetail' . $identifier]->Currency=$_POST['Currency']; //payment currency /*Get the exchange rate between the functional currency and the payment currency*/ - $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency . "'",$db); + $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail' . $identifier]->Currency . "'",$db); $myrow = DB_fetch_row($result); $tableExRate = $myrow[0]; //this is the rate of exchange between the functional currency and the payment currency - if ($_POST['Currency']==$_SESSION['PaymentDetail']->AccountCurrency){ + if ($_POST['Currency']==$_SESSION['PaymentDetail' . $identifier]->AccountCurrency){ $_POST['ExRate']=1; - $_SESSION['PaymentDetail']->ExRate=filter_number_format($_POST['ExRate']); //ex rate between payment currency and account currency + $_SESSION['PaymentDetail' . $identifier]->ExRate=filter_number_format($_POST['ExRate']); //ex rate between payment currency and account currency $SuggestedExRate=1; } - if ($_SESSION['PaymentDetail']->AccountCurrency==$_SESSION['CompanyRecord']['currencydefault']){ + if ($_SESSION['PaymentDetail' . $identifier]->AccountCurrency==$_SESSION['CompanyRecord']['currencydefault']){ $_POST['FunctionalExRate']=1; - $_SESSION['PaymentDetail']->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); + $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate=filter_number_format($_POST['FunctionalExRate']); $SuggestedExRate = $tableExRate; $SuggestedFunctionalExRate =1; @@ -176,12 +181,12 @@ */ /*Get suggested FunctionalExRate */ - $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->AccountCurrency . "'",$db); + $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail' . $identifier]->AccountCurrency . "'",$db); $myrow = DB_fetch_row($result); $SuggestedFunctionalExRate = $myrow[0]; /*Get the exchange rate between the functional currency and the payment currency*/ - $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency . "'",$db); + $result = DB_query("SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail' . $identifier]->Currency . "'",$db); $myrow = DB_fetch_row($result); $tableExRate = $myrow[0]; //this is the rate of exchange between the functional currency and the payment currency /*Calculate cross rate to suggest appropriate exchange rate between payment currency and account currency */ @@ -192,20 +197,20 @@ if (isset($_POST['Narrative']) AND $_POST['Narrative']!=''){ - $_SESSION['PaymentDetail']->Narrative=$_POST['Narrative']; + $_SESSION['PaymentDetail' . $identifier]->Narrative=$_POST['Narrative']; } if (isset($_POST['Amount']) AND $_POST['Amount']!=''){ - $_SESSION['PaymentDetail']->Amount=filter_number_format($_POST['Amount']); + $_SESSION['PaymentDetail' . $identifier]->Amount=filter_number_format($_POST['Amount']); } else { - if (!isset($_SESSION['PaymentDetail']->Amount)) { - $_SESSION['PaymentDetail']->Amount=0; + if (!isset($_SESSION['PaymentDetail' . $identifier]->Amount)) { + $_SESSION['PaymentDetail' . $identifier]->Amount=0; } } if (isset($_POST['Discount']) AND $_POST['Discount']!=''){ - $_SESSION['PaymentDetail']->Discount=filter_number_format($_POST['Discount']); + $_SESSION['PaymentDetail' . $identifier]->Discount=filter_number_format($_POST['Discount']); } else { - if (!isset($_SESSION['PaymentDetail']->Discount)) { - $_SESSION['PaymentDetail']->Discount=0; + if (!isset($_SESSION['PaymentDetail' . $identifier]->Discount)) { + $_SESSION['PaymentDetail' . $identifier]->Discount=0; } } @@ -227,12 +232,12 @@ /*First off check we have an amount entered as paid ?? */ $TotalAmount =0; - foreach ($_SESSION['PaymentDetail']->GLItems AS $PaymentItem) { + foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems AS $PaymentItem) { $TotalAmount += $PaymentItem->Amount; } if ($TotalAmount==0 AND - ($_SESSION['PaymentDetail']->Discount + $_SESSION['PaymentDetail']->Amount)/$_SESSION['PaymentDetail']->ExRate ==0){ + ($_SESSION['PaymentDetail' . $identifier]->Discount + $_SESSION['PaymentDetail' . $identifier]->Amount)/$_SESSION['PaymentDetail' . $identifier]->ExRate ==0){ prnMsg( _('This payment has no amounts entered and will not be processed'),'warn'); include('includes/footer.inc'); exit; @@ -258,11 +263,11 @@ $i++; } - $PeriodNo = GetPeriod($_SESSION['PaymentDetail']->DatePaid,$db); + $PeriodNo = GetPeriod($_SESSION['PaymentDetail' . $identifier]->DatePaid,$db); $sql="SELECT usepreprintedstationery FROM paymentmethods - WHERE paymentname='" . $_SESSION['PaymentDetail']->Paymenttype ."'"; + WHERE paymentname='" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype ."'"; $result=DB_query($sql, $db); $myrow=DB_fetch_row($result); @@ -277,7 +282,7 @@ <br /> <br />'; - echo '<form method=post action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">'; + echo '<form method=post action="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?identifier=' . $identifier) . '">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo _('Has the cheque been printed') . '? <br /> @@ -287,7 +292,7 @@ <input type="submit" name="ChequePrinted" value="' . _('Yes / Continue') . '" /> <input type="submit" name="PaymentCancelled" value="' . _('No / Cancel Payment') . '" />'; - echo '<br />Payment amount = ' . $_SESSION['PaymentDetail']->Amount; + echo '<br />Payment amount = ' . $_SESSION['PaymentDetail' . $identifier]->Amount; } else { @@ -296,7 +301,7 @@ $result = DB_Txn_Begin($db); - if ($_SESSION['PaymentDetail']->SupplierID=='') { + if ($_SESSION['PaymentDetail' . $identifier]->SupplierID=='') { //its a nominal bank transaction type 1 @@ -305,7 +310,7 @@ if ($_SESSION['CompanyRecord']['gllink_creditors']==1){ /* then enter GLTrans */ $TotalAmount=0; - foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { + foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) { /*The functional currency amount will be the payment currenct amount / the bank account currency exchange rate - to get to the bank account currency @@ -322,11 +327,11 @@ tag) "; $SQL= $SQL . "VALUES (1, '" . $TransNo . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', '" . $PeriodNo . "', '" . $PaymentItem->GLCode . "', '" . $PaymentItem->Narrative . "', - '" . ($PaymentItem->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "', + '" . ($PaymentItem->Amount/$_SESSION['PaymentDetail' . $identifier]->ExRate/$_SESSION['PaymentDetail' . $identifier]->FunctionalExRate) . "', '". $PaymentItem->Cheque ."', '" . $PaymentItem->Tag . "' )"; @@ -335,13 +340,13 @@ $TotalAmount += $PaymentItem->Amount; } - $_SESSION['PaymentDetail']->Amount = $TotalAmount; - $_SESSION['PaymentDetail']->Discount=0; + $_SESSION['PaymentDetail' . $identifier]->Amount = $TotalAmount; + $_SESSION['PaymentDetail' . $identifier]->Discount=0; } //Run through the GL postings to check to see if there is a posting to another bank account (or the same one) if there is then a receipt needs to be created for this account too - foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { + foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) { if (in_array($PaymentItem->GLCode, $BankAccounts)) { @@ -357,9 +362,9 @@ $TrfToBankCurrCode = $TrfToBankRow['currcode']; $TrfToBankExRate = $TrfToBankRow['rate']; - if ($_SESSION['PaymentDetail']->AccountCurrency == $TrfToBankCurrCode){ + if ($_SESSION['PaymentDetail' . $identifier]->AccountCurrency == $TrfToBankCurrCode){ /*Make sure to use the same rate if the transfer is between two bank accounts in the same currency */ - $TrfToBankExRate = $_SESSION['PaymentDetail']->FunctionalExRate; + $TrfToBankExRate = $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate; } /*Consider an example @@ -403,13 +408,13 @@ VALUES ('" . $ReceiptTransNo . "', 2, '" . $PaymentItem->GLCode . "', - '" . _('Act Transfer From ') . $_SESSION['PaymentDetail']->Account . ' - ' . $PaymentItem->Narrative . "', - '" . (($_SESSION['PaymentDetail']->ExRate * $_SESSION['PaymentDetail']->FunctionalExRate)/$TrfToBankExRate). "', + '" . _('Act Transfer From ') . $_SESSION['PaymentDetail' . $identifier]->Account . ' - ' . $PaymentItem->Narrative . "', + '" . (($_SESSION['PaymentDetail' . $identifier]->ExRate * $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate)/$TrfToBankExRate). "', '" . $TrfToBankExRate . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - '" . $_SESSION['PaymentDetail']->Paymenttype . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "', '" . $PaymentItem->Amount . "', - '" . $_SESSION['PaymentDetail']->Currency . "' + '" . $_SESSION['PaymentDetail' . $identifier]->Currency . "' )"; $ErrMsg = _('Cannot insert a bank transaction because'); $DbgMsg = _('Cannot insert a bank transaction with the SQL'); @@ -419,7 +424,7 @@ } } else { /*Its a supplier payment type 22 */ - $CreditorTotal = (($_SESSION['PaymentDetail']->Discount + $_SESSION['PaymentDetail']->Amount)/$_SESSION['PaymentDetail']->ExRate)/$_SESSION['PaymentDetail']->FunctionalExRate; + $CreditorTotal = (($_SESSION['PaymentDetail' . $identifier]->Discount + $_SESSION['PaymentDetail' . $identifier]->Amount)/$_SESSION['PaymentDetail' . $identifier]->ExRate)/$_SESSION['PaymentDetail' . $identifier]->FunctionalExRate; $TransNo = GetNextTransNo(22, $db); $TransType = 22; @@ -436,13 +441,13 @@ transtext) "; $SQL = $SQL . "valueS ('" . $TransNo . "', 22, - '" . $_SESSION['PaymentDetail']->SupplierID . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', + '" . $_SESSION['PaymentDetail' . $identifier]->SupplierID . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', '" . date('Y-m-d H-i-s') . "', - '" . $_SESSION['PaymentDetail']->Paymenttype . "', - '" . ($_SESSION['PaymentDetail']->FunctionalExRate/$_SESSION['PaymentDetail']->ExRate) . "', - '" . (-$_SESSION['PaymentDetail']->Amount-$_SESSION['PaymentDetail']->Discount) . "', - '" . $_SESSION['PaymentDetail']->Narrative . "' + '" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "', + '" . ($_SESSION['PaymentDetail' . $identifier]->FunctionalExRate/$_SESSION['PaymentDetail' . $identifier]->ExRate) . "', + '" . (-$_SESSION['PaymentDetail' . $identifier]->Amount-$_SESSION['PaymentDetail' . $identifier]->Discount) . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "' )"; $ErrMsg = _('Cannot insert a payment transaction against the supplier because'); @@ -451,9 +456,9 @@ /*Update the supplier master with the date and amount of the last payment made */ $SQL = "UPDATE suppliers - SET lastpaiddate = '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - lastpaid='" . $_SESSION['PaymentDetail']->Amount ."' - WHERE suppliers.supplierid='" . $_SESSION['PaymentDetail']->SupplierID . "'"; + SET lastpaiddate = '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', + lastpaid='" . $_SESSION['PaymentDetail' . $identifier]->Amount ."' + WHERE suppliers.supplierid='" . $_SESSION['PaymentDetail' . $identifier]->SupplierID . "'"; @@ -461,7 +466,7 @@ $DbgMsg = _('Cannot update the supplier record for the date of the last payment made using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - $_SESSION['PaymentDetail']->Narrative = $_SESSION['PaymentDetail']->SupplierID . '-' . $_SESSION['PaymentDetail']->Narrative; + $_SESSION['PaymentDetail' . $identifier]->Narrative = $_SESSION['PaymentDetail' . $identifier]->SupplierID . '-' . $_SESSION['PaymentDetail' . $identifier]->Narrative; if ($_SESSION['CompanyRecord']['gllink_creditors']==1){ /* then do the supplier control GLTrans */ /* Now debit creditors account with payment + discount */ @@ -475,16 +480,16 @@ amount) "; $SQL=$SQL . "VALUES (22, '" . $TransNo . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['creditorsact'] . "', - '" . $_SESSION['PaymentDetail']->Narrative . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "', '" . $CreditorTotal . "')"; $ErrMsg = _('Cannot insert a GL transaction for the creditors account debit because'); $DbgMsg = _('Cannot insert a GL transaction for the creditors account debit using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); - if ($_SESSION['PaymentDetail']->Discount !=0){ + if ($_SESSION['PaymentDetail' . $identifier]->Discount !=0){ /* Now credit Discount received account with discounts */ $SQL="INSERT INTO gltrans ( type, typeno, @@ -495,11 +500,11 @@ amount) VALUES (22, '" . $TransNo . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['pytdiscountact'] . "', - '" . $_SESSION['PaymentDetail']->Narrative . "', - '" . (-$_SESSION['PaymentDetail']->Discount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "' + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "', + '" . (-$_SESSION['PaymentDetail' . $identifier]->Discount/$_SESSION['PaymentDetail' . $identifier]->ExRate/$_SESSION['PaymentDetail' . $identifier]->FunctionalExRate) . "' )"; $ErrMsg = _('Cannot insert a GL transaction for the payment discount credit because'); $DbgMsg = _('Cannot insert a GL transaction for the payment discount credit using the SQL'); @@ -511,7 +516,7 @@ if ($_SESSION['CompanyRecord']['gllink_creditors']==1){ /* then do the common GLTrans */ - if ($_SESSION['PaymentDetail']->Amount !=0){ + if ($_SESSION['PaymentDetail' . $identifier]->Amount !=0){ /* Bank account entry first */ $SQL = "INSERT INTO gltrans ( type, typeno, @@ -522,11 +527,11 @@ amount) VALUES ('" . $TransType . "', '" . $TransNo . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', '" . $PeriodNo . "', - '" . $_SESSION['PaymentDetail']->Account . "', - '" . $_SESSION['PaymentDetail']->Narrative . "', - '" . (-$_SESSION['PaymentDetail']->Amount/$_SESSION['PaymentDetail']->ExRate/$_SESSION['PaymentDetail']->FunctionalExRate) . "')"; + '" . $_SESSION['PaymentDetail' . $identifier]->Account . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "', + '" . (-$_SESSION['PaymentDetail' . $identifier]->Amount/$_SESSION['PaymentDetail' . $identifier]->ExRate/$_SESSION['PaymentDetail' . $identifier]->FunctionalExRate) . "')"; $ErrMsg = _('Cannot insert a GL transaction for the bank account credit because'); $DbgMsg = _('Cannot insert a GL transaction for the bank account credit using the SQL'); @@ -550,21 +555,21 @@ currcode) VALUES ('" . $TransNo . "', '" . $TransType . "', - '" . $_SESSION['PaymentDetail']->Account . "', - '" . $_SESSION['PaymentDetail']->Narrative . "', - '" . $_SESSION['PaymentDetail']->ExRate . "', - '" . $_SESSION['PaymentDetail']->FunctionalExRate . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - '" . $_SESSION['PaymentDetail']->Paymenttype . "', - '" . -$_SESSION['PaymentDetail']->Amount . "', - '" . $_SESSION['PaymentDetail']->Currency . "' + '" . $_SESSION['PaymentDetail' . $identifier]->Account . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "', + '" . $_SESSION['PaymentDetail' . $identifier]->ExRate . "', + '" . $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "', + '" . -$_SESSION['PaymentDetail' . $identifier]->Amount . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Currency . "' )"; $ErrMsg = _('Cannot insert a bank transaction because'); $DbgMsg = _('Cannot insert a bank transaction using the SQL'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } else { - foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { + foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) { $SQL="INSERT INTO banktrans (transno, type, bankact, @@ -577,14 +582,14 @@ currcode) VALUES ('" . $TransNo . "', '" . $TransType . "', - '" . $_SESSION['PaymentDetail']->Account . "', - '" . $_SESSION['PaymentDetail']->Narrative . "', - '" . $_SESSION['PaymentDetail']->ExRate . "', - '" . $_SESSION['PaymentDetail']->FunctionalExRate . "', - '" . FormatDateForSQL($_SESSION['PaymentDetail']->DatePaid) . "', - '" . $_SESSION['PaymentDetail']->Paymenttype . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Account . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Narrative . "', + '" . $_SESSION['PaymentDetail' . $identifier]->ExRate . "', + '" . $_SESSION['PaymentDetail' . $identifier]->FunctionalExRate . "', + '" . FormatDateForSQL($_SESSION['PaymentDetail' . $identifier]->DatePaid) . "', + '" . $_SESSION['PaymentDetail' . $identifier]->Paymenttype . "', '" . -$PaymentItem->Amount . "', - '" . $_SESSION['PaymentDetail']->Currency . "' )"; + '" . $_SESSION['PaymentDetail' . $identifier]->Currency . "' )"; $ErrMsg = _('Cannot insert a bank transaction because'); $DbgMsg = _('Cannot insert a bank transaction using the SQL'); @@ -595,7 +600,7 @@ DB_Txn_Commit($db); prnMsg(_('Payment') . ' ' . $TransNo . ' ' . _('has been successfully entered'),'success'); - $LastSupplier = ($_SESSION['PaymentDetail']->SupplierID); + $LastSupplier = ($_SESSION['PaymentDetail' . $identifier]->SupplierID); unset($_POST['BankAccount']); unset($_POST['DatePaid']); @@ -605,8 +610,8 @@ unset($_POST['Narrative']); unset($_POST['Amount']); unset($_POST['Discount']); - unset($_SESSION['PaymentDetail']->GLItems); - unset($_SESSION['PaymentDetail']); + unset($_SESSION['PaymentDetail' . $identifier]->GLItems); + unset($_SESSION['PaymentDetail' . $identifier]); /*Set up a newy in case user wishes to enter another */ if (isset($LastSupplier) and $LastSupplier!='') { @@ -617,7 +622,7 @@ echo '<br /><a href="' . $rootpath . '/Payments.php?SupplierID=' . $LastSupplier . '">' . _('Enter another Payment for') . ' ' . $myrow['suppname'] . '</a>'; } else { - echo '<br /><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) .'">' . _('Enter another General Ledger Payment') . '</a><br />'; + echo '<br /><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '">' . _('Enter another General Ledger Payment') . '</a><br />'; } } @@ -626,7 +631,7 @@ } elseif (isset($_GET['Delete'])){ /* User hit delete the receipt entry from the batch */ - $_SESSION['PaymentDetail']->Remove_GLItem($_GET['Delete']); + $_SESSION['PaymentDetail' . $identifier]->Remove_GLItem($_GET['Delete']); } elseif (isset($_POST['Process']) AND !$BankAccountEmpty){ //user hit submit a new GL Analysis line into the payment @@ -648,7 +653,7 @@ prnMsg( _('The Cheque/Voucher number has already been used') . ' - ' . _('This GL analysis item could not be added'),'error'); } else { $myrow = DB_fetch_array($Result); - $_SESSION['PaymentDetail']->add_to_glanalysis(filter_number_format($_POST['GLAmount']), + $_SESSION['PaymentDetail' . $identifier]->add_to_glanalysis(filter_number_format($_POST['GLAmount']), $_POST['GLNarrative'], $_POST['GLManualCode'], $myrow['accountname'], @@ -664,7 +669,7 @@ $SQL = "SELECT accountname FROM chartmaster WHERE accountcode='" . $_POST['GLCode'] . "'"; $Result=DB_query($SQL,$db); $myrow=DB_fetch_array($Result); - $_SESSION['PaymentDetail']->add_to_glanalysis(filter_number_format($_POST['GLAmount']), + $_SESSION['PaymentDetail' . $identifier]->add_to_glanalysis(filter_number_format($_POST['GLAmount']), $_POST['GLNarrative'], $_POST['GLCode'], $myrow['accountname'], @@ -690,14 +695,14 @@ if (isset($_POST['DatePaid']) AND ($_POST['DatePaid']=='' - OR !Is_Date($_SESSION['PaymentDetail']->DatePaid))){ + OR !Is_Date($_SESSION['PaymentDetail' . $identifier]->DatePaid))){ $_POST['DatePaid']= Date($_SESSION['DefaultDateFormat']); - $_SESSION['PaymentDetail']->DatePaid = $_POST['DatePaid']; + $_SESSION['PaymentDetail' . $identifier]->DatePaid = $_POST['DatePaid']; } -if ($_SESSION['PaymentDetail']->Currency=='' AND $_SESSION['PaymentDetail']->SupplierID==''){ - $_SESSION['PaymentDetail']->Currency=$_SESSION['CompanyRecord']['currencydefault']; +if ($_SESSION['PaymentDetail' . $identifier]->Currency=='' AND $_SESSION['PaymentDetail' . $identifier]->SupplierID==''){ + $_SESSION['PaymentDetail' . $identifier]->Currency=$_SESSION['CompanyRecord']['currencydefault']; } @@ -715,29 +720,29 @@ if (DB_num_rows($result)==1){ $myrow = DB_fetch_row($result); - $_SESSION['PaymentDetail']->BankAccountName = $myrow[0]; + $_SESSION['PaymentDetail' . $identifier]->BankAccountName = $myrow[0]; unset($result); } elseif (DB_num_rows($result)==0){ prnMsg( _('The bank account number') . ' ' . $_POST['BankAccount'] . ' ' . _('is not set up as a bank account with a valid general ledger account'),'error'); } } -echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">'; +echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?identifier=' . $identifier) . '" method="post">'; echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<p><table class="selection">'; echo '<tr><th colspan="4"><font size="3" color="blue">' . _('Payment'); -if ($_SESSION['PaymentDetail']->SupplierID!=''){ - echo ' ' . _('to') . ' ' . $_SESSION['PaymentDetail']->SuppName; +if ($_SESSION['PaymentDetail' . $identifier]->SupplierID!=''){ + echo ' ' . _('to') . ' ' . $_SESSION['PaymentDetail' . $identifer]->SuppName; } -if ($_SESSION['PaymentDetail']->BankAccountName!=''){ - echo ' ' . _('from the') . ' ' . $_SESSION['PaymentDetail']->BankAccountName; +if ($_SESSION['PaymentDetail' . $identifier]->BankAccountName!=''){ + echo ' ' . _('from the') . ' ' . $_SESSION['PaymentDetail' . $identifier]->BankAccountName; } -echo ' ' . _('on') . ' ' . $_SESSION['PaymentDetail']->DatePaid . '</font></th></tr>'; +echo ' ' . _('on') . ' ' . $_SESSION['PaymentDetail' . $identifier]->DatePaid . '</font></th></tr>'; $SQL = "SELECT bankaccountname, bankaccounts.accountcode, @@ -777,11 +782,11 @@ echo '<tr> <td>' . _('Date Paid') . ':</td> - <td><input type="text" name="DatePaid" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" onChange="isDate(this, this.value, '."'".$_SESSION['DefaultDateFormat']."'".')" value="' . $_SESSION['PaymentDetail']->DatePaid . '" /></td> + <td><input type="text" name="DatePaid" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" onChange="isDate(this, this.value, '."'".$_SESSION['DefaultDateFormat']."'".')" value="' . $_SESSION['PaymentDetail' . $identifier]->DatePaid . '" /></td> </tr>'; -if ($_SESSION['PaymentDetail']->SupplierID==''){ +if ($_SESSION['PaymentDetail' . $identifier]->SupplierID==''){ echo '<tr><td>' . _('Currency of Payment') . ':</td> <td><select name="Currency" onChange="ReloadForm(UpdateHeader)">'; $SQL = "SELECT currency, currabrev, rate FROM currencies"; @@ -793,7 +798,7 @@ prnMsg( _('No currencies are defined yet. Payments cannot be entered until a currency is defined'),'error'); } else { while ($myrow=DB_fetch_array($result)){ - if ($_SESSION['PaymentDetail']->Currency==$myrow['currabrev']){ + if ($_SESSION['PaymentDetail' . $identifier]->Currency==$myrow['currabrev']){ echo '<option selected="selected" value="' . $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>'; } else { echo '<option value="' . $myrow['currabrev'] . '">' . $myrow['currency'] . '</option>'; @@ -806,17 +811,16 @@ } else { /*its a supplier payment so it must be in the suppliers currency */ echo '<tr> <td>' . _('Supplier Currency') . ':</td> - <td>' . $_SESSION['PaymentDetail']->Currency . '</td> + <td>' . $_SESSION['PaymentDetail' . $identifier]->Currency . '</td> </tr>'; - echo '<input type="hidden" name="Currency" value="' . $_SESSION['PaymentDetail']->Currency . '" />'; + echo '<input type="hidden" name="Currency" value="' . $_SESSION['PaymentDetail' . $identifier]->Currency . '" />'; /*get the default rate from the currency table if it has not been set */ if (!isset($_POST['ExRate']) OR $_POST['ExRate']==''){ - $SQL = "SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail']->Currency ."'"; + $SQL = "SELECT rate FROM currencies WHERE currabrev='" . $_SESSION['PaymentDetail' . $identifier]->Currency ."'"; $Result=DB_query($SQL,$db); $myrow=DB_fetch_row($Result); $_POST['ExRate']=locale_number_format($myrow[0],'Variable'); } - } if (!isset($_POST['ExRate'])){ @@ -826,7 +830,7 @@ if (!isset($_POST['FunctionalExRate'])){ $_POST['FunctionalExRate']=1; } -if ($_SESSION['PaymentDetail']->AccountCurrency!=$_SESSION['PaymentDetail']->Currency AND isset($_SESSION['PaymentDetail']->AccountCurrency)){ +if ($_SESSION['PaymentDetail' . $identifier]->AccountCurrency!=$_SESSION['PaymentDetail' . $identifier]->Currency AND isset($_SESSION['PaymentDetail' . $identifier]->AccountCurrency)){ if (isset($SuggestedExRate)){ $SuggestedExRateText = '<b>' . _('Suggested rate:') . ' ' . locale_number_format($SuggestedExRate,6) . '</b>'; } else { @@ -838,12 +842,12 @@ echo '<tr> <td>' . _('Payment Exchange Rate') . ':</td> <td><input class="number" type="text" name="ExRate" maxlength="10" size="12" value="' . $_POST['ExRate'] . '" /></td> - <td>' . $SuggestedExRateText . ' <i>' . _('The exchange rate between the currency of the bank account currency and the currency of the payment') . '. 1 ' . $_SESSION['PaymentDetail']->AccountCurrency . ' = ? ' . $_SESSION['PaymentDetail']->Currency . '</i></td> + <td>' . $SuggestedExRateText . ' <i>' . _('The exchange rate between the currency of the bank account currency and the currency of the payment') . '. 1 ' . $_SESSION['PaymentDetail' . $identifier]->AccountCurrency . ' = ? ' . $_SESSION['PaymentDetail' . $identifier]->Currency . '</i></td> </tr>'; } -if ($_SESSION['PaymentDetail']->AccountCurrency!=$_SESSION['CompanyRecord']['currencydefault'] - AND isset($_SESSION['PaymentDetail']->AccountCurrency)){ +if ($_SESSION['PaymentDetail' . $identifier]->AccountCurrency!=$_SESSION['CompanyRecord']['currencydefault'] + AND isset($_SESSION['PaymentDetail' . $identifier]->AccountCurrency)){ if (isset($SuggestedFunctionalExRate)){ $SuggestedFunctionalExRateText = '<b>' . _('Suggested rate:') . ' ' . locale_number_format($SuggestedFunctionalExRate,6) . '</b>'; } else { @@ -855,7 +859,7 @@ echo '<tr> <td>' . _('Functional Exchange Rate') . ':</td> <td><input type="text" name="FunctionalExRate" maxlength="10" size="12" value="' . $_POST['FunctionalExRate'] . '" /></td> - <td>' . ' ' . $SuggestedFunctionalExRateText . ' <i>' . _('The exchange rate between the currency of the business (the functional currency) and the currency of the bank account') . '. 1 ' . $_SESSION['CompanyRecord']['currencydefault'] . ' = ? ' . $_SESSION['PaymentDetail']->AccountCurrency . '</i></td> + <td>' . ' ' . $SuggestedFunctionalExRateText . ' <i>' . _('The exchange rate between the currency of the business (the functional currency) and the currency of the bank account') . '. 1 ' . $_SESSION['CompanyRecord']['currencydefault'] . ' = ? ' . $_SESSION['PaymentDetail' . $identifier]->AccountCurrency . '</i></td> </tr>'; } echo '<tr> @@ -902,7 +906,7 @@ echo '</table><br />'; -if ($_SESSION['CompanyRecord']['gllink_creditors']==1 AND $_SESSION['PaymentDetail']->SupplierID==''){ +if ($_SESSION['CompanyRecord']['gllink_creditors']==1 AND $_SESSION['PaymentDetail' . $identifier]->SupplierID==''){ /* Set upthe form for the transaction entry for a GL Payment Analysis item */ echo '<br /><table class="selection">'; @@ -1023,11 +1027,11 @@ if (isset($_POST['GLAmount'])) { echo '<tr> - <td>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . '):</td> + <td>' . _('Amount') . ' (' . $_SESSION['PaymentDetail' . $identifier]->Currency . '):</td> <td><input type="text" name="GLAmount" maxlength="12" size="12" class="number" value="' . $_POST['GLAmount'] . '" /></td> </tr>'; } else { - echo '<tr><td>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . '):</td> + echo '<tr><td>' . _('Amount') . ' (' . $_SESSION['PaymentDetail' . $identifier]->Currency . '):</td> <td><input type="text" name="GLAmount" maxlength="12" size="12" class="number" /></td> </tr>'; } @@ -1038,19 +1042,19 @@ <input type="submit" name="Cancel" value="' . _('Cancel') . '" /> </div>'; - if (sizeOf($_SESSION['PaymentDetail']->GLItems)>0) { + if (sizeOf($_SESSION['PaymentDetail' . $identifier]->GLItems)>0) { echo '<br /> <table class="selection"> <tr> <th>' . _('Cheque No').'</th> - <th>' . _('Amount') . ' (' . $_SESSION['PaymentDetail']->Currency . ')</th> + <th>' . _('Amount') . ' (' . $_SESSION['PaymentDetail' . $identifier]->Currency . ')</th> <th>' . _('GL Account') . '</th> <th>' . _('Narrative') . '</th> <th>' . _('Tag') . '</th> </tr>'; $PaymentTotal = 0; - foreach ($_SESSION['PaymentDetail']->GLItems as $PaymentItem) { + foreach ($_SESSION['PaymentDetail' . $identifier]->GLItems as $PaymentItem) { $Tagsql="SELECT tagdescription from tags where tagref='" . $PaymentItem->Tag . "'"; $TagResult=DB_query($Tagsql, $db); $TagMyrow=DB_fetch_row($TagResult); @@ -1062,17 +1066,17 @@ echo '<tr> <td>' . $PaymentItem->Cheque . '</td> - <td class="number">' . locale_number_format($PaymentItem->Amount,$_SESSION['PaymentDetail']->CurrDecimalPlaces) . '</td> + <td class="number">' . locale_number_format($PaymentItem->Amount,$_SESSION['PaymentDetail' . $identifier]->CurrDecimalPlaces) . '</td> <td>' . $PaymentItem->GLCode . ' - ' . $PaymentItem->GLActName . '</td> <td>' . stripslashes($PaymentItem->Narrative) . '</td> <td>' . $PaymentItem->Tag . ' - ' . $TagName . '</td> - <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF']) . '?Delete=' . $PaymentItem->ID . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this payment analysis item?') . '\');">' . _('Delete') . '</a></td> + <td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?identifier=' . $identifier) . '?Delete=' . $PaymentItem->ID . '" onclick="return confirm(\'' . _('Are you sure you wish to delete this payment analysis item?') . '\');">' . _('Delete') . '</a></td> </tr>'; $PaymentTotal += $PaymentItem->Amount; } echo '<tr> <td></td> - <td class="number"><b>' . locale_number_format($PaymentTotal,$_SESSION['PaymentDetail']->CurrDecimalPlaces) . '</b></td> + <td class="number"><b>' . locale_number_format($PaymentTotal,$_SESSION['PaymentDetail' . $identifier]->CurrDecimalPlaces) . '</b></td> <td></td> <td></td> <td></td> @@ -1088,16 +1092,16 @@ echo '<table class="selection"> <tr> - <td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail']->Currency . ':</td> - <td><input class="number" type="text" name="Amount" maxlength="12" size="13" value="' . $_SESSION['PaymentDetail']->Amount . '" /></td> + <td>' . _('Amount of Payment') . ' ' . $_SESSION['PaymentDetail' . $identifier]->Currency . ':</td> + <td><input class="number" type="text" name="Amount" maxlength="12" size="13" value="' . $_SESSION['PaymentDetail' . $identifier]->Amount . '" /></td> </tr>'; - if (isset($_SESSION['PaymentDetail']->SupplierID)){ /*So it is a supplier payment so show the discount entry item */ + if (isset($_SESSION['PaymentDetail' . $identifier]->SupplierID)){ /*So it is a supplier payment so show the discount entry item */ echo '<tr> <td>' . _('Amount of Discount') . ':</td> - <td><input class="number" type="text" name="Discount" maxlength="12" size="13" value="' . $_SESSION['PaymentDetail']->Discount . '" /></td> + <td><input class="number" type="text" name="Discount" maxlength="12" size="13" value="' . $_SESSION['PaymentDetail' . $identifier]->Discount . '" /></td> </tr>'; - echo '<input type="hidden" name="SuppName" value="' . $_SESSION['PaymentDetail']->SuppName . '" />'; + echo '<input type="hidden" name="SuppName" value="' . $_SESSION['PaymentDetail' . $identifier]->SuppName . '" />'; } else { echo '<input type="hidden" name="Discount" Value="0" />'; } @@ -1107,4 +1111,4 @@ echo '</form>'; include('includes/footer.inc'); -?> \ No newline at end of file +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |