From: <dai...@us...> - 2011-09-14 08:06:54
|
Revision: 4689 http://web-erp.svn.sourceforge.net/web-erp/?rev=4689&view=rev Author: daintree Date: 2011-09-14 08:06:45 +0000 (Wed, 14 Sep 2011) Log Message: ----------- number_formatting Modified Paths: -------------- trunk/BankReconciliation.php trunk/PDFGrn.php trunk/PDFOrdersInvoiced.php trunk/PDFPeriodStockTransListing.php trunk/PDFPickingList.php trunk/PDFPriceList.php trunk/PDFPrintLabel.php trunk/PDFQuotation.php trunk/PDFQuotationPortrait.php trunk/PDFReceipt.php trunk/PDFRemittanceAdvice.php trunk/PDFStockCheckComparison.php trunk/PDFStockLocTransfer.php trunk/SelectOrderItems.php trunk/StockTransfers.php trunk/includes/GLPostings.inc trunk/includes/LanguageSetup.php trunk/includes/SQL_CommonFunctions.inc trunk/includes/SelectOrderItems_IntoCart.inc Modified: trunk/BankReconciliation.php =================================================================== --- trunk/BankReconciliation.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/BankReconciliation.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -19,27 +19,26 @@ if (isset($_POST['PostExchangeDifference']) and is_numeric($_POST['DoExchangeDifference'])){ - if (!is_numeric($_POST['BankStatementBalance'])){ + if (!is_numeric(filter_number_format($_POST['BankStatementBalance']))){ prnMsg(_('The entry in the bank statement balance is not numeric. The balance on the bank statement should be entered. The exchange difference has not been calculated and no general ledger journal has been created'),'warn'); echo '<p>' . $_POST['BankStatementBalance']; } else { + $_POST['BankStatementBalance'] = filter_number_format($_POST['BankStatementBalance']); /* Now need to get the currency of the account and the current table ex rate */ $SQL = "SELECT rate, bankaccountname, - decimalplaces + decimalplaces AS currdecimalplaces FROM bankaccounts INNER JOIN currencies ON bankaccounts.currcode=currencies.currabrev WHERE bankaccounts.accountcode = '" . $_POST['BankAccount']."'"; $ErrMsg = _('Could not retrieve the exchange rate for the selected bank account'); $CurrencyResult = DB_query($SQL,$db); - $CurrencyRow = DB_fetch_row($CurrencyResult); - $ExRate = $CurrencyRow[0]; - $BankAccountName = $CurrencyRow[1]; - $CurrDecimalPlaces = $CurrencyRow[2]; - $CalculatedBalance = $_POST['DoExchangeDifference']; + $CurrencyRow = DB_fetch_array($CurrencyResult); + + $CalculatedBalance = filter_number_format($_POST['DoExchangeDifference']); - $ExchangeDifference = ($CalculatedBalance - $_POST['BankStatementBalance'])/$ExRate; + $ExchangeDifference = filter_number_format(($CalculatedBalance - $_POST['BankStatementBalance'])/$CurrencyRow['rate']); include ('includes/SQL_CommonFunctions.inc'); $ExDiffTransNo = GetNextTransNo(36,$db); @@ -62,7 +61,7 @@ '" . FormatDateForSQL($PostingDate) . "', '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['exchangediffact'] . "', - '" . $BankAccountName . ' ' . _('reconciliation on') . " " . + '" . $CurrencyRow['bankaccountname'] . ' ' . _('reconciliation on') . " " . Date($_SESSION['DefaultDateFormat']) . "','" . $ExchangeDifference . "')"; $ErrMsg = _('Cannot insert a GL entry for the exchange difference because'); @@ -80,13 +79,13 @@ '" . FormatDateForSQL($PostingDate) . "', '" . $PeriodNo . "', '" . $_POST['BankAccount'] . "', - '" . $BankAccountName . ' ' . _('reconciliation on') . ' ' . Date($_SESSION['DefaultDateFormat']) . "', + '" . $CurrencyRow['bankaccountname'] . ' ' . _('reconciliation on') . ' ' . Date($_SESSION['DefaultDateFormat']) . "', '" . (-$ExchangeDifference) . "')"; $result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); $result = DB_Txn_Commit($db); - prnMsg(_('Exchange difference of') . ' ' . locale_number_format($ExchangeDifference,2) . ' ' . _('has been posted'),'success'); + prnMsg(_('Exchange difference of') . ' ' . locale_money_format($ExchangeDifference,$_SESSION['CompanyRecord']['decimalplaces']) . ' ' . _('has been posted'),'success'); } //end if the bank statement balance was numeric } @@ -153,25 +152,24 @@ /* Now need to get the currency of the account and the current table ex rate */ $SQL = "SELECT rate, bankaccounts.currcode, - bankaccounts.bankaccountname + bankaccounts.bankaccountname, + currencies.decimalplaces AS currdecimalplaces FROM bankaccounts INNER JOIN currencies ON bankaccounts.currcode=currencies.currabrev WHERE bankaccounts.accountcode = '" . $_POST['BankAccount']."'"; $ErrMsg = _('Could not retrieve the currency and exchange rate for the selected bank account'); $CurrencyResult = DB_query($SQL,$db); - $CurrencyRow = DB_fetch_row($CurrencyResult); - $ExRate = $CurrencyRow[0]; - $BankCurrCode = $CurrencyRow[1]; - $BankAccountName = $CurrencyRow[2]; + $CurrencyRow = DB_fetch_array($CurrencyResult); + echo '<table class="selection"> - <tr class="EvenTableRows"><td colspan=6><b>' . $BankAccountName . ' ' . _('Balance as at') . ' ' . Date($_SESSION['DefaultDateFormat']); + <tr class="EvenTableRows"><td colspan=6><b>' . $CurrencyRow['bankaccountname'] . ' ' . _('Balance as at') . ' ' . Date($_SESSION['DefaultDateFormat']); - if ($_SESSION['CompanyRecord']['currencydefault']!=$BankCurrCode){ - echo ' (' . $BankCurrCode . ' @ ' . $ExRate .')'; + if ($_SESSION['CompanyRecord']['currencydefault']!=$CurrencyRow['currcode']){ + echo ' (' . $CurrencyRow['currcode'] . ' @ ' . $CurrencyRow['rate'] .')'; } echo '</b></td> - <td valign=bottom class="number"><b>' . locale_number_format($Balance*$ExRate,$CurrDecimalPlaces) . '</b></td></tr>'; + <td valign=bottom class="number"><b>' . locale_money_format($Balance*$CurrencyRow['rate'],$CurrencyRow['currdecimalplaces']) . '</b></td></tr>'; $SQL = "SELECT amount/exrate AS amt, amountcleared, @@ -222,15 +220,15 @@ <td>%s</td> <td>%s</td> <td>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> + <td class="number">%s</td> + <td class="number">%s</td> </tr>', ConvertSQLDate($myrow['transdate']), $myrow['typename'], $myrow['transno'], $myrow['ref'], - locale_number_format($myrow['amt'],$CurrDecimalPlaces), - locale_number_format($myrow['outstanding'],$CurrDecimalPlaces)); + locale_money_format($myrow['amt'],$CurrencyRow['currdecimalplaces']), + locale_money_format($myrow['outstanding'],$CurrencyRow['currdecimalplaces'])); $TotalUnpresentedCheques +=$myrow['outstanding']; @@ -241,20 +239,20 @@ } } //end of while loop + $TotalUnpresentedCheques = filter_number_format($TotalUnpresentedCheques); echo '<tr></tr> - <tr class=EvenTableRows><td colspan=6>' . _('Total of all unpresented cheques') . '</td><td class="number">' . locale_number_format($TotalUnpresentedCheques,$CurrDecimalPlaces) . '</td></tr>'; + <tr class=EvenTableRows><td colspan=6>' . _('Total of all unpresented cheques') . '</td><td class="number">' . locale_money_format($TotalUnpresentedCheques,$CurrencyRow['currdecimalplaces']) . '</td></tr>'; $SQL = "SELECT amount/exrate AS amt, amountcleared, - (amount/exrate)-amountcleared as outstanding, + (amount/exrate)-amountcleared AS outstanding, ref, transdate, systypes.typename, transno - FROM banktrans, - systypes - WHERE banktrans.type = systypes.typeid - AND banktrans.bankact='" . $_POST['BankAccount'] . "' + FROM banktrans INNER JOIN systypes + ON banktrans.type = systypes.typeid + WHERE banktrans.bankact='" . $_POST['BankAccount'] . "' AND amount > 0 AND ABS((amount/exrate)-amountcleared)>0.009 ORDER BY transdate"; @@ -264,7 +262,7 @@ $UPChequesResult = DB_query($SQL,$db,$ErrMsg); - echo '<tr><td colspan=6><b>' . _('Less deposits not cleared') . ':</b></td></tr>'; + echo '<tr><td colspan="6"><b>' . _('Less deposits not cleared') . ':</b></td></tr>'; $TableHeader = '<tr> <th>' . _('Date') . '</th> @@ -294,15 +292,15 @@ <td>%s</td> <td>%s</td> <td>%s</td> - <td class=number>%s</td> - <td class=number>%s</td> + <td class="number">%s</td> + <td class="number">%s</td> </tr>', ConvertSQLDate($myrow['transdate']), $myrow['typename'], $myrow['transno'], $myrow['ref'], - locale_number_format($myrow['amt'],$CurrDecimalPlaces), - locale_number_format($myrow['outstanding'],$CurrDecimalPlaces) ); + locale_money_format($myrow['amt'],$CurrencyRow['currdecimalplaces']), + locale_money_format($myrow['outstanding'],$CurrencyRow['currdecimalplaces']) ); $TotalUnclearedDeposits +=$myrow['outstanding']; @@ -316,25 +314,28 @@ echo '<tr></tr> <tr class=EvenTableRows> <td colspan=6>' . _('Total of all uncleared deposits') . '</td> - <td class=number>' . locale_number_format($TotalUnclearedDeposits,$CurrDecimalPlaces) . '</td> + <td class="number">' . locale_money_format($TotalUnclearedDeposits,$CurrencyRow['currdecimalplaces']) . '</td> </tr>'; - $FXStatementBalance = ($Balance*$ExRate) - $TotalUnpresentedCheques -$TotalUnclearedDeposits; + $FXStatementBalance = filter_number_format(($Balance*$CurrencyRow['rate']) - $TotalUnpresentedCheques -$TotalUnclearedDeposits); echo '<tr></tr> <tr class=EvenTableRows> - <td colspan=6><b>' . _('Bank statement balance should be') . ' (' . $BankCurrCode . ')</b></td> - <td class=number>' . locale_number_format($FXStatementBalance,$CurrDecimalPlaces) . '</td></tr>'; + <td colspan=6><b>' . _('Bank statement balance should be') . ' (' . $CurrencyRow['currcode'] . ')</b></td> + <td class="number">' . locale_money_format($FXStatementBalance,$CurrencyRow['currdecimalplaces']) . '</td></tr>'; if (isset($_POST['DoExchangeDifference'])){ - echo '<input type="hidden" name="DoExchangeDifference" value=' . $FXStatementBalance . '>'; - echo '<tr><td colspan=6>' . _('Enter the actual bank statement balance') . ' (' . $BankCurrCode . ')</b></td> - <td class=number><input type="text" name="BankStatementBalance" maxlength=15 size=15 value=' . $_POST['BankStatementBalance'] . '><td></tr>'; + echo '<input type="hidden" name="DoExchangeDifference" value=' . $FXStatementBalance . ' />'; + if (!isset($_POST['BankStatementBalance'])){ + $_POST['BankStatementBalance'] =0; + } + echo '<tr><td colspan=6>' . _('Enter the actual bank statement balance') . ' (' . $CurrencyRow['currcode'] . ')</b></td> + <td class="number"><input type="text" name="BankStatementBalance" maxlength="15" size="15" value=' . locale_number_format($_POST['BankStatementBalance'],$CurrencyRow['currdecimalplaces']) . ' /><td></tr>'; echo '<tr><td colspan=7 align="center"><input type="submit" name="PostExchangeDifference" value="' . _('Calculate and Post Exchange Difference') . '" onclick="return confirm(\'' . _('This will create a general ledger journal to write off the exchange difference in the current balance of the account. It is important that the exchange rate above reflects the current value of the bank account currency') . ' - ' . _('Are You Sure?') . '\');"></td></tr>'; } - if ($_SESSION['CompanyRecord']['currencydefault']!=$BankCurrCode AND !isset($_POST['DoExchangeDifference'])){ + if ($_SESSION['CompanyRecord']['currencydefault']!=$CurrencyRow['currcode'] AND !isset($_POST['DoExchangeDifference'])){ echo '<tr><td colspan=7><hr></td></tr> <tr><td colspan=7>' . _('It is normal for foreign currency accounts to have exchange differences that need to be reflected as the exchange rate varies. This reconciliation is prepared using the exchange rate set up in the currencies table (see the set-up tab). This table must be maintained with the current exchange rate before running the reconciliation. If you wish to create a journal to reflect the exchange difference based on the current exchange rate to correct the reconciliation to the actual bank statement balance click below.') . '</td></tr>'; Modified: trunk/PDFGrn.php =================================================================== --- trunk/PDFGrn.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFGrn.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -54,12 +54,12 @@ ON grns.podetailitem=purchorderdetails.podetailitem LEFT JOIN stockmaster ON grns.itemcode=stockmaster.stockid - WHERE grnbatch='".$GRNNo."'"; - + WHERE grnbatch='".filter_number_format($GRNNo)."'"; + $GRNResult=DB_query($sql, $db); $NoOfGRNs = DB_num_rows($GRNResult); if($NoOfGRNs>0) { //there are GRNs to print - + $sql = "SELECT suppliers.suppname, suppliers.address1, suppliers.address2 , @@ -69,14 +69,14 @@ suppliers.address6 FROM grns INNER JOIN suppliers ON grns.supplierid=suppliers.supplierid - WHERE grnbatch='".$GRNNo."'"; + WHERE grnbatch='".filter_number_format($GRNNo)."'"; $SuppResult = DB_query($sql,$db,_('Could not get the supplier of the selected GRN')); $SuppRow = DB_fetch_array($SuppResult); } } // get data to print if ($NoOfGRNs >0){ include ('includes/PDFGrnHeader.inc'); //head up the page - + $YPos=$FormDesign->Data->y; for ($i=1;$i<=$NoOfGRNs;$i++) { if ($GRNNo!='Preview'){ @@ -88,13 +88,13 @@ $DecimalPlaces=2; } if (is_numeric($myrow['conversionfactor']) AND $myrow['conversionfactor'] !=0){ - $SuppliersQuantity=locale_number_format($myrow['qtyrecd']/$myrow['conversionfactor'],$DecimalPlaces); + $SuppliersQuantity=locale_number_format(filter_number_format($myrow['qtyrecd']/$myrow['conversionfactor']),$DecimalPlaces); } else { $SuppliersQuantity=locale_number_format($myrow['qtyrecd'],$DecimalPlaces); } $OurUnitsQuantity=locale_number_format($myrow['qtyrecd'],$DecimalPlaces); $DeliveryDate = ConvertSQLDate($myrow['deliverydate']); - + $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column1->x,$Page_Height-$YPos,$FormDesign->Data->Column1->Length,$FormDesign->Data->Column1->FontSize, $myrow['itemcode']); $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column2->x,$Page_Height-$YPos,$FormDesign->Data->Column2->Length,$FormDesign->Data->Column2->FontSize, $myrow['itemdescription']); $LeftOvers = $pdf->addTextWrap($FormDesign->Data->Column3->x,$Page_Height-$YPos,$FormDesign->Data->Column3->Length,$FormDesign->Data->Column3->FontSize, $DeliveryDate); @@ -114,13 +114,13 @@ $LeftOvers = $pdf->addText($FormDesign->ReceiptDate->x,$Page_Height-$FormDesign->ReceiptDate->y,$FormDesign->ReceiptDate->FontSize, _('Date of Receipt: ') . $DeliveryDate); $LeftOvers = $pdf->addText($FormDesign->SignedFor->x,$Page_Height-$FormDesign->SignedFor->y,$FormDesign->SignedFor->FontSize, _('Signed for ').'______________________'); - $pdf->OutputD($_SESSION['DatabaseName'] . '_GRN_' . date('Y-m-d').'.pdf');//UldisN - $pdf->__destruct(); //UldisN + $pdf->OutputD($_SESSION['DatabaseName'] . '_GRN_' . date('Y-m-d').'.pdf'); + $pdf->__destruct(); } else { //there were not GRNs to print $title = _('GRN Error'); include('includes/header.inc'); prnMsg(_('There were no GRNs to print'),'warn'); - echo '<br /><a href="'.$rootpath.'/index.php?' . SID . '">'. _('Back to the menu').'</a>'; + echo '<br /><a href="'.$rootpath.'/index.php">'. _('Back to the menu').'</a>'; include('includes/footer.inc'); } ?> \ No newline at end of file Modified: trunk/PDFOrdersInvoiced.php =================================================================== --- trunk/PDFOrdersInvoiced.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFOrdersInvoiced.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -211,7 +211,7 @@ stockmaster.description, stockmaster.units, stockmaster.decimalplaces"; - + } elseif ($_POST['CategoryID']!='All' AND $_POST['location']!='All'){ $sql= "SELECT salesorders.orderno, @@ -290,7 +290,7 @@ if($OrderNo != $myrow['orderno']){ if ($AccumOrderTotal !=0){ $LeftOvers = $pdf->addTextWrap($Left_Margin+250,$YPos,120,$FontSize,_('Total Invoiced for order') . ' ' . $OrderNo , 'left'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_number_format($AccumOrderTotal,2), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_money_format(filter_number_format($AccumOrderTotal),$_SESSION['CompanyRecord']['decimalplaces']), 'right'); $YPos -= ($line_height); $AccumOrderTotal =0; } @@ -395,12 +395,12 @@ while ($InvRow=DB_fetch_array($InvoicesResult)){ - $ValueInvoiced = $InvRow['price']*$InvRow['quantity']; + $ValueInvoiced = filter_number_format($InvRow['price']*$InvRow['quantity']); $LeftOvers = $pdf->addTextWrap($Left_Margin+150,$YPos,90,$FontSize,$InvRow['typename'] . ' ' . $InvRow['transno'], 'left'); $LeftOvers = $pdf->addTextWrap($Left_Margin+240,$YPos,60,$FontSize,locale_number_format($InvRow['quantity'],$myrow['decimalplaces']), 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+300,$YPos,60,$FontSize,locale_number_format($InvRow['price'],2), 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_number_format($ValueInvoiced,2), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+300,$YPos,60,$FontSize,locale_money_format($InvRow['price'],$_SESSION['CompanyRecord']['decimalplaces']), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_money_format($ValueInvoiced,$_SESSION['CompanyRecord']['decimalplaces']), 'right'); $YPos -= ($line_height); @@ -414,7 +414,6 @@ } - $YPos -= ($line_height); if ($YPos - (2 *$line_height) < $Bottom_Margin){ /*Then set up a new page */ @@ -425,7 +424,7 @@ $YPos -= ($line_height); $LeftOvers = $pdf->addTextWrap($Left_Margin+260,$YPos,100,$FontSize,_('GRAND TOTAL INVOICED'), 'right'); -$LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_number_format($AccumTotalInv,2), 'right'); +$LeftOvers = $pdf->addTextWrap($Left_Margin+360,$YPos,80,$FontSize,locale_money_format(filter_number_format($AccumTotalInv),$_SESSION['CompanyRecord']['decimalplaces']), 'right'); $YPos -= ($line_height); $pdf->OutputD($_SESSION['DatabaseName'] . '_OrdersInvoiced_' . date('Y-m-d') . '.pdf'); Modified: trunk/PDFPeriodStockTransListing.php =================================================================== --- trunk/PDFPeriodStockTransListing.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFPeriodStockTransListing.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -1,207 +1,207 @@ -<?php -/* $Id: PDFPeriodStockTransListing.php 4307 2010-12-22 16:06:03Z tim_schofield $*/ - -include('includes/SQL_CommonFunctions.inc'); -include ('includes/session.inc'); - -$InputError=0; -if (isset($_POST['FromDate']) AND !Is_Date($_POST['FromDate'])){ - $msg = _('The date must be specified in the format') . ' ' . $_SESSION['DefaultDateFormat']; - $InputError=1; - unset($_POST['FromDate']); -} - -if (!isset($_POST['FromDate'])){ - - $title = _('Stock Transaction Listing'); - include ('includes/header.inc'); - - echo '<div class="centre"> - <p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . $title . '" alt="">' . ' '. _('Stock Transaction Listing').'</img></p> - </div>'; - - if ($InputError==1){ - prnMsg($msg,'error'); - } - - echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; - echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; - echo '<table class="selection">'; - echo '<tr> - <td>' . _('Enter the date from which the transactions are to be listed') . ':</td> - <td><input type="text" name="FromDate" maxlength="10" size="10" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" value="' . Date($_SESSION['DefaultDateFormat']) . '"></td> - </tr>'; - echo '<tr> - <td>' . _('Enter the date to which the transactions are to be listed') . ':</td> - <td><input type="text" name="ToDate" maxlength="10" size="10" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" value="' . Date($_SESSION['DefaultDateFormat']) . '"></td> - </tr>'; - - echo '<tr><td>' . _('Transaction type') . '</td><td>'; - - echo '<select name="TransType">'; - - echo '<option value=10>' . _('Sales Invoice').'</option> - <option value=11>' . _('Sales Credit Note').'</option> - <option value=16>' . _('Location Transfer').'</option> - <option value=17>' . _('Stock Adjustment').'</option> - <option value=25>' . _('Purchase Order Delivery').'</option> - <option value=26>' . _('Work Order Receipt').'</option> - <option value=28>' . _('Work Order Issue').'</option>'; - - echo '</select></td></tr>'; - - $sql = "SELECT loccode, locationname FROM locations"; - $resultStkLocs = DB_query($sql, $db); - - echo '<tr><td>' . _('For Stock Location') . ':</td> - <td><select name="StockLocation">'; - echo '<option value="All">' . _('All') . '</option>'; - while ($myrow=DB_fetch_array($resultStkLocs)){ - if (isset($_POST['StockLocation']) AND $_POST['StockLocation']!='All'){ - if ($myrow['loccode'] == $_POST['StockLocation']){ - echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; - } else { - echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; - } - } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ - echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; - $_POST['StockLocation']=$myrow['loccode']; - } else { - echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; - } - } - echo '</select></td></tr>'; - - echo '</table> - <br /> - <div class="centre"> - <input type=submit name="Go" value="' . _('Create PDF') . '" /> - </div>'; - - include('includes/footer.inc'); - exit; -} else { - - include('includes/ConnectDB.inc'); -} - - -if ($_POST['StockLocation']=='All') { - $sql= "SELECT stockmoves.type, - stockmoves.stockid, - stockmaster.description, - stockmaster.decimalplaces, - stockmoves.transno, - stockmoves.trandate, - stockmoves.qty, - stockmoves.reference, - stockmoves.narrative, - locations.locationname - FROM stockmoves - LEFT JOIN stockmaster - ON stockmoves.stockid=stockmaster.stockid - LEFT JOIN locations - ON stockmoves.loccode=locations.loccode - WHERE type='" . $_POST['TransType'] . "' - AND date_format(trandate, '%Y-%m-%d')>='".FormatDateForSQL($_POST['FromDate'])."' - AND date_format(trandate, '%Y-%m-%d')<='".FormatDateForSQL($_POST['ToDate'])."'"; -} else { - $sql= "SELECT stockmoves.type, - stockmoves.stockid, - stockmaster.description, - stockmaster.decimalplaces, - stockmoves.transno, - stockmoves.trandate, - stockmoves.qty, - stockmoves.reference, - stockmoves.narrative, - locations.locationname - FROM stockmoves - LEFT JOIN stockmaster - ON stockmoves.stockid=stockmaster.stockid - LEFT JOIN locations - ON stockmoves.loccode=locations.loccode - WHERE type='" . $_POST['TransType'] . "' - AND date_format(trandate, '%Y-%m-%d')>='".FormatDateForSQL($_POST['FromDate'])."' - AND date_format(trandate, '%Y-%m-%d')<='".FormatDateForSQL($_POST['ToDate'])."' - AND stockmoves.loccode='" . $_POST['StockLocation'] . "'"; -} -$result=DB_query($sql,$db,'','',false,false); - -if (DB_error_no($db)!=0){ - $title = _('Transaction Listing'); - include('includes/header.inc'); - prnMsg(_('An error occurred getting the transactions'),'error'); - include('includes/footer.inc'); - exit; -} elseif (DB_num_rows($result) == 0){ - $title = _('Transaction Listing'); - include('includes/header.inc'); - echo '<br />'; - prnMsg (_('There were no transactions found in the database between the dates') . ' ' . $_POST['FromDate'] . ' ' . _('and') . ' '. $_POST['ToDate'] .'<br />' ._('Please try again selecting a different date'), 'info'); - include('includes/footer.inc'); - exit; -} - -include('includes/PDFStarter.php'); - -/*PDFStarter.php has all the variables for page size and width set up depending on the users default preferences for paper size */ - -$pdf->addInfo('Title',_('Stock Transaction Listing')); -$pdf->addInfo('Subject',_('Stock transaction listing from') . ' ' . $_POST['FromDate'] . ' ' . $_POST['ToDate']); -$line_height=12; -$PageNumber = 1; - - -switch ($_POST['TransType']) { - case 10: - $TransType=_('Customer Invoices'); - break; - case 11: - $TransType=_('Customer Credit Notes'); - break; - case 16: - $TransType=_('Location Transfers'); - break; - case 17: - $TransType=_('Stock Adjustments'); - break; - case 25: - $TransType=_('Purchase Order Deliveries'); - break; - case 26: - $TransType=_('Work Order Receipts'); - break; - case 28: - $TransType=_('Work Order Issues'); - break; -} - -include ('includes/PDFPeriodStockTransListingPageHeader.inc'); - -while ($myrow=DB_fetch_array($result)){ - - $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,160,$FontSize,$myrow['description'], 'left'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+162,$YPos,80,$FontSize,$myrow['transno'], 'left'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+242,$YPos,70,$FontSize,ConvertSQLDate($myrow['trandate']), 'left'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+312,$YPos,70,$FontSize,locale_number_format($myrow['qty'],$myrow['decimalplaces']), 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+382,$YPos,70,$FontSize,$myrow['locationname'], 'right'); - $LeftOvers = $pdf->addTextWrap($Left_Margin+452,$YPos,70,$FontSize,$myrow['reference'], 'right'); - - $YPos -= ($line_height); - - if ($YPos - (2 *$line_height) < $Bottom_Margin){ - /*Then set up a new page */ - $PageNumber++; - include ('includes/PDFPeriodStockTransListingPageHeader.inc'); - } /*end of new page header */ -} /* end of while there are customer receipts in the batch to print */ - - -$YPos-=$line_height; - -$ReportFileName = $_SESSION['DatabaseName'] . '_StockTransListing_' . date('Y-m-d').'.pdf'; -$pdf->OutputD($ReportFileName); -$pdf->__destruct(); - +<?php +/* $Id: PDFPeriodStockTransListing.php 4307 2010-12-22 16:06:03Z tim_schofield $*/ + +include('includes/SQL_CommonFunctions.inc'); +include ('includes/session.inc'); + +$InputError=0; +if (isset($_POST['FromDate']) AND !Is_Date($_POST['FromDate'])){ + $msg = _('The date must be specified in the format') . ' ' . $_SESSION['DefaultDateFormat']; + $InputError=1; + unset($_POST['FromDate']); +} + +if (!isset($_POST['FromDate'])){ + + $title = _('Stock Transaction Listing'); + include ('includes/header.inc'); + + echo '<div class="centre"> + <p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/transactions.png" title="' . $title . '" alt="">' . ' '. _('Stock Transaction Listing').'</img></p> + </div>'; + + if ($InputError==1){ + prnMsg($msg,'error'); + } + + echo '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">'; + echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; + echo '<table class="selection">'; + echo '<tr> + <td>' . _('Enter the date from which the transactions are to be listed') . ':</td> + <td><input type="text" name="FromDate" maxlength="10" size="10" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" value="' . Date($_SESSION['DefaultDateFormat']) . '"></td> + </tr>'; + echo '<tr> + <td>' . _('Enter the date to which the transactions are to be listed') . ':</td> + <td><input type="text" name="ToDate" maxlength="10" size="10" class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" value="' . Date($_SESSION['DefaultDateFormat']) . '"></td> + </tr>'; + + echo '<tr><td>' . _('Transaction type') . '</td><td>'; + + echo '<select name="TransType">'; + + echo '<option value=10>' . _('Sales Invoice').'</option> + <option value=11>' . _('Sales Credit Note').'</option> + <option value=16>' . _('Location Transfer').'</option> + <option value=17>' . _('Stock Adjustment').'</option> + <option value=25>' . _('Purchase Order Delivery').'</option> + <option value=26>' . _('Work Order Receipt').'</option> + <option value=28>' . _('Work Order Issue').'</option>'; + + echo '</select></td></tr>'; + + $sql = "SELECT loccode, locationname FROM locations"; + $resultStkLocs = DB_query($sql, $db); + + echo '<tr><td>' . _('For Stock Location') . ':</td> + <td><select name="StockLocation">'; + echo '<option value="All">' . _('All') . '</option>'; + while ($myrow=DB_fetch_array($resultStkLocs)){ + if (isset($_POST['StockLocation']) AND $_POST['StockLocation']!='All'){ + if ($myrow['loccode'] == $_POST['StockLocation']){ + echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + } else { + echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + } + } elseif ($myrow['loccode']==$_SESSION['UserStockLocation']){ + echo '<option selected value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + $_POST['StockLocation']=$myrow['loccode']; + } else { + echo '<option value="' . $myrow['loccode'] . '">' . $myrow['locationname'] . '</option>'; + } + } + echo '</select></td></tr>'; + + echo '</table> + <br /> + <div class="centre"> + <input type="submit" name="Go" value="' . _('Create PDF') . '" /> + </div>'; + + include('includes/footer.inc'); + exit; +} else { + + include('includes/ConnectDB.inc'); +} + + +if ($_POST['StockLocation']=='All') { + $sql= "SELECT stockmoves.type, + stockmoves.stockid, + stockmaster.description, + stockmaster.decimalplaces, + stockmoves.transno, + stockmoves.trandate, + stockmoves.qty, + stockmoves.reference, + stockmoves.narrative, + locations.locationname + FROM stockmoves + LEFT JOIN stockmaster + ON stockmoves.stockid=stockmaster.stockid + LEFT JOIN locations + ON stockmoves.loccode=locations.loccode + WHERE type='" . $_POST['TransType'] . "' + AND date_format(trandate, '%Y-%m-%d')>='".FormatDateForSQL($_POST['FromDate'])."' + AND date_format(trandate, '%Y-%m-%d')<='".FormatDateForSQL($_POST['ToDate'])."'"; +} else { + $sql= "SELECT stockmoves.type, + stockmoves.stockid, + stockmaster.description, + stockmaster.decimalplaces, + stockmoves.transno, + stockmoves.trandate, + stockmoves.qty, + stockmoves.reference, + stockmoves.narrative, + locations.locationname + FROM stockmoves + LEFT JOIN stockmaster + ON stockmoves.stockid=stockmaster.stockid + LEFT JOIN locations + ON stockmoves.loccode=locations.loccode + WHERE type='" . $_POST['TransType'] . "' + AND date_format(trandate, '%Y-%m-%d')>='".FormatDateForSQL($_POST['FromDate'])."' + AND date_format(trandate, '%Y-%m-%d')<='".FormatDateForSQL($_POST['ToDate'])."' + AND stockmoves.loccode='" . $_POST['StockLocation'] . "'"; +} +$result=DB_query($sql,$db,'','',false,false); + +if (DB_error_no($db)!=0){ + $title = _('Transaction Listing'); + include('includes/header.inc'); + prnMsg(_('An error occurred getting the transactions'),'error'); + include('includes/footer.inc'); + exit; +} elseif (DB_num_rows($result) == 0){ + $title = _('Transaction Listing'); + include('includes/header.inc'); + echo '<br />'; + prnMsg (_('There were no transactions found in the database between the dates') . ' ' . $_POST['FromDate'] . ' ' . _('and') . ' '. $_POST['ToDate'] .'<br />' ._('Please try again selecting a different date'), 'info'); + include('includes/footer.inc'); + exit; +} + +include('includes/PDFStarter.php'); + +/*PDFStarter.php has all the variables for page size and width set up depending on the users default preferences for paper size */ + +$pdf->addInfo('Title',_('Stock Transaction Listing')); +$pdf->addInfo('Subject',_('Stock transaction listing from') . ' ' . $_POST['FromDate'] . ' ' . $_POST['ToDate']); +$line_height=12; +$PageNumber = 1; + + +switch ($_POST['TransType']) { + case 10: + $TransType=_('Customer Invoices'); + break; + case 11: + $TransType=_('Customer Credit Notes'); + break; + case 16: + $TransType=_('Location Transfers'); + break; + case 17: + $TransType=_('Stock Adjustments'); + break; + case 25: + $TransType=_('Purchase Order Deliveries'); + break; + case 26: + $TransType=_('Work Order Receipts'); + break; + case 28: + $TransType=_('Work Order Issues'); + break; +} + +include ('includes/PDFPeriodStockTransListingPageHeader.inc'); + +while ($myrow=DB_fetch_array($result)){ + + $LeftOvers = $pdf->addTextWrap($Left_Margin,$YPos,160,$FontSize,$myrow['description'], 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+162,$YPos,80,$FontSize,$myrow['transno'], 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+242,$YPos,70,$FontSize,ConvertSQLDate($myrow['trandate']), 'left'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+312,$YPos,70,$FontSize,locale_number_format($myrow['qty'],$myrow['decimalplaces']), 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+382,$YPos,70,$FontSize,$myrow['locationname'], 'right'); + $LeftOvers = $pdf->addTextWrap($Left_Margin+452,$YPos,70,$FontSize,$myrow['reference'], 'right'); + + $YPos -= ($line_height); + + if ($YPos - (2 *$line_height) < $Bottom_Margin){ + /*Then set up a new page */ + $PageNumber++; + include ('includes/PDFPeriodStockTransListingPageHeader.inc'); + } /*end of new page header */ +} /* end of while there are customer receipts in the batch to print */ + + +$YPos-=$line_height; + +$ReportFileName = $_SESSION['DatabaseName'] . '_StockTransListing_' . date('Y-m-d').'.pdf'; +$pdf->OutputD($ReportFileName); +$pdf->__destruct(); + ?> \ No newline at end of file Modified: trunk/PDFPickingList.php =================================================================== --- trunk/PDFPickingList.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFPickingList.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -21,9 +21,9 @@ if ((!isset($_GET['TransNo']) or $_GET['TransNo']=="") and !isset($_POST['TransDate'])){ $title = _('Select Picking Lists'); include('includes/header.inc'); - $sql='SELECT loccode, + $sql="SELECT loccode, locationname - FROM locations'; + FROM locations"; $result=DB_query($sql, $db); echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/sales.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p><br />'; echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post" name="form">'; @@ -49,78 +49,78 @@ if (!isset($_POST['TransDate']) and $_GET['TransNo'] != 'Preview') { /* If there is no transaction date set, then it must be for a single order */ $sql = "SELECT salesorders.debtorno, - salesorders.orderno, - salesorders.customerref, - salesorders.comments, - salesorders.orddate, - salesorders.deliverto, - salesorders.deladd1, - salesorders.deladd2, - salesorders.deladd3, - salesorders.deladd4, - salesorders.deladd5, - salesorders.deladd6, - salesorders.deliverblind, - salesorders.deliverydate, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - debtorsmaster.address5, - debtorsmaster.address6, - shippers.shippername, - salesorders.printedpackingslip, - salesorders.datepackingslipprinted, - locations.locationname - FROM salesorders, - debtorsmaster, - shippers, - locations - WHERE salesorders.debtorno=debtorsmaster.debtorno - AND salesorders.shipvia=shippers.shipper_id - AND salesorders.fromstkloc=locations.loccode - AND salesorders.orderno='" . $_GET['TransNo']."'"; -} else if (isset($_POST['TransDate']) + salesorders.orderno, + salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.deliverblind, + salesorders.deliverydate, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + locations.locationname + FROM salesorders, + debtorsmaster, + shippers, + locations + WHERE salesorders.debtorno=debtorsmaster.debtorno + AND salesorders.shipvia=shippers.shipper_id + AND salesorders.fromstkloc=locations.loccode + AND salesorders.orderno='" . filter_number_format($_GET['TransNo'])."'"; +} else if (isset($_POST['TransDate']) OR (isset($_GET['TransNo']) AND $_GET['TransNo'] != 'Preview')) { /* We are printing picking lists for all orders on a day */ $sql = "SELECT salesorders.debtorno, - salesorders.orderno, - salesorders.customerref, - salesorders.comments, - salesorders.orddate, - salesorders.deliverto, - salesorders.deladd1, - salesorders.deladd2, - salesorders.deladd3, - salesorders.deladd4, - salesorders.deladd5, - salesorders.deladd6, - salesorders.deliverblind, - salesorders.deliverydate, - debtorsmaster.name, - debtorsmaster.address1, - debtorsmaster.address2, - debtorsmaster.address3, - debtorsmaster.address4, - debtorsmaster.address5, - debtorsmaster.address6, - shippers.shippername, - salesorders.printedpackingslip, - salesorders.datepackingslipprinted, - locations.locationname - FROM salesorders, - debtorsmaster, - shippers, - locations - WHERE salesorders.debtorno=debtorsmaster.debtorno - AND salesorders.shipvia=shippers.shipper_id - AND salesorders.fromstkloc=locations.loccode - AND salesorders.fromstkloc='".$_POST['loccode']."' - AND salesorders.deliverydate='" . FormatDateForSQL($_POST['TransDate'])."'"; + salesorders.orderno, + salesorders.customerref, + salesorders.comments, + salesorders.orddate, + salesorders.deliverto, + salesorders.deladd1, + salesorders.deladd2, + salesorders.deladd3, + salesorders.deladd4, + salesorders.deladd5, + salesorders.deladd6, + salesorders.deliverblind, + salesorders.deliverydate, + debtorsmaster.name, + debtorsmaster.address1, + debtorsmaster.address2, + debtorsmaster.address3, + debtorsmaster.address4, + debtorsmaster.address5, + debtorsmaster.address6, + shippers.shippername, + salesorders.printedpackingslip, + salesorders.datepackingslipprinted, + locations.locationname + FROM salesorders, + debtorsmaster, + shippers, + locations + WHERE salesorders.debtorno=debtorsmaster.debtorno + AND salesorders.shipvia=shippers.shipper_id + AND salesorders.fromstkloc=locations.loccode + AND salesorders.fromstkloc='".$_POST['loccode']."' + AND salesorders.deliverydate='" . FormatDateForSQL($_POST['TransDate'])."'"; } -if (isset($_POST['TransDate']) +if (isset($_POST['TransDate']) OR (isset($_GET['TransNo']) AND $_GET['TransNo'] != 'Preview')) { $result=DB_query($sql,$db, $ErrMsg); @@ -185,7 +185,7 @@ $pdf->addInfo('Title', _('Picking List') ); $pdf->addInfo('Subject', _('Laser Picking List') ); $FontSize=12; -$ListCount = 0; +$ListCount = 0; $Copy=''; $line_height=$FormDesign->LineHeight; @@ -207,44 +207,46 @@ /* Are there any picking lists for this order already */ $sql="SELECT COUNT(orderno) FROM pickinglists - WHERE orderno='" . $OrdersToPick[$i]['orderno'] . "'"; + WHERE orderno='" . filter_number_format($OrdersToPick[$i]['orderno']) . "'"; $countresult=DB_query($sql, $db); $count=DB_fetch_row($countresult); if ($count[0]==0) { /* There are no previous picking lists for this order */ $sql = "SELECT salesorderdetails.stkcode, - stockmaster.description, - salesorderdetails.orderlineno, - salesorderdetails.quantity, - salesorderdetails.qtyinvoiced, - salesorderdetails.unitprice, - salesorderdetails.narrative - FROM salesorderdetails - INNER JOIN stockmaster - ON salesorderdetails.stkcode=stockmaster.stockid - WHERE salesorderdetails.orderno='" . $OrdersToPick[$i]['orderno'] ."'"; + stockmaster.description, + salesorderdetails.orderlineno, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + salesorderdetails.unitprice, + salesorderdetails.narrative, + stockmaster.decimalplaces + FROM salesorderdetails + INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + WHERE salesorderdetails.orderno='" . filer_number_format($OrdersToPick[$i]['orderno']) ."'"; } else { /* There are previous picking lists for this order so * need to take those quantities into account */ $sql = "SELECT salesorderdetails.stkcode, - stockmaster.description, - salesorderdetails.orderlineno, - salesorderdetails.quantity, - salesorderdetails.qtyinvoiced, - SUM(pickinglistdetails.qtyexpected) as qtyexpected, - SUM(pickinglistdetails.qtypicked) as qtypicked, - salesorderdetails.unitprice, - salesorderdetails.narrative - FROM salesorderdetails - INNER JOIN stockmaster - ON salesorderdetails.stkcode=stockmaster.stockid - LEFT JOIN pickinglists - ON salesorderdetails.orderno=pickinglists.orderno - LEFT JOIN pickinglistdetails - ON pickinglists.pickinglistno=pickinglistdetails.pickinglistno - WHERE salesorderdetails.orderno='" . $OrdersToPick[$i]['orderno'] ."' - AND salesorderdetails.orderlineno=pickinglistdetails.orderlineno"; + stockmaster.description, + salesorderdetails.orderlineno, + salesorderdetails.quantity, + salesorderdetails.qtyinvoiced, + SUM(pickinglistdetails.qtyexpected) as qtyexpected, + SUM(pickinglistdetails.qtypicked) as qtypicked, + salesorderdetails.unitprice, + salesorderdetails.narrative, + stockmaster.decimalplaces + FROM salesorderdetails + INNER JOIN stockmaster + ON salesorderdetails.stkcode=stockmaster.stockid + LEFT JOIN pickinglists + ON salesorderdetails.orderno=pickinglists.orderno + LEFT JOIN pickinglistdetails + ON pickinglists.pickinglistno=pickinglistdetails.pickinglistno + WHERE salesorderdetails.orderno='" . filter_number_format($OrdersToPick[$i]['orderno']) ."' + AND salesorderdetails.orderlineno=pickinglistdetails.orderlineno"; } $lineresult=DB_query($sql,$db, $ErrMsg); } @@ -258,7 +260,7 @@ $sql="INSERT INTO pickinglists VALUES ( '" . $PickingListNo ."', - '" . $OrdersToPick[$i]['orderno']."', + '" . filter_number_format($OrdersToPick[$i]['orderno'])."', '" . FormatDateForSQL($_POST['TransDate'])."', '" . date('Y-m-d')."', '0000-00-00')"; @@ -284,16 +286,16 @@ $myrow2['qtyexpected']=0; $myrow2['qtypicked']=0; } - $DisplayQty = locale_number_format($myrow2['quantity'],2); - $DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],2); - $DisplayQtySupplied = locale_number_format($myrow2['quantity'] - $myrow2['qtyinvoiced']-$myrow2['qtyexpected']-$myrow2['qtypicked'],2); + $DisplayQty = locale_number_format($myrow2['quantity'],$myrow2['decimalplaces']); + $DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],$myrow2['decimalplaces']); + $DisplayQtySupplied = locale_number_format(filer_number_format($myrow2['quantity'] - $myrow2['qtyinvoiced']-$myrow2['qtyexpected']-$myrow2['qtypicked']),$myrow2['decimalplaces']); $itemdesc = $myrow2['description'] . ' - ' . $myrow2['narrative']; $sql="INSERT INTO pickinglistdetails VALUES( '" . $PickingListNo ."', '" . $Lines."', '" . $myrow2['orderlineno']."', - '" . $DisplayQtySupplied."', + '" . filter_number_format($DisplayQtySupplied) ."', 0)"; $lineresult=DB_query($sql, $db); } @@ -327,6 +329,6 @@ exit; } else { $pdf->OutputD($_SESSION['DatabaseName'] . '_PickingLists_' . date('Y-m-d') . '.pdf'); - $pdf->__destruct(); + $pdf->__destruct(); } ?> \ No newline at end of file Modified: trunk/PDFPriceList.php =================================================================== --- trunk/PDFPriceList.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFPriceList.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -1,7 +1,6 @@ <?php -/* $Revision: 1.14 $ */ +/* $Id$*/ -//$PageSecurity = 2; include('includes/session.inc'); If (isset($_POST['PrintPDF']) @@ -27,7 +26,7 @@ include('includes/header.inc'); echo '<br />'; prnMsg( _('The customer must first be selected from the select customer link') . '. ' . _('Re-run the price list once the customer has been selected') ); - echo '<br /><br /><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Back') . '</a>'; + echo '<br /><br /><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Back') . '</a>'; include('includes/footer.inc'); exit; } @@ -35,7 +34,7 @@ $title = _('Special price List - No Customer Selected'); include('includes/header.inc'); prnMsg(_('The effective date must be entered in the format') . ' ' . $_SESSION['DefaultDateFormat'],'error'); - echo '<br /><br /><a href="' . $_SERVER['PHP_SELF'] . '?' . SID . '">' . _('Back') . '</a>'; + echo '<br /><br /><a href="' . $_SERVER['PHP_SELF'] . '">' . _('Back') . '</a>'; include('includes/footer.inc'); exit; } @@ -50,32 +49,35 @@ $SalesType = $CustNameRow[1]; $SQL = "SELECT prices.typeabbrev, - prices.stockid, - stockmaster.description, - stockmaster.longdescription, - prices.currabrev, - prices.startdate, - prices.enddate, - prices.price, - stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standardcost, - stockmaster.categoryid, - stockcategory.categorydescription, - prices.debtorno, - prices.branchcode, - custbranch.brname - FROM stockmaster, - stockcategory, - prices LEFT JOIN custbranch + prices.stockid, + stockmaster.description, + stockmaster.longdescription, + prices.currabrev, + prices.startdate, + prices.enddate, + prices.price, + stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standardcost, + stockmaster.categoryid, + stockcategory.categorydescription, + prices.debtorno, + prices.branchcode, + custbranch.brname, + currencies.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN prices + ON stockmaster.stockid=prices.stockid + INNER JOIN currencies + ON prices.currabrev=currencies.currabrev + LEFT JOIN custbranch ON prices.debtorno=custbranch.debtorno AND prices.branchcode=custbranch.branchcode - WHERE stockmaster.stockid=prices.stockid - AND stockmaster.categoryid=stockcategory.categoryid - AND prices.typeabbrev = '" . $SalesType . "' + WHERE prices.typeabbrev = '" . $SalesType . "' AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' AND prices.debtorno='" . $_SESSION['CustomerID'] . "' AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' - AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') + AND (prices.enddate='0000-00-00' OR prices.enddate >'" . FormatDateForSQL($_POST['EffectiveDate']) . "') ORDER BY prices.currabrev, stockmaster.categoryid, stockmaster.stockid, @@ -89,31 +91,33 @@ $SalesTypeName = $SalesTypeRow[0]; $SQL = "SELECT prices.typeabbrev, - prices.stockid, - prices.startdate, - prices.enddate, - stockmaster.description, - stockmaster.longdescription, - prices.currabrev, - prices.price, - stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost as standardcost, - stockmaster.categoryid, - stockcategory.categorydescription - FROM prices, - stockmaster, - stockcategory - WHERE stockmaster.stockid=prices.stockid - AND stockmaster.categoryid=stockcategory.categoryid - AND stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' - AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' - AND prices.typeabbrev='" . $_POST['SalesType'] . "' - AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' - AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') - AND prices.debtorno='' - ORDER BY prices.currabrev, - stockmaster.categoryid, - stockmaster.stockid, - prices.startdate"; + prices.stockid, + prices.startdate, + prices.enddate, + stockmaster.description, + stockmaster.longdescription, + prices.currabrev, + prices.price, + stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost as standardcost, + stockmaster.categoryid, + stockcategory.categorydescription, + currencies.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + INNER JOIN prices + ON stockmaster.stockid=prices.stockid + INNER JOIN currencies + ON prices.currabrev=currencies.currabrev + WHERE stockmaster.categoryid >= '" . $_POST['FromCriteria'] . "' + AND stockmaster.categoryid <= '" . $_POST['ToCriteria'] . "' + AND prices.typeabbrev='" . $_POST['SalesType'] . "' + AND prices.startdate<='" . FormatDateForSQL($_POST['EffectiveDate']) . "' + AND (prices.enddate='0000-00-00' OR prices.enddate>'" . FormatDateForSQL($_POST['EffectiveDate']) . "') + AND prices.debtorno='' + ORDER BY prices.currabrev, + stockmaster.categoryid, + stockmaster.stockid, + prices.startdate"; } $PricesResult = DB_query($SQL,$db,'','',false,false); @@ -121,7 +125,7 @@ $title = _('Price List') . ' - ' . _('Problem Report....'); include('includes/header.inc'); prnMsg( _('The Price List could not be retrieved by the SQL because'). ' - ' . DB_error_msg($db), 'error'); - echo '<br /><a href="' .$rootpath .'/index.php?' . SID . '">'. _('Back to the menu'). '</a>'; + echo '<br /><a href="' .$rootpath .'/index.php">'. _('Back to the menu'). '</a>'; if ($debug==1){ prnMsg(_('For debugging purposes the SQL used was:') . $SQL,'error'); } @@ -132,7 +136,7 @@ $title = _('Print Price List Error'); include('includes/header.inc'); prnMsg(_('There were no price details to print out for the customer or category specified'),'warn'); - echo '<br /><a href="'.$_SERVER['PHP_SELF'] .'?' . SID . '">'. _('Back').'</a>'; + echo '<br /><a href="'.$_SERVER['PHP_SELF'] . '">'. _('Back').'</a>'; include('includes/footer.inc'); exit; } @@ -173,11 +177,11 @@ } $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47,$YPos,47,$FontSize,$DisplayEndDate); $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47,$YPos,130,$FontSize,$PriceList['description']); - $DisplayUnitPrice = locale_number_format($PriceList['price'],2); + $DisplayUnitPrice = locale_money_format($PriceList['price'],$PriceList['decimalplaces']); $LeftOvers = $pdf->addTextWrap($Left_Margin+80+47+47+130,$YPos,150,$FontSize,$DisplayUnitPrice, 'right'); if ($PriceList['price']!=0){ - $DisplayGPPercent = (int)(($PriceList['price']-$PriceList['standardcost'])*100/$PriceList['price']) . '%'; + $DisplayGPPercent = (int)filter_number_format((($PriceList['price']-$PriceList['standardcost'])*100/$PriceList['price'])) . '%'; } else { $DisplayGPPercent = 0; } @@ -272,28 +276,30 @@ DB_data_seek($CatResult,0); While ($myrow = DB_fetch_array($CatResult)){ - echo '<option VALUE="' . $myrow['categoryid'] . '">' . $myrow['categoryid'] . ' - ' . $myrow['categorydescription']; + echo '<option value="' . $myrow['categoryid'] . '">' . $myrow['categoryid'] . ' - ' . $myrow['categorydescription'] . '</option>'; } echo '</select></td></tr>'; - echo '<tr><td>' . _('For Sales Type/Price List').':</td><td><select name="SalesType">'; - $sql = 'SELECT sales_type, typeabbrev FROM salestypes'; + echo '<tr><td>' . _('For Sales Type/Price List').':</td> + <td><select name="SalesType">'; + $sql = "SELECT sales_type, typeabbrev FROM salestypes"; $SalesTypesResult=DB_query($sql,$db); while ($myrow=DB_fetch_array($SalesTypesResult)){ - echo '<option Value="' . $myrow['typeabbrev'] . '">' . $myrow['sales_type']; + echo '<option Value="' . $myrow['typeabbrev'] . '">' . $myrow['sales_type'] . '</option>'; } echo '</select></td></tr>'; - echo '<tr><td>' . _('Show Gross Profit %') . ':</td><td><select name="ShowGPPercentages">'; - echo '<option selected Value="No">'. _('Prices Only'); - echo '<option Value="Yes">'. _('Show GP % too'); + echo '<tr><td>' . _('Show Gross Profit %') . ':</td> + <td><select name="ShowGPPercentages">'; + echo '<option selected Value="No">'. _('Prices Only') . '</option>'; + echo '<option Value="Yes">'. _('Show GP % too') . '</option>'; echo '</select></td></tr>'; echo '<tr><td>' . _('Price Listing Type'). ':</td><td><select name="CustomerSpecials">'; - echo '<option selected Value="Sales Type Prices">'. _('Default Sales Type Prices'); - echo '<option Value="Customer Special Prices Only">'. _('Customer Special Prices Only'); - echo '<option Value="Full Description">'. _('Full Description'); + echo '<option selected value="Sales Type Prices">'. _('Default Sales Type Prices'); + echo '<option Value="Customer Special Prices Only">'. _('Customer Special Prices Only') . '</option>'; + echo '<option Value="Full Description">'. _('Full Description') . '</option>'; echo '</select></td></tr>'; echo '<tr><td>' . _('Effective As At') . ':</td><td><input type="text" size=11 class="date" alt="' . $_SESSION['DefaultDateFormat'] . '" name="EffectiveDate" value="' . Date($_SESSION['DefaultDateFormat']) . '">'; Modified: trunk/PDFPrintLabel.php =================================================================== --- trunk/PDFPrintLabel.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFPrintLabel.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -243,9 +243,10 @@ return noneButton( _('This category has no items to show') ); } - $txt=array( - _('Code'), _('Description'), _('Price').'<br />('.$_POST['Currency'].')', - _('All') + $txt=array(_('Code'), + _('Description'), + _('Price'). '<br />('.$_POST['Currency'].')', + _('All') ); $ix=0; // The table's header @@ -265,7 +266,7 @@ $ok=true; $odd=true; while ($myrow=DB_fetch_array($result)) { - $price = locale_number_format($myrow['price'],$DecimalPlaces); + $price = locale_money_format($myrow['price'],$DecimalPlaces); $oddEven=$odd?"Odd":"Even"; $odd = !$odd; $html .= <<<ZZZ @@ -307,23 +308,23 @@ } else { $WhereClause = "stockmaster.categoryid='$CategoryID' ORDER BY stockmaster.stockid"; } - + $WhereClause = " stockmaster.discontinued!=1 AND " . $WhereClause; - $sql="SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.longdescription, - stockmaster.barcode, - prices.price - FROM stockmaster LEFT JOIN prices - ON stockmaster.stockid=prices.stockid - AND prices.currabrev = '" . $CurrCode . "' + $sql="SELECT stockmaster.stockid, + stockmaster.description, + stockmaster.longdescription, + stockmaster.barcode, + prices.price + FROM stockmaster LEFT JOIN prices + ON stockmaster.stockid=prices.stockid + AND prices.currabrev = '" . $CurrCode . "' AND prices.typeabbrev= '" . $SalesType . "' AND prices.startdate <= '" . $EffectiveDate . "' - AND (prices.enddate >= '" . $EffectiveDate . "' OR prices.enddate='0000-00-00') + AND (prices.enddate >= '" . $EffectiveDate . "' OR prices.enddate='0000-00-00') AND prices.debtorno='' WHERE " . $WhereClause; - + return DB_query($sql, $db); } @@ -491,7 +492,7 @@ unset($ldescrip); break; case 'price': - $txt = locale_number_format($itemData['price'], $DecimalPlaces). ' '. $Currency; + $txt = locale_money_format($itemData['price'], $DecimalPlaces). ' '. $Currency; // $adj='left'; break; case 'bcode': break; Modified: trunk/PDFQuotation.php =================================================================== --- trunk/PDFQuotation.php 2011-09-12 23:37:53 UTC (rev 4688) +++ trunk/PDFQuotation.php 2011-09-14 08:06:45 UTC (rev 4689) @@ -19,7 +19,7 @@ } /*retrieve the order details from the database to print */ -$ErrMsg = _('There was a problem retrieving the quotation header details for Order Number') . ' ' . $_GET['QuotationNo'] . ' ' . _('from the database'); +$ErrMsg = _('There was a problem retrieving the quotation header details for Order Number') . ' ' . filter_number_format($_GET['QuotationNo']) . ' ' . _('from the database'); $sql = "SELECT salesorders.customerref, salesorders.comments, @@ -44,15 +44,18 @@ salesorders.datepackingslipprinted, salesorders.branchcode, locations.taxprovinceid, - locations.locationname + locations.locationname, + currencies.decimalplaces AS currdecimalplaces FROM salesorders INNER JOIN debtorsmaster ON salesorders.debtorno=debtorsmaster.debtorno - INNER JOIN shippers + INNER JOIN shippers ON salesorders.shipvia=shippers.shipper_id - INNER JOIN locations + INNER JOIN locations ON salesorders.fromstkloc=locations.loccode + INNER JOIN currencies + ON debtorsmaster.currcode=currencies.currabrev WHERE salesorders.quotation=1 - AND salesorders.orderno='" . $_GET['QuotationNo'] ."'"; + AND salesorders.orderno='" . filter_number_format($_GET['QuotationNo']) ."'"; $result=DB_query($sql,$db, $ErrMsg); @@ -61,7 +64,7 @@ $title = _('Print Quotation Error'); include('includes/header.inc'); echo '<div class="centre"><br /><br /><br />'; - prnMsg( _('Unable to Locate Quotation Number') . ' : ' . $_GET['QuotationNo'] . ' ', 'error'); + prnMsg( _('Unable to Locate Quotation Number') . ' : ' . filter_number_format($_GET['QuotationNo']) . ' ', 'error'); echo '<br /> <br /> <br /> @@ -109,14 +112,15 @@ salesorderdetails.unitprice, salesorderdetails.discountpercent, stockmaster.taxcatid, - salesorderdetails.narrative + salesorderdetails.narrative, + stockmaster.decimalplaces FROM salesorderdetails INNER JOIN stockmaster ON salesorderdetails.stkcode=stockmaster.stockid - WHERE salesorderdetails.orderno='" . $_GET['QuotationNo'] . "'"; + WHERE salesorderdetails.orderno='" . filter_number_format($_GET['QuotationNo']) . "'"; $result=DB_query($sql,$db, $ErrMsg); -$ListCount = 0; +$ListCount = 0; if (DB_num_rows($result)>0){ /*Yes there are line items to start the ball rolling with a page header */ @@ -139,26 +143,26 @@ } //end if need a new page headed up - $DisplayQty = locale_number_format($myrow2['quantity'],2); - $DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],2); - $DisplayPrice = locale_number_format($myrow2['unitprice'],2); + $DisplayQty = locale_number_format($myrow2['quantity'],$myrow2['decimalplaces']); + $DisplayPrevDel = locale_number_format($myrow2['qtyinvoiced'],$myrow2['decimalplaces']); + $DisplayPrice = locale_money_format($myrow2['unitprice'],$myrow['currdecimalplaces']); $DisplayDiscount = locale_number_format($myrow2['discountpercent']*100,2) . '%'; - $SubTot = $myrow2['unitprice']*$myrow2['quantity']*(1-$myrow2['discountpercent']); + $SubTot = filter_number_format($myrow2['unitprice']*$myrow2['quantity']*(1-$myrow2['... [truncated message content] |