$PROCESSED["reviewed_date"] = "0";
                $PROCESSED["flag"] = "0";
                $PROCESSED["flagged_by"] = "0";
                $PROCESSED["flagged_date"] = "0";
                $PROCESSED["order"] = "0";
                $PROCESSED["updated_date"] = date(time());
                $PROCESSED["updated_by"] = $ENTRADA_USER->getID();
                $PROCESSED["_edata"] = serialize(array("description" => $PROCESSED["description"], "filename" => $filename));
                $PROCESSED["type"] = "FILE";
                $pentry = new Models_Eportfolio_Entry();
                if ($pentry->fromArray($PROCESSED)->insert()) {
                    echo "inserted";
                    $pfartifact = $pentry->getPfartifact();
                    $pfolder = $pfartifact->getFolder();
                    $portfolio = $pfolder->getPortfolio();
                    $file_realpath = EPORTFOLIO_STORAGE_PATH . "/portfolio-" . $portfolio->getID() . "/folder-" . $pfolder->getID() . "/artifact-" . $pfartifact->getID() . "/user-" . $pentry->getProxyID() . "/" . $pentry->getID();
                    if (!copy($_FILES["file"]["tmp_name"], $file_realpath)) {
                        add_error("Failed to copy file.");
                    } else {
                        echo "copied";
                    }
                }
            } else {
                echo display_error();
            }
            break;
    }
    switch ($STEP) {
        case 1:
            ?>
			<h1>Entrada ePortfolio</h1>
     $pentry = Models_Eportfolio_Entry::fetchRow($PROCESSED["pentry_id"]);
     if ($pentry->fromArray($PROCESSED)->update()) {
         $PROCESSED["_edata"] = unserialize($PROCESSED["_edata"]);
         echo json_encode(array("status" => "success", "data" => array("pentry_id" => $pentry->getID(), "type" => $pentry->getType(), "edata" => $pentry->getEdataDecoded(), "submitted_date" => $PROCESSED["submitted_date"])));
     } else {
         echo json_encode(array("status" => "error", "data" => "fail"));
     }
 } else {
     $pentry = new Models_Eportfolio_Entry();
     if ($pentry->fromArray($PROCESSED)->insert()) {
         if ($PROCESSED["filename"]) {
             if ($pentry->saveFile($_FILES["file"]["tmp_name"])) {
                 if (isset($_POST["isie"]) && $_POST["isie"] == "isie") {
                     header('Location: ' . ENTRADA_URL . '/profile/eportfolio#' . $pfolder->getID());
                 } else {
                     echo json_encode(array("status" => "success", "data" => array("pentry_id" => $pentry->getID(), "type" => $pentry->getType(), "edata" => $pentry->getEdataDecoded(), "submitted_date" => $PROCESSED["submitted_date"])));
                 }
             } else {
                 if (isset($_POST["isie"]) && $_POST["isie"] == "isie") {
                     header('Location: ' . ENTRADA_URL . '/profile/eportfolio#' . $pfolder->getID());
                 } else {
                     echo json_encode(array("status" => "error", "data" => "Failed to save file"));
                 }
             }
         } else {
             echo json_encode(array("status" => "success", "data" => array("pentry_id" => $pentry->getID(), "type" => $pentry->getType(), "edata" => $pentry->getEdataDecoded(), "submitted_date" => $PROCESSED["submitted_date"])));
         }
     } else {
         if (isset($_POST["isie"]) && $_POST["isie"] == "isie") {
             header('Location: ' . ENTRADA_URL . '/profile/eportfolio#' . $pfolder->getID());
         } else {