frontend/controllers/ReferralController.php
/**
     * Sends invoice as PDF
     *
     * @return mixed
     */
Sends invoice as PDF
@return mixed
Sends invoice as PDF @return mixed
public function actionDownloadInvoice ()
    {
        $user = Yii::$app->user->identity;
        $transaction = $user->getTransactions()
            ->where(['type' => Transaction::TYPE_INCOMING])
            ->orderBy(['timestamp' => SORT_DESC])
            ->one();
        if ($transaction == null) {
            throw HttpNotFoundException();
        }
        $mpdf = new \mPDF('', 'A4', 0, 'dejavusans');
        $mpdf->WriteHTML($this->renderFile('@frontend/views/referral/_invoice.php', [
            'id' => $transaction->id,
            'transaction' => $transaction
        ]));
        return Yii::$app->response->sendContentAsFile(
            $mpdf->Output(null,'S'),
            'invoice.pdf',
            [
                'mimeType' => 'application/pdf',
                'inline' => false
            ]);
    }
public function actionDownloadInvoice ( ) { $ user = Yii :: $ app -> user -> identity ; $ transaction = $ user -> getTransactions ( ) -> where ( [ 'type' => Transaction :: TYPE_INCOMING ] ) -> orderBy ( [ 'timestamp' => SORT_DESC ] ) -> one ( ) ; if ( $ transaction == null ) { throw HttpNotFoundException ( ) ; } $ mpdf = new \ mPDF ( '' , 'A4' , 0 , 'dejavusans' ) ; $ mpdf -> WriteHTML ( $ this -> renderFile ( '@frontend/views/referral/_invoice.php' , [ 'id' => $ transaction -> id , 'transaction' => $ transaction ] ) ) ; return Yii :: $ app -> response -> sendContentAsFile ( $ mpdf -> Output ( null , 'S' ) , 'invoice.pdf' , [ 'mimeType' => 'application/pdf' , 'inline' => false ] ) ; }
Sends invoice as PDF
 @return mixed
Sends invoice as PDF @return mixed