[Weberp-svn] SF.net SVN: weberp:[8300] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-10-28 10:43:03
|
Revision: 8300 http://weberp.svn.sourceforge.net/weberp/?rev=8300&view=rev Author: tim_schofield Date: 2011-10-28 10:42:57 +0000 (Fri, 28 Oct 2011) Log Message: ----------- Show numbers in correct formatting for the users locale Modified Paths: -------------- trunk/ContractBOM.php trunk/ContractOtherReqts.php trunk/Contracts.php trunk/includes/DefineContractClass.php Modified: trunk/ContractBOM.php =================================================================== --- trunk/ContractBOM.php 2011-10-28 10:40:35 UTC (rev 8299) +++ trunk/ContractBOM.php 2011-10-28 10:42:57 UTC (rev 8300) @@ -28,7 +28,7 @@ //this is the same as deleting the line - so delete it $_SESSION['Contract'.$identifier]->Remove_ContractComponent($ContractComponent->ComponentID); } else { - $_SESSION['Contract'.$identifier]->ContractBOM[$ContractComponent->ComponentID]->Quantity=$_POST['Qty'.$ContractComponent->ComponentID]; + $_SESSION['Contract'.$identifier]->ContractBOM[$ContractComponent->ComponentID]->Quantity=filter_number_input($_POST['Qty'.$ContractComponent->ComponentID]); } } // end loop around the items on the contract BOM } // end if the contract is not currently committed to by the customer @@ -167,9 +167,10 @@ if (isset($_POST['NewItem'])){ /* NewItem is set from the part selection list as the part code selected */ /* take the form entries and enter the data from the form into the PurchOrder class variable */ foreach ($_POST as $key => $value) { - if (mb_substr($key, 0, 3)=='qty') { - $ItemCode=mb_substr($key, 3, mb_strlen($key)-3); - $Quantity=$value; + if (mb_substr($key, 0, 7)=='StockID') { + $Index=mb_substr($key, 7); + $ItemCode=$value; + $Quantity=filter_number_input($_POST['qty'.$Index]); $AlreadyOnThisBOM = 0; if (count($_SESSION['Contract'.$identifier]->ContractBOM)!=0){ @@ -203,7 +204,7 @@ $_SESSION['Contract'.$identifier]->Add_To_ContractBOM ($ItemCode, $myrow['description'], - $DefaultWorkCentre, + $_SESSION['Contract'.$identifier]->DefaultWorkCentre, $Quantity, /* Qty */ $myrow['unitcost'], $myrow['units']); @@ -251,7 +252,7 @@ $LineTotal = $ContractComponent->Quantity * $ContractComponent->ItemCost; - $DisplayLineTotal = number_format($LineTotal,2); + $DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['Contract'.$identifier]->CurrCode); if ($k==1){ echo '<tr class="EvenTableRows">'; @@ -263,15 +264,15 @@ echo '<td>' . $ContractComponent->StockID . '</td> <td>' . $ContractComponent->ItemDescription . '</td> - <td><input type="text" class="number" name="Qty' . $ContractComponent->ComponentID . '" size="11" value="' . $ContractComponent->Quantity . '" /></td> + <td><input type="text" class="number" name="Qty' . $ContractComponent->ComponentID . '" size="11" value="' . locale_number_format($ContractComponent->Quantity, $ContractComponent->DecimalPlaces) . '" /></td> <td>' . $ContractComponent->UOM . '</td> - <td class="number">' . $ContractComponent->ItemCost . '</td> + <td class="number">' . locale_number_format($ContractComponent->ItemCost,4) . '</td> <td class="number">' . $DisplayLineTotal . '</td> <td><a href="' . $_SERVER['PHP_SELF'] . '?identifier='.$identifier. '&Delete=' . $ContractComponent->ComponentID . '">' . _('Delete') . '</a></td></tr>'; $TotalCost += $LineTotal; } - $DisplayTotal = number_format($TotalCost,2); + $DisplayTotal = locale_money_format($TotalCost,$_SESSION['Contract'.$identifier]->CurrCode); echo '<tr><td colspan="6" class="number">' . _('Total Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>'; echo '<br /><div class="centre"><input type="submit" name="UpdateLines" value="' . _('Update Lines') . '" />'; echo '<input type="submit" name="BackToHeader" value="' . _('Back To Contract Header') . '" /></div>'; @@ -345,7 +346,7 @@ </tr>'; echo $TableHeader; - $j = 1; + $Index = 1; $k=0; //row colour counter while ($myrow=DB_fetch_array($SearchResult)) { @@ -369,13 +370,15 @@ <td>'.$myrow['description'].'</td> <td>'.$myrow['units'] . '</td> <td>'.$ImageSource.'</td> - <td><input class="number" type="text" size="6" value="0" name="qty'.$myrow['stockid'].'" /></td> + <td><input class="number" type="text" size="6" value="0" name="qty'.$Index.'" /></td> + <td><input type="hidden" value="'.$myrow['stockid'].'" name="StockID'.$Index.'" /></td> </tr>'; $PartsDisplayed++; if ($PartsDisplayed == $Maximum_Number_Of_Parts_To_Show){ break; } + $Index++; #end of page full new headings if } #end of while loop @@ -390,8 +393,6 @@ echo '<br /><div class="centre"><input type="submit" name="NewItem" value="' . _('Add to Contract Bill Of Material') .'" /></div>'; }#end if SearchResults to show -echo '<hr />'; - echo '</form>'; include('includes/footer.inc'); ?> \ No newline at end of file Modified: trunk/ContractOtherReqts.php =================================================================== --- trunk/ContractOtherReqts.php 2011-10-28 10:40:35 UTC (rev 8299) +++ trunk/ContractOtherReqts.php 2011-10-28 10:42:57 UTC (rev 8300) @@ -28,8 +28,8 @@ //this is the same as deleting the line - so delete it $_SESSION['Contract'.$identifier]->Remove_ContractRequirement($ContractComponentID); } else { - $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Quantity=$_POST['Qty'.$ContractComponentID]; - $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->CostPerUnit=$_POST['CostPerUnit'.$ContractComponentID]; + $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Quantity=filter_number_input($_POST['Qty'.$ContractComponentID]); + $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->CostPerUnit=filter_currency_input($_POST['CostPerUnit'.$ContractComponentID]); $_SESSION['Contract'.$identifier]->ContractReqts[$ContractComponentID]->Requirement=$_POST['Requirement'.$ContractComponentID]; } } // end loop around the items on the contract requirements array @@ -55,18 +55,18 @@ } if (isset($_POST['EnterNewRequirement'])){ $InputError = false; - if (!is_numeric($_POST['Quantity'])){ + if (!is_numeric(filter_number_input($_POST['Quantity']))){ prnMsg(_('The quantity of the new requirement is expected to be numeric'),'error'); $InputError = true; } - if (!is_numeric($_POST['CostPerUnit'])){ + if (!is_numeric(filter_currency_input($_POST['CostPerUnit']))){ prnMsg(_('The cost per unit of the new requirement is expected to be numeric'),'error'); $InputError = true; } if (!$InputError){ $_SESSION['Contract'.$identifier]->Add_To_ContractRequirements ($_POST['RequirementDescription'], - $_POST['Quantity'], - $_POST['CostPerUnit']); + filter_number_input($_POST['Quantity']), + filter_currency_input($_POST['CostPerUnit'])); unset($_POST['RequirementDescription']); unset($_POST['Quantity']); unset($_POST['CostPerUnit']); @@ -102,7 +102,7 @@ $LineTotal = $ContractComponent->Quantity * $ContractComponent->CostPerUnit; - $DisplayLineTotal = number_format($LineTotal,2); + $DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['Contract'.$identifier]->CurrCode); if ($k==1){ echo '<tr class="EvenTableRows">'; @@ -113,14 +113,14 @@ } echo '<td><textarea name="Requirement' . $ContractReqtID . '" cols="30" rows="3">' . $ContractComponent->Requirement . '</textarea></td> - <td><input type="text" class="number" name="Qty' . $ContractReqtID . '" size="11" value="' . $ContractComponent->Quantity . '" /></td> - <td><input type="text" class="number" name="CostPerUnit' . $ContractReqtID . '" size="11" value="' . $ContractComponent->CostPerUnit . '" /></td> + <td><input type="text" class="number" name="Qty' . $ContractReqtID . '" size="11" value="' . locale_number_format($ContractComponent->Quantity,2) . '" /></td> + <td><input type="text" class="number" name="CostPerUnit' . $ContractReqtID . '" size="11" value="' . locale_money_format($ContractComponent->CostPerUnit,$_SESSION['Contract'.$identifier]->CurrCode) . '" /></td> <td class="number">' . $DisplayLineTotal . '</td> <td><a href="' . $_SERVER['PHP_SELF'] . '?identifier='.$identifier. '&Delete=' . $ContractReqtID . '">' . _('Delete') . '</a></td></tr>'; $TotalCost += $LineTotal; } - $DisplayTotal = number_format($TotalCost,2); + $DisplayTotal = locale_money_format($TotalCost,$_SESSION['Contract'.$identifier]->CurrCode); echo '<tr><td colspan="4" class="number">' . _('Total Other Requirements Cost') . '</td><td class="number"><b>' . $DisplayTotal . '</b></td></tr></table>'; echo '<br /><div class="centre"><input type="submit" name="UpdateLines" value="' . _('Update Other Requirements Lines') . '" />'; echo ' <input type="submit" name="BackToHeader" value="' . _('Back To Contract Header') . '" /></div>'; Modified: trunk/Contracts.php =================================================================== --- trunk/Contracts.php 2011-10-28 10:40:35 UTC (rev 8299) +++ trunk/Contracts.php 2011-10-28 10:42:57 UTC (rev 8300) @@ -67,9 +67,10 @@ $_SESSION['Contract'.$identifier]->CategoryID = $_POST['CategoryID']; $_SESSION['Contract'.$identifier]->LocCode = $_POST['LocCode']; $_SESSION['Contract'.$identifier]->RequiredDate = $_POST['RequiredDate']; - $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; + $_SESSION['Contract'.$identifier]->Margin = filter_number_input($_POST['Margin']); $_SESSION['Contract'.$identifier]->CustomerRef = $_POST['CustomerRef']; - $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; + $_SESSION['Contract'.$identifier]->ExRate = filter_number_input($_POST['ExRate']); + $_SESSION['Contract'.$identifier]->DefaultWorkCentre = $_POST['DefaultWorkCentre']; /*User hit the button to enter line items - @@ -258,10 +259,10 @@ $_SESSION['Contract'.$identifier]->CategoryID = $_POST['CategoryID']; $_SESSION['Contract'.$identifier]->LocCode = $_POST['LocCode']; $_SESSION['Contract'.$identifier]->RequiredDate = $_POST['RequiredDate']; - $_SESSION['Contract'.$identifier]->Margin = $_POST['Margin']; + $_SESSION['Contract'.$identifier]->Margin = filter_number_input($_POST['Margin']); $_SESSION['Contract'.$identifier]->Status = $_POST['Status']; $_SESSION['Contract'.$identifier]->CustomerRef = $_POST['CustomerRef']; - $_SESSION['Contract'.$identifier]->ExRate = $_POST['ExRate']; + $_SESSION['Contract'.$identifier]->ExRate = filter_number_input($_POST['ExRate']); /*Get the first work centre for the users location - until we set this up properly */ $result = DB_query("SELECT code FROM workcentres WHERE location='" . $_SESSION['Contract'.$identifier]->LocCode ."'",$db); @@ -793,7 +794,7 @@ } else { echo '<td></td>'; } - echo '<td><input tabindex="'.number_format($j+5).'" type="submit" name="Submit'.$j.'" value="'.htmlentities($myrow['brname'], ENT_QUOTES,'UTF-8').'" /></td> + echo '<td><input type="submit" name="Submit'.$j.'" value="'.htmlentities($myrow['brname'], ENT_QUOTES,'UTF-8').'" /></td> <input type="hidden" name="SelectedCustomer'.$j.'" value="'.$myrow['debtorno'].'" /> <input type="hidden" name="SelectedBranch'.$j.'" value="'.$myrow['branchcode'].'" /> <td>'.htmlentities($myrow['contactname'], ENT_QUOTES,'UTF-8').'</td> @@ -872,7 +873,30 @@ } echo '</select></td></tr>'; + echo '<tr><td>' . _('Default Work Centre') . ': </td><td>'; + echo '<select name="DefaultWorkCentre">'; + $sql = "SELECT code, description FROM workcentres"; + $result = DB_query($sql,$db); + + if (DB_num_rows($result)==0){ + prnMsg( _('There are no work centres set up yet') . '. ' . _('Please use the link below to set up work centres'),'warn'); + echo '<br /><a href="'.$rootpath.'/WorkCentres.php">' . _('Work Centre Maintenance') . '</a>'; + include('includes/footer.inc'); + exit; + } + + while ($myrow = DB_fetch_array($result)) { + if (isset($_POST['DefaultWorkCentre']) and $myrow['code']==$_POST['DefaultWorkCentre']) { + echo '<option selected="True" value="'.$myrow['code'] . '">' . $myrow['description'] . '</option>'; + } else { + echo '<option value="'.$myrow['code'] . '">' . $myrow['description'] . '</option>'; + } + } //end while loop + + DB_free_result($result); + + echo '</select></td></tr>'; echo '<tr><td>' . _('Contract Description'); echo ':</td><td><textarea name="ContractDescription" style="width:100%" rows="5">' . $_SESSION['Contract'.$identifier]->ContractDescription . '</textarea></td></tr>'; @@ -888,11 +912,11 @@ if (!isset($_SESSION['Contract'.$identifier]->Margin)){ $_SESSION['Contract'.$identifier]->Margin =50; } - echo '<tr><td>' . _('Gross Profit') . ' %:</td><td><input type="text" name="Margin" size="4" maxlength="4" value="' . $_SESSION['Contract'.$identifier]->Margin . '" /></td></tr>'; + echo '<tr><td>' . _('Gross Profit') . ' %:</td><td><input class="number" type="text" name="Margin" size="6" maxlength="6" value="' . locale_number_format($_SESSION['Contract'.$identifier]->Margin, 2) . '" /></td></tr>'; if ($_SESSION['CompanyRecord']['currencydefault'] != $_SESSION['Contract'.$identifier]->CurrCode){ echo '<tr><td>' . $_SESSION['Contract'.$identifier]->CurrCode . ' ' . _('Exchange Rate') . ':</td> - <td><input type="text" name="ExRate" size="10" maxlength="10" value="' . $_SESSION['Contract'.$identifier]->ExRate . '" /></td></tr>'; + <td><input class="number" type="text" name="ExRate" size="10" maxlength="10" value="' . locale_number_format($_SESSION['Contract'.$identifier]->ExRate, 4) . '" /></td></tr>'; } else { echo '<input type="hidden" name="ExRate" value="' . $_SESSION['Contract'.$identifier]->ExRate . '" />'; } @@ -933,14 +957,14 @@ foreach ($_SESSION['Contract'.$identifier]->ContractBOM as $Component) { echo '<tr><td>' . $Component->StockID . '</td> <td>' . $Component->ItemDescription . '</td> - <td class="number">' . $Component->Quantity . '</td> + <td class="number">' . locale_number_format($Component->Quantity, $Component->DecimalPlaces) . '</td> <td>' . $Component->UOM . '</td> - <td class="number">' . number_format($Component->ItemCost,2) . '</td> - <td class="number">' . number_format(($Component->ItemCost * $Component->Quantity),2) . '</td> + <td class="number">' . locale_money_format($Component->ItemCost,$_SESSION['Contract'.$identifier]->CurrCode) . '</td> + <td class="number">' . locale_money_format(($Component->ItemCost * $Component->Quantity),$_SESSION['Contract'.$identifier]->CurrCode) . '</td> </tr>'; $ContractBOMCost += ($Component->ItemCost * $Component->Quantity); } - echo '<tr><th colspan="5"><b>' . _('Total stock cost') . '</b></th><th class="number"><b>' . number_format($ContractBOMCost,2) . '</b></th></tr>'; + echo '<tr><th colspan="5"><b>' . _('Total stock cost') . '</b></th><th class="number"><b>' . locale_money_format($ContractBOMCost,$_SESSION['Contract'.$identifier]->CurrCode) . '</b></th></tr>'; } else { //there are no items set up against this contract echo '<tr><td colspan="6"><i>' . _('None Entered') . '</i></td></tr>'; } @@ -955,19 +979,19 @@ <th>' . _('Total Cost') . '</th></tr>'; foreach ($_SESSION['Contract'.$identifier]->ContractReqts as $Requirement) { echo '<tr><td>' . $Requirement->Requirement . '</td> - <td class="number">' . $Requirement->Quantity . '</td> - <td class="number">' . $Requirement->CostPerUnit . '</td> - <td class="number">' . number_format(($Requirement->CostPerUnit * $Requirement->Quantity),2) . '</td> + <td class="number">' . locale_number_format($Requirement->Quantity,2) . '</td> + <td class="number">' . locale_money_format($Requirement->CostPerUnit, $_SESSION['Contract'.$identifier]->CurrCode) . '</td> + <td class="number">' . locale_money_format(($Requirement->CostPerUnit * $Requirement->Quantity),$_SESSION['Contract'.$identifier]->CurrCode) . '</td> </tr>'; $ContractReqtsCost += ($Requirement->CostPerUnit * $Requirement->Quantity); } - echo '<tr><th colspan="3"><b>' . _('Total other costs') . '</b></th><th class="number"><b>' . number_format($ContractReqtsCost,2) . '</b></th></tr>'; + echo '<tr><th colspan="3"><b>' . _('Total other costs') . '</b></th><th class="number"><b>' . locale_money_format($ContractReqtsCost,$_SESSION['Contract'.$identifier]->CurrCode) . '</b></th></tr>'; } else { //there are no items set up against this contract echo '<tr><td colspan="4"><i>' . _('None Entered') . '</i></td></tr>'; } echo '</table></td></tr></table>'; echo '<br />'; - echo'<table class="selection"><tr><th>' . _('Total Contract Cost') . '</th><th class="number">' . number_format(($ContractBOMCost+$ContractReqtsCost),2) . '</th><th>' . _('Contract Price') . '</th><th class="number">' . number_format(($ContractBOMCost+$ContractReqtsCost)*((100+$_SESSION['Contract'.$identifier]->Margin)/100),2) . '</th></tr></table>'; + echo'<table class="selection"><tr><th>' . _('Total Contract Cost') . '</th><th class="number">' . locale_money_format(($ContractBOMCost+$ContractReqtsCost),$_SESSION['Contract'.$identifier]->CurrCode) . '</th><th>' . _('Contract Price') . '</th><th class="number">' . locale_money_format(($ContractBOMCost+$ContractReqtsCost)*((100+$_SESSION['Contract'.$identifier]->Margin)/100),$_SESSION['Contract'.$identifier]->CurrCode) . '</th></tr></table>'; echo'<p></p>'; echo '<div class="centre"><input type="submit" name="EnterContractBOM" value="' . _('Enter Items Required') . '" /> Modified: trunk/includes/DefineContractClass.php =================================================================== --- trunk/includes/DefineContractClass.php 2011-10-28 10:40:35 UTC (rev 8299) +++ trunk/includes/DefineContractClass.php 2011-10-28 10:42:57 UTC (rev 8300) @@ -24,6 +24,7 @@ var $ExRate; /*the rate of exchange between customer currency and company functional currency used when quoting */ var $BOMComponentCounter; var $RequirementsCounter; + var $DefaultWorkCentre; var $ContractBOM; /*array of stockid components required for the contract */ var $ContractReqts; /*array of other items required for the contract */ @@ -95,6 +96,7 @@ var $Quantity; var $ItemCost; var $UOM; + var $DecimalPlaces; function ContractComponent ($ComponentID, $StockID, @@ -104,6 +106,7 @@ $ItemCost, $UOM){ /* Constructor function to add a new Contract Component object with passed params */ + global $db; $this->ComponentID = $ComponentID; $this->StockID = $StockID; $this->ItemDescription = $ItemDescription; @@ -111,6 +114,11 @@ $this->Quantity = $Quantity; $this->ItemCost= $ItemCost; $this->UOM = $UOM; + + $SQL="SELECT decimalplaces FROM stockmaster WHERE stockid='".$StockID."'"; + $result=DB_query($SQL, $db); + $myrow=DB_fetch_array($result); + $this->DecimalPlaces=$myrow['decimalplaces']; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |