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

@@ -19,27 +19,28 @@ use common\models\Product;
use common\models\ShoppingCart;
use common\models\Customer;
use frontend\models\ContractForm;
use common\components\MpdfUtil;
/**
* ContractController implements the CRUD actions for Contract model.
*/
class ContractController extends Controller {
public function behaviors() {
return [
'verbs' => [
return [
'verbs' => [
'class' => VerbFilter::className (),
'actions' => [
'delete' => [
'post'
'actions' => [
'delete' => [
'post'
],
'payout' => [
'post'
'payout' => [
'post'
],
'cancel' => [
'post'
]
]
]
'cancel' => [
'post'
]
]
]
];
}
@@ -51,18 +52,18 @@ class ContractController extends Controller {
*/
public function actionIndex($id_card) {
$card = Card::findOne ( $id_card );
if (! isset ( $card ))
throw new NotFoundHttpException ( 'A bérlet nem található' );
$searchModel = new ContractSearch ();
$searchModel->card = $card;
$searchModel->customer = $card->customer;
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
return $this->render ( 'index', [
return $this->render ( 'index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider
'dataProvider' => $dataProvider
] );
}
@@ -77,20 +78,20 @@ class ContractController extends Controller {
$model = $this->findModel ( $id );
$customer = $model->customer;
$card = $customer->card;
$installments = TicketInstallmentRequest::find ()->andWhere ( [
'id_contract' => $model->id_contract
] )->orderBy ( [
'ticket_installment_request.priority' => SORT_ASC
$installments = TicketInstallmentRequest::find ()->andWhere ( [
'id_contract' => $model->id_contract
] )->orderBy ( [
'ticket_installment_request.priority' => SORT_ASC
] )->all ();
return $this->render ( 'view', [
return $this->render ( 'view', [
'model' => $model,
'intstallments' => $installments,
'card' => $card
'card' => $card
] );
}
/**
* Creates a new Contract model.
* If creation is successful, the browser will be redirected to the 'view' page.
@@ -99,15 +100,15 @@ class ContractController extends Controller {
*/
public function actionCreate() {
$model = new Contract ();
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [
return $this->redirect ( [
'view',
'id' => $model->id_contract
'id' => $model->id_contract
] );
} else {
return $this->render ( 'create', [
'model' => $model
return $this->render ( 'create', [
'model' => $model
] );
}
}
@@ -122,15 +123,15 @@ class ContractController extends Controller {
*/
public function actionUpdate($id) {
$model = $this->findModel ( $id );
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
return $this->redirect ( [
return $this->redirect ( [
'view',
'id' => $model->id_contract
'id' => $model->id_contract
] );
} else {
return $this->render ( 'update', [
'model' => $model
return $this->render ( 'update', [
'model' => $model
] );
}
}
@@ -146,12 +147,12 @@ class ContractController extends Controller {
*/
public function actionDelete($id) {
$this->findModel ( $id )->delete ();
return $this->redirect ( [
'index'
return $this->redirect ( [
'index'
] );
}
/**
* EGY RÉSZLET KIFIZETÉSE
*/
@@ -160,33 +161,33 @@ class ContractController extends Controller {
$contract = $part->contract;
$customer = $contract->customer;
$card = $customer->card;
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
$result = Transfer::sellContractTicket ( $contract, $part, Account::readDefaultObject (), Transfer::STATUS_NOT_PAID, Transfer::PAYMENT_METHOD_CASH, true );
$transfer = $result [0];
$ticket = $result [1];
if ($part->status != TicketInstallmentRequest::$STATUS_REJECTED) {
$contract->part_required = $contract->part_required + 1;
}
$contract->part_paid = $contract->part_paid + 1;
if ($contract->part_paid >= $contract->part_required) {
$contract->status = Contract::$STATUS_PAID;
} else {
$contract->status = Contract::$STATUS_NOT_PAID;
}
$contract->save ( false );
$part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
$part->id_transfer = $transfer->id_transfer;
$part->request_processed_at = Helper::getDateTimeString ();
$part->id_ticket = $ticket->id_ticket;
$part->save ( false );
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', "Részlet a bevásárló kosárba helyezve!" );
@@ -194,10 +195,10 @@ class ContractController extends Controller {
$transaction->rollback ();
Yii::error ( "Nem sikerült a kifizetés." );
}
return $this->redirect ( [
return $this->redirect ( [
'view',
'id' => $contract->id_contract
'id' => $contract->id_contract
] );
}
@@ -211,26 +212,26 @@ class ContractController extends Controller {
*/
public function actionCancel($id,$flag) {
$contract = $this->findModel ( $id );
if ( $flag != Contract::$FLAG_CANCELED && $flag != Contract::$FLAG_CANCELED_2){
\Yii::error("A felmondási státusz nem található! ($flag)");
throw new NotFoundHttpException("Az oldal nem található!");
}
$customer = $contract->customer;
$card = $customer->card;
if ($contract->canCancel ()) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
$contract->flag = $flag;
$contract->save ();
$requests = $contract->requests;
$buntetes = 0;
foreach ( $requests as $request ) {
/** @var \common\models\TicketInstallmentRequest $request*/
if ($request->isStatusAccepted ()) {
@@ -240,15 +241,15 @@ class ContractController extends Controller {
$request->save ( false );
}
}
$productBuntetes = Product::find ()->andWhere ( [
'product_number' => Product::$BUNTETES
$productBuntetes = Product::find ()->andWhere ( [
'product_number' => Product::$BUNTETES
] )->one ();
// if there is a fee , generate fee and put it to the shopping cart
if (isset ( $productBuntetes )) {
if ($buntetes > 0) {
$sale = new Sale ();
$sale->id_account = Account::readDefault ();
$sale->id_product = $productBuntetes->id_product;
@@ -258,29 +259,29 @@ class ContractController extends Controller {
$sale->count = $buntetes;
$sale->money = $buntetes * $sale->item_price;
$sale->id_user = \Yii::$app->user->id;
$sale->save ( false );
$transfer = Transfer::createProductTransfer ( $sale, Account::readDefaultObject (), null, null, $sale->count, $productBuntetes, Transfer::STATUS_NOT_PAID, $customer );
$transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
$transfer->id_user = Yii::$app->user->id;
$transfer->save ( false );
$cart = new ShoppingCart ();
$cart->id_customer = $customer->id_customer;
$cart->id_transfer = $transfer->id_transfer;
$cart->save ( false );
}
}
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" );
return $this->redirect ( [
return $this->redirect ( [
'product/sale',
'number' => $card->number
'number' => $card->number
] );
} catch ( Exception $e ) {
$transaction->rollback ();
@@ -289,10 +290,10 @@ class ContractController extends Controller {
} else {
\Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" );
}
return $this->redirect ( [
return $this->redirect ( [
'view',
'id' => $contract->id_contract
'id' => $contract->id_contract
] );
}
@@ -303,31 +304,31 @@ class ContractController extends Controller {
*/
public function actionMake($id) {
$customer = Customer::findOne ( $id );
if (! isset ( $customer )) {
throw new Exception ( "Az oldal nem található" );
}
$model = new ContractForm ( [
$model = new ContractForm ( [
'customer' => $customer ,
'idUser' => \Yii::$app->user->id,
'idAccount' => Account::readDefault ()
] );
$model->started_at = date(date('Y.m.d'));
$model->fillOut ();
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
$model->make ();
$transaction->commit();
return $this->redirect ( [
return $this->redirect ( [
'contract/view',
'id' => $model->contract->id_contract
] );
@@ -336,9 +337,9 @@ class ContractController extends Controller {
\Yii::$app->session->setFlash('danger', $e->getMessage());
}
}
return $this->render ( '_make_contract', [
'model' => $model
return $this->render ( '_make_contract', [
'model' => $model
] );
}
@@ -349,16 +350,18 @@ class ContractController extends Controller {
*/
public function actionContract($id){
$model = $this->findModel($id);
// print_r($model);
//$mpdf=new \mPDF('utf-8', 'A4');
$mpdf=new \mPDF('utf-8','A4','','','15','15','26','18','3');
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8','A4','','','15','15','26','18','3');
$mpdf->SetHTMLHeader("<div style='height: 80px; text-align: right; ' ><img height='80px' src='" . \Yii::getAlias("@webroot") . DIRECTORY_SEPARATOR. "images" . DIRECTORY_SEPARATOR . "cutler_contract_pdf_header.jpg'></div>");
$mpdf->setFooter('{PAGENO} / {nb}');
$mpdf->WriteHTML($this->renderPartial('_contract', [
'model' => $model,
]));
$fileName = "szerzodes";
$fileName .= "." . $model->customer->name;
$fileName .= "." .\Yii::$app->formatter->asDate( $model->created_at, "Y");
@@ -367,12 +370,12 @@ class ContractController extends Controller {
// $mpdf->Output('szerzodes.pdf', 'I');//open in new tab
exit;
}
/**
* Finds the Contract 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 Contract the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/