require_once("include/global.php"); drawHeader("RepRap Bill of Materials - " . date("F d, Y")); if (isset($_POST['submit'])) { $suppliers = loadSupplierData(); $list = new SupplierList; foreach ($_POST['parts'] AS $key => $part) { $supplier = new Supplier($_POST['suppliers'][$key]); $supplier->name = str_replace("_", " ", $part); $supplier->quantity = $_POST['quantities'][$key]; $list->addSupplier($supplier); } $corps = $list->getSuppliers(); ?>
" . count($corps) . " total suppliers selected. You may want to print this to help keep track of what parts you need.
"; foreach ($corps AS $corp) { $parts = $list->getParts($corp); if (count($parts)) { if ($corp == 'M') renderMouserParts($parts); else if ($corp == 'RS') renderRSParts($parts); else if ($corp == 'F') renderFarnellParts($parts); else if ($corp == '') renderUnknownParts($parts); else { if (isset($suppliers[$corp])) renderParts($parts, $suppliers[$corp]); else renderParts($parts, $corp); } } } } else echo "Oops, you gotta POST here bro."; drawFooter(); //VIEW FUNCTIONS BELOW. function renderParts($parts, $corp) { if ($corp instanceof Corporation) { echo '$corp->description
"; } else echo "Part # | Quantity | Name|
---|---|---|
"; if ($corp->buy_url) { $url = str_replace("%%PARTID%%", $part->part_id, $corp->buy_url); echo '' . $part->name . ''; } else if (preg_match("/http:/", $part->part_id)) echo '' . $part->part_id . ""; else echo $part->part_id; echo " | $part->quantity | "; echo "" . stripslashes($part->name) . " | "; echo "
Copy and paste the text below into their BOM Importer tool. You'll need an account, but you need one anyway to check out.
} function renderRsParts($parts) { ?>Go to their website, Ready to order? -> Copy & paste your order. Then do just that with the text below.
} function renderFarnellParts($parts) { ?>Go to their website, Choose country -> Quick Paste. Then do just that with the text below.
} function renderUnknownParts($parts) { ?>Part | Quantity |
---|---|
" . stripslashes($part->name) . " | $part->quantity |