<h2>Sub Category</h2> <form action = "inventory-sub.php" method = "get"> <label for="maincc">Choose Main Category: </label> <span id="maincc"> <select name = "maincc"> <?php Inv_maincategory::findAllOption(); ?> </select> </span> <input id="submitBTN" type="submit" value="Submit" /> </form> <?php if (isset($_GET['maincc'])) { try { $inv_subcategories = Inv_subcategory::findByMainCategoryCode($_GET['maincc']); $inv_maincategory = new Inv_maincategory($_GET['maincc']); } catch (fExpectedException $e) { echo $e->printMessage(); } printf("<br /><h3 id=\"mainCategoryTitle\" key=\"%s\">%s</h3>", $_GET['maincc'], $inv_maincategory->prepareDescription()); printf("<table><thead><tr><td>Sub Category Code</td><td>Description</td><td>Main Category Code</td><td>Status</td></tr></thead><tbody>"); foreach ($inv_subcategories as $inv_subcategory) { printf("<tr><td class=\"hideFirst\"><span class=\"varInput\" id=\"Id\">%s</span></td>\r\n\t\t\t\t\t\t\t\t<td><span class=\"varInput\" id=\"Categorycode\">%s</span></td>\r\n\t\t\t\t\t\t\t\t<td><span class=\"varInput\" id=\"Description\">%s</span></td>\r\n\t\t\t\t\t\t\t\t<td><span class=\"varInput\" id=\"MainCategorycode\">%s</span></td>\r\n\t\t\t\t\t\t\t\t<td><span class=\"varInput\" id=\"Status\">%s</span></td>", $inv_subcategory->prepareId(), $inv_subcategory->prepareCategoryCode(), $inv_subcategory->prepareDescription(), $inv_subcategory->prepareMainCategoryCode(), $inv_subcategory->prepareStatus() == 1 ? "Active" : "Inactive"); printf("<td id=\"iconCell\" class=\"hideFirst\"><ul id=\"icons\" class=\"ui-widget ui-helper-clearfix\">\r\n\t\t\t\t\t\t<li id=\"save\" title=\"Save\" class=\"ui-state-default ui-corner-all\"><span class=\"ui-icon ui-icon-circle-check\"></span></li>\r\n\t\t\t\t\t\t<li id=\"cancel\" title=\"Cancel\" class=\"ui-state-default ui-corner-all\"><span class=\"ui-icon ui-icon-circle-close\"></span></li>\r\n\t\t\t\t\t\t</ul></td></tr>"); } ?> <tr id="newItem"> <td> <span id="Categorycode"> <input type="text" name="category_code" value="Input Category Code" />
$inv_maincategory->populate(); $inv_maincategory->store(); $inv_subcategories = Inv_subcategory::findByMainCategoryCode($_POST['key']); foreach ($inv_subcategories as $inv_subcategory) { $inv_subcategory->setMainCategoryCode($_POST['category_code']); $inv_subcategory->store(); } } catch (fExpectedException $e) { echo $e->printMessage(); } } else { if ($_POST['type'] == "delete") { try { $inv_maincategory = new Inv_maincategory($_POST['key']); $inv_maincategory->delete(); $inv_subcategories = Inv_subcategory::findByMainCategoryCode($_POST['key']); foreach ($inv_subcategories as $inv_subcategory) { $inv_subcategory->delete(); } } catch (fExpectedException $e) { echo $e->printMessage(); } } else { if ($_POST['type'] == "add") { try { $inv_maincategory = new Inv_maincategory(); $inv_maincategory->populate(); $inv_maincategory->store(); } catch (fExpectedException $e) { echo $e->printMessage(); }