Esempio n. 1
0
function submitPurchase($purchase_id, $purchase)
{
    $purchase_id = escape($purchase_id);
    //make sure not already submitted
    $result = mysql_query("SELECT status, club_id, instance_id FROM purchase_order WHERE id = '{$purchase_id}'");
    if ($row = mysql_fetch_array($result)) {
        if ($row[0] != 0) {
            return -1;
        } else {
            $purchase_name = $row[1];
            $instance_id = $row[2];
        }
    } else {
        return -2;
    }
    $error = customSave($instance_id, $purchase);
    if ($error !== TRUE) {
        return -2;
    }
    //create the PDF
    $filename = customSubmit($instance_id, "Puchase Order", $purchase_name);
    if ($filename === -1) {
        //if error during PDF generation
        return -2;
    } else {
        if ($filename === -2) {
            //if incomplete
            return -3;
        }
    }
    mysql_query("UPDATE purchase_order SET status='1', filename='{$filename}' WHERE id = '{$purchase_id}'");
    return 0;
}
Esempio n. 2
0
function submitRecommendation($recommend_id, $recommendation)
{
    $recommend_id = escape($recommend_id);
    //make sure not already submitted; also get recommender name and instance id
    $result = mysql_query("SELECT status, author, instance_id FROM recommendations WHERE id = '{$recommend_id}'");
    if ($row = mysql_fetch_array($result)) {
        if ($row[0] != 0) {
            return -1;
        } else {
            $recommender_name = $row[1];
            $instance_id = $row[2];
        }
    } else {
        return -2;
    }
    $error = customSave($instance_id, $recommendation);
    if ($error !== TRUE) {
        return -2;
    }
    //create the PDF
    $filename = customSubmit($instance_id, "Recommendation letter", $recommender_name);
    if ($filename === -1) {
        //if error during PDF generation
        return -2;
    } else {
        if ($filename === -2) {
            //if incomplete
            return -3;
        }
    }
    mysql_query("UPDATE recommendations SET status='1', filename='{$filename}' WHERE id = '{$recommend_id}'");
    return 0;
}