Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/yajra.zip
Ðазад
PK Dj*[H�kkV V + laravel-datatables-export/phpstan.neon.distnu �[��� includes: - ./vendor/larastan/larastan/extension.neon parameters: paths: - src level: max ignoreErrors: - '#Parameter \#1 \$callback of method Illuminate\\Container\\Container::call\(\) expects \(callable\(\): mixed\)\|string*#' excludePaths: - tests checkMissingIterableValueType: false PK Dj*[���i� � 1 laravel-datatables-export/src/WithExportQueue.phpnu �[��� <?php namespace Yajra\DataTables; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Bus; use Yajra\DataTables\Jobs\DataTableExportJob; /** * @mixin \Yajra\DataTables\Services\DataTable */ trait WithExportQueue { /** * Process dataTables needed render output. * * @return mixed * * @throws \Throwable */ public function render(?string $view = null, array $data = [], array $mergeData = []) { if (request()->ajax() && request('action') == 'exportQueue') { return $this->exportQueue(); } return parent::render($view, $data, $mergeData); } /** * Create and run batch job. * * * @throws \Throwable */ public function exportQueue(): string { $job = new DataTableExportJob( [self::class, $this->attributes], request()->all(), Auth::id() ?? 0, $this->sheetName(), ); $batch = Bus::batch([$job])->name('datatables-export')->dispatch(); return $batch->id; } /** * Default sheet name. * Character limit 31. */ protected function sheetName(): string { return request('sheetName', 'Sheet1'); } } PK Dj*[�H�?k k @ laravel-datatables-export/src/Livewire/ExportButtonComponent.phpnu �[��� <?php namespace Yajra\DataTables\Livewire; use Illuminate\Bus\Batch; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Facades\Bus; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Livewire\Component; use Symfony\Component\HttpFoundation\StreamedResponse; /** * @property Batch $exportBatch */ class ExportButtonComponent extends Component { public string $class = 'btn btn-primary'; public ?string $tableId = null; public ?string $emailTo = ''; public string $type = 'xlsx'; public string $filename = ''; public string $buttonName = 'Export'; public string $sheetName = 'Sheet1'; public bool $autoDownload = false; public bool $downloaded = false; public bool $exporting = false; public bool $exportFinished = false; public bool $exportFailed = false; public ?string $batchJobId = null; public function export(string $batchJobId): void { $this->batchJobId = $batchJobId; $this->exportFinished = false; $this->exportFailed = false; $this->exporting = true; $this->downloaded = false; } public function getExportBatchProperty(): ?Batch { if (! $this->batchJobId) { return null; } return Bus::findBatch($this->batchJobId); } public function updateExportProgress(): ?StreamedResponse { $this->exportFinished = $this->exportBatch->finished(); $this->exportFailed = $this->exportBatch->hasFailures(); if ($this->exportFinished) { $this->exporting = false; if ($this->autoDownload and ! $this->downloaded) { $this->downloaded = true; return $this->downloadExport(); } } return null; } public function downloadExport(): StreamedResponse { if ($this->getS3Disk()) { return Storage::disk($this->getS3Disk()) ->download($this->batchJobId.'.'.$this->getType(), $this->getFilename()); } return Storage::disk($this->getDisk())->download($this->batchJobId.'.'.$this->getType(), $this->getFilename()); } protected function getType(): string { if (Str::endsWith($this->filename, ['csv', 'xlsx'])) { return pathinfo($this->filename, PATHINFO_EXTENSION); } return $this->type == 'csv' ? 'csv' : 'xlsx'; } protected function getFilename(): string { if (Str::endsWith(Str::lower($this->filename), ['csv', 'xlsx'])) { return $this->filename; } return Str::random().'.'.$this->getType(); } public function render(): Renderable { return view('datatables-export::export-button', [ 'fileType' => $this->getType(), ]); } protected function getDisk(): string { /** @var string $disk */ $disk = config('datatables-export.disk', 'local'); return $disk; } protected function getS3Disk(): string { /** @var string $disk */ $disk = config('datatables-export.s3_disk', ''); return $disk; } } PK Dj*[ ��Y Y G laravel-datatables-export/src/Commands/DataTablesPurgeExportCommand.phpnu �[��� <?php namespace Yajra\DataTables\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; class DataTablesPurgeExportCommand extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'datatables:purge-export'; /** * The console command description. * * @var string */ protected $description = 'Remove exported files that datatables-export generate.'; /** * Execute the console command. * * @return void */ public function handle() { /** @var string $disk */ $disk = config('datatables-export.disk', 'local'); /** @var int $daysOld */ $daysOld = config('datatables-export.purge.days', 1); $timestamp = now()->subDays($daysOld)->getTimestamp(); collect(Storage::disk($disk)->files()) ->each(function ($file) use ($timestamp, $disk) { $path = Storage::disk($disk)->path($file); if (File::lastModified($path) < $timestamp && Str::endsWith(strtolower($file), ['xlsx', 'csv'])) { File::delete($path); } }); $this->info('The command was successful. Export files are cleared!'); } } PK Dj*[�[ % % 9 laravel-datatables-export/src/Jobs/DataTableExportJob.phpnu �[��� <?php namespace Yajra\DataTables\Jobs; use Carbon\Carbon; use DateTimeInterface; use Illuminate\Auth\Events\Login; use Illuminate\Bus\Batchable; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Http\File; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Arr; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use OpenSpout\Common\Entity\Cell; use OpenSpout\Common\Entity\Row; use OpenSpout\Common\Entity\Style\Style; use OpenSpout\Writer\Common\Creator\WriterFactory; use OpenSpout\Writer\XLSX\Helper\DateHelper; use OpenSpout\Writer\XLSX\Writer as XLSXWriter; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use Yajra\DataTables\Html\Column; use Yajra\DataTables\Services\DataTable; class DataTableExportJob implements ShouldBeUnique, ShouldQueue { use Batchable; use Dispatchable; use InteractsWithQueue; use Queueable; use SerializesModels; /** * @var class-string<DataTable> */ public string $dataTable; public array $attributes = []; /** * @param array{class-string<DataTable>, array} $instance */ public function __construct( array $instance, public array $request, public int|string|null $user, public string $sheetName = 'Sheet1' ) { $this->dataTable = $instance[0]; $this->attributes = $instance[1]; } /** * Execute the job. * * @throws \OpenSpout\Common\Exception\IOException * @throws \OpenSpout\Common\Exception\UnsupportedTypeException * @throws \OpenSpout\Writer\Exception\WriterNotOpenedException * @throws \OpenSpout\Writer\Exception\InvalidSheetNameException */ public function handle(): void { if ($this->user) { Event::forget(Login::class); Auth::loginUsingId($this->user); } /** @var DataTable $oTable */ $oTable = resolve($this->dataTable); request()->merge($this->request); $query = app()->call([$oTable->with($this->attributes), 'query']); /** @var \Yajra\DataTables\QueryDataTable $dataTable */ $dataTable = app()->call([$oTable, 'dataTable'], compact('query')); $dataTable->skipPaging(); $type = 'xlsx'; $exportType = request('export_type', 'xlsx'); if (is_string($exportType)) { $type = Str::of($exportType)->startsWith('csv') ? 'csv' : 'xlsx'; } $filename = $this->batchId.'.'.$type; $path = Storage::disk($this->getDisk())->path($filename); $writer = WriterFactory::createFromFile($filename); $writer->openToFile($path); if ($writer instanceof XLSXWriter) { $sheet = $writer->getCurrentSheet(); $sheet->setName(substr($this->sheetName, 0, 31)); } $columns = $this->getExportableColumns($oTable); $headers = []; $columns->each(function (Column $column) use (&$headers) { $headers[] = strip_tags($column->title); }); $writer->addRow(Row::fromValues($headers)); if ($this->usesLazyMethod()) { $chunkSize = 1_000; if (is_int(config('datatables-export.chunk'))) { $chunkSize = config('datatables-export.chunk'); } $query = $dataTable->getFilteredQuery()->lazy($chunkSize); } else { $query = $dataTable->getFilteredQuery()->cursor(); } foreach ($query as $row) { $cells = []; $row = $row instanceof Arrayable ? $row->toArray() : (array) $row; if ($this->usesLazyMethod() && is_array($row)) { $row = Arr::dot($row); } $defaultDateFormat = 'yyyy-mm-dd'; if (config('datatables-export.default_date_format') && is_string(config('datatables-export.default_date_format')) ) { $defaultDateFormat = config('datatables-export.default_date_format'); } $columns->map(function (Column $column) use ($row, &$cells, $defaultDateFormat) { $property = $column->data; /* Handles orthogonal data */ if (is_array($property)) { $property = $property['_'] ?? $column->name; } /** @var array|bool|int|string|null|DateTimeInterface $value */ $value = $row[$property] ?? ''; if (is_array($value)) { $value = json_encode($value); } switch (true) { case $this->wantsText($column): if ($value instanceof DateTimeInterface) { $cellValue = $value->format($defaultDateFormat); } else { $cellValue = strval($value); } $format = $column->exportFormat ?? '@'; break; case $this->wantsDateFormat($column): if ($value instanceof DateTimeInterface) { $cellValue = DateHelper::toExcel($value); } else { $cellValue = $value ? DateHelper::toExcel(Carbon::parse(strval($value))) : ''; } $format = $column->exportFormat ?? $defaultDateFormat; break; case $this->wantsNumeric($column): if ($value instanceof DateTimeInterface) { $cellValue = 0.0; } else { $cellValue = floatval($value); } $format = $column->exportFormat; break; case $value instanceof DateTimeInterface: $cellValue = $value; $format = $column->exportFormat ?? $defaultDateFormat; break; default: $cellValue = $this->isNumeric($value) ? floatval($value) : $value; $format = $column->exportFormat ?? NumberFormat::FORMAT_GENERAL; } $cells[] = Cell::fromValue($cellValue, (new Style)->setFormat($format)); }); $writer->addRow(new Row($cells)); } $writer->close(); if ($this->getS3Disk()) { Storage::disk($this->getS3Disk())->putFileAs('', (new File($path)), $filename); } $emailTo = request('emailTo'); if ($emailTo && is_string($emailTo)) { $data = ['email' => urldecode($emailTo), 'path' => $path]; $this->sendResults($data); } } protected function getDisk(): string { $disk = 'local'; if (is_string(config('datatables-export.disk'))) { $disk = config('datatables-export.disk'); } return $disk; } /** * @return \Illuminate\Support\Collection<array-key, Column> */ protected function getExportableColumns(DataTable $dataTable): Collection { $columns = $dataTable->html()->getColumns(); return $columns->filter(fn (Column $column) => $column->exportable); } protected function usesLazyMethod(): bool { return config('datatables-export.method', 'lazy') === 'lazy'; } protected function wantsText(Column $column): bool { if (! isset($column['exportFormat'])) { return false; } return in_array($column['exportFormat'], (array) config('datatables-export.text_formats', ['@'])); } protected function wantsDateFormat(Column $column): bool { if (! isset($column['exportFormat'])) { return false; } /** @var array $formats */ $formats = config('datatables-export.date_formats', []); return in_array($column['exportFormat'], $formats); } protected function wantsNumeric(Column $column): bool { return Str::contains($column->exportFormat, ['0', '#']); } /** * @param int|bool|string|null $value */ protected function isNumeric($value): bool { // Skip numeric style if value has leading zeroes. if (Str::startsWith(strval($value), '0')) { return false; } return is_numeric($value); } protected function getS3Disk(): string { $disk = ''; if (config('datatables-export.s3_disk') && is_string(config('datatables-export.s3_disk'))) { $disk = config('datatables-export.s3_disk'); } return $disk; } public function sendResults(array $data): void { Mail::send('datatables-export::export-email', $data, function ($message) use ($data) { $message->attach($data['path']); $message->to($data['email']) ->subject('Export Report'); $message->from(config('datatables-export.mail_from')); }); } } PK Dj*[�4��) ) D laravel-datatables-export/src/resources/views/export-email.blade.phpnu �[��� Attached you will find requested report. PK Dj*[�V�] ] E laravel-datatables-export/src/resources/views/export-button.blade.phpnu �[��� <div class="d-flex align-items-center" x-data> <form class="mr-2" x-on:submit.prevent=" $refs.exportBtn.disabled = true; var oTable = LaravelDataTables['{{ $tableId }}']; var baseUrl = oTable.ajax.url() === '' ? window.location.toString() : oTable.ajax.url(); var url = new URL(baseUrl); var searchParams = new URLSearchParams(url.search); searchParams.set('action', 'exportQueue'); searchParams.set('exportType', '{{$fileType}}'); searchParams.set('sheetName', '{{$sheetName}}'); searchParams.set('buttonName', '{{$buttonName}}'); searchParams.set('emailTo', '{{urlencode($emailTo)}}'); var tableParams = $.param(oTable.ajax.params()); if (tableParams) { var tableSearchParams = new URLSearchParams(tableParams); tableSearchParams.forEach((value, key) => { searchParams.append(key, value); }); } url.search = searchParams.toString(); $.get(url.toString()).then(function(exportId) { $wire.export(exportId); }).catch(function(error) { $wire.exportFinished = true; $wire.exporting = false; $wire.exportFailed = true; }); " > <button type="submit" x-ref="exportBtn" :disabled="$wire.exporting" class="{{ $class }}" >{{$buttonName}} </button> </form> @if($exporting && $emailTo) <div class="d-inline">Export will be emailed to {{ $emailTo }}.</div> @endif @if($exporting && !$exportFinished) <div class="d-inline" wire:poll="updateExportProgress">Exporting...please wait.</div> @endif @if($exportFinished && !$exportFailed && !$autoDownload) <span>Done. Download file <a href="#" class="text-primary" wire:click.prevent="downloadExport">here</a></span> @endif @if($exportFinished && !$exportFailed && $autoDownload && $downloaded) <span>Done. File has been downloaded.</span> @endif @if($exportFailed) <span>Export failed, please try again later.</span> @endif </div> PK Dj*[^�m� � 7 laravel-datatables-export/src/ExportServiceProvider.phpnu �[��� <?php namespace Yajra\DataTables; use Illuminate\Support\ServiceProvider; use Livewire\Livewire; use Livewire\LivewireServiceProvider; use Yajra\DataTables\Commands\DataTablesPurgeExportCommand; use Yajra\DataTables\Livewire\ExportButtonComponent; class ExportServiceProvider extends ServiceProvider { public function boot(): void { $this->loadViewsFrom(__DIR__.'/resources/views', 'datatables-export'); $this->publishAssets(); Livewire::component('export-button', ExportButtonComponent::class); } protected function publishAssets(): void { $this->publishes([ __DIR__.'/config/datatables-export.php' => config_path('datatables-export.php'), ], 'datatables-export'); $this->publishes([ __DIR__.'/resources/views' => base_path('/resources/views/vendor/datatables-export'), ], 'datatables-export'); } public function register(): void { $this->mergeConfigFrom(__DIR__.'/config/datatables-export.php', 'datatables-export'); $this->commands([DataTablesPurgeExportCommand::class]); $this->app->register(LivewireServiceProvider::class); } } PK Dj*[*9�R R : laravel-datatables-export/src/config/datatables-export.phpnu �[��� <?php use PhpOffice\PhpSpreadsheet\Style\NumberFormat; return [ /* |-------------------------------------------------------------------------- | Method |-------------------------------------------------------------------------- | | Method to use to iterate with the query results. | Options: lazy, cursor | | @link https://laravel.com/docs/eloquent#cursors | @link https://laravel.com/docs/eloquent#chunking-using-lazy-collections | */ 'method' => 'lazy', /* |-------------------------------------------------------------------------- | Chunk Size |-------------------------------------------------------------------------- | | Chunk size to be used when using lazy method. | */ 'chunk' => 1000, /* |-------------------------------------------------------------------------- | Export filesystem disk |-------------------------------------------------------------------------- | | Export filesystem disk where generated files will be stored. | */ 'disk' => 'local', /* |-------------------------------------------------------------------------- | Use S3 for final file destination |-------------------------------------------------------------------------- | | After generating the file locally, it can be uploaded to s3. | */ 's3_disk' => '', /* |-------------------------------------------------------------------------- | Mail from address |-------------------------------------------------------------------------- | | Will be used to email report from this address. | */ 'mail_from' => env('MAIL_FROM_ADDRESS', ''), /* |-------------------------------------------------------------------------- | Default Date Format |-------------------------------------------------------------------------- | | Default export format for date. | */ 'default_date_format' => 'yyyy-mm-dd', /* |-------------------------------------------------------------------------- | Valid Date Formats |-------------------------------------------------------------------------- | | List of valid date formats to be used for auto-detection. | */ 'date_formats' => [ 'mm/dd/yyyy', NumberFormat::FORMAT_DATE_DATETIME, NumberFormat::FORMAT_DATE_YYYYMMDD, NumberFormat::FORMAT_DATE_XLSX22, NumberFormat::FORMAT_DATE_DDMMYYYY, NumberFormat::FORMAT_DATE_DMMINUS, NumberFormat::FORMAT_DATE_DMYMINUS, NumberFormat::FORMAT_DATE_DMYSLASH, NumberFormat::FORMAT_DATE_MYMINUS, NumberFormat::FORMAT_DATE_TIME1, NumberFormat::FORMAT_DATE_TIME2, NumberFormat::FORMAT_DATE_TIME3, NumberFormat::FORMAT_DATE_TIME4, NumberFormat::FORMAT_DATE_TIME5, NumberFormat::FORMAT_DATE_TIME6, NumberFormat::FORMAT_DATE_TIME7, NumberFormat::FORMAT_DATE_XLSX14, NumberFormat::FORMAT_DATE_XLSX15, NumberFormat::FORMAT_DATE_XLSX16, NumberFormat::FORMAT_DATE_XLSX17, NumberFormat::FORMAT_DATE_YYYYMMDD2, NumberFormat::FORMAT_DATE_YYYYMMDDSLASH, ], /* |-------------------------------------------------------------------------- | Valid Text Formats |-------------------------------------------------------------------------- | | List of valid text formats to be used. | */ 'text_formats' => [ '@', NumberFormat::FORMAT_GENERAL, NumberFormat::FORMAT_TEXT, ], /* |-------------------------------------------------------------------------- | Purge Options |-------------------------------------------------------------------------- | | Purge all exported by purge.days old files. | */ 'purge' => [ 'days' => 1, ], ]; PK Dj*[� zɩ � ) laravel-datatables-export/CONTRIBUTING.mdnu �[��� # Contributing Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-datatables-export). ## Pull Requests - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. **Happy coding**!PK Dj*[���O O $ laravel-datatables-export/LICENSE.mdnu �[��� (The MIT License) Copyright (c) 2013-2022 Arjay Angeles <aqangeles@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK Dj*[5ɢb * laravel-datatables-export/phpunit.xml.distnu �[��� <?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false"> <testsuites> <testsuite name="Package Test Suite"> <directory suffix="Test.php">./tests/</directory> </testsuite> </testsuites> </phpunit> PK Dj*[ދ�� $ laravel-datatables-export/rector.phpnu �[��� <?php declare(strict_types=1); use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; use Rector\Config\RectorConfig; use Rector\Set\ValueObject\LevelSetList; return static function (RectorConfig $rectorConfig): void { $rectorConfig->paths([ __DIR__.'/src', __DIR__.'/tests', ]); // register a single rule $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); // define sets of rules $rectorConfig->sets([ LevelSetList::UP_TO_PHP_82, ]); }; PK Dj*[�$�� � $ laravel-datatables-export/UPGRADE.mdnu �[��� # UPGRADE GUIDE ## Upgrade from 10.x to 11.x 1. Update the composer.json file and change the version of the package to `^11.0`: ```json "require": { "yajra/laravel-datatables-export": "^11.0" } ``` 2. Run `composer update` to update the package. PK Dj*[P��^7 7 &