$supplier->populate();
            $supplier->store();
        } catch (fExpectedException $e) {
            echo $e->printMessage();
        }
    } else {
        if ($_POST['type'] == "add") {
            try {
                $supplier = new Supplier();
                $supplier->populate();
                $supplier->store();
            } catch (fExpectedException $e) {
                echo $e->printMessage();
            }
        } else {
            if ($_POST['type'] == "option") {
                echo "<select>";
                Status::printOption('1');
                echo "</select>";
            } else {
                if ($_POST['type'] == "generate") {
                    try {
                        Supplier::generateInfo($_POST['key']);
                    } catch (fExpectedException $e) {
                        echo "Invalid supplier";
                    }
                }
            }
        }
    }
}
         echo $e->printMessage();
     }
 } else {
     if ($_POST['type'] == "url") {
         try {
             $inv_item = new Inv_item($_POST['key']);
             $inv_item->setImageUrl($_POST['url']);
             $inv_item->store();
         } catch (fExpectedException $e) {
             echo $e->printMessage();
         }
     } else {
         if ($_POST['type'] == "option") {
             $selectedOption = $_POST['input'] == "Active" ? 1 : 0;
             echo "<select>";
             Status::printOption($selectedOption);
             echo "</select>";
         } else {
             if ($_POST['type'] == "lastCode") {
                 $counter = Inv_item::findByClassificationCode($_POST['classific']);
                 echo sprintf("%03d", $counter->count() + 1);
             } else {
                 if ($_POST['type'] == "upload") {
                     try {
                         $uploadDirectory = new fDirectory('../storage/image/' . $_POST['hiddenId']);
                     } catch (fExpectedException $e) {
                         $uploadDirectory = fDirectory::create('../storage/image/' . $_POST['hiddenId']);
                     }
                     try {
                         $uploader = new fUpload();
                         $uploader->setMIMETypes(array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'), 'The file uploaded is not an image');
							</span>
							<br />
							<table id="tableDetail" class="hideFirst">
							<tbody>
								<tr><td>Item Code: </td><td><input type="hidden" id="idInput"></input><span id="idSpan"></span><br /></td></tr>
								<tr><td>Description: </td><td><input type="text" id="desc"></input><br /></td></tr>
								<tr><td>Weight: </td><td><input type="text" id="weight"></input><br /></td></tr>
								<tr><td>Dimension: </td><td><input type="text" id="dim"></input><br /></td></tr>
								<tr><td>Part Number: </td><td><input type="text" id="part"></input><br /></td></tr>
								<tr><td>Unit of Measurement: </td><td><input type="text" id="uom"></input><br /></td></tr>
								<tr><td>Rate: </td><td><input type="text" id="rate"></input><br /></td></tr>
								<tr><td>Currency: </td><td><input type="text" id="curr"></input><br /></td></tr>
								<tr><td>Purchase Year: </td><td><input type="text" id="pury"></input><br /></td></tr>
								<tr><td>Detailed Description: </td><td><input type="text" id="detailed"></input><br /></td></tr>
								<tr><td>Status: </td><td><select id="statusVal"><?php 
Status::printOption();
?>
</select></td></tr>
							</tbody>
							<tfoot>
								<tr><td colspan="2"><input id="addBTN" type="button" value="Submit" /></td></tr>
							</tfoot>
							</table>
						</form>
					</td>
				</tr>
			</tbody>
			</table>
		</div>
	</div>
</div>