From: <Ex...@us...> - 2012-03-13 02:01:16
|
Revision: 5099 http://web-erp.svn.sourceforge.net/web-erp/?rev=5099&view=rev Author: ExsonQu Date: 2012-03-13 02:01:10 +0000 (Tue, 13 Mar 2012) Log Message: ----------- 13/3/2012 Exson: Fixed that same parent and component but added in different Work Centers and Locations will display twice in BOMs.php. And fixed that to delete one line of same parents and component will delete all lines with same parents and components. Add ArrayUnique function to get unique array for multi-dimensional array. Modified Paths: -------------- trunk/BOMs.php Modified: trunk/BOMs.php =================================================================== --- trunk/BOMs.php 2012-03-13 01:27:21 UTC (rev 5098) +++ trunk/BOMs.php 2012-03-13 02:01:10 UTC (rev 5099) @@ -73,7 +73,9 @@ $sql = "SELECT bom.component, stockmaster.description as itemdescription, locations.locationname, + locations.loccode, workcentres.description as workcentrename, + workcentres.code as workcentrecode, bom.quantity, bom.effectiveafter, bom.effectiveto, @@ -148,7 +150,7 @@ <td class="number">%s</td> <td><a href="%s&Select=%s&SelectedComponent=%s">' . _('Edit') . '</a></td> <td>'.$DrillText.'</td> - <td><a href="%s&Select=%s&SelectedComponent=%s&delete=1&ReSelect=%s" onclick="return confirm(\'' . _('Are you sure you wish to delete this component from the bill of material?') . '\');">' . _('Delete') . '</a></td> + <td><a href="%s&Select=%s&SelectedComponent=%s&delete=1&ReSelect=%s&Location=%s&WorkCentre=%s" onclick="return confirm(\'' . _('Are you sure you wish to delete this component from the bill of material?') . '\');">' . _('Delete') . '</a></td> </tr>', $Level1, $myrow['component'], @@ -168,7 +170,9 @@ htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES,'UTF-8') . '?', $Parent, $myrow['component'], - $UltimateParent); + $UltimateParent, + $myrow['loccode'], + $myrow['workcentrecode']); } //END WHILE LIST LOOP } //end of function DisplayBOMItems @@ -356,7 +360,9 @@ $sql="DELETE FROM bom WHERE parent='".$SelectedParent."' - AND component='".$SelectedComponent."'"; + AND component='".$SelectedComponent."' + AND loccode='".$Location."' + AND workcentreadded='".$WorkCentre."'"; $ErrMsg = _('Could not delete this BOM components because'); $DbgMsg = _('The SQL used to delete the BOM was'); @@ -548,7 +554,7 @@ $UltimateParent = $SelectedParent; $k = 0; $RowCounter = 1; - + $BOMTree = arrayUnique($BOMTree); foreach($BOMTree as $BOMItem){ $Level = $BOMItem['Level']; $Parent = $BOMItem['Parent']; @@ -909,7 +915,32 @@ echo '</div>'; echo '</form>'; -} //end StockID already selected + } //end StockID already selected +// This function created by Dominik Jungowski on PHP developer blog +function arrayUnique($array, $preserveKeys = false) +{ + //Unique Array for return + $arrayRewrite = array(); + //Array with the md5 hashes + $arrayHashes = array(); + foreach($array as $key => $item) { + // Serialize the current element and create a md5 hash + $hash = md5(serialize($item)); + // If the md5 didn't come up yet, add the element to + // arrayRewrite, otherwise drop it + if (!isset($arrayHashes[$hash])) { + // Save the current element hash + $arrayHashes[$hash] = $hash; + //Add element to the unique Array + if ($preserveKeys) { + $arrayRewrite[$key] = $item; + } else { + $arrayRewrite[] = $item; + } + } + } + return $arrayRewrite; +} include('includes/footer.inc'); ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |