test
This commit is contained in:
@@ -7,12 +7,14 @@ use App\Filament\Clusters\Cards\CardsCluster;
|
||||
use App\Modules\AppHelpers\Repositories\DateHelper;
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\CardBalance\Repositories\CardBalanceRepository;
|
||||
use App\Modules\CardTransaction\Repositories\CardTransactionRepository;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -127,13 +129,25 @@ class CardResource extends Resource
|
||||
->modalContent(fn (Card $record): View => CardBalanceRepository::make()->showCardBalance($record))
|
||||
->modalFooterActions([]),
|
||||
|
||||
Action::make('card_balance')
|
||||
->label(__('Card requisite'))
|
||||
->icon('heroicon-m-document-text')
|
||||
Action::make('card_transaction')
|
||||
->label(__('Card transaction'))
|
||||
->icon('heroicon-m-arrows-right-left')
|
||||
->requiresConfirmation()
|
||||
->modal()
|
||||
->modalContent(fn (Card $record): View => CardBalanceRepository::make()->showCardBalance($record))
|
||||
->modalFooterActions([]),
|
||||
->modalIcon('heroicon-m-arrows-right-left')
|
||||
->schema([
|
||||
DatePicker::make('start_date')
|
||||
->label(__('Start date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
|
||||
DatePicker::make('end_date')
|
||||
->label(__('End date'))
|
||||
->native(false)
|
||||
->required()
|
||||
->beforeOrEqual('today'),
|
||||
])
|
||||
->action(fn (array $data, Card $record) => CardTransactionRepository::make()->downloadCardTransaction($data, $record)),
|
||||
|
||||
EditAction::make()
|
||||
->label(''),
|
||||
|
||||
@@ -27,7 +27,7 @@ class CardRequisiteModule implements ModuleContract
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ class CardRequisiteModule implements ModuleContract
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,12 +2,9 @@
|
||||
|
||||
namespace App\Modules\CardRequisite\Repositories;
|
||||
|
||||
use App\Modules\CardRequisite\Models\CardRequisite;
|
||||
use App\Modules\Makeable;
|
||||
|
||||
class CardRequisiteRepository
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
|
||||
}
|
||||
|
||||
64
app/Modules/CardTransaction/CardTransactionModule.php
Normal file
64
app/Modules/CardTransaction/CardTransactionModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CardTransaction;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class CardTransactionModule implements ModuleContract
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Module is enabled
|
||||
*/
|
||||
protected bool $enabled = true;
|
||||
|
||||
/**
|
||||
* Check if is module enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable module
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable module
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has a filament resource
|
||||
*/
|
||||
public function hasFilamentResource(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer requirements
|
||||
*/
|
||||
public function getComposerRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer suggestions
|
||||
*/
|
||||
public function getComposerSuggestions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\CardTransaction\Repositories;
|
||||
|
||||
use App\Modules\Card\Models\Card;
|
||||
use App\Modules\Makeable;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CardTransactionRepository
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Download card transaction
|
||||
*
|
||||
* @param array{start_date: string, end_date: string} $data
|
||||
*/
|
||||
public function downloadCardTransaction(array $data, Card $record)
|
||||
{
|
||||
$start_date = Carbon::create($data['start_date']);
|
||||
$end_date = Carbon::create($data['end_date']);
|
||||
|
||||
$response = $this->fetchApi(
|
||||
passport_serie: user()->getOption('passport_serie') ?? 'I',
|
||||
passport_id: user()->getOption('passport_id') ?? '909090',
|
||||
card_number_masked: Str::mask($record->number, '*', 6, 6),
|
||||
card_expire_date: $record->month.'/'.substr($record->year, 2),
|
||||
start_date: $start_date->format('d.m.Y'),
|
||||
end_date: $end_date->format('d.m.Y'),
|
||||
);
|
||||
|
||||
info([
|
||||
'response' => $response,
|
||||
'type' => gettype($response),
|
||||
]);
|
||||
|
||||
// /** @var ResponseTypes\AzatApiClientInfoAllResponse */
|
||||
// $data = Str::isJson($response)
|
||||
// ? json_decode($response)
|
||||
// : emptyClass(errCode: 1, message: 'Connection issue to VP');
|
||||
|
||||
// if ($data->errCode != 0) {
|
||||
// return ActionResponse::danger($data->message);
|
||||
// }
|
||||
|
||||
// $url = $this->doFiles($model, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch from internal API
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetchApi(
|
||||
string $passport_serie,
|
||||
string $passport_id,
|
||||
string $card_number_masked,
|
||||
string $card_expire_date,
|
||||
string $start_date,
|
||||
string $end_date
|
||||
) {
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => 'http://10.3.158.102:9999/api/clientinfo/all',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => sprintf('{ "idSeria": "%s", "idNo": "%s", "clientType": "recipient", "cardMaskNumber": "%s", "expDate": "%s", "fromDate" : "%s", "toDate" : "%s" }', $passport_serie, $passport_id, $card_number_masked, $card_expire_date, $start_date, $end_date),
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Authorization: Basic dGJ1c2VyOlFBWndzeDEyMw==',
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
2
lang/vendor/filament-actions/tk/modal.php
vendored
2
lang/vendor/filament-actions/tk/modal.php
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
return [
|
||||
|
||||
'confirmation' => 'Muny etmek isleýärsiňizmi?',
|
||||
'confirmation' => 'Dowam etmek üçin Tassykla düwmesine basyň',
|
||||
|
||||
'actions' => [
|
||||
|
||||
|
||||
Reference in New Issue
Block a user