From: <dai...@us...> - 2011-09-11 04:06:57
|
Revision: 4685 http://web-erp.svn.sourceforge.net/web-erp/?rev=4685&view=rev Author: daintree Date: 2011-09-11 04:06:48 +0000 (Sun, 11 Sep 2011) Log Message: ----------- number_formatting Modified Paths: -------------- trunk/ConfirmDispatchControlled_Invoice.php trunk/ConfirmDispatch_Invoice.php trunk/CounterSales.php trunk/Credit_Invoice.php trunk/DeliveryDetails.php trunk/OutstandingGRNs.php trunk/PDFLowGP.php trunk/SelectOrderItems.php trunk/includes/DefineCartClass.php trunk/includes/footer.inc Modified: trunk/ConfirmDispatchControlled_Invoice.php =================================================================== --- trunk/ConfirmDispatchControlled_Invoice.php 2011-09-10 04:52:21 UTC (rev 4684) +++ trunk/ConfirmDispatchControlled_Invoice.php 2011-09-11 04:06:48 UTC (rev 4685) @@ -69,7 +69,7 @@ /*TotalQuantity set inside this include file from the sum of the bundles of the item selected for dispatch */ -$_SESSION['Items']->LineItems[$LineNo]->QtyDispatched = $TotalQuantity; +$_SESSION['Items']->LineItems[$LineNo]->QtyDispatched = filter_number_format($TotalQuantity); include('includes/footer.inc'); exit; Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2011-09-10 04:52:21 UTC (rev 4684) +++ trunk/ConfirmDispatch_Invoice.php 2011-09-11 04:06:48 UTC (rev 4685) @@ -208,11 +208,11 @@ $_SESSION['Items']->ShipVia = $_POST['ShipVia']; } if (isset($_POST['ChargeFreightCost'])){ - $_SESSION['Items']->FreightCost = $_POST['ChargeFreightCost']; + $_SESSION['Items']->FreightCost = filter_number_format($_POST['ChargeFreightCost']); } foreach ($_SESSION['Items']->FreightTaxes as $FreightTaxLine) { if (isset($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder])){ - $_SESSION['Items']->FreightTaxes[$FreightTaxLine->TaxCalculationOrder]->TaxRate = $_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder]/100; + $_SESSION['Items']->FreightTaxes[$FreightTaxLine->TaxCalculationOrder]->TaxRate = filter_number_format($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder]/100); } } @@ -220,14 +220,14 @@ if (sizeOf($Itm->SerialItems) > 0) { $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = 0; //initialise QtyDispatched foreach ($Itm->SerialItems as $SerialItem) { //calculate QtyDispatched from bundle quantities - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched += filter_number_format($SerialItem->BundleQty); } - } else if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ])AND $_POST[$Itm->LineNumber . '_QtyDispatched'] <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = $_POST[$Itm->LineNumber . '_QtyDispatched']; + } else if (is_numeric($_POST[$Itm->LineNumber . '_QtyDispatched' ]) AND filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']) <= ($_SESSION['Items']->LineItems[$Itm->LineNumber]->Quantity - $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyInv)){ + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']); } foreach ($Itm->Taxes as $TaxLine) { if (isset($_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])){ - $_SESSION['Items']->LineItems[$Itm->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = $_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']/100; + $_SESSION['Items']->LineItems[$Itm->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = filter_number_format($_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']/100); } } } //end foreach lineitem @@ -323,8 +323,8 @@ } } $DisplayDiscountPercent = locale_number_format($LnItm->DiscountPercent*100,2) . '%'; - $DisplayLineNetTotal = locale_number_format($LineTotal,$_SESSION['Items']->CurrDecimalPlaces); - $DisplayPrice = locale_number_format($LnItm->Price,$_SESSION['Items']->CurrDecimalPlaces); + $DisplayLineNetTotal = locale_money_format($LineTotal,$_SESSION['Items']->CurrDecimalPlaces); + $DisplayPrice = locale_money_format($LnItm->Price,$_SESSION['Items']->CurrDecimalPlaces); echo '<td class="number">'.$DisplayPrice.'</td> <td class="number">'.$DisplayDiscountPercent.'</td> <td class="number">'.$DisplayLineNetTotal.'</td>'; @@ -373,9 +373,9 @@ $TaxTotal += $TaxLineTotal; - $DisplayTaxAmount = locale_number_format($TaxLineTotal ,$_SESSION['Items']->CurrDecimalPlaces); + $DisplayTaxAmount = locale_money_format($TaxLineTotal ,$_SESSION['Items']->CurrDecimalPlaces); - $DisplayGrossLineTotal = locale_number_format($LineTotal+ $TaxLineTotal,$_SESSION['Items']->CurrDecimalPlaces); + $DisplayGrossLineTotal = locale_money_format($LineTotal+ $TaxLineTotal,$_SESSION['Items']->CurrDecimalPlaces); echo '<td class="number">'.$DisplayTaxAmount.'</td><td class="number">'.$DisplayGrossLineTotal.'</td>'; @@ -392,8 +392,8 @@ } echo '</tr>'; if (mb_strlen($LnItm->Narrative)>1){ - $narrative=str_replace('\r\n','<br />', $LnItm->Narrative); - echo $RowStarter . '<td colspan=12>' . stripslashes($narrative) . '</td></tr>'; + $Narrative=str_replace('\r\n','<br />', $LnItm->Narrative); + echo $RowStarter . '<td colspan=12>' . stripslashes($Narrative) . '</td></tr>'; } }//end foreach ($line) @@ -511,13 +511,13 @@ } echo '</td>'; -echo '<td class="number">' . locale_number_format($FreightTaxTotal,$_SESSION['Items']->CurrDecimalPlaces) . '</td> - <td class="number">' . locale_number_format($FreightTaxTotal+ $_POST['ChargeFreightCost'],$_SESSION['Items']->CurrDecimalPlaces) . '</td> +echo '<td class="number">' . locale_money_format($FreightTaxTotal,$_SESSION['Items']->CurrDecimalPlaces) . '</td> + <td class="number">' . locale_money_format($FreightTaxTotal+ $_POST['ChargeFreightCost'],$_SESSION['Items']->CurrDecimalPlaces) . '</td> </tr>'; $TaxTotal += $FreightTaxTotal; -$DisplaySubTotal = locale_number_format(($_SESSION['Items']->total + $_POST['ChargeFreightCost']),$_SESSION['Items']->CurrDecimalPlaces); +$DisplaySubTotal = locale_money_format(($_SESSION['Items']->total + $_POST['ChargeFreightCost']),$_SESSION['Items']->CurrDecimalPlaces); /* round the totals to avoid silly entries */ @@ -529,8 +529,8 @@ <td colspan="10" class="number">' . _('Invoice Totals'). '</td> <td class="number:><hr><b>'.$DisplaySubTotal.'</b><hr></td> <td colspan="2"></td> - <td class="number"><hr><b>' . locale_number_format($TaxTotal,$_SESSION['Items']->CurrDecimalPlaces) . '</b><hr></td> - <td class="number"><hr><b>' . locale_number_format($TaxTotal+($_SESSION['Items']->total + $_POST['ChargeFreightCost']),$_SESSION['Items']->CurrDecimalPlaces) . '</b><hr></td> + <td class="number"><hr><b>' . locale_money_format($TaxTotal,$_SESSION['Items']->CurrDecimalPlaces) . '</b><hr></td> + <td class="number"><hr><b>' . locale_money_format($TaxTotal+($_SESSION['Items']->total + $_POST['ChargeFreightCost']),$_SESSION['Items']->CurrDecimalPlaces) . '</b><hr></td> </tr>'; if (! isset($_POST['DispatchDate']) OR ! Is_Date($_POST['DispatchDate'])){ @@ -587,7 +587,7 @@ /*Now look for assembly components that would go negative */ $SQL = "SELECT bom.component, stockmaster.description, - locstock.quantity-(" . $OrderLine->QtyDispatched . "*bom.quantity) AS qtyleft + locstock.quantity-(" . filter_number_format($OrderLine->QtyDispatched) . "*bom.quantity) AS qtyleft FROM bom INNER JOIN locstock ON bom.component=locstock.stockid @@ -763,13 +763,13 @@ '', '" . $_SESSION['Items']->DefaultSalesType . "', '" . $_SESSION['ProcessingOrder'] . "', - '" . $_SESSION['Items']->total . "', - '" . $TaxTotal . "', - '" . $_POST['ChargeFreightCost'] . "', - '" . $_SESSION['CurrencyRate'] . "', - '" . $_POST['InvoiceText'] . "', + '" . filter_number_format($_SESSION['Items']->total) . "', + '" . filter_number_format($TaxTotal) . "', + '" . filter_number_format($_POST['ChargeFreightCost']) . "', + '" . filter_number_format($_SESSION['CurrencyRate']) . "', + '" . DB_escape_string($_POST['InvoiceText']) . "', '" . $_SESSION['Items']->ShipVia . "', - '" . $_POST['Consignment'] . "' )"; + '" . DB_escape_string($_POST['Consignment']) . "' )"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction record was used'); @@ -785,7 +785,7 @@ taxamount) VALUES ('" . $DebtorTransID . "', '" . $TaxAuthID . "', - '" . $TaxAmount/$_SESSION['CurrencyRate'] . "')"; + '" . filter_number_format($TaxAmount/$_SESSION['CurrencyRate']) . "')"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction taxes records could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction taxes record was used'); @@ -815,7 +815,7 @@ if ($_POST['BOPolicy']=='CAN'){ $SQL = "UPDATE salesorderdetails - SET quantity = quantity - " . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . " + SET quantity = quantity - " . filter_number_format($OrderLine->Quantity - $OrderLine->QtyDispatched) . " WHERE orderno = '" . $_SESSION['ProcessingOrder'] . " ' AND stkcode = '" . $OrderLine->StockID . "'"; @@ -837,7 +837,7 @@ '" . $_SESSION['ProcessingOrder'] . "', '" . $InvoiceNo . "', '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', 'CAN')"; @@ -849,7 +849,7 @@ - } elseif (($OrderLine->Quantity - $OrderLine->QtyDispatched) >0 && DateDiff(ConvertSQLDate($DefaultDispatchDate),$_SESSION['Items']->DeliveryDate,'d') >0) { + } elseif (($OrderLine->Quantity - $OrderLine->QtyDispatched) >0 AND DateDiff(ConvertSQLDate($DefaultDispatchDate),$_SESSION['Items']->DeliveryDate,'d') > 0) { /*The order is being short delivered after the due date - need to insert a delivery differnce log */ @@ -865,7 +865,7 @@ '" . $_SESSION['ProcessingOrder'] . "', '" . $InvoiceNo . "', '" . $OrderLine->StockID . "', - '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', 'BO' @@ -883,14 +883,14 @@ // Test above to see if the line is completed or not if ($OrderLine->QtyDispatched>=($OrderLine->Quantity - $OrderLine->QtyInv) OR $_POST['BOPolicy']=='CAN'){ $SQL = "UPDATE salesorderdetails - SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", + SET qtyinvoiced = qtyinvoiced + " . filter_number_format($OrderLine->QtyDispatched) . ", actualdispatchdate = '" . $DefaultDispatchDate . "', completed=1 WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' AND orderlineno = '" . $OrderLine->LineNumber . "'"; } else { $SQL = "UPDATE salesorderdetails - SET qtyinvoiced = qtyinvoiced + " . $OrderLine->QtyDispatched . ", + SET qtyinvoiced = qtyinvoiced + " . filter_number_format($OrderLine->QtyDispatched) . ", actualdispatchdate = '" . $DefaultDispatchDate . "' WHERE orderno = '" . $_SESSION['ProcessingOrder'] . "' AND orderlineno = '" . $OrderLine->LineNumber . "'"; @@ -930,7 +930,7 @@ $QtyOnHandPrior = 0; } - $SQL = "UPDATE locstock SET quantity = locstock.quantity - " . $OrderLine->QtyDispatched . " + $SQL = "UPDATE locstock SET quantity = locstock.quantity - " . filter_number_format($OrderLine->QtyDispatched) . " WHERE locstock.stockid = '" . $OrderLine->StockID . "' AND loccode = '" . $_SESSION['Items']->Location . "'"; @@ -1002,10 +1002,10 @@ '" . $_SESSION['Items']->Branch . "', '" . $PeriodNo . "', '" . _('Assembly') . ': ' . $OrderLine->StockID . ' ' . _('Order') . ': ' . $_SESSION['ProcessingOrder'] . "', - '" . -$AssParts['quantity'] * $OrderLine->QtyDispatched . "', + '" . filter_number_format(-$AssParts['quantity'] * $OrderLine->QtyDispatched) . "', '" . $AssParts['standard'] . "', 0, - '" . ($QtyOnHandPrior - $AssParts['quantity'] * $OrderLine->QtyDispatched) . "' )"; + '" . filter_number_format($QtyOnHandPrior - $AssParts['quantity'] * $OrderLine->QtyDispatched) . "' )"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('Stock movement records for the assembly components of'). ' '. $OrderLine->StockID . ' ' . _('could not be inserted because'); $DbgMsg = _('The following SQL to insert the assembly components stock movement records was used'); @@ -1013,7 +1013,7 @@ $SQL = "UPDATE locstock - SET quantity = locstock.quantity - " . $AssParts['quantity'] * $OrderLine->QtyDispatched . " + SET quantity = locstock.quantity - " . filter_number_format($AssParts['quantity'] * $OrderLine->QtyDispatched) . " WHERE locstock.stockid = '" . $AssParts['component'] . "' AND loccode = '" . $_SESSION['Items']->Location . "'"; @@ -1028,7 +1028,7 @@ } /* end of its an assembly */ // Insert stock movements - with unit cost - $LocalCurrencyPrice= ($OrderLine->Price / $_SESSION['CurrencyRate']); + $LocalCurrencyPrice = ($OrderLine->Price / $_SESSION['CurrencyRate']); if (empty($OrderLine->StandardCost)) { $OrderLine->StandardCost=0; @@ -1056,13 +1056,13 @@ '" . $DefaultDispatchDate . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', - '" . $LocalCurrencyPrice . "', + '" . filter_number_format($LocalCurrencyPrice) . "', '" . $PeriodNo . "', '" . $_SESSION['ProcessingOrder'] . "', - '" . -$OrderLine->QtyDispatched . "', - '" . $OrderLine->DiscountPercent . "', - '" . $OrderLine->StandardCost . "', - '" . ($QtyOnHandPrior - $OrderLine->QtyDispatched) . "', + '" . filter_number_format(-$OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->DiscountPercent) . "', + '" . filter_number_format($OrderLine->StandardCost) . "', + '" . filter_number_format($QtyOnHandPrior - $OrderLine->QtyDispatched) . "', '" . DB_escape_string($OrderLine->Narrative) . "' )"; } else { // its an assembly or dummy and assemblies/dummies always have nil stock (by definition they are made up at the time of dispatch so new qty on hand will be nil @@ -1090,12 +1090,12 @@ '" . $DefaultDispatchDate . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', - '" . $LocalCurrencyPrice . "', + '" . filter_number_format($LocalCurrencyPrice) . "', '" . $PeriodNo . "', '" . $_SESSION['ProcessingOrder'] . "', - '" . -$OrderLine->QtyDispatched . "', - '" . $OrderLine->DiscountPercent . "', - '" . $OrderLine->StandardCost . "', + '" . filter_number_format(-$OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->DiscountPercent) . "', + '" . filter_number_format($OrderLine->StandardCost) . "', '" . DB_escape_string($OrderLine->Narrative) . "')"; } @@ -1117,7 +1117,7 @@ taxontax) VALUES ('" . $StkMoveNo . "', '" . $Tax->TaxAuthID . "', - '" . $Tax->TaxRate . "', + '" . filter_number_format($Tax->TaxRate) . "', '" . $Tax->TaxCalculationOrder . "', '" . $Tax->TaxOnTax . "')"; @@ -1133,10 +1133,10 @@ foreach($OrderLine->SerialItems as $Item){ /*We need to add the StockSerialItem record and the StockSerialMoves as well */ - $SQL = "UPDATE stockserialitems SET quantity= quantity - " . $Item->BundleQty . " + $SQL = "UPDATE stockserialitems SET quantity= quantity - " . filter_number_format($Item->BundleQty) . " WHERE stockid='" . $OrderLine->StockID . "' AND loccode='" . $_SESSION['Items']->Location . "' - AND serialno='" . $Item->BundleRef . "'"; + AND serialno='" . DB_escape_string($Item->BundleRef) . "'"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock item record could not be updated because'); $DbgMsg = _('The following SQL to update the serial stock item record was used'); @@ -1150,8 +1150,8 @@ moveqty) VALUES ('" . $StkMoveNo . "', '" . $OrderLine->StockID . "', - '" . $Item->BundleRef . "', - '" . -$Item->BundleQty . "')"; + '" . DB_escape_string($Item->BundleRef) . "', + '" . filter_number_format(-$Item->BundleQty) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The serial stock movement record could not be inserted because'); $DbgMsg = _('The following SQL to insert the serial stock movement records was used'); @@ -1202,10 +1202,10 @@ if ($myrow[0]>0){ /*Update the existing record that already exists */ - $SQL = "UPDATE salesanalysis SET amt=amt+" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . ", - cost=cost+" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . ", - qty=qty +" . $OrderLine->QtyDispatched . ", - disc=disc+" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . " + $SQL = "UPDATE salesanalysis SET amt=amt+" . filter_number_format($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . ", + cost=cost+" . filter_number_format($OrderLine->StandardCost * $OrderLine->QtyDispatched) . ", + qty=qty +" . filter_number_format($OrderLine->QtyDispatched) . ", + disc=disc+" . filter_number_format($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . " WHERE salesanalysis.area='" . $myrow[5] . "' AND salesanalysis.salesperson='" . $myrow[8] . "' AND typeabbrev ='" . $_SESSION['Items']->DefaultSalesType . "' @@ -1233,12 +1233,12 @@ stkcategory ) SELECT '" . $_SESSION['Items']->DefaultSalesType . "', '" . $PeriodNo . "', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', - '" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', + '" . filter_number_format($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', - '" . $OrderLine->QtyDispatched . "', - '" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', + '" . filter_number_format($OrderLine->QtyDispatched) . "', + '" . filter_number_format($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', '" . $OrderLine->StockID . "', custbranch.area, 1, @@ -1275,7 +1275,7 @@ '" . $PeriodNo . "', '" . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . $OrderLine->StandardCost * $OrderLine->QtyDispatched . "')"; + '" . filter_number_format($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1298,7 +1298,7 @@ '" . $PeriodNo . "', '" . $StockGLCode['stockact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; + '" . filter_number_format(-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The stock side of the cost of sales GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1325,7 +1325,7 @@ '" . $PeriodNo . "', '" . $SalesGLAccounts['salesglcode'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "', - '" . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format(-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales GL posting could not be inserted because'); $DbgMsg = '<br />' ._('The following SQL to insert the GLTrans record was used'); @@ -1347,7 +1347,7 @@ '" . $PeriodNo . "', '" . $SalesGLAccounts['discountglcode'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . ($OrderLine->DiscountPercent * 100) . "%', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The sales discount GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1393,7 +1393,7 @@ '" . $PeriodNo . "', '" . $DisposalRow['accumdepnact'] . "', '" . $_SESSION['Items']->DebtorNo . ' - ' . $OrderLine->StockID . ' ' . _('disposal') . "', - '" . -$DisposalRow['accumdpen'] . "')"; + '" . filter_number_format(-$DisposalRow['accumdpen']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The reversal of accumulated depreciation GL posting on disposal could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1415,7 +1415,7 @@ '" . $PeriodNo . "', '" . $DisposalRow['costact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', - '" . -$DisposalRow['cost'] . "')"; + '" . filter_number_format(-$DisposalRow['cost']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The reversal of asset cost on dispoal GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1437,7 +1437,7 @@ '" . $PeriodNo . "', '" . $DisposalRow['disposalact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', - '" . ($DisposalRow['cost']-$DisposalRow['accumdepn']) . "')"; + '" . filter_number_format($DisposalRow['cost']-$DisposalRow['accumdepn']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal net book value GL posting could not be inserted because'); $DbgMsg = '<br />' ._('The following SQL to insert the GLTrans record was used'); @@ -1459,7 +1459,7 @@ '" . $PeriodNo . "', '" . $DisposalRow['disposalact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', - '" . (-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format(-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The disposal proceeds GL posting could not be inserted because'); $DbgMsg = '<br />' ._('The following SQL to insert the GLTrans record was used'); @@ -1487,14 +1487,14 @@ '" . $PeriodNo . "', '" . Date('Y-m-d') . "', 'disposal', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', + '" . filter_number_format($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', '" . $DefaultDispatchDate . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The fixed asset transaction could not be inserted because'); $DbgMsg = '<br />' ._('The following SQL to insert the fixed asset transaction record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); $SQL = "UPDATE fixedassets - SET disposalproceeds ='" . ($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', + SET disposalproceeds ='" . filter_number_format($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', disposaldate ='" . $DefaultDispatchDate . "' WHERE assetid ='" . $AssetNumber . "'"; @@ -1525,7 +1525,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['debtorsact'] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format(($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the total debtors control GLTrans record was used'); @@ -1550,7 +1550,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['freightact'] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (-($_SESSION['Items']->FreightCost)/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format(-($_SESSION['Items']->FreightCost)/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The freight GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); @@ -1572,7 +1572,7 @@ '" . $PeriodNo . "', '" . $TaxGLCodes[$TaxAuthID] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (-$TaxAmount/$_SESSION['CurrencyRate']) . "')"; + '" . filter_number_format(-$TaxAmount/$_SESSION['CurrencyRate']) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The tax GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the GLTrans record was used'); Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2011-09-10 04:52:21 UTC (rev 4684) +++ trunk/CounterSales.php 2011-09-11 04:06:48 UTC (rev 4685) @@ -33,10 +33,10 @@ unset($_POST['PartSearch']); } -if (isset($_POST['OrderItems'])){ - foreach ($_POST as $key => $value) { - if (mb_strstr($key,'itm')) { - $NewItemArray[mb_substr($key,3)] = trim($value); +if (isset($_POST['SelectingOrderItems'])){ + foreach ($_POST as $FormVariable => $Quantity) { + if (mb_strpos($FormVariable,'OrderQty')!==false) { + $NewItemArray[$_POST['StockID' . mb_substr($FormVariable,8)]] = filter_number_format(trim($Quantity)); } } } @@ -66,11 +66,11 @@ $_SESSION['PrintedPackingSlip'] = 0; /*Of course 'cos the order ain't even started !!*/ /*Get the default customer-branch combo from the user's default location record */ $sql = "SELECT cashsalecustomer, - cashsalebranch, - locationname, - taxprovinceid - FROM locations - WHERE loccode='" . $_SESSION['UserStockLocation'] ."'"; + cashsalebranch, + locationname, + taxprovinceid + FROM locations + WHERE loccode='" . $_SESSION['UserStockLocation'] ."'"; $result = DB_query($sql,$db); if (DB_num_rows($result)==0) { prnMsg(_('Your user account does not have a valid default inventory location set up. Please see the system administrator to modify your user account.'),'error'); @@ -149,13 +149,13 @@ FROM custbranch WHERE custbranch.branchcode='" . $_SESSION['Items'.$identifier]->Branch . "' AND custbranch.debtorno = '" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; - $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('cannot be retrieved because'); + $ErrMsg = _('The customer branch record of the customer selected') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('cannot be retrieved because'); $DbgMsg = _('SQL used to retrieve the branch details was') . ':'; $result =DB_query($sql,$db,$ErrMsg,$DbgMsg); if (DB_num_rows($result)==0){ - prnMsg(_('The branch details for branch code') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('against customer code') . ': ' . $_POST['Select'] . ' ' . _('could not be retrieved') . '. ' . _('Check the set up of the customer and branch'),'error'); + prnMsg(_('The branch details for branch code') . ': ' . $_SESSION['Items'.$identifier]->Branch . ' ' . _('against customer code') . ': ' . $_SESSION['Items'.$identifier]->DebtorNo . ' ' . _('could not be retrieved') . '. ' . _('Check the set up of the customer and branch'),'error'); if ($debug==1){ echo '<br />' . _('The SQL that failed to get the branch details was') . ':<br />' . $sql; @@ -179,13 +179,15 @@ prnMsg($_SESSION['Items'.$identifier]->SpecialInstructions,'warn'); } - if ($_SESSION['CheckCreditLimits'] > 0) { /*Check credit limits is 1 for warn and 2 for prohibit sales */ + if ($_SESSION['CheckCreditLimits'] > 0 AND $AlreadyWarnedAboutCredit==false) { /*Check credit limits is 1 for warn and 2 for prohibit sales */ $_SESSION['Items'.$identifier]->CreditAvailable = GetCreditAvailable($_SESSION['Items'.$identifier]->DebtorNo,$db); if ($_SESSION['CheckCreditLimits']==1 AND $_SESSION['Items'.$identifier]->CreditAvailable <=0){ prnMsg(_('The') . ' ' . $myrow['brname'] . ' ' . _('account is currently at or over their credit limit'),'warn'); + $AlreadyWarnedAboutCredit = true; } elseif ($_SESSION['CheckCreditLimits']==2 AND $_SESSION['Items'.$identifier]->CreditAvailable <=0){ prnMsg(_('No more orders can be placed by') . ' ' . $myrow[0] . ' ' . _(' their account is currently at or over their credit limit'),'warn'); + $AlreadyWarnedAboutCredit = true; include('includes/footer.inc'); exit; } @@ -375,7 +377,7 @@ /*Process Quick Entry */ /* If enter is pressed on the quick entry screen, the default button may be Recalculate */ - if (isset($_POST['OrderItems']) + if (isset($_POST['SelectingOrderItems']) OR isset($_POST['QuickEntry']) OR isset($_POST['Recalculate'])){ @@ -383,7 +385,7 @@ /*Discount can only be set later on -- after quick entry -- so default discount to 0 in the first place */ $Discount = 0; - + $AlreadyWarnedAboutCredit = false; $i=1; while ($i<=$_SESSION['QuickEntries'] AND isset($_POST['part_' . $i]) @@ -400,7 +402,7 @@ $NewItem = mb_strtoupper($_POST[$QuickEntryCode]); } if (isset($_POST[$QuickEntryQty])) { - $NewItemQty = $_POST[$QuickEntryQty]; + $NewItemQty = filter_number_format($_POST[$QuickEntryQty]); } if (isset($_POST[$QuickEntryItemDue])) { $NewItemDue = $_POST[$QuickEntryItemDue]; @@ -477,23 +479,23 @@ if (isset($_GET['Delete'])){ $_SESSION['Items'.$identifier]->remove_from_cart($_GET['Delete']); /*Don't do any DB updates*/ } - + $AlreadyWarnedAboutCredit = false; foreach ($_SESSION['Items'.$identifier]->LineItems as $OrderLine) { if (isset($_POST['Quantity_' . $OrderLine->LineNumber])){ - $Quantity = $_POST['Quantity_' . $OrderLine->LineNumber]; + $Quantity = filter_number_format($_POST['Quantity_' . $OrderLine->LineNumber]); - if (abs($OrderLine->Price - $_POST['Price_' . $OrderLine->LineNumber])>0.01){ - $Price = $_POST['Price_' . $OrderLine->LineNumber]; - $_POST['GPPercent_' . $OrderLine->LineNumber] = (($Price*(1-($_POST['Discount_' . $OrderLine->LineNumber]/100))) - $OrderLine->StandardCost*$ExRate)/($Price *(1-$_POST['Discount_' . $OrderLine->LineNumber])/100); - } else if (abs($OrderLine->GPPercent - $_POST['GPPercent_' . $OrderLine->LineNumber])>=0.001) { + if (abs($OrderLine->Price - filter_number_format($_POST['Price_' . $OrderLine->LineNumber]))>0.01){ + $Price = filter_number_format($_POST['Price_' . $OrderLine->LineNumber]); + $_POST['GPPercent_' . $OrderLine->LineNumber] = (($Price*(1-(filter_number_format($_POST['Discount_' . $OrderLine->LineNumber])/100))) - $OrderLine->StandardCost*$ExRate)/($Price *(1-filter_number_format($_POST['Discount_' . $OrderLine->LineNumber]))/100); + } else if (abs($OrderLine->GPPercent - filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber]))>=0.001) { //then do a recalculation of the price at this new GP Percentage - $Price = ($OrderLine->StandardCost*$ExRate)/(1 -(($_POST['GPPercent_' . $OrderLine->LineNumber] + $_POST['Discount_' . $OrderLine->LineNumber])/100)); + $Price = ($OrderLine->StandardCost*$ExRate)/(1 -((filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber]) + filter_number_format($_POST['Discount_' . $OrderLine->LineNumber]))/100)); } else { - $Price = $_POST['Price_' . $OrderLine->LineNumber]; + $Price = filter_number_format($_POST['Price_' . $OrderLine->LineNumber]); } - $DiscountPercentage = $_POST['Discount_' . $OrderLine->LineNumber]; + $DiscountPercentage = filter_number_format($_POST['Discount_' . $OrderLine->LineNumber]); if ($_SESSION['AllowOrderLineItemNarrative'] == 1) { $Narrative = $_POST['Narrative_' . $OrderLine->LineNumber]; } else { @@ -514,14 +516,14 @@ or $OrderLine->POLine != $_POST['POLine_' . $OrderLine->LineNumber]) { $_SESSION['Items'.$identifier]->update_cart_item($OrderLine->LineNumber, - $Quantity, - $Price, - ($DiscountPercentage/100), - $Narrative, - 'Yes', /*Update DB */ - $_POST['ItemDue_' . $OrderLine->LineNumber], - $_POST['POLine_' . $OrderLine->LineNumber], - $_POST['GPPercent_' . $OrderLine->LineNumber]); + $Quantity, + $Price, + ($DiscountPercentage/100), + $Narrative, + 'Yes', /*Update DB */ + $_POST['ItemDue_' . $OrderLine->LineNumber], + $_POST['POLine_' . $OrderLine->LineNumber], + filter_number_format($_POST['GPPercent_' . $OrderLine->LineNumber])); } } //page not called from itself - POST variables not set } @@ -574,6 +576,8 @@ Now figure out if the item is a kit set - the field MBFlag='K' * controlled items and ghost/phantom items cannot be selected because the SQL to show items to select doesn't show 'em * */ + $AlreadyWarnedAboutCredit = false; + $sql = "SELECT stockmaster.mbflag, stockmaster.taxcatid FROM stockmaster @@ -620,9 +624,11 @@ } /*end of if its a new item */ -if (isset($NewItemArray) and isset($_POST['OrderItems'])){ +if (isset($NewItemArray) AND isset($_POST['SelectingOrderItems'])){ /* get the item details from the database and hold them in the cart object make the quantity 1 by default then add it to the cart */ /*Now figure out if the item is a kit set - the field MBFlag='K'*/ + $AlreadyWarnedAboutCredit = false; + foreach($NewItemArray as $NewItem => $NewItemQty) { if($NewItemQty > 0) { $sql = "SELECT stockmaster.mbflag @@ -772,7 +778,7 @@ echo '<td><input class="number" type="text" name="Price_' . $OrderLine->LineNumber . '" size="16" maxlength="16" value="' . $OrderLine->Price . '" /></td> <td><input class="number" type="text" name="Discount_' . $OrderLine->LineNumber . '" size="5" maxlength="4" value="' . ($OrderLine->DiscountPercent * 100) . '" /></td> <td><input class="number" type="text" name="GPPercent_' . $OrderLine->LineNumber . '" size="3" maxlength="40" value="' . $OrderLine->GPPercent . '" /></td>'; - echo '<td class="number">' . locale_number_format($SubTotal,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; + echo '<td class="number">' . locale_money_format($SubTotal,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; $LineDueDate = $OrderLine->ItemDue; if (!Is_Date($OrderLine->ItemDue)){ $LineDueDate = DateAdd (Date($_SESSION['DefaultDateFormat']),'d', $_SESSION['Items'.$identifier]->DeliveryDays); @@ -798,8 +804,8 @@ $TaxTotal += $TaxLineTotal; $_SESSION['Items'.$identifier]->TaxTotals=$TaxTotals; $_SESSION['Items'.$identifier]->TaxGLCodes=$TaxGLCodes; - echo '<td class="number">' . locale_number_format($TaxLineTotal ,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; - echo '<td class="number">' . locale_number_format($SubTotal + $TaxLineTotal ,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; + echo '<td class="number">' . locale_money_format($TaxLineTotal ,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; + echo '<td class="number">' . locale_money_format($SubTotal + $TaxLineTotal ,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td>'; echo '<td><a href="' . $_SERVER['PHP_SELF'] . '?identifier='.$identifier . '&Delete=' . $OrderLine->LineNumber . '" onclick="return confirm(\'' . _('Are You Sure?') . '\');">' . _('Delete') . '</a></td></tr>'; if ($_SESSION['AllowOrderLineItemNarrative'] == 1){ @@ -816,9 +822,9 @@ } /* end of loop around items */ echo '<tr class="EvenTableRows"><td colspan="8" class="number"><b>' . _('Total') . '</b></td> - <td class="number">' . locale_number_format(($_SESSION['Items'.$identifier]->total),$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> - <td class="number">' . locale_number_format($TaxTotal,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> - <td class="number">' . locale_number_format(($_SESSION['Items'.$identifier]->total+$TaxTotal),$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> + <td class="number">' . locale_money_format(($_SESSION['Items'.$identifier]->total),$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> + <td class="number">' . locale_money_format($TaxTotal,$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> + <td class="number">' . locale_money_format(($_SESSION['Items'.$identifier]->total+$TaxTotal),$_SESSION['Items'.$identifier]->CurrDecimalPlaces) . '</td> </tr> </table>'; echo '<input type="hidden" name="TaxTotal" value="'.$TaxTotal.'" />'; @@ -851,7 +857,7 @@ echo '<tr><td>' . _('Payment Type') . ':</td><td><select name="PaymentMethod">'; while ($PaymentMethodRow = DB_fetch_array($PaymentMethodsResult)){ - if (isset($_POST['PaymentMethod']) and $_POST['PaymentMethod'] == $PaymentMethodRow['paymentid']){ + if (isset($_POST['PaymentMethod']) AND $_POST['PaymentMethod'] == $PaymentMethodRow['paymentid']){ echo '<option selected="True" value="' . $PaymentMethodRow['paymentid'] . '">' . $PaymentMethodRow['paymentname'] . '</option>'; } else { echo '<option value="' . $PaymentMethodRow['paymentid'] . '">' . $PaymentMethodRow['paymentname'] . '</option>'; @@ -863,7 +869,7 @@ echo '<tr><td>' . _('Banked to') . ':</td><td><select name="BankAccount">'; while ($BankAccountsRow = DB_fetch_array($BankAccountsResult)){ - if (isset($_POST['BankAccount']) and $_POST['BankAccount'] == $BankAccountsRow['accountcode']){ + if (isset($_POST['BankAccount']) AND $_POST['BankAccount'] == $BankAccountsRow['accountcode']){ echo '<option selected="True" value="' . $BankAccountsRow['accountcode'] . '">' . $BankAccountsRow['bankaccountname'] . '</option>'; } else { echo '<option value="' . $BankAccountsRow['accountcode'] . '">' . $BankAccountsRow['bankaccountname'] . '</option>'; @@ -874,7 +880,7 @@ if (!isset($_POST['AmountPaid'])){ $_POST['AmountPaid'] =0; } - echo '<tr><td>' . _('Amount Paid') . ':</td><td><input type="text" class="number" name="AmountPaid" maxlength="12" size="12" value="' . $_POST['AmountPaid'] . '" /></td></tr>'; + echo '<tr><td>' . _('Amount Paid') . ':</td><td><input type="text" class="number" name="AmountPaid" maxlength="12" size="12" value="' . filter_number_format($_POST['AmountPaid']) . '" /></td></tr>'; echo '</table>'; //end the sub table in the second column of master table echo '</th></tr></table>'; //end of column/row/master table @@ -887,7 +893,7 @@ * Invoice Processing Here * ********************************** * */ -if (isset($_POST['ProcessSale']) and $_POST['ProcessSale'] != ''){ +if (isset($_POST['ProcessSale']) AND $_POST['ProcessSale'] != ''){ $InputError = false; //always assume the best //but check for the worst @@ -895,7 +901,7 @@ prnMsg(_('There are no lines on this sale. Please enter lines to invoice first'),'error'); $InputError = true; } - if (abs($_POST['AmountPaid'] -($_SESSION['Items'.$identifier]->total+$_POST['TaxTotal']))>=0.01) { + if (abs(filter_number_format($_POST['AmountPaid']) -($_SESSION['Items'.$identifier]->total+filter_number_format($_POST['TaxTotal'])))>=0.01) { prnMsg(_('The amount entered as payment does not equal the amount of the invoice. Please ensure the customer has paid the correct amount and re-enter'),'error'); $InputError = true; } @@ -1234,23 +1240,22 @@ /*Now insert the DebtorTrans */ - $SQL = "INSERT INTO debtortrans ( - transno, - type, - debtorno, - branchcode, - trandate, - inputdate, - prd, - reference, - tpe, - order_, - ovamount, - ovgst, - rate, - invtext, - shipvia, - alloc ) + $SQL = "INSERT INTO debtortrans (transno, + type, + debtorno, + branchcode, + trandate, + inputdate, + prd, + reference, + tpe, + order_, + ovamount, + ovgst, + rate, + invtext, + shipvia, + alloc ) VALUES ( '". $InvoiceNo . "', 10, @@ -1259,15 +1264,15 @@ '" . $DefaultDispatchDate . "', '" . date('Y-m-d H-i-s') . "', '" . $PeriodNo . "', - '" . $_SESSION['Items'.$identifier]->CustRef . "', + '" . DB_escape_string($_SESSION['Items'.$identifier]->CustRef) . "', '" . $_SESSION['Items'.$identifier]->DefaultSalesType . "', '" . $OrderNo . "', '" . $_SESSION['Items'.$identifier]->total . "', - '" . $_POST['TaxTotal'] . "', + '" . filter_number_format($_POST['TaxTotal']) . "', '" . $ExRate . "', - '" . $_SESSION['Items'.$identifier]->Comments . "', + '" . DB_escape_string($_SESSION['Items'.$identifier]->Comments) . "', '" . $_SESSION['Items'.$identifier]->ShipVia . "', - '" . ($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal']) . "')"; + '" . ($_SESSION['Items'.$identifier]->total + filter_number_format($_POST['TaxTotal'])) . "')"; $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The debtor transaction record could not be inserted because'); $DbgMsg = _('The following SQL to insert the debtor transaction record was used'); @@ -1752,7 +1757,7 @@ if ($_SESSION['CompanyRecord']['gllink_debtors']==1){ /*Post debtors transaction to GL debit debtors, credit freight re-charged and credit sales */ - if (($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal']) !=0) { + if (($_SESSION['Items'.$identifier]->total + filter_number_format($_POST['TaxTotal'])) !=0) { $SQL = "INSERT INTO gltrans ( type, typeno, trandate, @@ -1766,7 +1771,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['debtorsact'] . "', '" . $_SESSION['Items'.$identifier]->DebtorNo . "', - '" . (($_SESSION['Items'.$identifier]->total + $_POST['TaxTotal'])/$ExRate) . "')"; + '" . (($_SESSION['Items'.$identifier]->total + filter_number_format($_POST['TaxTotal']))/$ExRate) . "')"; $ErrMsg = _('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The total debtor GL posting could not be inserted because'); $DbgMsg = _('The following SQL to insert the total debtors control GLTrans record was used'); @@ -1802,19 +1807,19 @@ if ($_POST['AmountPaid']!=0){ $ReceiptNumber = GetNextTransNo(12,$db); $SQL="INSERT INTO gltrans (type, - typeno, - trandate, - periodno, - account, - narrative, - amount) - VALUES (12, - '" . $ReceiptNumber . "', - '" . $DefaultDispatchDate . "', - '" . $PeriodNo . "', - '" . $_POST['BankAccount'] . "', - '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', - '" . ($_POST['AmountPaid']/$ExRate) . "')"; + typeno, + trandate, + periodno, + account, + narrative, + amount) + VALUES (12, + '" . $ReceiptNumber . "', + '" . $DefaultDispatchDate . "', + '" . $PeriodNo . "', + '" . $_POST['BankAccount'] . "', + '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', + '" . (filter_number_format($_POST['AmountPaid'])/$ExRate) . "')"; $DbgMsg = _('The SQL that failed to insert the GL transaction for the bank account debit was'); $ErrMsg = _('Cannot insert a GL transaction for the bank account debit'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -1833,7 +1838,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['debtorsact'] . "', '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') . ' ' . $InvoiceNo . "', - '" . -($_POST['AmountPaid']/$ExRate) . "')"; + '" . -(filter_number_format($_POST['AmountPaid'])/$ExRate) . "')"; $DbgMsg = _('The SQL that failed to insert the GL transaction for the debtors account credit was'); $ErrMsg = _('Cannot insert a GL transaction for the debtors account credit'); $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); @@ -1846,8 +1851,9 @@ //Now need to add the receipt banktrans record //First get the account currency that it has been banked into $result = DB_query("SELECT rate FROM currencies - INNER JOIN bankaccounts ON currencies.currabrev=bankaccounts.currcode - WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); + INNER JOIN bankaccounts + ON currencies.currabrev=bankaccounts.currcode + WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'",$db); $myrow = DB_fetch_row($result); $BankAccountExRate = $myrow[0]; @@ -1883,7 +1889,7 @@ '" . $BankAccountExRate . "', '" . $DefaultDispatchDate . "', '" . $_POST['PaymentMethod'] . "', - '" . ($_POST['AmountPaid'] * $BankAccountExRate) . "', + '" . (filter_number_format($_POST['AmountPaid']) * $BankAccountExRate) . "', '" . $_SESSION['Items'.$identifier]->DefaultCurrency . "')"; $DbgMsg = _('The SQL that failed to insert the bank account transaction was'); @@ -1911,8 +1917,8 @@ '" . $PeriodNo . "', '" . $InvoiceNo . "', '" . $ExRate . "', - '" . -$_POST['AmountPaid'] . "', - '" . -$_POST['AmountPaid'] . "', + '" . -filter_number_format($_POST['AmountPaid']) . "', + '" . -filter_number_format($_POST['AmountPaid']) . "', '" . $_SESSION['Items'.$identifier]->LocationName . ' ' . _('Counter Sale') ."')"; $DbgMsg = _('The SQL that failed to insert the customer receipt transaction was'); @@ -1922,7 +1928,7 @@ $ReceiptDebtorTransID = DB_Last_Insert_ID($db,'debtortrans','id'); $SQL = "UPDATE debtorsmaster SET lastpaiddate = '" . $DefaultDispatchDate . "', - lastpaid='" . $_POST['AmountPaid'] . "' + lastpaid='" . filter_number_format($_POST['AmountPaid']) . "' WHERE debtorsmaster.debtorno='" . $_SESSION['Items'.$identifier]->DebtorNo . "'"; $DbgMsg = _('The SQL that failed to update the date of the last payment received was'); @@ -1935,7 +1941,7 @@ datealloc, transid_allocfrom, transid_allocto ) - VALUES ('" . $_POST['AmountPaid'] . "', + VALUES ('" . filter_number_format($_POST['AmountPaid']) . "', '" . $DefaultDispatchDate . "', '" . $ReceiptDebtorTransID . "', '" . $DebtorTransID . "')"; @@ -1974,7 +1980,6 @@ * ***************************** */ - /* Now show the stock item selection search stuff below */ if (!isset($_POST['ProcessSale'])){ if (isset($_POST['PartSearch']) and $_POST['PartSearch']!=''){ @@ -2012,6 +2017,7 @@ <th>' . _('Available') . '</th> <th>' . _('Quantity') . '</th></tr>'; echo $TableHeader; + $i = 0; $j = 1; $k=0; //row colour counter @@ -2096,7 +2102,7 @@ <td style="text-align:center">%s</td> <td style="text-align:center">%s</td> <td style="text-align:center">%s</td> - <td><font size=1><input class="number" tabindex="'.strval($j+7).'" type="textbox" size="6" name="itm%s" value="0" /> + <td><font size=1><input class="number" tabindex="'.strval($j+7).'" type="textbox" size="6" name="OrderQty%s" value="0" /><input type="hidden" name="StockID%s" value="%s" /> </td> </tr>', $myrow['stockid'], @@ -2106,15 +2112,18 @@ $DemandQty, $OnOrder, $Available, + $i, + $i, $myrow['stockid']); if ($j==1) { - $jsCall = '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.itm'.$myrow['stockid'].');}</script>'; + $jsCall = '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.OrderQty'.$i.');}</script>'; } - $j++; + $j++;//counter for paging + $i++;//index for controls #end of page full new headings if } #end of while loop for Frequently Ordered Items - echo '<td style="text-align:center" colspan="8"><input type="hidden" name="OrderItems" value="1" /><input tabindex='.strval($j+8).' type="submit" value="'._('Add to Sale').'" /></td>'; + echo '<td style="text-align:center" colspan="8"><input type="hidden" name="SelectingOrderItems" value="1" /><input tabindex='.strval($j+8).' type="submit" value="'._('Add to Sale').'" /></td>'; echo '</table>'; } //end of if Frequently Ordered Items > 0 if (isset($msg)){ @@ -2178,7 +2187,7 @@ echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; echo '<table class="table1">'; echo '<tr><td><input type="hidden" name="previous" value="'.strval($Offset-1).'" /><input tabindex="'.strval($j+7).'" type="submit" name="Prev" value="'._('Prev').'" /></td>'; - echo '<td style="text-align:center" colspan="6"><input type="hidden" name="OrderItems" value="1" /><input tabindex="'.strval($j+8).'" type="submit" value="'._('Add to Sale').'" /></td>'; + echo '<td style="text-align:center" colspan="6"><input type="hidden" name="SelectingOrderItems" value="1" /><input tabindex="'.strval($j+8).'" type="submit" value="'._('Add to Sale').'" /></td>'; echo '<td><input type="hidden" name="NextList" value="'.strval($Offset+1).'" /><input tabindex="'.strval($j+9).'" type="submit" name="Next" value="'._('Next').'" /></td></tr>'; $TableHeader = '<tr><th>' . _('Code') . '</th> <th>' . _('Description') . '</th> @@ -2189,7 +2198,7 @@ <th>' . _('Available') . '</th> <th>' . _('Quantity') . '</th></tr>'; echo $TableHeader; - + $i=0; $k=0; //row colour counter while ($myrow=DB_fetch_array($SearchResult)) { @@ -2272,7 +2281,7 @@ <td class="number">%s</td> <td class="number">%s</td> <td class="number">%s</td> - <td><font size="1"><input class="number" tabindex="'.strval($j+7).'" type="textbox" size="6" name="itm%s" value="0" /></font></td> + <td><font size="1"><input class="number" tabindex="'.strval($j+7).'" type="textbox" size="6" name="OrderQty%s" value="0" /></font><input type="hidden" name="StockID%s" value="%s" /></td> </tr>', $myrow['stockid'], $myrow['description'], @@ -2281,6 +2290,8 @@ locale_number_format($DemandQty, $myrow['decimalplaces']), locale_number_format($OnOrder, $myrow['decimalplaces']), locale_number_format($Available, $myrow['decimalplaces']), + $i, + $i, $myrow['stockid']); if ($j==1) { $jsCall = '<script type="text/javascript">if (document.SelectParts) {defaultControl(document.SelectParts.itm'.$myrow['stockid'].');}</script>'; @@ -2296,7 +2307,7 @@ echo '<input type="hidden" name="Email" value="'.$_SESSION['Items'.$identifier]->Email.'" />'; echo '<tr><td><input type="hidden" name="previous" value="'.strval($Offset-1).'" /><input tabindex="'.strval($j+7).'" type="submit" name="Prev" value="'._('Prev').'" /></td>'; - echo '<td style="text-align:center" colspan="6"><input type="hidden" name="OrderItems" value="1" /><input tabindex="'.strval($j+8).'" type="submit" value="'._('Add to Sale').'" /></td>'; + echo '<td style="text-align:center" colspan="6"><input type="hidden" name="SelectingOrderItems" value="1" /><input tabindex="'.strval($j+8).'" type="submit" value="'._('Add to Sale').'" /></td>'; echo '<td><input type="hidden" name="NextList" value="'.strval($Offset+1).'" /><input tabindex="'.strval($j+9).'" type="submit" name="Next" value="'._('Next').'" /></td></tr>'; echo '</table></form>'; echo $jsCall; Modified: trunk/Credit_Invoice.php =================================================================== --- trunk/Credit_Invoice.php 2011-09-10 04:52:21 UTC (rev 4684) +++ trunk/Credit_Invoice.php 2011-09-11 04:06:48 UTC (rev 4685) @@ -208,12 +208,12 @@ } } if (isset($_POST['ChargeFreightCost'])){ - $_SESSION['CreditItems']->FreightCost = $_POST['ChargeFreightCost']; + $_SESSION['CreditItems']->FreightCost = filter_number_format($_POST['ChargeFreightCost']); } foreach ($_SESSION['CreditItems']->FreightTaxes as $FreightTaxLine) { if (isset($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder])){ - $_SESSION['CreditItems']->FreightTaxes[$FreightTaxLine->TaxCalculationOrder]->TaxRate = $_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder]/100; + $_SESSION['CreditItems']->FreightTaxes[$FreightTaxLine->TaxCalculationOrder]->TaxRate = filter_number_format($_POST['FreightTaxRate' . $FreightTaxLine->TaxCalculationOrder])/100; } } @@ -228,9 +228,9 @@ if (isset($_POST['Quantity_' . $LineItem->LineNumber])){ $Narrative = $_POST['Narrative_' . $LineItem->LineNumber]; - $Quantity = $_POST['Quantity_' . $LineItem->LineNumber]; - $Price = $_POST['Price_' . $LineItem->LineNumber]; - $DiscountPercentage = $_POST['Discount_' . $LineItem->LineNumber]; + $Quantity = filter_number_format($_POST['Quantity_' . $LineItem->LineNumber]); + $Price = filter_number_format($_POST['Price_' . $LineItem->LineNumber]); + $DiscountPercentage = filter_number_format($_POST['Discount_' . $LineItem->LineNumber]); If ($Quantity<0 OR $Price <0 OR $DiscountPercentage >100 OR $DiscountPercentage <0){ prnMsg(_('The item could not be updated because you are attempting to set the quantity credited to less than 0 or the price less than 0 or the discount more than 100% or less than 0%'),'error'); @@ -242,7 +242,7 @@ } foreach ($LineItem->Taxes as $TaxLine) { if (isset($_POST[$LineItem->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])){ - $_SESSION['CreditItems']->LineItems[$LineItem->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = $_POST[$LineItem->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate']/100; + $_SESSION['CreditItems']->LineItems[$LineItem->LineNumber]->Taxes[$TaxLine->TaxCalculationOrder]->TaxRate = filter_number_format($_POST[$LineItem->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])/100; } } } @@ -293,11 +293,11 @@ $j=0; //row counter foreach ($_SESSION['CreditItems']->LineItems as $LnItm) { - $LineTotal =($LnItm->QtyDispatched * $LnItm->Price * (1 - $LnItm->DiscountPercent)); + $LineTotal =(filter_number_format($LnItm->QtyDispatched) * filter_number_format($LnItm->Price) * (1 - filter_number_format($LnItm->DiscountPercent))); if (!isset($_POST['ProcessCredit'])) { - $_SESSION['CreditItems']->total = $_SESSION['CreditItems']->total + $LineTotal; - $_SESSION['CreditItems']->totalVolume = $_SESSION['CreditItems']->totalVolume + $LnItm->QtyDispatched * $LnItm->Volume; - $_SESSION['CreditItems']->totalWeight = $_SESSION['CreditItems']->totalWeight + $LnItm->QtyDispatched * $LnItm->Weight; + $_SESSION['CreditItems']->total += $LineTotal; + $_SESSION['CreditItems']->totalVolume += (filter_number_format($LnItm->QtyDispatched) * filter_number_format($LnItm->Volume)); + $_SESSION['CreditItems']->totalWeight += (filter_number_format($LnItm->QtyDispatched) * filter_number_format($LnItm->Weight)); if ($k==1){ $RowStarter = 'class="EvenTableRows"'; @@ -310,7 +310,7 @@ echo '<tr '.$RowStarter.'><td>' . $LnItm->StockID . '</td> <td>' . $LnItm->ItemDescription . '</td> - <td class=number>' . locale_number_format($LnItm->Quantity,$LnItm->DecimalPlaces) . '</td> + <td class="number">' . locale_number_format($LnItm->Quantity,$LnItm->DecimalPlaces) . '</td> <td>' . $LnItm->Units . '</td>'; if ($LnItm->Controlled==1){ @@ -323,12 +323,12 @@ } - $DisplayLineTotal = locale_number_format($LineTotal,$_SESSION['CreditItems']->CurrDecimalPlaces); + $DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['CreditItems']->CurrDecimalPlaces); $j++; - echo '<td><input tabindex=' . $j . ' type="text" class=number name="Price_' . $LnItm->LineNumber . '" maxlength=12 size=6 value=' . $LnItm->Price . '></td> + echo '<td><input tabindex=' . $j . ' type="text" class="number" name="Price_' . $LnItm->LineNumber . '" maxlength=12 size=... [truncated message content] |