update mpdf lib version from 6 to 8
This commit is contained in:
@@ -16,16 +16,17 @@ use common\models\User;
|
||||
use common\components\accountstate\AccountStateMail;
|
||||
use common\models\Transfer;
|
||||
use common\components\Helper;
|
||||
use common\components\MpdfUtil;
|
||||
|
||||
/**
|
||||
* AccountStateController implements the CRUD actions for AccountState model.
|
||||
*/
|
||||
class AccountStateController extends Controller {
|
||||
public function behaviors() {
|
||||
return [
|
||||
'access' => [
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className (),
|
||||
'only' => [
|
||||
'only' => [
|
||||
'index',
|
||||
'open',
|
||||
'close',
|
||||
@@ -34,17 +35,17 @@ class AccountStateController extends Controller {
|
||||
],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => [
|
||||
'@'
|
||||
]
|
||||
]
|
||||
]
|
||||
'roles' => [
|
||||
'@'
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
// everything else is denied
|
||||
|
||||
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,15 +61,15 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
|
||||
$searchModel = new AccountstateSearch ();
|
||||
|
||||
|
||||
$searchModel->accounts = Account::read ();
|
||||
$searchModel->users = User::read ();
|
||||
|
||||
|
||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||
|
||||
return $this->render ( 'index', [
|
||||
|
||||
return $this->render ( 'index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider
|
||||
'dataProvider' => $dataProvider
|
||||
] );
|
||||
}
|
||||
|
||||
@@ -98,38 +99,38 @@ class AccountStateController extends Controller {
|
||||
public function actionOpen() {
|
||||
$lastStates = AccountState::readLastForUser ( AccountState::TYPE_CLOSE );
|
||||
$lastStates = AccountState::modelsToArray ( $lastStates );
|
||||
|
||||
|
||||
|
||||
|
||||
$model = new AccountState ();
|
||||
$model->type = AccountState::TYPE_OPEN;
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
|
||||
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
|
||||
|
||||
|
||||
|
||||
if ( Helper::isAccountStateOpenSendMail() ){
|
||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||
$mail->sednMail();
|
||||
}
|
||||
|
||||
|
||||
$redirectTo = 'index';
|
||||
|
||||
if ( Helper::isReceptionAccountStateIndexToday() ){
|
||||
$redirectTo = 'today';
|
||||
}
|
||||
|
||||
return $this->redirect ( [
|
||||
return $this->redirect ( [
|
||||
$redirectTo
|
||||
] );
|
||||
} else {
|
||||
|
||||
|
||||
$accounts = Account::read ();
|
||||
|
||||
return $this->render ( 'open', [
|
||||
|
||||
return $this->render ( 'open', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'lastStates' => $lastStates,
|
||||
@@ -151,19 +152,19 @@ class AccountStateController extends Controller {
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
$model->id_account = Account::readDefault ();
|
||||
$account = Account::readDefaultObject();
|
||||
|
||||
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
|
||||
|
||||
|
||||
|
||||
|
||||
$lastCassaState = AccountState::readLast(null,null, Account::readDefault());
|
||||
|
||||
|
||||
|
||||
|
||||
if ( Helper::isAccountStateClosePreloadMoney()){
|
||||
$model->money = $this->readCassaClose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
|
||||
|
||||
|
||||
if ( Helper::isAccountStateCloseSendMail()){
|
||||
$mail = new AccountStateMail(['model' => $model,'controller' => $this]);
|
||||
$mail->sednMail();
|
||||
@@ -181,10 +182,10 @@ class AccountStateController extends Controller {
|
||||
] );
|
||||
// return $this->redirect(['view', 'id' => $model->id_account_state]);
|
||||
} else {
|
||||
|
||||
|
||||
$accounts = Account::read ();
|
||||
|
||||
return $this->render ( 'close', [
|
||||
|
||||
return $this->render ( 'close', [
|
||||
'model' => $model,
|
||||
'accounts' => $accounts,
|
||||
'account' => $account,
|
||||
@@ -193,7 +194,7 @@ class AccountStateController extends Controller {
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function readCassaClose(){
|
||||
$total = 0;
|
||||
$openDate = null;
|
||||
@@ -205,12 +206,12 @@ class AccountStateController extends Controller {
|
||||
$total += Transfer::readPaidCash($openDate, date('Y-m-d H:i:s'), \Yii::$app->user->id);
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the AccountState model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param integer $id
|
||||
* @return AccountState the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
@@ -228,12 +229,12 @@ class AccountStateController extends Controller {
|
||||
throw new NotFoundHttpException ( 'The requested page does not exist.' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes an existing AccountState model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id) {
|
||||
@@ -264,7 +265,7 @@ class AccountStateController extends Controller {
|
||||
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||
$details = null;
|
||||
if ($accountState->isTypeClose ()) {
|
||||
|
||||
|
||||
$prev = null;
|
||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||
if (isset ( $accountState->prev_state )) {
|
||||
@@ -276,53 +277,53 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
$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()) );
|
||||
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||
$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
|
||||
]));
|
||||
/** @noinspection SpellCheckingInspection */
|
||||
$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');
|
||||
exit(0);
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
return $this->render ( 'view', [
|
||||
|
||||
return $this->render ( 'view', [
|
||||
'model' => $accountState,
|
||||
'details' => $details
|
||||
'details' => $details
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function actionMixed($id){
|
||||
$accountState = $this->findModel ( $id );
|
||||
$output = Yii::$app->getRequest ()->getQueryParam ( 'output' );
|
||||
$details = null;
|
||||
|
||||
|
||||
if ($accountState->isTypeClose ()) {
|
||||
|
||||
|
||||
$prev = null;
|
||||
if ($accountState->type == AccountState::TYPE_CLOSE) {
|
||||
if (isset ( $accountState->prev_state )) {
|
||||
@@ -334,30 +335,30 @@ class AccountStateController extends Controller {
|
||||
}
|
||||
$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');
|
||||
$mpdf=new Mpdf('utf-8', 'A4');
|
||||
$mpdf->useSubstitutions=false;
|
||||
$mpdf->simpleTables = true;
|
||||
$mpdf->SetHeader( \Yii::$app->params[ "company_name" ] . " - Létrehozva: " .$user->username . ", ".\Yii::$app->formatter->asDatetime(time()) );
|
||||
/** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||
$mpdf->setFooter('{PAGENO} / {nb}');
|
||||
|
||||
|
||||
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
|
||||
$mpdf->WriteHTML($stylesheet,1);
|
||||
|
||||
|
||||
$stylesheet = file_get_contents( \Yii::getAlias('@frontend'.'/web/css/account_close.css')); // external css
|
||||
$mpdf->WriteHTML($stylesheet,1);
|
||||
|
||||
|
||||
|
||||
|
||||
$mpdf->WriteHTML($this->renderPartial("@frontend/views/account-state/mixed_pdf", [
|
||||
'model' => $accountState,
|
||||
'details' => $details
|
||||
@@ -367,8 +368,8 @@ class AccountStateController extends Controller {
|
||||
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
|
||||
$fn= $type .$dt.".pdf";
|
||||
$mpdf->Output($fn, 'D');
|
||||
exit();
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
return $this->render ( 'mixed', [
|
||||
'model' => $accountState,
|
||||
|
||||
Reference in New Issue
Block a user