当前位置: 首页>>代码示例>>PHP>>正文


PHP invoice::generate_pdf方法代码示例

本文整理汇总了PHP中invoice::generate_pdf方法的典型用法代码示例。如果您正苦于以下问题:PHP invoice::generate_pdf方法的具体用法?PHP invoice::generate_pdf怎么用?PHP invoice::generate_pdf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invoice的用法示例。


在下文中一共展示了invoice::generate_pdf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: invoice_form_export_process

function invoice_form_export_process($type, $returnpage_error, $returnpage_success)
{
    log_debug("inc_invoices_forms", "Executing invoice_form_export_process({$type}, {$returnpage_error}, {$returnpage_success})");
    /*
    	Start the invoice
    */
    $invoice = new invoice();
    $invoice->type = $type;
    /*
    	Fetch all form data
    */
    // get the ID for an edit
    $invoice->id = @security_form_input_predefined("int", "id_invoice", 1, "");
    // general details
    $data["formname"] = @security_form_input_predefined("any", "formname", 1, "");
    if ($data["formname"] == "invoice_export_email") {
        // send email
        $data["sender"] = @security_form_input_predefined("any", "sender", 1, "");
        $data["subject"] = @security_form_input_predefined("any", "subject", 1, "");
        $data["email_to"] = @security_form_input_predefined("multiple_email", "email_to", 1, "");
        $data["email_cc"] = @security_form_input_predefined("multiple_email", "email_cc", 0, "");
        $data["email_bcc"] = @security_form_input_predefined("multiple_email", "email_bcc", 0, "");
        $data["message"] = @security_form_input_predefined("any", "email_message", 1, "");
        // check if email sending is permitted
        if (sql_get_singlevalue("SELECT value FROM config WHERE name='EMAIL_ENABLE'") != "enabled") {
            log_write("error", "inc_invoices_process", "Sorry, the ability to email invoices has been disabled. Please contact your system administrator if you require this feature to be enabled.");
        }
    } else {
        // PDF download
        $data["invoice_mark_as_sent"] = @security_form_input_predefined("any", "invoice_mark_as_sent", 0, "");
    }
    // make sure that the invoice exists
    $sql_obj = new sql_query();
    $sql_obj->string = "SELECT id FROM `account_" . $invoice->type . "` WHERE id='" . $invoice->id . "'";
    $sql_obj->execute();
    if (!$sql_obj->num_rows()) {
        $_SESSION["error"]["message"][] = "The invoice you have attempted to edit - " . $invoice->id . " - does not exist in this system.";
    }
    //// ERROR CHECKING ///////////////////////
    /// if there was an error, go back to the entry page
    if (!empty($_SESSION["error"]["message"])) {
        header("Location: ../../index.php?page={$returnpage_error}&id=" . $invoice->id . "");
        exit(0);
    } else {
        if ($data["formname"] == "invoice_export_email") {
            /*
            	Generate a PDF of the invoice and email it to the customer
            */
            // stripslashes from the variables - by default all input variables are quoted for security reasons but
            // we don't want this going through to the email.
            $data["subject"] = stripslashes($data["subject"]);
            $data["message"] = stripslashes($data["message"]);
            // send email
            $invoice->load_data();
            $invoice->email_invoice($data["sender"], $data["email_to"], $data["email_cc"], $data["email_bcc"], $data["subject"], $data["message"]);
            $_SESSION["notification"]["message"][] = "Email sent successfully.";
        } else {
            /*
            	Mark invoice as being sent if user requests it
            */
            if ($data["invoice_mark_as_sent"]) {
                $sql_obj = new sql_query();
                $sql_obj->string = "UPDATE account_" . $invoice->type . " SET date_sent='" . date("Y-m-d") . "', sentmethod='manual' WHERE id='" . $invoice->id . "'";
                $sql_obj->execute();
            }
            /*
            	Provide PDF to user's browser
            */
            // generate PDF
            $invoice->load_data();
            $invoice->generate_pdf();
            // PDF headers
            if ($type == "quotes") {
                $filename = "/tmp/quote_" . $invoice->data["code_quote"] . ".pdf";
            } else {
                $filename = "/tmp/invoice_" . $invoice->data["code_invoice"] . ".pdf";
            }
            // required for IE, otherwise Content-disposition is ignored
            if (ini_get('zlib.output_compression')) {
                ini_set('zlib.output_compression', 'Off');
            }
            header("Pragma: public");
            // required
            header("Expires: 0");
            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
            header("Cache-Control: private", false);
            // required for certain browsers
            header("Content-Type: application/pdf");
            header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";");
            header("Content-Transfer-Encoding: binary");
            // output the PDF
            print $invoice->obj_pdf->output;
            exit(0);
        }
        // display updated details
        header("Location: ../../index.php?page={$returnpage_success}&id=" . $invoice->id . "");
        exit(0);
    }
    // end if passed tests
}
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:100,代码来源:inc_invoices_process.php

示例2: SoapFault

 function get_invoice_pdf($id, $invoicetype)
 {
     log_debug("invoices_manage_soap", "Executing get_invoice_pdf({$id}, {$invoicetype})");
     // check the invoice type
     if ($invoicetype != "ar" && $invoicetype != "ap") {
         throw new SoapFault("Sender", "INVALID_INVOICE_TYPE");
     }
     if (user_permissions_get("accounts_" . $invoicetype . "_view")) {
         $obj_invoice = new invoice();
         $obj_invoice->type = $invoicetype;
         // sanitise input
         $obj_invoice->id = @security_script_input_predefined("int", $id);
         if (!$obj_invoice->id || $obj_invoice->id == "error") {
             throw new SoapFault("Sender", "INVALID_INPUT");
         }
         // verify that the invoice is valid
         if (!$obj_invoice->verify_invoice()) {
             throw new SoapFault("Sender", "INVALID_INVOICE");
         }
         // load data from DB for this invoice
         if (!$obj_invoice->load_data()) {
             throw new SoapFault("Sender", "UNEXPECTED_ACTION_ERROR");
         }
         // generate PDF
         $obj_invoice->generate_pdf();
         // return data
         return base64_encode($obj_invoice->obj_pdf->output);
     } else {
         throw new SoapFault("Sender", "ACCESS_DENIED");
     }
 }
开发者ID:carriercomm,项目名称:amberdms-bs,代码行数:31,代码来源:invoices_manage.php


注:本文中的invoice::generate_pdf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。