[Weberp-svn] SF.net SVN: weberp:[8209] trunk
Brought to you by:
sotandeka,
tim_schofield
From: <tim...@us...> - 2011-10-03 18:36:29
|
Revision: 8209 http://weberp.svn.sourceforge.net/weberp/?rev=8209&view=rev Author: tim_schofield Date: 2011-10-03 18:36:22 +0000 (Mon, 03 Oct 2011) Log Message: ----------- Add item category properties to sales order entry Modified Paths: -------------- trunk/DeliveryDetails.php trunk/SelectOrderItems.php trunk/includes/DefineCartClass.php trunk/includes/SelectOrderItems_IntoCart.inc Modified: trunk/DeliveryDetails.php =================================================================== --- trunk/DeliveryDetails.php 2011-10-02 23:45:01 UTC (rev 8208) +++ trunk/DeliveryDetails.php 2011-10-03 18:36:22 UTC (rev 8209) @@ -417,6 +417,23 @@ $ErrMsg = _('Unable to add the sales order line'); $Ins_LineItemResult = DB_query($LineItemsSQL,$db,$ErrMsg,$DbgMsg,true); + if (count($StockItem->ItemProperties) > 0) { + foreach ($StockItem->ItemProperties as $PropertyID=>$PropertyValue) { + $ItemPropertiesSQL = "INSERT INTO stockorderitemproperties ( + stockid, + orderno, + orderlineno, + stkcatpropid, + value) + VALUES ( + '" . $StockItem->StockID . "', + '" . $OrderNo . "', + '" . $StockItem->LineNumber . "', + '" . $PropertyID . "', + '" . $PropertyValue . "')"; + $ItemPropertyResult = DB_query($ItemPropertiesSQL,$db,$ErrMsg,$DbgMsg,true); + } + } /*Now check to see if the item is manufactured * and AutoCreateWOs is on * and it is a real order (not just a quotation)*/ @@ -776,6 +793,16 @@ $ErrMsg = _('The updated order line cannot be modified because'); $Upd_LineItemResult = DB_query($LineItemsSQL,$db,$ErrMsg,$DbgMsg,true); + foreach ($StockItem->ItemProperties as $PropertyID=>$PropertyValue) { + $ItemPropertiesSQL = "UPDATE stockorderitemproperties + SET value='" . $PropertyValue . "' + WHERE stockid='" . $StockItem->StockID . "' + AND orderno='" . $OrderNo . "' + AND orderlineno='" . $StockItem->LineNumber . "' + AND stkcatpropid='" . $PropertyID . "'"; + $ItemPropertyResult = DB_query($ItemPropertiesSQL,$db,$ErrMsg,$DbgMsg,true); + } + } /* updated line items into sales order details */ $Result=DB_Txn_Commit($db); @@ -832,10 +859,10 @@ foreach ($_SESSION['Items'.$identifier]->LineItems as $StockItem) { $LineTotal = $StockItem->Quantity * $StockItem->Price * (1 - $StockItem->DiscountPercent); - $DisplayLineTotal = number_format($LineTotal,2); - $DisplayPrice = number_format($StockItem->Price,2); - $DisplayQuantity = number_format($StockItem->Quantity,$StockItem->DecimalPlaces); - $DisplayDiscount = number_format(($StockItem->DiscountPercent * 100),2); + $DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['Items'.$identifier]->DefaultCurrency); + $DisplayPrice = locale_money_format($StockItem->Price,$_SESSION['Items'.$identifier]->DefaultCurrency); + $DisplayQuantity = locale_number_format($StockItem->Quantity,$StockItem->DecimalPlaces); + $DisplayDiscount = locale_number_format(($StockItem->DiscountPercent * 100),2); if ($k==1){ @@ -860,14 +887,14 @@ $_SESSION['Items'.$identifier]->totalWeight = $_SESSION['Items'.$identifier]->totalWeight + ($StockItem->Quantity * $StockItem->Weight); } - $DisplayTotal = number_format($_SESSION['Items'.$identifier]->total,2); + $DisplayTotal = locale_money_format($_SESSION['Items'.$identifier]->total,$_SESSION['Items'.$identifier]->DefaultCurrency); echo '<tr class="EvenTableRows"> <td colspan="6" class="number"><b>'. _('TOTAL Excl Tax/Freight') .'</b></td> <td class="number">'.$DisplayTotal.'</td> </tr>'; - $DisplayVolume = number_format($_SESSION['Items'.$identifier]->totalVolume,2); - $DisplayWeight = number_format($_SESSION['Items'.$identifier]->totalWeight,2); + $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,2); + $DisplayWeight = locale_number_format($_SESSION['Items'.$identifier]->totalWeight,2); echo '<br /><tr class="EvenTableRows"><td colspan="3"></td> <td>'. _('Total Weight') .':</td> <td class="number">'.$DisplayWeight.'</td> @@ -895,9 +922,9 @@ foreach ($_SESSION['Items'.$identifier]->LineItems as $StockItem) { $LineTotal = $StockItem->Quantity * $StockItem->Price * (1 - $StockItem->DiscountPercent); - $DisplayLineTotal = number_format($LineTotal,2); - $DisplayPrice = number_format($StockItem->Price,2); - $DisplayQuantity = number_format($StockItem->Quantity,$StockItem->DecimalPlaces); + $DisplayLineTotal = locale_money_format($LineTotal,$_SESSION['Items'.$identifier]->DefaultCurrency); + $DisplayPrice = locale_money_format($StockItem->Price,$_SESSION['Items'.$identifier]->DefaultCurrency); + $DisplayQuantity = locale_number_format($StockItem->Quantity,$StockItem->DecimalPlaces); if ($k==1){ echo '<tr class="OddTableRows">'; @@ -919,7 +946,7 @@ } - $DisplayTotal = number_format($_SESSION['Items'.$identifier]->total,2); + $DisplayTotal = locale_money_format($_SESSION['Items'.$identifier]->total,$_SESSION['Items'.$identifier]->DefaultCurrency); echo '<table class="selection"><tr> <td>'. _('Total Weight') .':</td> <td>'.$DisplayWeight .'</td> @@ -927,8 +954,8 @@ <td>'.$DisplayVolume .'</td> </tr></table>'; - $DisplayVolume = number_format($_SESSION['Items'.$identifier]->totalVolume,2); - $DisplayWeight = number_format($_SESSION['Items'.$identifier]->totalWeight,2); + $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,2); + $DisplayWeight = locale_number_format($_SESSION['Items'.$identifier]->totalWeight,2); echo '<table class="selection"><tr> <td>'. _('Total Weight') .':</td> <td>'. $DisplayWeight .'</td> Modified: trunk/SelectOrderItems.php =================================================================== --- trunk/SelectOrderItems.php 2011-10-02 23:45:01 UTC (rev 8208) +++ trunk/SelectOrderItems.php 2011-10-03 18:36:22 UTC (rev 8209) @@ -21,17 +21,22 @@ if (isset($_POST['QuickEntry'])){ unset($_POST['PartSearch']); } - -if (isset($_POST['order_items'])){ - foreach ($_POST as $key => $value) { - if (mb_strstr($key,'StockID')) { - $Index=mb_substr($key, 7); - $StockID=$value; - $NewItem_array[$StockID] = filter_number_input($_POST['Quantity'.$Index]); - $_POST['Units'.$StockID]=$_POST['Units'.$Index]; - $NewItem='Here'; - } +foreach ($_POST as $key => $value) { + if (mb_strstr($key,'StockID')) { + $Index=mb_substr($key, 7); + $StockID=$value; + $NewItem_array[$StockID] = filter_number_input($_POST['Quantity'.$Index]); + $_POST['Units'.$StockID]=$_POST['Units'.$Index]; + $NewItem=True; } + if (mb_strstr($key, 'PropOrderLine')) { + $OrderLinePropertyArray = explode('x', mb_substr($key, 13)); + $OrderLine = $OrderLinePropertyArray[0]; + $Index = $OrderLinePropertyArray[1]; + $PropCategoryID = $_POST['PropID'.$OrderLine.'x'.$Index]; + $PropValue = $_POST['PropValue'.$OrderLine.'x'.$Index]; + $PropertiesArray[$OrderLine][$PropCategoryID] = $PropValue; + } } if (isset($_GET['NewItem'])){ @@ -227,6 +232,21 @@ while ($myrow=db_fetch_array($LineItemsResult)) { if ($myrow['completed']==0){ + + $PropertiesSQL="SELECT stkcatpropid, + value + FROM stockorderitemproperties + WHERE orderno='" . $_GET['ModifyOrderNumber'] . "' + AND orderlineno='" . $myrow['orderlineno'] . "'"; + $PropertiesResult=DB_query($PropertiesSQL, $db); + if (DB_num_rows($PropertiesResult)==0) { + $PropertiesArray=array(); + } else { + while ($MyPropertiesRow=DB_fetch_array($PropertiesResult)) { + $PropertiesArray[$MyPropertiesRow['stkcatpropid']]=$MyPropertiesRow['value']; + } + } + $_SESSION['Items'.$identifier]->add_to_cart($myrow['stkcode'], $myrow['quantity'], $myrow['description'], @@ -254,8 +274,8 @@ $myrow['eoq'], $myrow['nextserialno'], $ExRate, - $myrow['conversionfactor'] ); - + $myrow['conversionfactor'], + $PropertiesArray ); /*Just populating with existing order - no DBUpdates */ } $LastLineNo = $myrow['orderlineno']; @@ -639,12 +659,12 @@ echo '<td><input tabindex="3" type="text" name="CustPhone" size="15" maxlength="18" /></td>'; echo '</tr>'; echo '</table>'; - echo '<br /><div class="centre"><input tabindex="4" type="submit" name="SearchCust" value="' . _('Search Now') . '" />'; - echo '<input tabindex="5" type="reset" value="' . _('Reset') . '" /></div>'; + echo '<br /><div class="centre"><input tabindex="4" type="submit" name="SearchCust" value="' . _('Search Now') . '" />'; + echo '<input tabindex="5" type="reset" value="' . _('Reset') . '" /></div>'; if (isset($result_CustSelect)) { - echo '<table cellpadding="2">'; + echo '<table cellpadding="2" class="selection">'; $TableHeader = '<br /><tr> <th>' . _('Customer') . '</th> @@ -885,11 +905,6 @@ if (DB_num_rows($SearchResult)==0 ){ prnMsg (_('There are no products available meeting the criteria specified'),'info'); } - if (DB_num_rows($SearchResult)==1){ - $myrow=DB_fetch_array($SearchResult); - $NewItem = $myrow['stockid']; - DB_data_seek($SearchResult,0); - } if (DB_num_rows($SearchResult)<$_SESSION['DisplayRecordsMax']){ $Offset=0; } @@ -916,7 +931,7 @@ /*Process Quick Entry */ /* If enter is pressed on the quick entry screen, the default button may be Recalculate */ - if (isset($_POST['order_items']) + if (isset($_POST['order_items']) OR isset($_POST['QuickEntry']) OR isset($_POST['Recalculate'])){ @@ -1156,8 +1171,8 @@ OR ABS($OrderLine->DiscountPercent -$DiscountPercentage/100) >0.001 OR $OrderLine->Narrative != $Narrative OR $OrderLine->ItemDue != $_POST['ItemDue_' . $OrderLine->LineNumber] - OR $OrderLine->POLine != $_POST['POLine_' . $OrderLine->LineNumber]) { - + OR $OrderLine->POLine != $_POST['POLine_' . $OrderLine->LineNumber] + OR isset($PropertiesArray)) { $_SESSION['Items'.$identifier]->update_cart_item($OrderLine->LineNumber, $Quantity, $Price, @@ -1168,7 +1183,8 @@ 'Yes', /*Update DB */ $_POST['ItemDue_' . $OrderLine->LineNumber], $_POST['POLine_' . $OrderLine->LineNumber], - $_POST['GPPercent_' . $OrderLine->LineNumber]); + $_POST['GPPercent_' . $OrderLine->LineNumber], + $PropertiesArray[$OrderLine->LineNumber]); } } //page not called from itself - POST variables not set } @@ -1314,8 +1330,8 @@ /* This is where the order as selected should be displayed reflecting any deletions or insertions*/ echo '<br /> - <table width="90%" cellpadding="2" colspan="7"> - <tr bgcolor=#800000>'; + <table width="90%" cellpadding="2" colspan="7" class="selection"> + <tr bgcolor="#800000">'; if($_SESSION['Items'.$identifier]->DefaultPOLine == 1){ echo '<th>' . _('PO Line') . '</th>'; } @@ -1411,6 +1427,75 @@ echo '<input type="hidden" name="Narrative" value="" />'; } + $PropertySQL="SELECT label, + controltype, + stkcatpropid, + numericvalue + FROM stockcatproperties + LEFT JOIN stockmaster + ON stockcatproperties.categoryid=stockmaster.categoryid + WHERE stockmaster.stockid='".$OrderLine->StockID."' + AND reqatsalesorder=1"; + $PropertyResult=DB_query($PropertySQL, $db); + if (DB_num_rows($PropertyResult)>0) { + $PropertyCounter=0; + while ($PropertyRow=DB_fetch_array($PropertyResult)) { + if ($k==1){ + echo '<tr class="OddTableRows">'; + $k=0; + } else { + echo '<tr class="EvenTableRows">'; + $k=1; + } + echo '<td>' . $PropertyRow['label'] . '</td>'; + echo '<input type="hidden" name="PropOrderLine' . $OrderLine->LineNumber . 'x' . $PropertyCounter . '" value="" />'; + echo '<input type="hidden" name="PropID' . $OrderLine->LineNumber . 'x' . $PropertyCounter . '" value="' . $PropertyRow['stkcatpropid'] . '" />'; + switch ($PropertyRow['controltype']) { + case 0: + if ($PropertyRow['numericvalue']==0) { + echo '<td><input type="text" name="PropValue'.$OrderLine->LineNumber . 'x' . $PropertyCounter.'" value="'.$OrderLine->ItemProperties[$PropertyRow['stkcatpropid']].'" /></td>'; + } else { + echo '<td><input type="text" class="number" size="12" name="PropValue'.$OrderLine->LineNumber . 'x' . $PropertyCounter.'" value="'.$OrderLine->ItemProperties[$PropertyRow['stkcatpropid']].'" /></td>'; + } + break; + case 1; //select box + $OptionValues = array(); + if ($PropertyRow['label']=='Manufacturers') { + $sql="SELECT coyname from manufacturers"; + $result=DB_query($sql, $db); + while ($myrow=DB_fetch_array($result)) { + $OptionValues[]=$myrow['coyname']; + } + } else { + $OptionValues = explode(',',$PropertyRow['defaultvalue']); + } + echo '<select name="PropValue' . $OrderLine->LineNumber . 'x' . $PropertyCounter . '">'; + foreach ($OptionValues as $PropertyOptionValue){ + if ($PropertyOptionValue == $OrderLine->ItemProperties[$PropertyRow['stkcatpropid']]){ + echo '<option selected="True" value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; + } else { + echo '<option value="' . $PropertyOptionValue . '">' . $PropertyOptionValue . '</option>'; + } + } + echo '</select>'; + break; + case 2; //checkbox + if ($OrderLine->ItemProperties[$PropertyRow['stkcatpropid']]==1){ + echo '<input type="checkbox" name="PropValue' . $OrderLine->LineNumber . 'x' . $PropertyCounter . '" checked="True" />'; + } else { + echo '<input type="checkbox" name="PropValue' . $OrderLine->LineNumber . 'x' . $PropertyCounter . '" />'; + } + break; + case 3: //date box + echo '<td><input type="text" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" size="10" maxlength="10" name="PropValue'.$OrderLine->LineNumber . 'x' . $PropertyCounter.'" value="'.$OrderLine->ItemProperties[$PropertyRow['stkcatpropid']].'" /></td>'; + break; + default: + break; + } + echo '<td colspan="9"></td></tr>'; + $PropertyCounter++; + } + } $_SESSION['Items'.$identifier]->total = $_SESSION['Items'.$identifier]->total + $LineTotal; $_SESSION['Items'.$identifier]->totalVolume = $_SESSION['Items'.$identifier]->totalVolume + $OrderLine->Quantity * $OrderLine->Volume; $_SESSION['Items'.$identifier]->totalWeight = $_SESSION['Items'.$identifier]->totalWeight + $OrderLine->Quantity * $OrderLine->Weight; @@ -1428,7 +1513,7 @@ $DisplayVolume = locale_number_format($_SESSION['Items'.$identifier]->totalVolume,2); $DisplayWeight = locale_number_format($_SESSION['Items'.$identifier]->totalWeight,2); - echo '<table><tr class="EvenTableRows"><td>' . _('Total Weight') . ':</td> + echo '<br /><table class="selection"><tr class="EvenTableRows"><td>' . _('Total Weight') . ':</td> <td>' . $DisplayWeight . '</td> <td>' . _('Total Volume') . ':</td> <td>' . $DisplayVolume . '</td> @@ -1436,7 +1521,7 @@ echo '<br /><div class="centre"><input type="submit" name="Recalculate" value="' . _('Re-Calculate') . '" /> - <input type="submit" name="DeliveryDetails" value="' . _('Enter Delivery Details and Confirm Order') . '" /></div><hr />'; + <input type="submit" name="DeliveryDetails" value="' . _('Enter Delivery Details and Confirm Order') . '" /></div>'; } # end of if lines /* Now show the stock item selection search stuff below */ @@ -1592,7 +1677,7 @@ <input tabindex="'.($j+8).'" type="submit" value="'._('Add to Sales Order').'" /></td>'; echo '</table>'; } //end of if Frequently Ordered Items > 0 - + echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/magnifier.png" title="' . _('Search') . '" alt="" />' . ' '; echo _('Search for Order Items') . '</p>'; echo '<div class="page_help_text">' . _('Search for Order Items') . _(', Searches the database for items, you can narrow the results by selecting a stock category, or just enter a partial item description or partial item code') . '.</div><br />'; Modified: trunk/includes/DefineCartClass.php =================================================================== --- trunk/includes/DefineCartClass.php 2011-10-02 23:45:01 UTC (rev 8208) +++ trunk/includes/DefineCartClass.php 2011-10-03 18:36:22 UTC (rev 8209) @@ -46,15 +46,15 @@ var $ShipVia; var $FreightCost; var $FreightTaxes; - Var $OrderNo; - Var $Consignment; - Var $Quotation; - Var $DeliverBlind; - Var $CreditAvailable; //in customer currency - Var $TaxGroup; - Var $DispatchTaxProvince; - Var $DefaultPOLine; - Var $DeliveryDays; + var $OrderNo; + var $Consignment; + var $Quotation; + var $DeliverBlind; + var $CreditAvailable; //in customer currency + var $TaxGroup; + var $DispatchTaxProvince; + var $DefaultPOLine; + var $DeliveryDays; var $TaxTotals; var $TaxGLCodes; var $BuyerName; @@ -97,7 +97,8 @@ $EOQ=1, $NextSerialNo=0, $ExRate=1, - $ConversionFactor=1){ + $ConversionFactor=1, + $ItemProperties=array()){ if (isset($StockID) AND $StockID!="" AND $Qty>0 AND isset($Qty)){ @@ -136,6 +137,7 @@ $EOQ, $NextSerialNo, $ExRate); + $this->LineItems[$LineNumber]->ItemProperties=$ItemProperties; $this->ItemsOrdered++; if ($UpdateDB=='Yes'){ @@ -189,7 +191,8 @@ $UpdateDB='No', $ItemDue, $POLine, - $GPPercent){ + $GPPercent, + $ItemProperties=array()){ if ($Qty>0){ $this->LineItems[$UpdateLineNumber]->Quantity = $Qty; @@ -202,6 +205,7 @@ $this->LineItems[$UpdateLineNumber]->ItemDue = $ItemDue; $this->LineItems[$UpdateLineNumber]->POLine = $POLine; $this->LineItems[$UpdateLineNumber]->GPPercent = $GPPercent; + $this->LineItems[$UpdateLineNumber]->ItemProperties = $ItemProperties; if ($UpdateDB=='Yes'){ global $db; $result = DB_query("UPDATE salesorderdetails SET quantity='" . $Qty . "', @@ -419,37 +423,38 @@ } /* end of cart class defintion */ Class LineDetails { - Var $LineNumber; - Var $StockID; - Var $ItemDescription; - Var $Quantity; - Var $Price; - Var $DiscountPercent; - Var $Units; + var $LineNumber; + var $StockID; + var $ItemDescription; + var $Quantity; + var $Price; + var $DiscountPercent; + var $Units; var $ConversionFactor; - Var $Volume; - Var $Weight; - Var $ActDispDate; - Var $QtyInv; - Var $QtyDispatched; - Var $StandardCost; - Var $QOHatLoc; - Var $MBflag; /*Make Buy Dummy, Assembly or Kitset */ - Var $DiscCat; /* Discount Category of the item if any */ - Var $Controlled; - Var $Serialised; - Var $DecimalPlaces; + var $Volume; + var $Weight; + var $ActDispDate; + var $QtyInv; + var $QtyDispatched; + var $StandardCost; + var $QOHatLoc; + var $MBflag; /*Make Buy Dummy, Assembly or Kitset */ + var $DiscCat; /* Discount Category of the item if any */ + var $Controlled; + var $Serialised; + var $DecimalPlaces; var $PriceDecimals; - Var $SerialItems; - Var $Narrative; - Var $TaxCategory; - Var $Taxes; - Var $WorkOrderNo; - Var $ItemDue; - Var $POLine; - Var $EOQ; - Var $NextSerialNo; - Var $GPPercent; + var $SerialItems; + var $Narrative; + var $TaxCategory; + var $Taxes; + var $WorkOrderNo; + var $ItemDue; + var $POLine; + var $EOQ; + var $NextSerialNo; + var $GPPercent; + var $ItemProperties; function LineDetails ($LineNumber, $StockItem, @@ -507,6 +512,7 @@ $this->SerialItems = array(); $this->Narrative = $Narrative; $this->Taxes = array(); + $this->ItemProperties = array(); $this->TaxCategory = $TaxCategory; $this->WorkOrderNo = 0; $this->ItemDue = $ItemDue; @@ -525,11 +531,11 @@ } Class Tax { - Var $TaxCalculationOrder; /*the index for the array */ - Var $TaxAuthID; - Var $TaxAuthDescription; - Var $TaxRate; - Var $TaxOnTax; + var $TaxCalculationOrder; /*the index for the array */ + var $TaxAuthID; + var $TaxAuthDescription; + var $TaxRate; + var $TaxOnTax; var $TaxGLCode; function Tax ($TaxCalculationOrder, Modified: trunk/includes/SelectOrderItems_IntoCart.inc =================================================================== --- trunk/includes/SelectOrderItems_IntoCart.inc 2011-10-02 23:45:01 UTC (rev 8208) +++ trunk/includes/SelectOrderItems_IntoCart.inc 2011-10-03 18:36:22 UTC (rev 8209) @@ -161,7 +161,6 @@ $myItemRow['nextserialno'], $ExRate, $ConversionFactor); - } } else { prnMsg(_('The item code') . ' ' . $NewItem . ' ' . _('does not have a cost set up and order entry is set up to prohibit sales of items with no cost data entered'),'warn'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |