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

@@ -25,6 +25,7 @@ use common\models\Customer;
use frontend\models\CustomerCartForm;
use common\models\Card;
use common\components\Helper;
use common\components\MpdfUtil;
use yii\base\Exception;
use common\components\TransferPayout;
@@ -83,20 +84,20 @@ class TransferController extends Controller
if ( !Helper::isReceptionTransferIndexEnabled()){
throw new NotFoundHttpException();
}
$searchModel = new TransferSearch();
$searchModel->accounts = Account::read();
$searchModel->load(Yii::$app->request->queryParams);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$searchModel->totalsTransfers(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
@@ -119,7 +120,7 @@ class TransferController extends Controller
]);
}
/**
* Lists all Transfer models.
* @return mixed
@@ -129,14 +130,14 @@ class TransferController extends Controller
$searchModel = new TransferListSearch();
$searchModel->accounts = Account::read();
$searchModel->load(Yii::$app->request->queryParams);
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('list', [
'searchModel' => $searchModel,
]);
}
/**
@@ -151,7 +152,7 @@ class TransferController extends Controller
]);
}
/**
* Creates a new Transfer model.
* If creation is successful, the browser will be redirected to the 'view' page.
@@ -160,10 +161,10 @@ class TransferController extends Controller
public function actionMoneyMovementCreate()
{
$model = new Transfer();
$model->type = Transfer::TYPE_MONEY_MOVEMENT_OUT;
$model->direction = Transfer::DIRECTION_OUT;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_transfer]);
} else {
@@ -189,8 +190,8 @@ class TransferController extends Controller
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Updates an existing Transfer model.
* If update is successful, the browser will be redirected to the 'view' page.
@@ -221,16 +222,16 @@ class TransferController extends Controller
$transfer = $this->findModel($id);
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
$tp = new TransferPayout( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => [$transfer->id_transfer ],
'idTransfers' => [$transfer->id_transfer ],
'idAccount' => Account::readDefault (),
] );
$tp->payout ();
// UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Tranzakció fizetve: ' . $transfer->count ." db " . $transfer->getObjectName() . " - " . $transfer->money);
@@ -241,10 +242,10 @@ class TransferController extends Controller
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
return $this->redirect(Yii::$app->request->referrer);
}
/**
* Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
@@ -266,17 +267,17 @@ class TransferController extends Controller
// }else{
// throw new \Exception("Failed to save");
// }
} catch(Exception $e) {
$transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
}
return $this->redirect(Yii::$app->request->referrer);
}
protected function delete($id){
$transfer = $this->findModel($id);
$connection = \Yii::$app->db;
@@ -288,14 +289,14 @@ class TransferController extends Controller
}else{
throw new \Exception("Failed to save");
}
} catch(Exception $e) {
$transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció törlése nem sikerült' );
}
}
/**
* Lists all Transfer models.
* @return mixed
@@ -307,35 +308,35 @@ class TransferController extends Controller
$searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('sale', [
'searchModel' => $searchModel,
]);
}
public function actionSalePdf(){
$searchModel = new TransferSaleSearch();
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->productCategories = ProductCategory::read();
$searchModel->productOptions = Product::read();
$searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$mpdf->WriteHTML($this->renderPartial('_result_sale', [
'searchModel' => $searchModel,
]));
$mpdf->Output('eladasaim.pdf', 'D');
exit;
}
/**
* Lists all Transfer models.
@@ -347,43 +348,43 @@ class TransferController extends Controller
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams);
return $this->render('tickets', [
'searchModel' => $searchModel,
]);
}
public function actionTicketsPdf(){
$searchModel = new TransferTicketSearch();
$searchModel->accounts = Account::read();
$searchModel->users = User::read();
$searchModel->ticketTypes = TicketType::read(null, Account::readDefault());
$searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf=new Mpdf('utf-8', 'A4-L');
$mpdf->WriteHTML($this->renderPartial('_result_ticket', [
'searchModel' => $searchModel,
]));
$mpdf->Output('eladdot_berletek_'. \Yii::$app->formatter->asDatetime(time()).'.pdf', 'D');
exit;
}
public function actionUserCart(){
$defaultAccount = Account::readDefault();
if ( !isset($defaultAccount)){
return $this->redirect(['account/select']);
}
$model = new UserCartForm();
if ($model->load(Yii::$app->request->post()) && $model->payout()) {
return $this->redirect(['user-cart']);
@@ -391,31 +392,31 @@ class TransferController extends Controller
$model->run();
return $this->render("usercart",[ 'model' => $model]);
}
public function actionCustomerCart($id_card){
$defaultAccount = Account::readDefault();
if ( !isset($defaultAccount)){
return $this->redirect(['account/select']);
}
$hiddenAccounts = Account::find()
->andWhere(['type' => Account::TYPE_VALUE_HIDDEN])
->andWhere(['status' => Account::STATUS_ACTIVE])->all();
$customer = null;
$card = Card::findOne($id_card);
if ($card != null )
$customer = $card->customer;
if ( !isset($customer) ){
throw new NotFoundHttpException ( 'Az oldal nem található' );
}
$model = new CustomerCartForm();
$model->customer = $customer;
$model->hiddenAccounts = $hiddenAccounts;