diff --git a/README.md b/README.md index fb76c47..2f56fb8 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,3 @@ Jorayew Mammetjan 01/2040 I-AS 379514 25.05.2006ý - - -{"idSeria":string,"idNo":string,"cardMaskNumber":string,"expDate":string,"clientType":string,"fromDate":string,"toDate":string,"clientName":string,"depName":string,"cardPan":string,"cardAccountNumber":string,"birthDate":string,"mfo":string,"passOrg":string,"passDate":string,"address":string,"phone":string,"errCode":int,"message":string,"messageRu":string,"messageEn":string,"transactions": array} diff --git a/app/Http/Controllers/Api/CardTransactionController.php b/app/Http/Controllers/Api/CardTransactionController.php index a7a8c75..1271202 100644 --- a/app/Http/Controllers/Api/CardTransactionController.php +++ b/app/Http/Controllers/Api/CardTransactionController.php @@ -12,27 +12,27 @@ class CardTransactionController extends Controller { public function show(CardTransaction $transaction) { - $a = new DownloadCardTransaction; + // $a = new DownloadCardTransaction; - $start_date = Carbon::create(date('Y-m-d', strtotime('-12 months'))); - $end_date = Carbon::create(date('Y-m-d')); + // $start_date = Carbon::create(date('Y-m-d', strtotime('-12 months'))); + // $end_date = Carbon::create(date('Y-m-d')); - $response = $a->fetchApi( - passport_serie: $transaction->passport_serie, - passport_id: $transaction->passport_id, - card_number_masked: Str::mask($transaction->card_number, '*', 6, 6), - card_expire_date: $transaction->card_month.'/'.substr($transaction->card_year, 2), - start_date: $start_date->format('d.m.Y'), - end_date: $end_date->format('d.m.Y'), - ); + // $response = $a->fetchApi( + // passport_serie: $transaction->passport_serie, + // passport_id: $transaction->passport_id, + // card_number_masked: Str::mask($transaction->card_number, '*', 6, 6), + // card_expire_date: $transaction->card_month.'/'.substr($transaction->card_year, 2), + // start_date: $start_date->format('d.m.Y'), + // end_date: $end_date->format('d.m.Y'), + // ); - /** @var ResponseTypes\AzatApiClientInfoAllResponse */ - $data = Str::isJson($response) - ? json_decode($response) - : emptyClass(errCode: 1, message: 'Connection issue to VP'); + // /** @var ResponseTypes\AzatApiClientInfoAllResponse */ + // $data = Str::isJson($response) + // ? json_decode($response) + // : emptyClass(errCode: 1, message: 'Connection issue to VP'); - return view('orders.cards.card-transaction.download-card-transaction', [ - 'transaction' => $data - ]); + // return view('orders.cards.card-transaction.download-card-transaction', [ + // 'transaction' => $data + // ]); } } diff --git a/app/Nova/Resources/Order/Card/CardTransaction/Actions/DownloadCardTransaction.php b/app/Nova/Resources/Order/Card/CardTransaction/Actions/DownloadCardTransaction.php index 9af1c7c..52b20e9 100644 --- a/app/Nova/Resources/Order/Card/CardTransaction/Actions/DownloadCardTransaction.php +++ b/app/Nova/Resources/Order/Card/CardTransaction/Actions/DownloadCardTransaction.php @@ -6,12 +6,14 @@ use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Blade; use Illuminate\Support\Str; use Laravel\Nova\Actions\Action; use Laravel\Nova\Actions\ActionResponse; use Laravel\Nova\Fields\ActionFields; use Laravel\Nova\Fields\Date; use Laravel\Nova\Http\Requests\NovaRequest; +use Mpdf\Mpdf; class DownloadCardTransaction extends Action { @@ -127,5 +129,18 @@ class DownloadCardTransaction extends Action * * @param ResponseTypes\AzatApiClientInfoAllResponse $data */ - public function generateFile($data) {} + public function generateFile($data) + { + $mpdf = new Mpdf; + + // Write HTML content + $html = Blade::render('orders.cards.card-transaction.download-card-transaction', [ + 'data' => $data, + ]); + + $mpdf->WriteHTML($html); + + // Save the PDF to a file + $mpdf->Output(public_path('files/output.pdf'), \Mpdf\Output\Destination::FILE); + } } diff --git a/composer.json b/composer.json index a30f3fb..9b66332 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "maantje/pulse-php-fpm": "^0.2.1", "markwalet/nova-modal-response": "^0.3.0", "morrislaptop/laravel-pulse-4xx": "^0.0.2", + "mpdf/mpdf": "^8.2", "nurmuhammet/nova-custom-html": "@dev", "nurmuhammet/nova-inputmask": "^1.0", "outl1ne/nova-detached-filters": "^2.1", diff --git a/composer.lock b/composer.lock index 730984a..b6f4478 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "82fe0a50c348d46e4b9dab83abb99e96", + "content-hash": "7a2dbd9905ac906785253c58903ea32b", "packages": [ { "name": "adoy/fastcgi-client", @@ -4133,6 +4133,179 @@ }, "time": "2023-12-07T10:21:03+00:00" }, + { + "name": "mpdf/mpdf", + "version": "v8.2.5", + "source": { + "type": "git", + "url": "https://github.com/mpdf/mpdf.git", + "reference": "e175b05e3e00977b85feb96a8cccb174ac63621f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/e175b05e3e00977b85feb96a8cccb174ac63621f", + "reference": "e175b05e3e00977b85feb96a8cccb174ac63621f", + "shasum": "" + }, + "require": { + "ext-gd": "*", + "ext-mbstring": "*", + "mpdf/psr-http-message-shim": "^1.0 || ^2.0", + "mpdf/psr-log-aware-trait": "^2.0 || ^3.0", + "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 || ~8.3.0 || ~8.4.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/log": "^1.0 || ^2.0 || ^3.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": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Mpdf\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-only" + ], + "authors": [ + { + "name": "Matěj Humpál", + "role": "Developer, maintainer" + }, + { + "name": "Ian Back", + "role": "Developer (retired)" + } + ], + "description": "PHP library generating PDF files from UTF-8 encoded HTML", + "homepage": "https://mpdf.github.io", + "keywords": [ + "pdf", + "php", + "utf-8" + ], + "support": { + "docs": "https://mpdf.github.io", + "issues": "https://github.com/mpdf/mpdf/issues", + "source": "https://github.com/mpdf/mpdf" + }, + "funding": [ + { + "url": "https://www.paypal.me/mpdf", + "type": "custom" + } + ], + "time": "2024-11-18T15:30:42+00:00" + }, + { + "name": "mpdf/psr-http-message-shim", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-http-message-shim.git", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-http-message-shim/zipball/f25a0153d645e234f9db42e5433b16d9b113920f", + "reference": "f25a0153d645e234f9db42e5433b16d9b113920f", + "shasum": "" + }, + "require": { + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrHttpMessageShim\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + }, + { + "name": "Nigel Cunningham", + "email": "nigel.cunningham@technocrat.com.au" + } + ], + "description": "Shim to allow support of different psr/message versions.", + "support": { + "issues": "https://github.com/mpdf/psr-http-message-shim/issues", + "source": "https://github.com/mpdf/psr-http-message-shim/tree/v2.0.1" + }, + "time": "2023-10-02T14:34:03+00:00" + }, + { + "name": "mpdf/psr-log-aware-trait", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/mpdf/psr-log-aware-trait.git", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mpdf/psr-log-aware-trait/zipball/a633da6065e946cc491e1c962850344bb0bf3e78", + "reference": "a633da6065e946cc491e1c962850344bb0bf3e78", + "shasum": "" + }, + "require": { + "psr/log": "^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Mpdf\\PsrLogAwareTrait\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Dorison", + "email": "mark@chromatichq.com" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com" + } + ], + "description": "Trait to allow support of different psr/log versions.", + "support": { + "issues": "https://github.com/mpdf/psr-log-aware-trait/issues", + "source": "https://github.com/mpdf/psr-log-aware-trait/tree/v3.0.0" + }, + "time": "2023-05-03T06:19:36+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.13.0", @@ -5111,6 +5284,56 @@ }, "time": "2024-10-22T08:19:08+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" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.3", @@ -6055,6 +6278,78 @@ ], "time": "2025-02-18T12:50:31+00:00" }, + { + "name": "setasign/fpdi", + "version": "v2.6.3", + "source": { + "type": "git", + "url": "https://github.com/Setasign/FPDI.git", + "reference": "67c31f5e50c93c20579ca9e23035d8c540b51941" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Setasign/FPDI/zipball/67c31f5e50c93c20579ca9e23035d8c540b51941", + "reference": "67c31f5e50c93c20579ca9e23035d8c540b51941", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "setasign/tfpdf": "<1.31" + }, + "require-dev": { + "phpunit/phpunit": "^7", + "setasign/fpdf": "~1.8.6", + "setasign/tfpdf": "~1.33", + "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" + ], + "support": { + "issues": "https://github.com/Setasign/FPDI/issues", + "source": "https://github.com/Setasign/FPDI/tree/v2.6.3" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/setasign/fpdi", + "type": "tidelift" + } + ], + "time": "2025-02-05T13:22:35+00:00" + }, { "name": "spatie/db-dumper", "version": "3.8.0", diff --git a/resources/views/orders/cards/card-transaction/download-card-transaction.blade.php b/resources/views/orders/cards/card-transaction/download-card-transaction.blade.php index 0e57dfd..335b6ef 100644 --- a/resources/views/orders/cards/card-transaction/download-card-transaction.blade.php +++ b/resources/views/orders/cards/card-transaction/download-card-transaction.blade.php @@ -7,15 +7,15 @@

FM0

-

{{ $transaction->depName }}

-

МФО: {{ $transaction->mfo }}

+

{{ $data->depName }}

+

МФО: {{ $data->mfo }}

Н/к: 101301000408

Текущая дата: {{ now()->format('H:i, d.m.Y') }}

ВЫПИСКА ПО СЧЕТУ КЛИЕНТА №9341304011

-

Ф.И.О. владельца счета: {{ $transaction->clientName }}

-

за период с {{ $transaction->fromDate }} по {{ $transaction->toDate }}

+

Ф.И.О. владельца счета: {{ $data->clientName }}

+

за период с {{ $data->fromDate }} по {{ $data->toDate }}


Исходящий остаток: 7.73

@@ -37,16 +37,16 @@ - @foreach($transaction->transactions as $transaction_item) + @foreach($data->transactions as $transaction) - {{ $transaction_item->trandate }} - {{ $transaction_item->trandate }} - {{ $transaction->cardMaskNumber }} - {{ $transaction_item->opername }} + {{ $transaction->trandate }} + {{ $transaction->trandate }} + {{ $data->cardMaskNumber }} + {{ $transaction->opername }} YOK - {{ $transaction_item->currency }} - {{ $transaction_item->opersum }} - {{ $transaction_item->opersum }} + {{ $transaction->currency }} + {{ $transaction->opersum }} + {{ $transaction->opersum }} YOK @endforeach diff --git a/routes/web.php b/routes/web.php index 2fddd5b..d3c78c4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,5 @@ group(function () { Route::middleware(['auth'])->group(function () { Route::get('password-change', [PasswordChangeController::class, 'index'])->name('password-change'); Route::post('password-change', [PasswordChangeController::class, 'update'])->name('password-change.update'); - - Route::get('card-transaction/{transaction}', [CardTransactionController::class, 'show']); }); Route::get('tester', [ApiTesterController::class, 'index']);