update mpdf lib version from 6 to 8

This commit is contained in:
Schneider Roland
2022-12-27 14:42:55 +01:00
parent ac21048f95
commit f848b34245
13 changed files with 901 additions and 489 deletions

View File

@@ -2,6 +2,7 @@
namespace backend\controllers;
use Mpdf\Mpdf;
use Yii;
use common\models\AccountState;
use backend\models\AccountStateSearch;
@@ -11,6 +12,7 @@ use yii\filters\VerbFilter;
use common\models\Account;
use common\models\User;
use common\components\DailyListing;
use common\components\MpdfUtil;
/**
* AccountStateController implements the CRUD actions for AccountState model.
@@ -35,7 +37,7 @@ class AccountStateController extends \backend\controllers\BackendController
],
];
}
/**
* Lists all AccountState models.
* @return mixed
@@ -47,8 +49,8 @@ class AccountStateController extends \backend\controllers\BackendController
$accounts = Account::read();
$users = User::read();
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -73,7 +75,7 @@ class AccountStateController extends \backend\controllers\BackendController
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
$details = null;
if ($accountState->isTypeClose ()) {
$prev;
if ($accountState->type == AccountState::TYPE_CLOSE) {
if (isset ( $accountState->prev_state )) {
@@ -85,38 +87,38 @@ class AccountStateController extends \backend\controllers\BackendController
}
$details = new DailyListing();
$details->loadAccountState ( $accountState );
$details->readTotalEasy ();
$details->readTotalDetailed ();
$details->readTotalMedium ();
}
if ($output == 'pdf') {
$user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->useSubstitutions=false;
$mpdf->simpleTables = true;
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
$mpdf->setFooter('{PAGENO} / {nb}');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial("@common/views/account-state/account_state_pdf", [
'model' => $accountState,
'details' => $details
'details' => $details
]));
$type = $accountState->isTypeOpen() ? "kassza_nyitas" : "kassza_zaras";
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
$fn= $type .$dt.".pdf";
$mpdf->Output($fn, 'D');
} else {
return $this->render ( 'view', [
return $this->render ( 'view', [
'model' => $accountState,
'details' => $details
'details' => $details
] );
}
}
@@ -158,7 +160,7 @@ class AccountStateController extends \backend\controllers\BackendController
}
}
/**
* Deletes an existing AccountState model.
* If deletion is successful, the browser will be redirected to the 'index' page.
@@ -168,27 +170,27 @@ class AccountStateController extends \backend\controllers\BackendController
*/
public function actionDelete($id) {
$model = $this->findModel ( $id );
$delete = true;
if ( $model->isTypeOpen() ){
$closeStates = AccountState::find()->andWhere( ['prev_state' => $model->id_account_state] )->all();
if ( count($closeStates) > 0){
$delete = false;
\Yii::$app->session->setFlash('error', ['Nem lehet törölni a nyitást, mert van kapcsolódó zárás!']);
throw new \Exception('Nem lehet törölni a nyitást, mert van kapcsolódó zárás!');
}
}
}
if ( $delete == true ){
$model->delete();
\Yii::$app->session->setFlash ( 'success', 'Kassza művelet törölve' );
}
}
return $this->redirect ( ["index"] );
}
/**
* Deletes an existing AccountState model.
* If deletion is successful, the browser will be redirected to the 'index' page.