0

よろしくお願いします!今日、DOMPDF を使用して PDF で請求書を生成しようとすると問題が発生します。

説明しましょう: 請求書 ID を選択するビューがあります。「PDFを生成」ボタンをクリックすると、次のようになります。

(コントローラーに移動します)

foreach ($this->input->post('check') as $key)
    {

    $testLayout = load_modulo('bankX', 'invoice_bankX'); //here I call the file in views dir(bankX) and the view inside the file (case 'invoice_bankX') that brings me the bank invoice layout
    $filename = 'invoice_'.$key;
    pdf_create($testLayout, $filename, TRUE);

    }

(load_modulo 関数)

function load_modulo($modulo = NULL, $tela = NULL, $diretorio = 'panel') {

$CI = & get_instance();

if ($modulo != NULL) {

    return $CI->load->view("$diretorio/$modulo", array('tela' => $tela), TRUE);
} else {


    return FALSE;
    }
}

(pdf_create 関数)

function pdf_create($html, $filename = '', $stream = TRUE) {
require_once("dompdf/dompdf_config.inc.php");

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();

if ($stream) {
    $dompdf->stream($filename . ".pdf");
} else {

    $output = $dompdf->output();
    file_put_contents('Brochure.pdf', $output);


}

これで、「invoice_bankX」ビューに渡すデータがさらにあることがわかりました (クライアントで請求書をマウントしてデータを保存するために、このビューでコールバックできる銀行とクライアントの値を保持する変数が 1 つ必要です)。

すなわち

$invoiceData = 配列();

$invoiceData['invoice_number'] = 344;

$invoiceData['client_name'] = 'ジョン・マスターズ';

このようにして、値を渡して請求書を正しくマウントできるためです。誰でも方法を知っていますか?

*注 - 現在、ボタンをクリックして請求書 (PDF) を生成すると、これが機能します。しかし、請求書には、テスト用に書いた静的データが付属しています

4

1 に答える 1