function invoice_form_delete_process($type, $returnpage_error, $returnpage_success)
{
    log_debug("inc_invoices_forms", "Executing invoice_form_delete_process({$type}, {$mode}, {$returnpage_error}, {$returnpage_success})");
    $invoice = new invoice();
    $invoice->type = $type;
    /*
    	Import POST Data
    */
    $invoice->id = @security_form_input_predefined("int", "id_invoice", 1, "");
    $data["delete_confirm"] = @security_form_input_predefined("any", "delete_confirm", 1, "You must confirm the deletion");
    // we don't use this value (since we can't trust it) but we need to read it
    // in here to work around a limitation in the Amberphplib framework
    $data["code_invoice"] = @security_form_input_predefined("any", "code_invoice", 1, "");
    /*
    	Error Handling
    */
    // make sure the invoice actually exists
    if (!$invoice->verify_invoice()) {
        log_write("error", "process", "The invoice you have attempted to delete - " . $invoice->id . " - does not exist in this system.");
    }
    // check if invoice is locked or not
    if ($invoice->check_delete_lock()) {
        log_write("error", "process", "The invoice can not be deleted because it is locked.");
    }
    // return to input page in event of an error
    if ($_SESSION["error"]["message"]) {
        $_SESSION["error"]["form"][$type . "_invoice_delete"] = "failed";
        header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id);
        exit(0);
    }
    /*
    	Delete Invoice
    */
    if ($invoice->action_delete()) {
        $_SESSION["notification"]["message"] = array("Invoice has been successfully deleted.");
    } else {
        $_SESSION["error"]["message"][] = "Some problems were experienced while deleting the invoice.";
    }
    // display updated details
    header("Location: ../../index.php?page={$returnpage_success}&id={$id}");
    exit(0);
}
Ejemplo n.º 2
0
 function delete_invoice($id, $invoicetype)
 {
     log_debug("accounts_invoices_manage", "Executing delete_invoice({$id}, {$invoicetype})");
     // check the invoicetype
     if ($invoicetype != "ar" && $invoicetype != "ap") {
         throw new SoapFault("Sender", "INVALID_INVOICE_TYPE");
     }
     if (user_permissions_get("accounts_" . $invoicetype . "_write")) {
         $obj_invoice = new invoice();
         /*
         	Load SOAP Data
         */
         $obj_invoice->id = @security_script_input_predefined("int", $id);
         $obj_invoice->type = $invoicetype;
         /*
         	Error Handling
         */
         // verify invoice existance
         if (!$obj_invoice->verify_invoice()) {
             throw new SoapFault("Sender", "INVALID_INVOICE");
         }
         // make sure invoice is safe to delete
         if ($obj_invoice->check_delete_lock()) {
             throw new SoapFault("Sender", "LOCKED");
         }
         /*
         	Perform Changes
         */
         if ($obj_invoice->action_delete()) {
             return 1;
         } else {
             throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
         }
     } else {
         throw new SoapFault("Sender", "ACCESS DENIED");
     }
 }