From: <dai...@us...> - 2011-11-10 09:31:00
|
Revision: 4743 http://web-erp.svn.sourceforge.net/web-erp/?rev=4743&view=rev Author: daintree Date: 2011-11-10 09:30:52 +0000 (Thu, 10 Nov 2011) Log Message: ----------- Modified Paths: -------------- trunk/ConfirmDispatch_Invoice.php trunk/CounterSales.php trunk/GLTrialBalance.php trunk/PO_Items.php trunk/Z_DescribeTable.php trunk/doc/Change.log trunk/includes/DateFunctions.inc trunk/includes/LanguageSetup.php trunk/includes/PDFTransPageHeader.inc trunk/includes/SQL_CommonFunctions.inc Modified: trunk/ConfirmDispatch_Invoice.php =================================================================== --- trunk/ConfirmDispatch_Invoice.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/ConfirmDispatch_Invoice.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -225,7 +225,7 @@ $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched += $SerialItem->BundleQty; } } else if (is_numeric(filter_number_format($_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']); + $_SESSION['Items']->LineItems[$Itm->LineNumber]->QtyDispatched = round(filter_number_format($_POST[$Itm->LineNumber . '_QtyDispatched']),$Itm->DecimalPlaces); } foreach ($Itm->Taxes as $TaxLine) { if (isset($_POST[$Itm->LineNumber . $TaxLine->TaxCalculationOrder . '_TaxRate'])){ @@ -395,7 +395,7 @@ 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>'; + echo $RowStarter . '<td colspan="12">' . stripslashes($Narrative) . '</td></tr>'; } }//end foreach ($line) @@ -523,7 +523,7 @@ /* round the totals to avoid silly entries */ -$TaxTotal = round($TaxTotal,2); +$TaxTotal = round($TaxTotal,$_SESSION['Items']->CurrDecimalPlaces); $_SESSION['Items']->total = round($_SESSION['Items']->total,$_SESSION['Items']->CurrDecimalPlaces); $_POST['ChargeFreightCost'] = round($_POST['ChargeFreightCost'],$_SESSION['Items']->CurrDecimalPlaces); @@ -770,9 +770,9 @@ '" . $TaxTotal . "', '" . filter_number_format($_POST['ChargeFreightCost']) . "', '" . $_SESSION['CurrencyRate'] . "', - '" . DB_escape_string($_POST['InvoiceText']) . "', + '" . $_POST['InvoiceText'] . "', '" . $_SESSION['Items']->ShipVia . "', - '" . DB_escape_string($_POST['Consignment']) . "' )"; + '" . $_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'); @@ -829,31 +829,30 @@ if (($OrderLine->Quantity - $OrderLine->QtyDispatched)>0){ - $SQL = "INSERT INTO orderdeliverydifferenceslog ( orderno, + $SQL = "INSERT INTO orderdeliverydifferenceslog (orderno, invoiceno, stockid, quantitydiff, debtorno, branch, - can_or_bo ) + can_or_bo) VALUES ( '" . $_SESSION['ProcessingOrder'] . "', '" . $InvoiceNo . "', '" . $OrderLine->StockID . "', - '" . $OrderLine->Quantity - $OrderLine->QtyDispatched . "', + '" . ($OrderLine->Quantity - $OrderLine->QtyDispatched) . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', 'CAN')"; - + $ErrMsg =_('CRITICAL ERROR') . '! ' . _('NOTE DOWN THIS ERROR AND SEEK ASSISTANCE') . ': ' . _('The order delivery differences log record could not be inserted because'); $DbgMsg = _('The following SQL to insert the order delivery differences record was used'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } + } elseif (($OrderLine->Quantity - $OrderLine->QtyDispatched)>0 + AND 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 */ $SQL = "INSERT INTO orderdeliverydifferenceslog (orderno, @@ -919,9 +918,9 @@ /* Need to get the current location quantity will need it later for the stock movement */ $SQL="SELECT locstock.quantity - FROM locstock - WHERE locstock.stockid='" . $OrderLine->StockID . "' - AND loccode= '" . $_SESSION['Items']->Location . "'"; + FROM locstock + WHERE locstock.stockid='" . $OrderLine->StockID . "' + AND loccode= '" . $_SESSION['Items']->Location . "'"; $ErrMsg = _('WARNING') . ': ' . _('Could not retrieve current location stock'); $Result = DB_query($SQL, $db, $ErrMsg); @@ -933,7 +932,8 @@ $QtyOnHandPrior = 0; } - $SQL = "UPDATE locstock SET quantity = locstock.quantity - " . $OrderLine->QtyDispatched . " + $SQL = "UPDATE locstock + SET quantity = locstock.quantity - " . $OrderLine->QtyDispatched . " WHERE locstock.stockid = '" . $OrderLine->StockID . "' AND loccode = '" . $_SESSION['Items']->Location . "'"; @@ -949,10 +949,9 @@ $SQL = "SELECT bom.component, bom.quantity, stockmaster.materialcost+stockmaster.labourcost+stockmaster.overheadcost AS standard - FROM bom, - stockmaster - WHERE bom.component=stockmaster.stockid - AND bom.parent='" . $OrderLine->StockID . "' + FROM bom INNER JOIN stockmaster + ON bom.component=stockmaster.stockid + WHERE bom.parent='" . $OrderLine->StockID . "' AND bom.effectiveto >= '" . Date('Y-m-d') . "' AND bom.effectiveafter < '" . Date('Y-m-d') . "'"; @@ -1031,7 +1030,7 @@ } /* end of its an assembly */ // Insert stock movements - with unit cost - $LocalCurrencyPrice = ($OrderLine->Price / $_SESSION['CurrencyRate']); + $LocalCurrencyPrice = round(($OrderLine->Price / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']); if (empty($OrderLine->StandardCost)) { $OrderLine->StandardCost=0; @@ -1205,10 +1204,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) . ", + $SQL = "UPDATE salesanalysis SET amt=amt+" . round(($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . ", + cost=cost+" . round(($OrderLine->StandardCost * $OrderLine->QtyDispatched),$_SESSION['CompanyRecord']['decimalplaces']) . ", qty=qty +" . $OrderLine->QtyDispatched . ", - disc=disc+" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . " + disc=disc+" . round(($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . " WHERE salesanalysis.area='" . $myrow[5] . "' AND salesanalysis.salesperson='" . $myrow[8] . "' AND typeabbrev ='" . $_SESSION['Items']->DefaultSalesType . "' @@ -1236,12 +1235,12 @@ stkcategory ) SELECT '" . $_SESSION['Items']->DefaultSalesType . "', '" . $PeriodNo . "', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', - '" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "', + '" . round(($OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "', + '" . round(($OrderLine->StandardCost * $OrderLine->QtyDispatched),$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . $_SESSION['Items']->DebtorNo . "', '" . $_SESSION['Items']->Branch . "', '" . ($OrderLine->QtyDispatched) . "', - '" . ($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']) . "', + '" . round(($OrderLine->DiscountPercent * $OrderLine->Price * $OrderLine->QtyDispatched / $_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . $OrderLine->StockID . "', custbranch.area, 1, @@ -1278,7 +1277,7 @@ '" . $PeriodNo . "', '" . GetCOGSGLAccount($Area, $OrderLine->StockID, $_SESSION['Items']->DefaultSalesType, $db) . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . ($OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; + '" . round(($OrderLine->StandardCost * $OrderLine->QtyDispatched),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1301,7 +1300,7 @@ '" . $PeriodNo . "', '" . $StockGLCode['stockact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->StandardCost . "', - '" . (-$OrderLine->StandardCost * $OrderLine->QtyDispatched) . "')"; + '" . round((-$OrderLine->StandardCost * $OrderLine->QtyDispatched),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1328,7 +1327,7 @@ '" . $PeriodNo . "', '" . $SalesGLAccounts['salesglcode'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " x " . $OrderLine->QtyDispatched . " @ " . $OrderLine->Price . "', - '" . (-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']) . "')"; + '" . round((-$OrderLine->Price * $OrderLine->QtyDispatched/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1350,7 +1349,7 @@ '" . $PeriodNo . "', '" . $SalesGLAccounts['discountglcode'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . " @ " . ($OrderLine->DiscountPercent * 100) . "%', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']) . "')"; + '" . round(($OrderLine->Price * $OrderLine->QtyDispatched * $OrderLine->DiscountPercent/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1462,7 +1461,7 @@ '" . $PeriodNo . "', '" . $DisposalRow['disposalact'] . "', '" . $_SESSION['Items']->DebtorNo . " - " . $OrderLine->StockID . ' ' . _('disposal') . "', - '" . (-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "')"; + '" . round((-$OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1490,14 +1489,14 @@ '" . $PeriodNo . "', '" . Date('Y-m-d') . "', 'disposal', - '" . ($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']) . "', + '" . round(($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "', '" . $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 ='" . round(($OrderLine->Price * $OrderLine->QtyDispatched* (1 - $OrderLine->DiscountPercent)/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "', disposaldate ='" . $DefaultDispatchDate . "' WHERE assetid ='" . $AssetNumber . "'"; @@ -1528,7 +1527,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['debtorsact'] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']) . "')"; + '" . round((($_SESSION['Items']->total + $_SESSION['Items']->FreightCost + $TaxTotal)/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1553,7 +1552,7 @@ '" . $PeriodNo . "', '" . $_SESSION['CompanyRecord']['freightact'] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (-$_SESSION['Items']->FreightCost/$_SESSION['CurrencyRate']) . "')"; + '" . round((-$_SESSION['Items']->FreightCost/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); @@ -1575,13 +1574,14 @@ '" . $PeriodNo . "', '" . $TaxGLCodes[$TaxAuthID] . "', '" . $_SESSION['Items']->DebtorNo . "', - '" . (-$TaxAmount/$_SESSION['CurrencyRate']) . "')"; + '" . round((-$TaxAmount/$_SESSION['CurrencyRate']),$_SESSION['CompanyRecord']['decimalplaces']) . "')"; $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'); $Result = DB_query($SQL,$db,$ErrMsg,$DbgMsg,true); } } + EnsureGLEntriesBalance(10,$InvoiceNo,$db); } /*end of if Sales and GL integrated */ DB_Txn_Commit($db); @@ -1617,36 +1617,39 @@ $_POST['InvoiceText']=''; } $j++; - echo '<table class=selection><tr> - <td>' ._('Date On Invoice'). ':</td> - <td><input tabindex='.$j.' type="text" maxlength="10" size="15" - name="DispatchDate" value="'.$DefaultDispatchDate.'" id="datepicker" - alt="'.$_SESSION['DefaultDateFormat'].'" class="date"></td> - </tr>'; + echo '<table class="selection"> + <tr> + <td>' ._('Date On Invoice'). ':</td> + <td><input tabindex='.$j.' type="text" maxlength="10" size="15" name="DispatchDate" value="'.$DefaultDispatchDate.'" id="datepicker" alt="'.$_SESSION['DefaultDateFormat'].'" class="date"></td> + </tr>'; $j++; echo '<tr> - <td>' . _('Consignment Note Ref'). ':</td> - <td><input tabindex='.$j.' type="text" maxlength="15" size="15" name="Consignment" value="' . $_POST['Consignment'] . '"></td> - </tr>'; + <td>' . _('Consignment Note Ref'). ':</td> + <td><input tabindex='.$j.' type="text" maxlength="15" size="15" name="Consignment" value="' . $_POST['Consignment'] . '"></td> + </tr>'; $j++; echo '<tr> - <td>'._('Action For Balance'). ':</td> - <td><select tabindex='.$j.' name="BOPolicy"><option selected value="BO">'._('Automatically put balance on back order').'</option><option value="CAN">'._('Cancel any quantities not delivered').'</option></select></td> - </tr>'; + <td>'._('Action For Balance'). ':</td> + <td><select tabindex='.$j.' name="BOPolicy"><option selected value="BO">'._('Automatically put balance on back order').'</option><option value="CAN">'._('Cancel any quantities not delivered').'</option></select></td> + </tr>'; $j++; echo '<tr> - <td>' ._('Invoice Text'). ':</td> - <td><textarea tabindex="'.$j.'" name="InvoiceText" cols="31" rows="5">' . reverse_escape($_POST['InvoiceText']) . '</textarea></td> - </tr>'; - + <td>' ._('Invoice Text'). ':</td> + <td><textarea tabindex="'.$j.'" name="InvoiceText" cols="31" rows="5">' . reverse_escape($_POST['InvoiceText']) . '</textarea></td> + </tr>'; + $j++; echo '</table> - <br /><div class="centre"> - <input type=submit tabindex='.$j.' name="Update" value=' . _('Update'). '><br />'; + <br /> + <div class="centre"> + <input type="submit" tabindex="'.$j.'" name="Update" value="' . _('Update'). '" /> + <br />'; $j++; - echo '<br /><input type=submit tabindex='.$j.' name="ProcessInvoice" value="'._('Process Invoice').'"</div>'; - echo '<input type=hidden name="ShipVia" value="' . $_SESSION['Items']->ShipVia . '">'; + echo '<br /> + <input type="submit" tabindex="'.$j.'" name="ProcessInvoice" value="'._('Process Invoice').'" /> + </div> + <input type="hidden" name="ShipVia" value="' . $_SESSION['Items']->ShipVia . '" />'; } echo '</form>'; Modified: trunk/CounterSales.php =================================================================== --- trunk/CounterSales.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/CounterSales.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -239,31 +239,31 @@ if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decmimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.discontinued=0 - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decmimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.discontinued=0 - AND stockmaster.description " . LIKE . " '" . $SearchString . "' - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.description " . LIKE . " '" . $SearchString . "' + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; } } else if (mb_strlen($_POST['StockCode'])>0){ @@ -273,59 +273,59 @@ if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.discontinued=0 - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + AND (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.stockid " . LIKE . " '" . $SearchString . "' + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; } } else { if ($_POST['StockCat']=='All'){ $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.discontinued=0 - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + ORDER BY stockmaster.stockid"; } else { $SQL = "SELECT stockmaster.stockid, - stockmaster.description, - stockmaster.units, - stockmaster.decimalplaces - FROM stockmaster INNER JOIN stockcategory - ON stockmaster.categoryid=stockcategory.categoryid - WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') - AND stockmaster.mbflag <>'G' - AND stockmaster.controlled <> 1 - AND stockmaster.discontinued=0 - AND stockmaster.categoryid='" . $_POST['StockCat'] . "' - ORDER BY stockmaster.stockid"; + stockmaster.description, + stockmaster.units, + stockmaster.decimalplaces + FROM stockmaster INNER JOIN stockcategory + ON stockmaster.categoryid=stockcategory.categoryid + WHERE (stockcategory.stocktype='F' OR stockcategory.stocktype='D') + AND stockmaster.mbflag <>'G' + AND stockmaster.controlled <> 1 + AND stockmaster.discontinued=0 + AND stockmaster.categoryid='" . $_POST['StockCat'] . "' + ORDER BY stockmaster.stockid"; } } @@ -465,6 +465,8 @@ prnMsg(_('Phantom assemblies cannot be sold, these items exist only as bills of materials used in other manufactured items. The following item has not been added to the order:') . ' ' . $NewItem, 'warn'); } else if ($myrow['controlled']==1){ prnMsg(_('The system does not currently cater for counter sales of lot controlled or serialised items'),'warn'); + } else if ($NewItemQty<=0) { + prnMsg(_('Only items entered with a positive quantity can be added to the sale'),'warn'); } else { /*Its not a kit set item*/ include('includes/SelectOrderItems_IntoCart.inc'); $_SESSION['Items'.$identifier]->GetTaxes(($_SESSION['Items'.$identifier]->LineCounter - 1)); Modified: trunk/GLTrialBalance.php =================================================================== --- trunk/GLTrialBalance.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/GLTrialBalance.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -40,7 +40,8 @@ $DefaultFromDate = Date ('Y-m-d', Mktime(0,0,0,$_SESSION['YearEnd'] + 2,0,Date('Y')-1)); $FromDate = Date($_SESSION['DefaultDateFormat'], Mktime(0,0,0,$_SESSION['YearEnd'] + 2,0,Date('Y')-1)); } - $period=GetPeriod($FromDate, $db); + /*GetPeriod function creates periods if need be the return value is not used */ + $NotUsedPeriodNo = GetPeriod($FromDate, $db); /*Show a form to allow input of criteria for TB to show */ echo '<table class="selection"> @@ -75,14 +76,7 @@ echo '</select></td> </tr>'; if (!isset($_POST['ToPeriod']) OR $_POST['ToPeriod']==''){ - $lastDate = date('Y-m-d',mktime(0,0,0,Date('m')+1,0,Date('Y'))); - $sql = "SELECT periodno - FROM periods - WHERE lastdate_in_period = '" . $lastDate . "'"; - $MaxPrd = DB_query($sql,$db); - $MaxPrdrow = DB_fetch_row($MaxPrd); - $DefaultToPeriod = (int) ($MaxPrdrow[0]); - + $DefaultToPeriod = GetPeriod(date($_SESSION['DefaultDateFormat'],mktime(0,0,0,Date('m')+1,0,Date('Y'))),$db); } else { $DefaultToPeriod = $_POST['ToPeriod']; } Modified: trunk/PO_Items.php =================================================================== --- trunk/PO_Items.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/PO_Items.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -166,22 +166,22 @@ '" . $_SESSION['PO'.$identifier]->Initiator . "', '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', '" . $_SESSION['PO'.$identifier]->Location . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd1) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd2) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd3) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd4) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd5) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd6) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->Tel) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd1) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd2) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd3) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd4) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd5) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd6) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SupplierContact) . "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->SuppTel). "', - '" . DB_escape_string($_SESSION['PO'.$identifier]->Contact) . "', + '" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->Tel . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', + '" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', + '" . $_SESSION['PO'.$identifier]->SupplierContact . "', + '" . $_SESSION['PO'.$identifier]->SuppTel. "', + '" . $_SESSION['PO'.$identifier]->Contact . "', '" . $_SESSION['PO'.$identifier]->Version . "', '" . Date('Y-m-d') . "', '" . $_SESSION['PO'.$identifier]->DeliveryBy . "', @@ -254,7 +254,7 @@ /*Update the purchase order header with any changes */ $sql = "UPDATE purchorders SET supplierno = '" . $_SESSION['PO'.$identifier]->SupplierID . "' , - comments='" . DB_escape_string($_SESSION['PO'.$identifier]->Comments) . "', + comments='" . $_SESSION['PO'.$identifier]->Comments . "', rate='" . $_SESSION['PO'.$identifier]->ExRate . "', initiator='" . $_SESSION['PO'.$identifier]->Initiator . "', requisitionno= '" . $_SESSION['PO'.$identifier]->RequisitionNo . "', @@ -263,26 +263,26 @@ deliverydate='" . FormatDateForSQL($_SESSION['PO'.$identifier]->DeliveryDate) . "', revised= '" . Date('Y-m-d') . "', intostocklocation='" . $_SESSION['PO'.$identifier]->Location . "', - deladd1='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd1) . "', - deladd2='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd2) . "', - deladd3='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd3) . "', - deladd4='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd4) . "', - deladd5='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd5) . "', - deladd6='" . DB_escape_string($_SESSION['PO'.$identifier]->DelAdd6) . "', - deladd6='" . DB_escape_string($_SESSION['PO'.$identifier]->Tel) . "', - suppdeladdress1='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd1) . "', - suppdeladdress2='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd2) . "', - suppdeladdress3='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd3) . "', - suppdeladdress4='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd4) . "', - suppdeladdress5='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd5) . "', - suppdeladdress6='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppDelAdd6) . "', - suppliercontact='" . DB_escape_string($_SESSION['PO'.$identifier]->SupplierContact) . "', - supptel='" . DB_escape_string($_SESSION['PO'.$identifier]->SuppTel) . "', - contact='" . DB_escape_string($_SESSION['PO'.$identifier]->Contact) . "', + deladd1='" . $_SESSION['PO'.$identifier]->DelAdd1 . "', + deladd2='" . $_SESSION['PO'.$identifier]->DelAdd2 . "', + deladd3='" . $_SESSION['PO'.$identifier]->DelAdd3 . "', + deladd4='" . $_SESSION['PO'.$identifier]->DelAdd4 . "', + deladd5='" . $_SESSION['PO'.$identifier]->DelAdd5 . "', + deladd6='" . $_SESSION['PO'.$identifier]->DelAdd6 . "', + deladd6='" . $_SESSION['PO'.$identifier]->Tel . "', + suppdeladdress1='" . $_SESSION['PO'.$identifier]->SuppDelAdd1 . "', + suppdeladdress2='" . $_SESSION['PO'.$identifier]->SuppDelAdd2 . "', + suppdeladdress3='" . $_SESSION['PO'.$identifier]->SuppDelAdd3 . "', + suppdeladdress4='" . $_SESSION['PO'.$identifier]->SuppDelAdd4 . "', + suppdeladdress5='" . $_SESSION['PO'.$identifier]->SuppDelAdd5 . "', + suppdeladdress6='" . $_SESSION['PO'.$identifier]->SuppDelAdd6 . "', + suppliercontact='" . $_SESSION['PO'.$identifier]->SupplierContact . "', + supptel='" . $_SESSION['PO'.$identifier]->SuppTel . "', + contact='" . $_SESSION['PO'.$identifier]->Contact . "', paymentterms='" . $_SESSION['PO'.$identifier]->PaymentTerms . "', allowprint='" . $_SESSION['PO'.$identifier]->AllowPrintPO . "', status = '" . $_SESSION['PO'.$identifier]->Status . "', - stat_comment = '" . DB_escape_string($_SESSION['PO'.$identifier]->StatusComments) . "' + stat_comment = '" . $_SESSION['PO'.$identifier]->StatusComments . "' WHERE orderno = '" . $_SESSION['PO'.$identifier]->OrderNo ."'"; $ErrMsg = _('The purchase order could not be updated because'); Modified: trunk/Z_DescribeTable.php =================================================================== --- trunk/Z_DescribeTable.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/Z_DescribeTable.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -1,8 +1,6 @@ <?php /* $Id$*/ -//$PageSecurity = 11; - include('includes/session.inc'); $title = _('Database table details'); include('includes/header.inc'); Modified: trunk/doc/Change.log =================================================================== --- trunk/doc/Change.log 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/doc/Change.log 2011-11-10 09:30:52 UTC (rev 4743) @@ -1,5 +1,7 @@ webERP Change Log +10/11/11 Phil: includes/DateFunctions.inc fixed GetPeriod function to create new period when just one month ahead of last period - worried about this can't see how it could have been like this so long without a bug report? +10/11/11 Phil: includes/LanguageSetup.php now sets LC_NUMERIC locale category after LC_ALL to ensure SQL compliant calculations 8/11/11 Phil: includes/GetConfig.php no longer casts the VersionNumber to a double - issue highlighted by Tim 8/11/11 Felix Lim: includes/InputSerialItems.php and InputSerialItemsKeyed.php now sends $identifier 8/11/11 Phil: fixed bugs reported by Ron Wong and Don SelectSupplier.php sql error missed "s" off suppliers and CustomerReceipt.php - had not populated new class variable (property) of CurrDecimalPlaces Modified: trunk/includes/DateFunctions.inc =================================================================== --- trunk/includes/DateFunctions.inc 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/includes/DateFunctions.inc 2011-11-10 09:30:52 UTC (rev 4743) @@ -858,6 +858,7 @@ } elseif (mb_strpos ($TransDate,'.')) { $Date_Array = explode('.',$TransDate); } + if (($_SESSION['DefaultDateFormat']=='d/m/Y') or ($_SESSION['DefaultDateFormat']=='d.m.Y')){ $TransDate = mktime(0,0,0,$Date_Array[1],$Date_Array[0],$Date_Array[2]); } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y'){ @@ -879,6 +880,7 @@ $sql = "SELECT MAX(lastdate_in_period), MAX(periodno) from periods"; $result = DB_query($sql, $db); $myrow=DB_fetch_row($result); + if (is_null($myrow[0])){ $InsertFirstPeriodResult = DB_query("INSERT INTO periods VALUES (0,'" . Date('Y-m-d',mktime(0,0,0,Date('m')+1,0,Date('Y'))) . "')",$db,_('Could not insert first period')); $InsertFirstPeriodResult = DB_query("INSERT INTO periods VALUES (1,'" . Date('Y-m-d',mktime(0,0,0,Date('m')+2,0,Date('Y'))) . "')",$db,_('Could not insert second period')); @@ -886,7 +888,7 @@ $LastPeriodEnd = mktime(0,0,0,Date('m')+2,0,Date('Y')); } else { $Date_Array = explode('-', $myrow[0]); - $LastPeriodEnd = mktime(0,0,0,$Date_Array[1]+2,0,(int)$Date_Array[0]); + $LastPeriodEnd = mktime(0,0,0,$Date_Array[1]+1,0,(int)$Date_Array[0]); $LastPeriod = $myrow[1]; } /* Find the unix timestamp of the first period end date in periods table */ @@ -900,20 +902,20 @@ /* If the period number doesn't exist */ if (!PeriodExists($TransDate, $db)) { /* if the transaction is after the last period */ + if ($TransDate > $LastPeriodEnd) { + $PeriodEnd = mktime(0,0,0,Date('m', $TransDate)+1, 0, Date('Y', $TransDate)); - $Period = $LastPeriod + 1; + while ($PeriodEnd >= $LastPeriodEnd) { - CreatePeriod($Period, $LastPeriodEnd, $db); - $Period++; if (Date('m', $LastPeriodEnd)<=13) { $LastPeriodEnd = mktime(0,0,0,Date('m', $LastPeriodEnd)+2, 0, Date('Y', $LastPeriodEnd)); } else { $LastPeriodEnd = mktime(0,0,0,2, 0, Date('Y', $LastPeriodEnd)+1); } + $LastPeriod++; + CreatePeriod($LastPeriod, $LastPeriodEnd, $db); } - $PeriodEnd = mktime(0,0,0,Date('m', $LastPeriodEnd)+1, 0, Date('Y', $LastPeriodEnd)); - CreatePeriod($Period, $PeriodEnd, $db); } else { /* The transaction is before the first period */ $PeriodEnd = mktime(0,0,0,Date('m', $TransDate), 0, Date('Y', $TransDate)); Modified: trunk/includes/LanguageSetup.php =================================================================== --- trunk/includes/LanguageSetup.php 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/includes/LanguageSetup.php 2011-11-10 09:30:52 UTC (rev 4743) @@ -63,8 +63,9 @@ include('includes/LanguagesArray.php'); } else { include('includes/LanguagesArray.php'); - $LocaleSet = setlocale (LC_NUMERIC, 'en_US','english-us'); + $LocaleSet = setlocale (LC_ALL, $_SESSION['Language'],$LanguagesArray[$_SESSION['Language']]['WindowsLocale']); + $LocaleSet = setlocale (LC_NUMERIC, 'C','en_GB.utf8','en_GB','en_US','english-us'); if (defined('LC_MESSAGES')){ //it's a unix/linux server $LocaleSet = setlocale (LC_MESSAGES, $_SESSION['Language']); @@ -73,6 +74,7 @@ if ($_SESSION['Language']=='tr_TR.utf8') { $Locale = setlocale(LC_CTYPE, 'C'); } + // possibly even if locale fails the language will still switch by using Language instead of locale variable putenv('LANG=' . $_SESSION['Language']); putenv('LANGUAGE=' . $_SESSION['Language']); Modified: trunk/includes/PDFTransPageHeader.inc =================================================================== --- trunk/includes/PDFTransPageHeader.inc 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/includes/PDFTransPageHeader.inc 2011-11-10 09:30:52 UTC (rev 4743) @@ -180,14 +180,14 @@ /*Set up headings */ $FontSize=10; $pdf->addText($Left_Margin + 2, $YPos, $FontSize, _('Customer Tax Ref') . ':'); -$pdf->addText($Left_Margin+80, $YPos, $FontSize, $myrow['taxref']); +$pdf->addText($Left_Margin+100, $YPos, $FontSize, $myrow['taxref']); /*Print a vertical line */ $pdf->line($Left_Margin+248, $YPos-10+$line_height+3,$Left_Margin+248, $YPos - 18); if ($InvOrCredit=='Invoice'){ $pdf->addText($Left_Margin + 252, $YPos, $FontSize, _('Customer Order Ref.') . ':'); - $pdf->addText($Left_Margin+340, $YPos, $FontSize, $myrow['customerref']); + $pdf->addText($Left_Margin+370, $YPos, $FontSize, $myrow['customerref']); } /*Print a vertical line */ $pdf->line($Left_Margin+450, $YPos+$line_height-7,$Left_Margin+450,$YPos-18); Modified: trunk/includes/SQL_CommonFunctions.inc =================================================================== --- trunk/includes/SQL_CommonFunctions.inc 2011-11-08 09:03:06 UTC (rev 4742) +++ trunk/includes/SQL_CommonFunctions.inc 2011-11-10 09:30:52 UTC (rev 4743) @@ -330,4 +330,35 @@ } +/*Ensures general ledger entries balance for a given transaction */ +function EnsureGLEntriesBalance ($TransType, $TransTypeNo, $db) { + + $result = DB_query("SELECT SUM(amount) + FROM gltrans + WHERE type = '" . $TransType . "' + AND typeno = '" . $TransTypeNo . "'", + $db); + $myrow = DB_fetch_row($result); + $Difference = $myrow[0]; + if (abs($Difference)!=0){ + if (abs($Difference)>0.1){ + prnMsg(_('The general ledger entries created do not balance. See your system administrator'),'error'); + } else { + $result = DB_query("SELECT counterindex, + MAX(amount) + FROM gltrans + WHERE type = '" . $TransType . "' + AND typeno = '" . $TransTypeNo . "' + GROUP BY counterindex", + $db); + $myrow = DB_fetch_array($result); + $TransToAmend = $myrow['counterindex']; + $result = DB_query("UPDATE gltrans SET amount = amount - " . $Difference . " + WHERE counterindex = '" . $TransToAmend . "'", + $db); + + } + } +} + ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |