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.
@ -93,7 +95,7 @@ class AccountStateController extends \backend\controllers\BackendController
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()) );

View File

@ -4,6 +4,7 @@ namespace backend\controllers;
use common\models\Log;
use common\models\Transfer;
use Mpdf\Mpdf;
use Yii;
use common\models\Ticket;
use backend\models\TicketSearch;
@ -27,6 +28,7 @@ use yii\helpers\VarDumper;
use backend\models\TicketUpdate;
use yii\helpers\Url;
use common\components\Helper;
use common\components\MpdfUtil;
/**
* TicketController implements the CRUD actions for Ticket model.
@ -292,7 +294,7 @@ class TicketController extends \backend\controllers\BackendController {
$fileName = "berletek";
$fileName .= "_" . date ( "Ymd_His" );
$fileName .= ".pdf";
$mpdf = new \mPDF ( 'utf-8', 'A4' );
$mpdf = MpdfUtil::createMpdfWith6XConstructor( 'utf-8', 'A4' );
$mpdf->useSubstitutions = false;
$mpdf->simpleTables = true;
@ -333,7 +335,7 @@ class TicketController extends \backend\controllers\BackendController {
if ($searchModel->output == 'pdf') {
$user = User::findOne ( \Yii::$app->user->id );
$mpdf = new \mPDF ( 'utf-8', 'A4-L' );
$mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = "";
$ov = '_total_content_pdf';
$dt = "_letrehozva_" . date ( "Ymd_His" ) . "_" . $user->username;

View File

@ -21,6 +21,7 @@ use backend\models\TransferListUserGroupedSearch;
use backend\models\TransferLaterSearch;
use yii\helpers\Url;
use common\components\Helper;
use common\components\MpdfUtil;
/**
* TransferController implements the CRUD actions for Transfer model.
@ -249,7 +250,7 @@ class TransferController extends \backend\controllers\BackendController
protected function downloadPaymentLaterPDF($dataProvider) {
// $mpdf = new \mPDF ( 'utf-8', 'A4' );
$mpdf = new \mPDF ( 'utf-8', 'A4-L' );
$mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = "utolagos_fizetesek.pdf";
$mpdf->useSubstitutions = false;
@ -452,7 +453,7 @@ class TransferController extends \backend\controllers\BackendController
if ( $searchModel->output === 'pdf'){
$user = User::findOne(\Yii::$app->user->id);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$fn = "";
$ov = '_total_content_pdf';
$dt= "_letrehozva_".date("Ymd_His"). "_" . $user->username;
@ -561,7 +562,7 @@ class TransferController extends \backend\controllers\BackendController
$searchModel->search(Yii::$app->request->queryParams);
$mpdf=new \mPDF('utf-8', 'A4-L');
$mpdf= MpdfUtil::createMpdfWith6XConstructor('utf-8', 'A4-L');
$stylesheet = file_get_contents( \Yii::getAlias('@vendor'.'/bower/bootstrap/dist/css/bootstrap.css')); // external css
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML($this->renderPartial('_result_sale', [

View File

@ -10,6 +10,7 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\components\DetStatProcessor;
use common\components\MpdfUtil;
use backend\models\DestaUploadForm;
use yii\web\UploadedFile;
use yii\data\ArrayDataProvider;
@ -282,7 +283,7 @@ class UgiroController extends Controller {
}
protected function downloadUgiroPdf($model) {
$mpdf = new \mPDF ( 'utf-8', 'A4-L' );
$mpdf = MpdfUtil::createMpdfWith6XConstructor ( 'utf-8', 'A4-L' );
$fn = "köteg.". $model->id_ugiro . ".pdf";
$mpdf->useSubstitutions = false;

View File

@ -0,0 +1,41 @@
<?php
namespace common\components;
use Mpdf\Mpdf;
use yii\base\BaseObject;
class MpdfUtil extends BaseObject
{
// mpdf version 6 constructor
//function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
public static function createMpdfWith6XConstructor($mode = '', $format = 'A4', $default_font_size = 0, $default_font = '', $mgl = 15, $mgr = 15, $mgt = 16, $mgb = 16, $mgh = 9, $mgf = 9, $orientation = 'P')
{
return self::createMpdf([
'mode' => $mode,
'format' => $format,
'default_font_size' => $default_font_size,
'default_font' => $default_font,
'margin_left' => $mgl,
'margin_right' => $mgr,
'margin_top' => $mgt,
'margin_bottom' => $mgb,
'margin_header' => $mgh,
'margin_footer' => $mgf,
'orientation' => $orientation
]);
}
public static function createMpdf($options = [])
{
$mpdf = new Mpdf(
array_merge([
'mode' => 'utf-8',
'format' => 'A4'
], $options)
);
return $mpdf;
}
}

View File

@ -6,6 +6,7 @@ use common\models\User;
use common\models\Account;
use common\models\AccountState;
use common\components\DailyListing;
use common\components\MpdfUtil;
use yii\base\BaseObject;
/**
@ -76,7 +77,7 @@ class AccountStateMail extends BaseObject {
protected function attachPdf(){
$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()) );

View File

@ -27,7 +27,7 @@
"dmstr/yii2-adminlte-asset": "2.*",
"bassjobsen/bootstrap-3-typeahead": "^4.0",
"bower-asset/webcamjs": "^1.0",
"mpdf/mpdf": "^6.0",
"mpdf/mpdf": "^8.1",
"os/php-excel": "^2.1",
"phpoffice/phpexcel": "^1.8",
"2amigos/yii2-tinymce-widget": "~1.1",

356
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d1d630cf85ac72b3cb7d161afee070fe",
"content-hash": "138d862466e8a155a65957524deabe0f",
"packages": [
{
"name": "2amigos/yii2-tinymce-widget",
@ -2200,46 +2200,69 @@
},
{
"name": "mpdf/mpdf",
"version": "v6.0.0",
"version": "v8.1.4",
"source": {
"type": "git",
"url": "https://github.com/mpdf/mpdf.git",
"reference": "a15743d030ce3b5b7be36c6e83f76589b27c3f2c"
"reference": "add590e93b7502efafd9839a68cff99f3497b318"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/a15743d030ce3b5b7be36c6e83f76589b27c3f2c",
"reference": "a15743d030ce3b5b7be36c6e83f76589b27c3f2c",
"url": "https://api.github.com/repos/mpdf/mpdf/zipball/add590e93b7502efafd9839a68cff99f3497b318",
"reference": "add590e93b7502efafd9839a68cff99f3497b318",
"shasum": ""
},
"require": {
"ext-gd": "*",
"ext-mbstring": "*",
"php": ">=4.3.10"
"myclabs/deep-copy": "^1.7",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"php-http/message-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0 || ^2.0",
"setasign/fpdi": "^2.1"
},
"require-dev": {
"mockery/mockery": "^1.3.0",
"mpdf/qrcode": "^1.1.0",
"squizlabs/php_codesniffer": "^3.5.0",
"tracy/tracy": "~2.5",
"yoast/phpunit-polyfills": "^1.0"
},
"suggest": {
"ext-bcmath": "Needed for generation of some types of barcodes",
"ext-xml": "Needed mainly for SVG manipulation",
"ext-zlib": "Needed for compression of embedded resources, such as fonts"
},
"type": "library",
"autoload": {
"classmap": [
"mpdf.php",
"classes"
]
"psr-4": {
"Mpdf\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-1.0+"
"GPL-2.0-only"
],
"authors": [
{
"name": "Ian Back"
"name": "Matěj Humpál",
"role": "Developer, maintainer"
},
{
"name": "Ian Back",
"role": "Developer (retired)"
}
],
"description": "A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support",
"homepage": "http://www.mpdf1.com/mpdf/index.php",
"description": "PHP library generating PDF files from UTF-8 encoded HTML",
"homepage": "https://mpdf.github.io",
"keywords": [
"pdf",
"php",
"utf-8"
],
"time": "2015-03-01T10:27:49+00:00"
"time": "2022-12-15T11:24:39+00:00"
},
{
"name": "mrclay/minify",
@ -2286,6 +2309,55 @@
"homepage": "http://code.google.com/p/minify/",
"time": "2016-03-08T11:49:57+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/14daed4296fae74d9e3201d2c4925d1acb7aa614",
"reference": "14daed4296fae74d9e3201d2c4925d1acb7aa614",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"conflict": {
"doctrine/collections": "<1.6.8",
"doctrine/common": "<2.13.3 || >=3,<3.2.2"
},
"require-dev": {
"doctrine/collections": "^1.6.8",
"doctrine/common": "^2.13.3 || ^3.2.2",
"phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13"
},
"type": "library",
"autoload": {
"files": [
"src/DeepCopy/deep_copy.php"
],
"psr-4": {
"DeepCopy\\": "src/DeepCopy/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Create deep copies (clones) of your objects",
"keywords": [
"clone",
"copy",
"duplicate",
"object",
"object graph"
],
"time": "2022-03-03T13:19:32+00:00"
},
{
"name": "myclabs/php-enum",
"version": "1.6.6",
@ -2415,6 +2487,101 @@
],
"time": "2012-05-02T20:42:37+00:00"
},
{
"name": "paragonie/random_compat",
"version": "v9.99.100",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a",
"reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a",
"shasum": ""
},
"require": {
"php": ">= 7"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*",
"vimeo/psalm": "^1"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2020-10-15T08:29:30+00:00"
},
{
"name": "php-http/message-factory",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-http/message-factory.git",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1",
"shasum": ""
},
"require": {
"php": ">=5.4",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Factory interfaces for PSR-7 HTTP Message",
"homepage": "http://php-http.org",
"keywords": [
"factory",
"http",
"message",
"stream",
"uri"
],
"time": "2015-12-19T14:08:53+00:00"
},
{
"name": "phpoffice/phpexcel",
"version": "1.8.1",
@ -2473,6 +2640,103 @@
"abandoned": "phpoffice/phpspreadsheet",
"time": "2015-05-01T07:00:55+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2021-05-03T11:20:27+00:00"
},
{
"name": "rmrevin/yii2-fontawesome",
"version": "2.12.2",
@ -2525,6 +2789,68 @@
],
"time": "2015-11-20T09:17:45+00:00"
},
{
"name": "setasign/fpdi",
"version": "v2.3.6",
"source": {
"type": "git",
"url": "https://github.com/Setasign/FPDI.git",
"reference": "6231e315f73e4f62d72b73f3d6d78ff0eed93c31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Setasign/FPDI/zipball/6231e315f73e4f62d72b73f3d6d78ff0eed93c31",
"reference": "6231e315f73e4f62d72b73f3d6d78ff0eed93c31",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": "^5.6 || ^7.0 || ^8.0"
},
"conflict": {
"setasign/tfpdf": "<1.31"
},
"require-dev": {
"phpunit/phpunit": "~5.7",
"setasign/fpdf": "~1.8",
"setasign/tfpdf": "1.31",
"squizlabs/php_codesniffer": "^3.5",
"tecnickcom/tcpdf": "~6.2"
},
"suggest": {
"setasign/fpdf": "FPDI will extend this class but as it is also possible to use TCPDF or tFPDF as an alternative. There's no fixed dependency configured."
},
"type": "library",
"autoload": {
"psr-4": {
"setasign\\Fpdi\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jan Slabon",
"email": "jan.slabon@setasign.com",
"homepage": "https://www.setasign.com"
},
{
"name": "Maximilian Kresse",
"email": "maximilian.kresse@setasign.com",
"homepage": "https://www.setasign.com"
}
],
"description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.",
"homepage": "https://www.setasign.com/fpdi",
"keywords": [
"fpdf",
"fpdi",
"pdf"
],
"time": "2021-02-11T11:37:01+00:00"
},
{
"name": "sizeg/yii2-jwt",
"version": "v2.0.0",

33
doc/composer.md Normal file
View File

@ -0,0 +1,33 @@
# Composer Knowledge base
## upgrade packages
[upgrade.txt](./upgrade.txt)
## use newer github tokens
Edit the composer authentication configuration file ~/.composer/auth.json.
```bash
nano ~/.composer/auth.json
```
Then replace the following.
```json
{
"github-oauth": {
"github.com": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
```
With this (basic auth):
```json
{
"http-basic": {
"github.com": {
"username": "[YOUR-GITHUB-USERNAME]",
"password": "ghp_[YOUR-PERSONAL-TOKEN]"
}
}
}
```

View File

@ -31,7 +31,7 @@ RUN pecl update-channels
RUN pecl install mcrypt
RUN apt-get -y install \
# Required by composer
# Required by composr
git \
zlib1g-dev \
--no-install-recommends

View File

@ -16,6 +16,7 @@ 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.
@ -284,7 +285,7 @@ class AccountStateController extends Controller {
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()) );
@ -344,7 +345,7 @@ class AccountStateController extends Controller {
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()) );

View File

@ -19,6 +19,7 @@ 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.
@ -350,8 +351,10 @@ 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}');

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;
@ -327,7 +328,7 @@ class TransferController extends Controller
$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,
]));
@ -366,7 +367,7 @@ class TransferController extends Controller
$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,
]));