Implement toggle for read/write mode across entity pages and enhance Documents and Divers functionality
- Added a toggle for switching between read and write modes on the Articles, Documents, Journaux, Tiers, and Divers pages, allowing users to access both data retrieval and data submission endpoints. - Updated the Documents page to cover all 9 documented endpoints, including 7 for reading and 2 for writing, with appropriate error handling. - Created a new Divers page to handle three endpoints: getserialnumber, codes_list, and custom_geninv_updatestock (the latter being non-functional). - Introduced new methods in LogisticsService for handling PDF generation and stock updates, with corresponding updates in the API documentation. - Improved form field components for better visual spacing in input fields.
This commit is contained in:
117
app/Filament/Pages/Divers.php
Normal file
117
app/Filament/Pages/Divers.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Exceptions\LogisticsApiException;
|
||||
use App\Services\LogisticsService;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
|
||||
class Divers extends Page
|
||||
{
|
||||
protected static string|\BackedEnum|null $navigationIcon = Heroicon::OutlinedWrenchScrewdriver;
|
||||
|
||||
protected static ?string $navigationLabel = 'Divers';
|
||||
|
||||
protected static ?string $title = 'Divers';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected string $view = 'filament.pages.divers';
|
||||
|
||||
public string $mode = 'read';
|
||||
|
||||
// getserialnumber
|
||||
public array $serialData = [];
|
||||
|
||||
// codes_list
|
||||
public string $code = '';
|
||||
|
||||
public array $codesData = [];
|
||||
|
||||
// custom_geninv_updatestock
|
||||
public string $stkArtId = '';
|
||||
|
||||
public string $stkId = '';
|
||||
|
||||
public string $stkQty = '';
|
||||
|
||||
public string $stkToCheck = '';
|
||||
|
||||
public string $stkToCheckDetail = '';
|
||||
|
||||
public string $stkMode = '';
|
||||
|
||||
public array $updateStockResult = [];
|
||||
|
||||
public ?string $errorMessage = null;
|
||||
|
||||
public function getSerialNumber(): void
|
||||
{
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->getSerialNumber();
|
||||
|
||||
$this->serialData = is_array($response['data'] ?? null) ? $response['data'] : ['value' => $response['data'] ?? null];
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->serialData = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = "Erreur inattendue : {$e->getMessage()}";
|
||||
$this->serialData = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function searchCodes(): void
|
||||
{
|
||||
if (blank($this->code)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
$response = $service->codesList(['code' => $this->code]);
|
||||
|
||||
$this->codesData = $response['data'] ?? [];
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->codesData = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = "Erreur inattendue : {$e->getMessage()}";
|
||||
$this->codesData = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function updateStock(): void
|
||||
{
|
||||
if (blank($this->stkArtId) || blank($this->stkId) || blank($this->stkQty)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$service = app(LogisticsService::class);
|
||||
|
||||
$params = array_filter([
|
||||
'ARTID' => $this->stkArtId,
|
||||
'STKID' => $this->stkId,
|
||||
'QTY' => $this->stkQty,
|
||||
'TOCHECK' => $this->stkToCheck,
|
||||
'TOCHECKDETAIL' => $this->stkToCheckDetail,
|
||||
'MODE' => $this->stkMode,
|
||||
]);
|
||||
|
||||
$response = $service->customGeninvUpdatestock($params);
|
||||
|
||||
$this->updateStockResult = $response['data'] ?? [];
|
||||
$this->errorMessage = $response['error'] ?? null;
|
||||
} catch (LogisticsApiException $e) {
|
||||
$this->errorMessage = $e->getMessage();
|
||||
$this->updateStockResult = [];
|
||||
} catch (\Throwable $e) {
|
||||
$this->errorMessage = "Erreur inattendue : {$e->getMessage()}";
|
||||
$this->updateStockResult = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user