$supList = $sup->GetSuppliesList(true); $formpatch = ""; $status = ""; if (isset($_REQUEST["binid"])) { $bin->BinID = isset($_POST['binid']) ? $_POST['binid'] : $_GET['binid']; $bin->GetBin(); $bc->BinID = $bin->BinID; if (isset($_POST["action"]) && ($_POST["action"] == "Create" || $_POST["action"] == "Update") && ($_POST["location"] != null && $_POST["location"] != "")) { $bin->Location = $_POST["location"]; if ($_POST["action"] == "Create") { $bin->CreateBin(); } else { $binContents = $bc->GetBinContents(); // We don't want someone changing the name of a bin to a blank anymore than we want them creating one as a blank name $status = __("Updated"); $bin->UpdateBin(); // only attempt to alter the contents of the bin if we have the proper elements if (isset($_POST['supplyid']) && count($_POST['supplyid'] > 0)) { // process all of the submitted values into a new array to handle multiple instances of any part being added $cleansupplies = array(); foreach ($_POST['supplyid'] as $key => $value) { if ($_POST['count'][$key] != "" && $_POST['supplyid'][$key] != 0) { if (!isset($cleansupplies[$_POST['supplyid'][$key]])) { $cleansupplies[$_POST['supplyid'][$key]] = $_POST['count'][$key]; } else { // we're using -1 to remove an item from the bin. if ($_POST['count'][$key] != -1 && $cleansupplies[$_POST['supplyid'][$key]] != -1) { // Some prankster is trying to add the same part type multiple times so just add the values up $cleansupplies[$_POST['supplyid'][$key]] += $_POST['count'][$key]; } elseif ($cleansupplies[$_POST['supplyid'][$key]] == -1) { // Smart ass clicked the x to remove the part from the bin the added it back with a line below that.