Restaurant (and other packages) now show Rush, Reservation, VIP table, etc. instead of clinic terms like Emergency and Elderly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,6 +55,19 @@ class IndustryPackage
|
||||
return (array) ($this->definition['terminology'] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Priority keys stay global; labels are industry-specific.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function priorities(): array
|
||||
{
|
||||
$fromPackage = (array) ($this->definition['priorities'] ?? []);
|
||||
$fromIndustry = (array) config("qms.ticket_priorities_by_industry.{$this->key}", []);
|
||||
|
||||
return \App\Services\Qms\TicketPriorities::mergeDefaults(array_merge($fromIndustry, $fromPackage));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
|
||||
@@ -154,6 +154,7 @@ class IndustryPackageInstaller
|
||||
'skipped_reason' => $result['skipped_reason'],
|
||||
'ticket_entity' => $package->ticketEntity(),
|
||||
'terminology' => $package->terminology(),
|
||||
'priorities' => $package->priorities(),
|
||||
'announcement' => $package->announcement(),
|
||||
'display_layout' => $package->displayLayout(),
|
||||
'kpis' => $package->kpis(),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\Ticket;
|
||||
use App\Services\Qms\TicketPriorities;
|
||||
|
||||
class TicketPresenter
|
||||
{
|
||||
@@ -11,7 +12,7 @@ class TicketPresenter
|
||||
*/
|
||||
public static function toArray(Ticket $ticket, bool $includeQr = true): array
|
||||
{
|
||||
$ticket->loadMissing(['serviceQueue', 'counter', 'assignedCounter']);
|
||||
$ticket->loadMissing(['serviceQueue', 'counter', 'assignedCounter', 'organization']);
|
||||
|
||||
$serving = $ticket->counter;
|
||||
$assigned = $ticket->assignedCounter;
|
||||
@@ -22,6 +23,7 @@ class TicketPresenter
|
||||
'ticket_number' => $ticket->ticket_number,
|
||||
'status' => $ticket->status,
|
||||
'priority' => $ticket->priority,
|
||||
'priority_label' => TicketPriorities::label($ticket->organization, $ticket->priority),
|
||||
'position' => $ticket->position,
|
||||
'customer_name' => $ticket->customer_name,
|
||||
'customer_phone' => $ticket->customer_phone,
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Qms;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Services\Qms\Industry\IndustryPackageRegistry;
|
||||
|
||||
class TicketPriorities
|
||||
{
|
||||
/**
|
||||
* @return array<string, string> priority key => industry label
|
||||
*/
|
||||
public static function forOrganization(?Organization $organization): array
|
||||
{
|
||||
$stored = data_get($organization?->settings, 'industry_package.priorities');
|
||||
if (is_array($stored) && $stored !== []) {
|
||||
return self::mergeDefaults($stored);
|
||||
}
|
||||
|
||||
$key = (string) (
|
||||
data_get($organization?->settings, 'industry_package.key')
|
||||
?? data_get($organization?->settings, 'industry')
|
||||
?? 'custom'
|
||||
);
|
||||
|
||||
return self::forIndustryKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function forIndustryKey(string $key): array
|
||||
{
|
||||
$package = app(IndustryPackageRegistry::class)->get($key);
|
||||
|
||||
return $package?->priorities() ?? self::mergeDefaults(
|
||||
(array) config("qms.ticket_priorities_by_industry.{$key}", [])
|
||||
);
|
||||
}
|
||||
|
||||
public static function label(?Organization $organization, ?string $priority): string
|
||||
{
|
||||
if ($priority === null || $priority === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$map = self::forOrganization($organization);
|
||||
|
||||
return $map[$priority] ?? (string) (config("qms.ticket_priorities.{$priority}") ?? $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $overrides
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function mergeDefaults(array $overrides): array
|
||||
{
|
||||
$defaults = (array) config('qms.ticket_priorities', []);
|
||||
$merged = [];
|
||||
foreach ($defaults as $key => $label) {
|
||||
$merged[$key] = (string) ($overrides[$key] ?? $label);
|
||||
}
|
||||
|
||||
return $merged;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user