diff --git a/CLAUDE.md b/CLAUDE.md
index 18a5caf..31bc2b8 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project
-An ERP / work-management system (*toiminnanohjausjärjestelmä*) for a small (5–10 person) Finnish media/marketing company. Stack: Laravel 13, Livewire 4 (single-file components), TallStackUI 4 (Blade components, no prefix: ``, ``), Tailwind 4, Vite 8, Pest, Larastan. Domain code lives in modules under `app/Modules` (so far `Shared`, `Users`, `Customers`, `Catalog` (service units, services and work types, managed on the Pohjatiedot page; workflow templates of work types with ordered steps, read through `WorkflowTemplateQueries`, from which Jobs' `AddTasksFromWorkflowTemplate` makes a job's tasks, each with its own assignee and, by default, scheduled to end on its due date with the estimate booked backwards from it (`TaskPlanner::planBackwards`, not before today); hourly rates, products and the mileage rate on the Hinnasto page, read through `PriceListQueries`, never `CatalogQueries`) `Jobs` (customer jobs: numbering, members, tags, links, history, tasks with one assignee (`tasks.assignee_user_id`) and members (`task_members`, who see the task among their own but get no bookings), task checklists, task comments (`jobs::task-comments`: anyone with `jobs.update-task-status` comments, authors edit and remove their own, `jobs.remove-any-task-comment` removes anyone's), task images (`jobs::task-images`, same rules with `jobs.remove-any-task-image`; `GdTaskImageFiles` stores an upright, at most 2560 px JPEG without EXIF and a 400 px thumbnail under `task-images/` on the private `local` disk, served only through `ShowTaskImage` after `jobs.view-job`; `RemoveTask` also deletes the files), and the task calendar `jobs::calendar`: a Gantt of tasks on their assignee's row where `ScheduleTask` moves a task's planned period and assignee and `TaskPlanner`/`TaskScheduler` book its estimate into `task_bookings` for the assignee only, filling the working days in order up to the daily maximum (9 h → 7.5 h + 1.5 h) with the rest moved past the period's end; the daily maximum is `shared.daily_capacity_hours` (Shared's `DailyCapacity`, set on the company details page, 7.5 h when empty)) `TimeTracking` (hours on tasks: weekly sheet and task booking page) `Expenses` (expenses on jobs with cost, markup and billed amount; reads jobs and prices through its own `ExpenseJobs`/`ExpensePricing` ports) `Billing` (the monthly billing material (its running number `billing_exports.number` is reserved only when it is created, so discarded drafts leave no gaps, and a draft has none): a draft of invoices made of done jobs and monthly fee jobs (one line per unbilled month up to the draft's month, each such job an invoice of its own), management's billable hours, and on creation invoice lines with price snapshots, downloadable as a semicolon CSV with amounts in whole cents and the VAT rate in tenths of a percent (`billing.csv`, with consumers' identity codes for those who may see them); a monthly fee job's billed periods (its `monthly_fee` billing lines on created materials, with the months still to bill up to now through `MonthlyBillingViews`) on `billing::job-months`, linked from the job page's payment basis for `billing.manage`; reads and marks hours, expenses and jobs through its `BillingJobs`/`BillingHours`/`BillingExpenses`/`BillingPrices` ports, which call those modules' queries and the use cases `MarkJobHoursBilled`, `MarkJobExpensesBilled` and `ChangeJobStatus`) and `Sales` (quick sales of consumer products at the counter, credits and cash days; its `QuickSaleHours` port books product durations through Jobs' `ProvideQuickSaleTask` (the yearly "Pikamyynnit" job) and TimeTracking's `AddTaskHours`; receipts can be emailed (`ReceiptMailer`, queued `SendQuickSaleReceipt`, address encrypted on the sale); a sale of a product with a production process becomes a `QuickSaleOrder` with the day's pickup number (`QuickSaleOrders`: send, complete a step with its materials and hours, pay as an ordinary sale, cancel while unpaid; `sales::orders` on the quick sale page) through its `ProductionProcesses`, `ProductionQueue` and `OrderMaterials` ports) `Inventory` (stock, spec 19.1–19.3: item groups, items with an optional image (`StockItemImages` on the private disk, via Shared's `ImageResizer`) and a moving average cost kept in hundredths of a cent per unit (`StockValuation`), movements whose sum is the balance (quantities in thousandths, `StockQuantity`; purchase, use, write-off, stock count correction, reversal; never changed or deleted, users reverse their own use of the day), `inventory::task-materials` (Used material in a job's task card, with a workflow step's default materials as suggestions from Jobs' `TaskMaterialsSuggested` event) and stock counts (`InventoryCounts`, CSV); a task with stock movements is kept like one with hours (`TaskUsageWithStock` decorates Jobs' `TaskUsage`); `StockQueries`/`StockReportQueries` are read by other modules) `Machines` (spec 19.4–19.7: machines in service units that use stock, their counters, the day-by-day work list `MachineWorkList` (`machine_queue_entries`: job tasks via `machines::task-machine` in the task card, or steps of quick sale order lines; a finished task row marks the task done through its `MachineTasks` port, and Jobs' `TaskCompleted` event closes the row), maintenance items with a counter interval and/or a time interval (`MaintenancePeriod` day/week/month/year × N, `MaintenanceStatus`), maintenance records and the daily `notifications:maintenance-due` requests to the machine's responsible person, the touch-screen `machines::console` (layout `layouts.console`, no main menu; Change user logs out with `return_to`), and products' production processes `production_steps`) and `Reports` (management's reports behind `reports.view`: hours by person, unbilled hours, profitability by job and service unit, quick sales and expense reimbursements, each a `reports::` page with a period in the URL (`ReportPage` trait, `alku`/`loppu`), tables, a `` (TallStackUI's server-side `` as one image) and a CSV from `DownloadReport`; it reads the other modules only through its ports `ReportHours`, `ReportJobs`, `ReportCatalog`, `ReportPeople`, `ReportSales`, `ReportExpenses` and `ReportRevenue`, whose adapters call those modules' report queries (`TimeReportQueries`, `CustomerJobQueries::reportInfoOf`, `QuickSaleReportQueries`, `ExpenseReportQueries`, `BilledRevenueQueries`); hours are costed at the one internal hourly cost `catalog.internal_hourly_cost_cents`, set on the Hinnasto maintenance page; stock usage and stock value behind `reports.stock`, and stock used on jobs as a material cost in profitability through `ReportStock`)); `/` (route `home`) is the home page of the `Dashboard` module (`dashboard::home`: the user's open tasks on an agenda (late, today and tomorrow, this week), their open jobs, this week's hours and quick links; for admin and management also `dashboard::management`, loaded with `lazy="on-load"` behind `dashboard.management`: things to do, the month so far against the same days of the previous month through the Reports use cases, jobs by status and late work, and everyone's workload from the task calendar against the daily capacity × working days; it reads the other modules through its ports `DashboardWork`, `DashboardTime`, `DashboardAdmin` and `DashboardFigures`, Jobs' `JobOverviewQueries` among them). The layout `resources/views/layouts/app.blade.php` has the main menu and logout for signed-in users.
+An ERP / work-management system (*toiminnanohjausjärjestelmä*) for a small (5–10 person) Finnish media/marketing company. Stack: Laravel 13, Livewire 4 (single-file components), TallStackUI 4 (Blade components, no prefix: ``, ``), Tailwind 4, Vite 8, Pest, Larastan. Domain code lives in modules under `app/Modules` (so far `Shared`, `Users`, `Customers`, `Catalog` (service units, services and work types, managed on the Pohjatiedot page; workflow templates of work types with ordered steps, read through `WorkflowTemplateQueries`, from which Jobs' `AddTasksFromWorkflowTemplate` makes a job's tasks, each with its own assignee and, by default, scheduled to end on its due date with the estimate booked backwards from it (`TaskPlanner::planBackwards`, not before today); hourly rates, products and the mileage rate on the Hinnasto page, read through `PriceListQueries`, never `CatalogQueries`) `Jobs` (customer jobs: numbering, members, tags, links, history, tasks with one assignee (`tasks.assignee_user_id`) and members (`task_members`, who see the task among their own but get no bookings), task checklists, task comments (`jobs::task-comments`: anyone with `jobs.update-task-status` comments, authors edit and remove their own, `jobs.remove-any-task-comment` removes anyone's), task images (`jobs::task-images`, same rules with `jobs.remove-any-task-image`; `GdTaskImageFiles` stores an upright, at most 2560 px JPEG without EXIF and a 400 px thumbnail under `task-images/` on the private `local` disk, served only through `ShowTaskImage` after `jobs.view-job`; `RemoveTask` also deletes the files), and the task calendar `jobs::calendar`: a Gantt of tasks on their assignee's row where `ScheduleTask` moves a task's planned period and assignee and `TaskPlanner`/`TaskScheduler` book its estimate into `task_bookings` for the assignee only, filling the working days in order up to the daily maximum (9 h → 7.5 h + 1.5 h) with the rest moved past the period's end; the daily maximum is `shared.daily_capacity_hours` (Shared's `DailyCapacity`, set on the company details page, 7.5 h when empty)) `TimeTracking` (hours on tasks: weekly sheet and task booking page) `Expenses` (expenses on jobs with cost, markup and billed amount; reads jobs and prices through its own `ExpenseJobs`/`ExpensePricing` ports) `Billing` (the monthly billing material (its running number `billing_exports.number` is reserved only when it is created, so discarded drafts leave no gaps, and a draft has none): a draft of invoices made of done jobs and monthly fee jobs (one line per unbilled month up to the draft's month, each such job an invoice of its own), management's billable hours, and on creation invoice lines with price snapshots, downloadable as a semicolon CSV with amounts in whole cents and the VAT rate in tenths of a percent (`billing.csv`, with consumers' identity codes for those who may see them); a monthly fee job's billed periods (its `monthly_fee` billing lines on created materials, with the months still to bill up to now through `MonthlyBillingViews`) on `billing::job-months`, linked from the job page's payment basis for `billing.manage`; reads and marks hours, expenses and jobs through its `BillingJobs`/`BillingHours`/`BillingExpenses`/`BillingPrices` ports, which call those modules' queries and the use cases `MarkJobHoursBilled`, `MarkJobExpensesBilled` and `ChangeJobStatus`) and `Sales` (quick sales of consumer products at the counter, credits and cash days; its `QuickSaleHours` port books product durations through Jobs' `ProvideQuickSaleTask` (the yearly "Pikamyynnit" job) and TimeTracking's `AddTaskHours`; receipts can be emailed (`ReceiptMailer`, queued `SendQuickSaleReceipt`, address encrypted on the sale); a sale of a product with a production process becomes a `QuickSaleOrder` with the day's pickup number (`QuickSaleOrders`: send, complete a step with its materials and hours, pay as an ordinary sale, cancel while unpaid; `sales::orders` on the quick sale page) through its `ProductionProcesses`, `ProductionQueue` and `OrderMaterials` ports) `Inventory` (stock, spec 19.1–19.3: item groups, items with an optional image (`StockItemImages` on the private disk, via Shared's `ImageResizer`) and a moving average cost kept in hundredths of a cent per unit (`StockValuation`), movements whose sum is the balance (quantities in thousandths, `StockQuantity`; purchase, use, write-off, stock count correction, reversal; never changed or deleted, users reverse their own use of the day), `inventory::task-materials` (Used material in a job's task card, with a workflow step's default materials as suggestions from Jobs' `TaskMaterialsSuggested` event) and stock counts (`InventoryCounts`, CSV); a task with stock movements is kept like one with hours (`TaskUsageWithStock` decorates Jobs' `TaskUsage`); `StockQueries`/`StockReportQueries` are read by other modules) `Machines` (spec 19.4–19.7: machines in service units that use stock, their cumulative counters (users record a job's usage, `MachineMaintenance::recordUsage` adds it to the latest reading; the console suggests booked hours for `hour` counters), the day-by-day work list `MachineWorkList` (`machine_queue_entries`: job tasks via `machines::task-machine` in the task card, or steps of quick sale order lines; a finished task row marks the task done through its `MachineTasks` port, and Jobs' `TaskCompleted` event closes the row), maintenance items with a counter interval and/or a time interval (`MaintenancePeriod` day/week/month/year × N, `MaintenanceStatus`; a maintenance record resets the item: the counter interval counts down from the whole interval from the reading at the record, and the time interval restarts on the maintenance day), maintenance records and the daily `notifications:maintenance-due` requests to the machine's responsible person, the touch-screen `machines::console` at `/console/machines/{id}` (layout `layouts.console`, no main menu). The console has its own session: Users' `UseConsoleSession` (prepended to `web`) gives paths under `console/`, and Livewire requests whose snapshot `memo.path` is there, their own session cookie (`…_console`) and the `console` guard (`Auth::shouldUse`), so `auth()`, Gate and `can:` work unchanged; pages the console needs must live under `console/` (e.g. `inventory.items.console-image`). Links open it in a new window through `console.handoff` (a one-time cache key, 60 s); a signed-out console goes to `console.login` (`users::console-login`, PIN or password), `console.logout` signs out of the console only, and `/login` always signs in to the normal interface. Change user is `users::pin-switch` with the user's own console PIN code (`users.pin_hash`, set on `users::pin` at `/profile/pin`, `LoginPins`; traits `SignsInWithPin`, `SignsInWithPassword`). In tests, act on the console with `actingAs($user, 'console')`), and products' production processes `production_steps`) and `Reports` (management's reports behind `reports.view`: hours by person, unbilled hours, profitability by job and service unit, quick sales and expense reimbursements, each a `reports::` page with a period in the URL (`ReportPage` trait, `alku`/`loppu`), tables, a `` (TallStackUI's server-side `` as one image) and a CSV from `DownloadReport`; it reads the other modules only through its ports `ReportHours`, `ReportJobs`, `ReportCatalog`, `ReportPeople`, `ReportSales`, `ReportExpenses` and `ReportRevenue`, whose adapters call those modules' report queries (`TimeReportQueries`, `CustomerJobQueries::reportInfoOf`, `QuickSaleReportQueries`, `ExpenseReportQueries`, `BilledRevenueQueries`); hours are costed at the one internal hourly cost `catalog.internal_hourly_cost_cents`, set on the Hinnasto maintenance page; stock usage and stock value behind `reports.stock`, and stock used on jobs as a material cost in profitability through `ReportStock`)); `/` (route `home`) is the home page of the `Dashboard` module (`dashboard::home`: the user's open tasks on an agenda (late, today and tomorrow, this week), their open jobs, this week's hours and quick links; for admin and management also `dashboard::management`, loaded with `lazy="on-load"` behind `dashboard.management`: things to do, the month so far against the same days of the previous month through the Reports use cases, jobs by status and late work, and everyone's workload from the task calendar against the daily capacity × working days; it reads the other modules through its ports `DashboardWork`, `DashboardTime`, `DashboardAdmin` and `DashboardFigures`, Jobs' `JobOverviewQueries` among them). The layout `resources/views/layouts/app.blade.php` has the main menu and logout for signed-in users.
- **The specification is `docs/maarittely.md`** (Finnish). It defines roles and the permission table, money visibility, customers, customer jobs (*asiakastyö*) with fields and enum keys, Kanban, tasks, time entries, expenses, the service unit → service → work type hierarchy and pricing, Fennoa billing export, the data model, the phases with phase 1 in detail, and open questions. Read it before designing any domain feature. `määrittely.txt` is the original description with the customer's answers to questions 1–53, referenced as *(K12)* in the spec.
- **Language rule:** code (identifiers, tables, columns, enum keys) is in English; the specification is in Finnish. The UI is in Finnish (default) and English: every UI string lives in `lang/fi/*.php` **and** `lang/en/*.php` with the same keys and placeholders (`tests/Unit/TranslationFilesTest.php` fails otherwise). Number, money and date formats stay Finnish in both languages; the quick sale receipt is always Finnish.
diff --git a/app/Models/User.php b/app/Models/User.php
index 1cc5651..3f5b98d 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -33,7 +33,7 @@ use Illuminate\Support\Carbon;
* @property-read UserMoneyPermissionsModel|null $moneyPermissions
*/
#[Fillable(['name', 'email', 'password', 'role', 'is_active', 'employment_ends_on', 'supervisor_id', 'locale'])]
-#[Hidden(['password', 'remember_token'])]
+#[Hidden(['password', 'remember_token', 'pin_hash'])]
class User extends Authenticatable implements HasLocalePreference
{
/** @use HasFactory */
diff --git a/app/Modules/Inventory/Presentation/Routes/web.php b/app/Modules/Inventory/Presentation/Routes/web.php
index 7926ccf..2a96138 100644
--- a/app/Modules/Inventory/Presentation/Routes/web.php
+++ b/app/Modules/Inventory/Presentation/Routes/web.php
@@ -4,6 +4,13 @@ use App\Modules\Inventory\Presentation\Http\Controllers\DownloadInventoryCount;
use App\Modules\Inventory\Presentation\Http\Controllers\ShowStockItemImage;
use Illuminate\Support\Facades\Route;
+// Pictures on the machine console, which has its own session (paths under console/).
+Route::middleware(['web', 'auth', 'can:inventory.view'])
+ ->get('/console/inventory/items/{item}/image/{size}', ShowStockItemImage::class)
+ ->whereNumber('item')
+ ->whereIn('size', ['full', 'thumbnail'])
+ ->name('inventory.items.console-image');
+
Route::middleware(['web', 'auth', 'can:inventory.view'])
->prefix('inventory')
->name('inventory.')
diff --git a/app/Modules/Machines/Application/UseCases/MachineMaintenance.php b/app/Modules/Machines/Application/UseCases/MachineMaintenance.php
index 86098dc..0a76b87 100644
--- a/app/Modules/Machines/Application/UseCases/MachineMaintenance.php
+++ b/app/Modules/Machines/Application/UseCases/MachineMaintenance.php
@@ -24,7 +24,7 @@ use App\Modules\Users\Application\Contracts\Clock;
/**
* Machine maintenance (spec 19.5): maintenance items are kept by
- * management; counter readings and maintenance done are recorded by
+ * management; counter usage and maintenance done are recorded by
* anyone using the machine. A maintenance record starts the item's
* intervals again and uses up its stock item; a mistaken record is
* cancelled by management, never deleted.
@@ -98,50 +98,52 @@ final class MachineMaintenance
}
/**
- * Records a counter's reading, e.g. the machine's own total counter.
+ * Records how much of a counter one job used (spec 19.5): counters are
+ * cumulative, so the usage is added to the counter's latest reading.
+ *
+ * @return int The counter's new reading.
*
* @throws CounterNotFound
* @throws InvalidReading
*/
- public function recordReading(int $counterId, string $reading, int $actorUserId): int
+ public function recordUsage(int $counterId, string $usage, int $actorUserId): int
{
- $milli = Reading::parse($reading) ?? throw new InvalidReading;
+ $usageMilli = Reading::parse($usage);
- $this->transactions->run(function () use ($counterId, $milli, $actorUserId): void {
+ if ($usageMilli === null || $usageMilli <= 0) {
+ throw new InvalidReading;
+ }
+
+ return $this->transactions->run(function () use ($counterId, $usageMilli, $actorUserId): int {
$this->maintenance->machineOfCounter($counterId) ?? throw new CounterNotFound;
- $this->maintenance->addReading($counterId, $milli, $actorUserId, $this->clock->now());
- });
+ $reading = ($this->maintenance->latestReading($counterId) ?? 0) + $usageMilli;
+ $this->maintenance->addReading($counterId, $reading, $actorUserId, $this->clock->now());
- return $milli;
+ return $reading;
+ });
}
/**
- * Records maintenance done (Huolto tehty) with the counter's reading
- * (the latest one when not given) and uses up the item's stock item.
+ * Records maintenance done (Huolto tehty) at the counter's latest
+ * reading and uses up the item's stock item. This resets the item: the
+ * whole counter interval is left again, counted from this reading, and
+ * the time interval starts again from today.
*
* @return array{recordId: int, stockRecorded: bool}
*
* @throws MaintenanceItemNotFound
- * @throws InvalidReading
*/
- public function recordMaintenance(int $itemId, int $actorUserId, string $reading = '', ?string $note = null): array
+ public function recordMaintenance(int $itemId, int $actorUserId, ?string $note = null): array
{
- $readingMilli = Reading::parse($reading);
$note = $note === null ? '' : trim($note);
- return $this->transactions->run(function () use ($itemId, $actorUserId, $readingMilli, $note): array {
+ return $this->transactions->run(function () use ($itemId, $actorUserId, $note): array {
$item = $this->maintenance->findItem($itemId) ?? throw new MaintenanceItemNotFound;
- $now = $this->clock->now();
+ $readingMilli = $item->counterId() === null
+ ? null
+ : ($this->maintenance->latestReading($item->counterId()) ?? $item->baselineMilli());
- if ($item->counterId() !== null) {
- if ($readingMilli !== null) {
- $this->maintenance->addReading($item->counterId(), $readingMilli, $actorUserId, $now);
- } else {
- $readingMilli = $this->maintenance->latestReading($item->counterId()) ?? $item->baselineMilli();
- }
- }
-
- $recordId = $this->maintenance->addRecord($itemId, $now, $actorUserId, $item->counterId() === null ? null : $readingMilli, $note === '' ? null : mb_substr($note, 0, 2000));
+ $recordId = $this->maintenance->addRecord($itemId, $this->clock->now(), $actorUserId, $readingMilli, $note === '' ? null : mb_substr($note, 0, 2000));
$stockRecorded = $item->stockItemId() === null
|| $this->materials->use($item->stockItemId(), (int) $item->stockQuantityMilli(), $item->machineId(), $recordId, $actorUserId);
diff --git a/app/Modules/Machines/Domain/Services/MaintenanceStatus.php b/app/Modules/Machines/Domain/Services/MaintenanceStatus.php
index e4b76bf..024e5a5 100644
--- a/app/Modules/Machines/Domain/Services/MaintenanceStatus.php
+++ b/app/Modules/Machines/Domain/Services/MaintenanceStatus.php
@@ -12,7 +12,8 @@ use DateTimeImmutable;
/**
* Works out a maintenance item's state from what has accumulated since its
* last maintenance (spec 19.5). The counter interval counts the counter's
- * latest reading minus its reading at the last maintenance; the time
+ * latest reading minus its reading at the last maintenance, so a
+ * maintenance starts the whole interval again; the time
* interval counts calendar periods from the day of the last maintenance.
* With both, maintenance is due when either is. The advance warning
* applies to both, but not to daily maintenance.
diff --git a/app/Modules/Machines/Presentation/Livewire/Concerns/DescribesMaintenance.php b/app/Modules/Machines/Presentation/Livewire/Concerns/DescribesMaintenance.php
index 63fc52d..04e9161 100644
--- a/app/Modules/Machines/Presentation/Livewire/Concerns/DescribesMaintenance.php
+++ b/app/Modules/Machines/Presentation/Livewire/Concerns/DescribesMaintenance.php
@@ -2,7 +2,9 @@
namespace App\Modules\Machines\Presentation\Livewire\Concerns;
+use App\Modules\Machines\Application\DTOs\CounterSummary;
use App\Modules\Machines\Application\DTOs\MaintenanceItemStatus;
+use App\Modules\Machines\Domain\ValueObjects\Reading;
/**
* Texts of a maintenance item's state, shared by the machine page and the
@@ -68,4 +70,17 @@ trait DescribesMaintenance
return implode(__('machines.maintenance.or'), $parts);
}
+
+ /**
+ * E.g. "Laskuriin Tulosteet lisätty 350 kpl, laskuri nyt 20 350 kpl."
+ */
+ public function usageSaved(CounterSummary $counter, string $usage, int $readingMilli): string
+ {
+ return __('machines.maintenance.usage_saved', [
+ 'counter' => $counter->name,
+ 'usage' => $this->reading((int) Reading::parse($usage)),
+ 'reading' => $this->reading($readingMilli),
+ 'unit' => __('machines.counter_units.'.$counter->unit->value),
+ ]);
+ }
}
diff --git a/app/Modules/Machines/Presentation/Livewire/⚡console.blade.php b/app/Modules/Machines/Presentation/Livewire/⚡console.blade.php
index 1a6af6b..d1c5162 100644
--- a/app/Modules/Machines/Presentation/Livewire/⚡console.blade.php
+++ b/app/Modules/Machines/Presentation/Livewire/⚡console.blade.php
@@ -17,6 +17,8 @@ use App\Modules\Machines\Application\DTOs\MaintenanceItemStatus;
use App\Modules\Machines\Application\DTOs\QueueRow;
use App\Modules\Machines\Application\UseCases\MachineMaintenance;
use App\Modules\Machines\Application\UseCases\MachineWorkList;
+use App\Modules\Machines\Domain\Enums\CounterUnit;
+use App\Modules\Machines\Domain\ValueObjects\Reading;
use App\Modules\Machines\Presentation\Livewire\Concerns\DescribesMaintenance;
use App\Modules\Sales\Application\Contracts\QuickSaleOrderQueries;
use App\Modules\Sales\Application\DTOs\OrderLineSummary;
@@ -36,8 +38,9 @@ use Livewire\Component;
* for the tablet or touch screen next to a machine. It shows today's work
* list (late rows of earlier days included; the next day can be viewed),
* lets the user start and finish tasks, record the material used with
- * large item buttons, frequent items first, record today's hours, counter
- * readings and maintenance. Touch targets are at least 44 × 44 px. The
+ * large item buttons, frequent items first, record today's hours (which
+ * are suggested as the usage of the machine's hour counters), counter
+ * usage and maintenance. Touch targets are at least 44 × 44 px. The
* view refreshes itself, and the Refresh button fetches the latest state
* at once and tells what changed.
*/
@@ -85,15 +88,15 @@ new #[Layout('layouts.console')] class extends Component
public string $hours = '';
/**
+ * Usage typed, by counter id.
+ *
* @var array
*/
- public array $readings = [];
+ public array $usage = [];
#[Locked]
public ?int $recordingItemId = null;
- public string $recordReading = '';
-
#[Locked]
public string $message = '';
@@ -487,35 +490,55 @@ new #[Layout('layouts.console')] class extends Component
}
$this->message = __('machines.console.hours_saved', ['hours' => $this->hours, 'title' => $task->title, 'total' => $total]);
+ $this->suggestHourCounters($this->hours);
$this->hours = '';
}
- public function saveReading(int $counterId, MachineMaintenance $maintenance): void
+ /**
+ * Hours just booked on the machine are suggested as the usage of its
+ * hour counters; nothing is recorded until the user saves the counter.
+ */
+ private function suggestHourCounters(string $hours): void
+ {
+ $milli = Reading::parse($hours);
+
+ if ($milli === null || $milli <= 0) {
+ return;
+ }
+
+ foreach ($this->machine->counters as $counter) {
+ if ($counter->unit === CounterUnit::Hour) {
+ $this->usage[$counter->id] = str_replace("\u{00A0}", '', $this->reading($milli));
+ $this->message .= ' '.__('machines.console.hour_suggestion', ['hours' => $this->reading($milli), 'counter' => $counter->name]);
+ }
+ }
+ }
+
+ public function saveUsage(int $counterId, MachineMaintenance $maintenance): void
{
$this->authorize('machines.use');
- $this->resetErrorBag('readings.'.$counterId);
+ $this->resetErrorBag('usage.'.$counterId);
$counter = collect($this->machine->counters)->firstWhere('id', $counterId) ?? abort(404);
+ $usage = $this->usage[$counterId] ?? '';
try {
- $milli = $maintenance->recordReading($counterId, $this->readings[$counterId] ?? '', (int) auth()->id());
+ $milli = $maintenance->recordUsage($counterId, $usage, (int) auth()->id());
} catch (DomainException) {
- $this->addError('readings.'.$counterId, __('machines.maintenance.errors.reading'));
+ $this->addError('usage.'.$counterId, __('machines.maintenance.errors.usage'));
return;
}
- $this->message = __('machines.maintenance.reading_saved', ['counter' => $counter->name, 'reading' => $this->reading($milli), 'unit' => __('machines.counter_units.'.$counter->unit->value)]);
- unset($this->readings[$counterId], $this->machine, $this->maintenance);
+ $this->message = $this->usageSaved($counter, $usage, $milli);
+ unset($this->usage[$counterId], $this->machine, $this->maintenance);
}
public function startMaintenance(int $itemId): void
{
$this->authorize('machines.use');
- $item = collect($this->maintenance)->firstWhere('id', $itemId) ?? abort(404);
- $this->recordingItemId = $itemId;
- $this->recordReading = $item->readingMilli === null ? '' : str_replace("\u{00A0}", '', $this->reading($item->readingMilli));
+ $this->recordingItemId = (collect($this->maintenance)->firstWhere('id', $itemId) ?? abort(404))->id;
$this->js("setTimeout(() => document.getElementById('maintenance-confirm')?.focus())");
}
@@ -526,11 +549,9 @@ new #[Layout('layouts.console')] class extends Component
$item = collect($this->maintenance)->firstWhere('id', $this->recordingItemId) ?? abort(404);
try {
- $result = $maintenance->recordMaintenance($item->id, (int) auth()->id(), $item->counterId === null ? '' : $this->recordReading);
+ $result = $maintenance->recordMaintenance($item->id, (int) auth()->id());
} catch (DomainException) {
- $this->addError('recordReading', __('machines.maintenance.errors.reading'));
-
- return;
+ abort(404);
}
$this->message = __('machines.maintenance.recorded', ['name' => $item->name]).($result['stockRecorded'] ? '' : ' '.__('machines.maintenance.stock_not_recorded'));
@@ -612,14 +633,8 @@ new #[Layout('layouts.console')] class extends Component
{{ __('machines.console.refresh') }}
-
+
+ {{-- The normal user interface has a session of its own (Users' UseConsoleSession). --}}
{{ __('machines.console.back') }}
@@ -811,7 +826,7 @@ new #[Layout('layouts.console')] class extends Component
aria-label="{{ __('inventory.task.choose', ['item' => $item->name, 'balance' => $this->quantity($item->balanceMilli, $item->unit)]) }}"
>
@if ($item->hasImage)
-
+
@endif
{{ $item->name }}{{ $this->quantity($item->balanceMilli, $item->unit) }}
@@ -847,23 +862,24 @@ new #[Layout('layouts.console')] class extends Component
@endcan
+ @if ($machine->counters !== [] || $this->maintenance !== [])
@if ($recordingItemId === $item->id)
@else
@@ -895,4 +906,5 @@ new #[Layout('layouts.console')] class extends Component
@endforeach
+ @endif
diff --git a/app/Modules/Machines/Presentation/Livewire/⚡index.blade.php b/app/Modules/Machines/Presentation/Livewire/⚡index.blade.php
index 2b1d510..db5563c 100644
--- a/app/Modules/Machines/Presentation/Livewire/⚡index.blade.php
+++ b/app/Modules/Machines/Presentation/Livewire/⚡index.blade.php
@@ -128,7 +128,7 @@ new class extends Component
@endunless
- {{ __('machines.index.console_named', ['name' => $machine->name]) }}
+ {{ __('machines.index.console_named', ['name' => $machine->name]) }} ({{ __('layout.opens_in_new_window') }})
@endforeach
diff --git a/app/Modules/Machines/Presentation/Livewire/⚡maintenance.blade.php b/app/Modules/Machines/Presentation/Livewire/⚡maintenance.blade.php
index be823f7..e2d83ea 100644
--- a/app/Modules/Machines/Presentation/Livewire/⚡maintenance.blade.php
+++ b/app/Modules/Machines/Presentation/Livewire/⚡maintenance.blade.php
@@ -19,9 +19,11 @@ use Livewire\Component;
/**
* A machine's counters, maintenance items and maintenance history on its
- * page (spec 19.5). Anyone using the machine records counter readings and
- * maintenance done (the reading prefilled); management keeps the items
- * and cancels mistaken records. The history is filtered by item and days.
+ * page (spec 19.5). Anyone using the machine records how much of a
+ * counter a job used (counters are cumulative) and maintenance done;
+ * management keeps the items and cancels mistaken records. The history is
+ * filtered by item and days. Without counters and maintenance items the
+ * sections are left out, except the add button for management.
*/
new class extends Component
{
@@ -31,17 +33,15 @@ new class extends Component
public int $machineId;
/**
- * Readings typed, by counter id.
+ * Usage typed, by counter id.
*
* @var array
*/
- public array $readings = [];
+ public array $usage = [];
#[Locked]
public ?int $recordingItemId = null;
- public string $recordReading = '';
-
public string $recordNote = '';
public string $historyItem = '';
@@ -100,37 +100,36 @@ new class extends Component
}
}
- public function saveReading(int $counterId, MachineMaintenance $maintenance): void
+ public function saveUsage(int $counterId, MachineMaintenance $maintenance): void
{
$this->authorize('machines.use');
- $this->resetErrorBag('readings.'.$counterId);
+ $this->resetErrorBag('usage.'.$counterId);
$counter = collect($this->machine->counters)->firstWhere('id', $counterId) ?? abort(404);
+ $usage = $this->usage[$counterId] ?? '';
try {
- $milli = $maintenance->recordReading($counterId, $this->readings[$counterId] ?? '', (int) auth()->id());
+ $milli = $maintenance->recordUsage($counterId, $usage, (int) auth()->id());
} catch (InvalidReading) {
- $this->addError('readings.'.$counterId, __('machines.maintenance.errors.reading'));
+ $this->addError('usage.'.$counterId, __('machines.maintenance.errors.usage'));
return;
} catch (CounterNotFound) {
abort(404);
}
- $this->message = __('machines.maintenance.reading_saved', ['counter' => $counter->name, 'reading' => $this->reading($milli), 'unit' => __('machines.counter_units.'.$counter->unit->value)]);
- unset($this->readings[$counterId], $this->machine, $this->items);
+ $this->message = $this->usageSaved($counter, $usage, $milli);
+ unset($this->usage[$counterId], $this->machine, $this->items);
}
public function startRecord(int $itemId): void
{
$this->authorize('machines.use');
- $item = $this->item($itemId);
- $this->recordingItemId = $itemId;
- $this->recordReading = $item->readingMilli === null ? '' : str_replace("\u{00A0}", '', $this->reading($item->readingMilli));
+ $this->recordingItemId = $this->item($itemId)->id;
$this->recordNote = '';
$this->resetErrorBag();
- $this->js("setTimeout(() => document.getElementById('record-reading')?.focus() ?? document.getElementById('record-note')?.focus())");
+ $this->js("setTimeout(() => document.getElementById('record-note')?.focus())");
}
public function cancelRecording(): void
@@ -147,11 +146,7 @@ new class extends Component
$item = $this->item((int) $this->recordingItemId);
try {
- $result = $maintenance->recordMaintenance($item->id, (int) auth()->id(), $item->counterId === null ? '' : $this->recordReading, $this->recordNote);
- } catch (InvalidReading) {
- $this->addError('recordReading', __('machines.maintenance.errors.reading'));
-
- return;
+ $result = $maintenance->recordMaintenance($item->id, (int) auth()->id(), $this->recordNote);
} catch (MaintenanceItemNotFound) {
abort(404);
}
@@ -231,17 +226,17 @@ new class extends Component
@endif
-
@endforeach
@@ -249,6 +244,9 @@ new class extends Component
@endif
+ @php($hasMaintenance = $this->machine->counters !== [] || $this->items !== [])
+
+ @if ($hasMaintenance || auth()->user()?->can('machines.manage'))
{{ __('machines.maintenance.items') }}
@can('machines.manage')
@@ -292,11 +290,6 @@ new class extends Component
@if ($item->isActive)
@if ($recordingItemId === $item->id)
+ @endif
+ @if ($hasMaintenance)
{{ __('machines.maintenance.history') }}
@@ -358,6 +353,7 @@ new class extends Component
@endif
+ @endif
@can('machines.manage')
diff --git a/app/Modules/Machines/Presentation/Livewire/⚡show.blade.php b/app/Modules/Machines/Presentation/Livewire/⚡show.blade.php
index 8ceb00f..1be90d1 100644
--- a/app/Modules/Machines/Presentation/Livewire/⚡show.blade.php
+++ b/app/Modules/Machines/Presentation/Livewire/⚡show.blade.php
@@ -258,7 +258,8 @@ new class extends Component
{{ $machine->description }}
@endif
-
+ {{-- The console opens in its own window with its own session, signed in as the same user. --}}
+
@can('machines.manage')
@endcan
diff --git a/app/Modules/Machines/Presentation/Routes/web.php b/app/Modules/Machines/Presentation/Routes/web.php
index 2aecc7c..1e5f918 100644
--- a/app/Modules/Machines/Presentation/Routes/web.php
+++ b/app/Modules/Machines/Presentation/Routes/web.php
@@ -16,5 +16,10 @@ Route::middleware(['web', 'auth', 'can:machines.use'])
});
Route::livewire('/{machine}', 'machines::show')->whereNumber('machine')->name('show');
- Route::livewire('/{machine}/console', 'machines::console')->whereNumber('machine')->name('console');
});
+
+// The console has its own session (Users' UseConsoleSession: paths under console/).
+Route::livewire('/console/machines/{machine}', 'machines::console')
+ ->middleware(['web', 'auth', 'can:machines.use'])
+ ->whereNumber('machine')
+ ->name('machines.console');
diff --git a/app/Modules/Sales/Presentation/Livewire/⚡orders.blade.php b/app/Modules/Sales/Presentation/Livewire/⚡orders.blade.php
index fefd959..8a3e403 100644
--- a/app/Modules/Sales/Presentation/Livewire/⚡orders.blade.php
+++ b/app/Modules/Sales/Presentation/Livewire/⚡orders.blade.php
@@ -385,7 +385,7 @@ new class extends Component
diff --git a/app/Modules/Users/Presentation/Routes/web.php b/app/Modules/Users/Presentation/Routes/web.php
index ddce5f5..ad945f5 100644
--- a/app/Modules/Users/Presentation/Routes/web.php
+++ b/app/Modules/Users/Presentation/Routes/web.php
@@ -1,5 +1,7 @@
group(function () {
Route::livewire('/reset-password/{token}', 'users::reset-password')->name('password.reset');
});
+// The machine console's own session (UseConsoleSession: paths under console/).
+Route::middleware('web')->prefix('console')->name('console.')->group(function () {
+ Route::livewire('/login', 'users::console-login')->middleware('guest')->name('login');
+ Route::get('/handoff/{token}', [ConsoleHandoff::class, 'accept'])->middleware('throttle:30,1')->name('handoff.accept');
+ Route::post('/logout', ConsoleLogoutController::class)->middleware('auth')->name('logout');
+});
+
Route::middleware(['web', 'auth'])->group(function () {
Route::post('/logout', LogoutController::class)->name('logout');
+ Route::livewire('/profile/pin', 'users::pin')->middleware('can:machines.use')->name('profile.pin');
+ Route::get('/console-handoff', [ConsoleHandoff::class, 'start'])->middleware('throttle:30,1')->name('console.handoff');
Route::middleware('can:users.manage')
->prefix('users')
diff --git a/bootstrap/app.php b/bootstrap/app.php
index 1eb0fd8..c30641e 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -1,5 +1,6 @@
withMiddleware(function (Middleware $middleware): void {
- $middleware->redirectGuestsTo(fn () => route('login'));
- $middleware->redirectUsersTo(fn () => route('home'));
+ // The machine console has its own session and sign-in page.
+ $middleware->redirectGuestsTo(fn (Request $request) => UseConsoleSession::isConsole($request) ? route('console.login') : route('login'));
+ $middleware->redirectUsersTo(fn (Request $request) => UseConsoleSession::isConsole($request) ? route('machines.index') : route('home'));
})
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen(
diff --git a/config/auth.php b/config/auth.php
index 4c216ed..02328e6 100644
--- a/config/auth.php
+++ b/config/auth.php
@@ -42,6 +42,13 @@ return [
'driver' => 'session',
'provider' => 'users',
],
+
+ // The machine console's own session (spec 19.6): signing in or out
+ // there leaves the normal user interface's session alone.
+ 'console' => [
+ 'driver' => 'session',
+ 'provider' => 'users',
+ ],
],
/*
diff --git a/database/migrations/2026_11_29_071643_add_pin_hash_to_users_table.php b/database/migrations/2026_11_29_071643_add_pin_hash_to_users_table.php
new file mode 100644
index 0000000..f94409a
--- /dev/null
+++ b/database/migrations/2026_11_29_071643_add_pin_hash_to_users_table.php
@@ -0,0 +1,26 @@
+string('pin_hash')->nullable()->after('password');
+ });
+ }
+
+ public function down(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('pin_hash');
+ });
+ }
+};
diff --git a/docs/maarittely.md b/docs/maarittely.md
index 1713d80..94becbd 100644
--- a/docs/maarittely.md
+++ b/docs/maarittely.md
@@ -599,18 +599,20 @@ Päätetty: hankintahinta liukuvana keskihintana, negatiivinen saldo sallitaan v
### 19.5 Huoltokohteet ja huoltohistoria *(valmis)*
-- Koneella on **laskureita**, joilla huollon tarve mitataan, esim. tulosteet (kpl), arkit, tulostettu pinta-ala (m²), musteen kulutus (ml), leikattu matka (m) tai käyttötunnit. Konetyypin mukaan uudelle koneelle ehdotetaan tavalliset laskurit: painokoneelle tulosteet ja m², tarraleikkurille leikattu matka. Laskurin lukema kirjataan käsin konekäyttöliittymästä tai koneen sivulta (esim. koneen oma kokonaislaskuri); laskuri ei kasva kirjatuista töistä.
+- Koneella on **laskureita**, joilla huollon tarve mitataan, esim. tulosteet (kpl), arkit, tulostettu pinta-ala (m²), musteen kulutus (ml), leikattu matka (m) tai käyttötunnit. Konetyypin mukaan uudelle koneelle ehdotetaan tavalliset laskurit: painokoneelle tulosteet ja m², tarraleikkurille leikattu matka. Laskurit ovat kumulatiivisia: käyttäjä kirjaa konekäyttöliittymästä tai koneen sivulta arvion siitä, paljonko yksi työ kulutti (esim. 350 tulostetta), ja kulutus lisätään laskurin lukemaan, joka näytetään vihjeenä. Laskuri ei kasva kirjatuista töistä itsestään; tuntiperusteiselle laskurille (yksikkö h) konekäyttöliittymä kuitenkin ehdottaa kulutukseksi juuri kirjatut tunnit, ja ehdotus tallentuu vasta käyttäjän vahvistuksella.
- **Huoltokohde**: kone, nimi (painokoneella esim. jätemustesäiliön tai värijauhetankin tyhjennys, tulostuspään puhdistus, pyyhkimen vaihto; tarraleikkurilla esim. terän vaihto, leikkuualustan tai -nauhan vaihto, puhdistus), huoltoväli: **laskuriväli** (laskuri ja määrä, esim. 20 000 tulostetta), **aikaväli** (päivähuolto, viikkohuolto, kuukausihuolto tai vuosihuolto, joka N. jakso, esim. joka 2. viikko) tai molemmat, jolloin huolto erääntyy kumman tahansa täyttyessä ensin; aikavälin käyttö ei ole pakollista, ja koneella voi olla useita eri välein huollettavia kohteita yhtä aikaa (esim. päivittäinen puhdistus, viikoittainen tarkistus ja vuosihuolto), ennakkovaroitus (päivähuollolla ei ennakkovaroitusta) (esim. 90 % välistä) ja vapaaehtoinen ohje. Huoltokohteelle voi liittää varastonimikkeen (esim. vaihtorumpu), joka kirjataan käytetyksi huollon yhteydessä.
-- Erääntynyt huolto on **huoltopyyntö**: se näkyy tilassa *Huolto myöhässä* ja ilmoitetaan, ja se kuittautuu huoltokirjauksella. Aikaväli lasketaan kalenterijaksoina viimeisen huollon päivästä (kuukauden loppu rajataan, esim. 31.1. → 28.2.).
+- Erääntynyt huolto on **huoltopyyntö**: se näkyy tilassa *Huolto myöhässä* ja ilmoitetaan, ja se kuittautuu huoltokirjauksella. Aikaväli lasketaan kalenterijaksoina viimeisen huollon päivästä (kuukauden loppu rajataan, esim. 31.1. → 28.2.). Laskuriväli lasketaan huoltohetken lukemasta: jäljellä oleva määrä laskee huoltovälistä nollaan, ja huolto aloittaa koko huoltovälin alusta (väli 20 000, huolto lukemassa 19 500 → jäljellä taas 20 000).
- Huoltokohteen tila lasketaan viimeisestä huollosta kertyneestä määrästä: *Kunnossa*, *Huolto lähestyy* tai *Huolto myöhässä*; tila näytetään aina tekstinä ja kuvakkeena sekä jäljellä olevana määränä (esim. "jäljellä 1 200 tulostetta").
- Huollon tekee ja kuittaa koneen käyttäjä (kuka tahansa konekäyttöliittymää käyttävä, 19.9); erillistä huolto-oikeutta ei ole.
-- **Huoltokirjaus**: huoltokohde, aika, tekijä, laskurin lukema huoltohetkellä, vapaaehtoinen huomautus ja käytetyt varaosat/materiaalit varastosta. Kirjaus nollaa kohteen kertymän. Kirjauksia ei poisteta; virheellisen kirjauksen johto merkitsee perutuksi.
-- Koneen sivulla on huoltokohteet tiloineen ja huoltohistoria (suodatus huoltokohteella ja aikavälillä).
+- **Huoltokirjaus**: huoltokohde, aika, tekijä, laskurin lukema huoltohetkellä (viimeisin lukema), vapaaehtoinen huomautus ja käytetyt varaosat/materiaalit varastosta. Kirjaus nollaa kohteen: jäljellä on taas koko laskuriväli, ja aikaväli alkaa huoltopäivästä. Kirjauksia ei poisteta; virheellisen kirjauksen johto merkitsee perutuksi.
+- Koneen sivulla on huoltokohteet tiloineen ja huoltohistoria (suodatus huoltokohteella ja aikavälillä). Jos koneella ei ole laskureita eikä huoltokohteita, osiot jätetään pois (johto näkee silti Uusi huoltokohde -painikkeen).
- Lähestyvät ja myöhässä olevat huollot näytetään konekäyttöliittymässä, johdon etusivun *Vaatii toimia* -osassa ja ilmoituksina (luku 13) koneen vastuuhenkilölle; samasta huoltotarpeesta ei ilmoiteta kahdesti.
### 19.6 Konekäyttöliittymä (kosketusnäyttö) *(valmis)*
-- Jokaisella koneella on oma koko näytön näkymä (`/machines/{kone}/console`) koneen vieressä olevalle tabletille tai kosketusnäytölle. Näkymässä ei ole päävalikkoa, vain koneen nimi, käyttäjä, **Päivitä**, Vaihda käyttäjä ja paluu tavalliseen käyttöliittymään.
+- Jokaisella koneella on oma koko näytön näkymä (`/console/machines/{kone}`) koneen vieressä olevalle tabletille tai kosketusnäytölle. Näkymässä ei ole päävalikkoa, vain koneen nimi, käyttäjä, **Päivitä**, Vaihda käyttäjä ja paluu tavalliseen käyttöliittymään.
+- Konekäyttöliittymällä on **oma istuntonsa**, erillään tavallisesta käyttöliittymästä samassa selaimessa. Koneen sivulta (ja konelistasta ja tilauksista) se avautuu uuteen ikkunaan kirjautuneena samalle käyttäjälle kertakäyttöisellä, minuutin voimassa olevalla avaimella. Sen jälkeen istunnot elävät erillään: tavallisen käyttöliittymän sulkeminen tai uloskirjautuminen ei vaikuta konekäyttöliittymään, eikä konekäyttöliittymän käyttäjänvaihto tavalliseen. Kirjautumissivu `/login` kirjaa aina tavalliseen käyttöliittymään. Suoraan avattu konekäyttöliittymä (esim. erillinen tabletti) kysyy kirjautumisen omalla sivullaan (`/console/login`) PIN-koodilla tai sähköpostilla ja salasanalla.
+- **Vaihda käyttäjä** avaa valintaikkunan, jossa seuraava käyttäjä valitsee nimensä ja näppäilee oman 4–6-numeroisen **PIN-koodinsa** numeronäppäimillä. PIN-koodin asettaa käyttäjä itse profiilivalikon sivulla *Konsolin PIN-koodi* salasanallaan; siitä tallennetaan vain tiiviste. Vaihto koskee vain konekäyttöliittymän omaa istuntoa. Viisi väärää PIN-koodia lukitsee käyttäjän PIN-kirjautumisen 15 minuutiksi. Käyttäjä, jolla ei ole PIN-koodia, kirjautuu konekäyttöliittymän kirjautumissivulla sähköpostilla ja salasanalla takaisin konekäyttöliittymään.
- **Päivitä**-painike (iso, aina näkyvissä yläreunassa) lataa työlistan, tilausten tilat, saldot ja huoltojen tilat uudelleen palvelimelta. Näkymä päivittyy myös itsestään, mutta painikkeella saa heti ajantasaisen tilanteen, kun samaa asiaa on käsitelty toisella laitteella: esim. pikamyyntitilaus aloitetaan puhelimella, valmistetaan tabletilla konekäyttöliittymässä ja maksetaan lopuksi kassakoneella, josta kuitti tulostetaan. Päivityksen jälkeen ilmoitus (`role="status"`) kertoo päivitysajan ja uusien rivien määrän, ja fokus pysyy painikkeessa.
- Kosketusnäytölle mitoitettu: painikkeet ja kosketusalueet vähintään 44 × 44 px, isot fontit, vähän tekstinsyöttöä, ei hover-toimintoja; toimii pysty- ja vaaka-asennossa tabletin kokoisilla näytöillä ja myös puhelimella. Saavutettavuusvaatimukset (WCAG 2.2 AA) koskevat myös tätä näkymää.
- **Työlista**: kuluvan päivän tehtävät ja pikamyyntitilaukset (sekä myöhässä olevat aiemmilta päiviltä) järjestyksessä; tulevien päivien listat voi katsoa Seuraava päivä -painikkeella, mutta valmiiksi kuitataan vain tämän päivän ja myöhässä olevat rivit, seuraava korostettuna (tekstillä). Pikamyyntitilauksen rivillä on iso noutonumero ja Valmis-painike (19.7); uusi tilaus ilmoitetaan `aria-live`-alueella. Tehtävän valinta näyttää ohjeistuksen ja kuvauksen, ja tilan voi vaihtaa isoilla painikkeilla (Aloita = työn alla, Valmis, Tarkastettavaksi).
@@ -619,7 +621,7 @@ Päätetty: hankintahinta liukuvana keskihintana, negatiivinen saldo sallitaan v
- ensin tämän koneen yleisimmin ja viimeksi käyttämät nimikkeet, sitten ryhmäpainikkeet (esim. Paperit, Mediat), joilla lista rajataan;
- hakukenttä, joka suodattaa kirjoittaessa nimen ja koodin osista (isot ja pienet kirjaimet ja ääkköset samoin), sekä viivakoodinlukija, joka kirjoittaa koodin kenttään;
- määrä +/- painikkeilla tai numeronäppäimistöllä, yksikkö näkyvissä; kirjaus vahvistetaan yhdellä painalluksella, ja ilmoitus (`role="status"`) kertoo kirjatun määrän ja uuden saldon. Viimeisimmän kirjauksen voi perua heti.
-- **Laskurit ja huollot**: laskurin lukeman kirjaus numeronäppäimistöllä; huoltokohteet tiloineen ja huoltokirjaus (Huolto tehty, lukema esitäytettynä, käytetyt osat). Myöhässä olevat huollot näkyvät näkymän yläosassa tekstinä ja kuvakkeena.
+- **Laskurit ja huollot**: työn kulutuksen kirjaus laskuriin numeronäppäimistöllä (laskurin lukema vihjeenä); huoltokohteet tiloineen ja huoltokirjaus (Huolto tehty, käytetyt osat). Osio näytetään vain, jos koneella on laskureita tai huoltokohteita. Myöhässä olevat huollot näkyvät näkymän yläosassa tekstinä ja kuvakkeena.
- Tehtävän tunnit kirjataan tavalliseen tapaan (luku 9); konekäyttöliittymässä on pikakirjaus valitun tehtävän tämän päivän tunneille.
### 19.7 Pikamyyntituotteiden valmistus *(valmis)*
diff --git a/lang/en/layout.php b/lang/en/layout.php
index 7eac316..2e682ab 100644
--- a/lang/en/layout.php
+++ b/lang/en/layout.php
@@ -56,4 +56,5 @@ return [
'theme_system' => 'System default',
'selected' => '(selected)',
],
+ 'opens_in_new_window' => 'opens in a new window',
];
diff --git a/lang/en/machines.php b/lang/en/machines.php
index 93ca7c1..a526309 100644
--- a/lang/en/machines.php
+++ b/lang/en/machines.php
@@ -162,11 +162,11 @@ return [
'deactivated' => 'The maintenance item was taken out of use. Its history is kept.',
'counters' => 'Counters',
'no_reading' => 'No readings.',
- 'latest_reading' => 'Latest reading :reading :unit (:at).',
- 'new_reading' => 'New reading (:unit)',
- 'save_reading' => 'Record reading',
- 'save_reading_named' => 'Record reading: :counter',
- 'reading_saved' => 'Reading :reading :unit of :counter recorded.',
+ 'latest_reading' => 'Counter now :reading :unit (updated :at).',
+ 'usage' => 'Used by the job (:unit)',
+ 'save_usage' => 'Record usage',
+ 'save_usage_named' => 'Record usage: :counter',
+ 'usage_saved' => ':usage :unit added to :counter, counter now :reading :unit.',
'items' => 'Maintenance',
'add' => 'New maintenance item',
'none' => 'The machine has no maintenance items.',
@@ -193,7 +193,6 @@ return [
'edit_named' => 'Edit: :name',
'done' => 'Maintenance done',
'done_named' => 'Maintenance done: :name',
- 'reading_at' => 'Reading (:counter)',
'note' => 'Note',
'confirm_done' => 'Record maintenance',
'recorded' => 'Maintenance :name recorded.',
@@ -209,7 +208,7 @@ return [
'cancel' => 'Mark as cancelled',
'cancel_named' => 'Mark as cancelled: :name :at',
'cancel_title' => 'Mark the maintenance as cancelled?',
- 'cancel_text' => 'The record stays in the history marked as cancelled, and it no longer restarts the interval.',
+ 'cancel_text' => 'The record stays in the history marked as cancelled, and it no longer resets the interval.',
'cancelled' => 'Maintenance :name marked as cancelled.',
'errors' => [
'needs_interval' => 'Give a counter-based interval, a time-based interval or both.',
@@ -218,7 +217,7 @@ return [
'counter' => 'Choose a counter of the machine.',
'period_count' => 'Enter the period as a whole number 1–365.',
'warning' => 'Enter the advance warning as a percentage 1–99.',
- 'reading' => 'Enter a reading of zero or more, at most three decimals.',
+ 'usage' => 'Enter the amount the job used as a number greater than zero, e.g. 350, at most three decimals.',
],
],
'console' => [
@@ -274,7 +273,9 @@ return [
'undo' => 'Undo the latest record',
'reason_required' => 'Give a reason when no task is selected.',
'counters_and_maintenance' => 'Counters and maintenance',
- 'latest' => 'Latest reading :reading',
+ 'latest' => 'Counter now :reading',
+ 'usage' => ':counter: used by the job (:unit)',
+ 'hour_suggestion' => 'Suggestion: record :hours h on the counter :counter. Confirm with Record usage.',
],
'process' => [
'title' => 'Production process',
diff --git a/lang/en/users.php b/lang/en/users.php
index 9dbe36c..2de9b4b 100644
--- a/lang/en/users.php
+++ b/lang/en/users.php
@@ -86,6 +86,47 @@ return [
'supervisor_has_interns' => 'The user is the supervisor of active interns. First choose a new supervisor for the interns.',
],
+ 'pin' => [
+ 'title' => 'Console PIN code',
+ 'intro' => 'On a machine console you can switch to your user with your own PIN code, without your email and password. A session opened with the PIN code works only on the machine console.',
+ 'is_set' => 'You have a PIN code.',
+ 'not_set' => 'You do not have a PIN code yet.',
+ 'current_password' => 'Current password',
+ 'pin' => 'New PIN code',
+ 'pin_hint' => '4–6 digits.',
+ 'pin_confirmation' => 'PIN code again',
+ 'save' => 'Save PIN code',
+ 'remove' => 'Remove PIN code',
+ 'saved' => 'PIN code saved.',
+ 'removed' => 'PIN code removed.',
+ 'errors' => [
+ 'pin' => 'Enter 4–6 digits as the PIN code.',
+ 'confirmation' => 'The PIN codes do not match.',
+ 'password' => 'The password is not correct.',
+ ],
+ ],
+ 'console_login' => [
+ 'title' => 'Sign in to the machine console',
+ 'intro' => 'The machine console has a sign-in of its own. The normal user interface in the same browser does not change.',
+ 'with_pin' => 'With a PIN code',
+ 'with_password' => 'With email and password',
+ ],
+ 'pin_switch' => [
+ 'title' => 'Change user',
+ 'user' => 'Who are you?',
+ 'pin' => 'PIN code',
+ 'keypad' => 'Number keys',
+ 'clear' => 'Clear',
+ 'backspace' => 'Remove the last digit',
+ 'submit' => 'Sign in',
+ 'no_users' => 'Nobody has a PIN code yet. A PIN code is set from the profile menu.',
+ 'with_password' => 'Sign in with email and password',
+ 'errors' => [
+ 'user' => 'Choose your name.',
+ 'pin' => 'The PIN code is not correct.',
+ 'locked' => 'Too many wrong attempts. Try again in :minutes min or sign in with your password.',
+ ],
+ ],
'password_mail' => [
'subject' => 'Set your password',
'greeting' => 'Hello!',
diff --git a/lang/fi/layout.php b/lang/fi/layout.php
index cdbd9a4..64bb3be 100644
--- a/lang/fi/layout.php
+++ b/lang/fi/layout.php
@@ -56,4 +56,5 @@ return [
'theme_system' => 'Järjestelmän mukainen',
'selected' => '(valittu)',
],
+ 'opens_in_new_window' => 'avautuu uuteen ikkunaan',
];
diff --git a/lang/fi/machines.php b/lang/fi/machines.php
index 498e298..13bb756 100644
--- a/lang/fi/machines.php
+++ b/lang/fi/machines.php
@@ -162,11 +162,11 @@ return [
'deactivated' => 'Huoltokohde poistettu käytöstä. Sen historia säilyy.',
'counters' => 'Laskurit',
'no_reading' => 'Ei lukemia.',
- 'latest_reading' => 'Viimeisin lukema :reading :unit (:at).',
- 'new_reading' => 'Uusi lukema (:unit)',
- 'save_reading' => 'Kirjaa lukema',
- 'save_reading_named' => 'Kirjaa lukema: :counter',
- 'reading_saved' => 'Laskurin :counter lukema :reading :unit kirjattu.',
+ 'latest_reading' => 'Laskuri nyt :reading :unit (päivitetty :at).',
+ 'usage' => 'Työn kulutus (:unit)',
+ 'save_usage' => 'Kirjaa kulutus',
+ 'save_usage_named' => 'Kirjaa kulutus: :counter',
+ 'usage_saved' => 'Laskuriin :counter lisätty :usage :unit, laskuri nyt :reading :unit.',
'items' => 'Huollot',
'add' => 'Uusi huoltokohde',
'none' => 'Koneelle ei ole huoltokohteita.',
@@ -193,7 +193,6 @@ return [
'edit_named' => 'Muokkaa: :name',
'done' => 'Huolto tehty',
'done_named' => 'Huolto tehty: :name',
- 'reading_at' => 'Lukema (:counter)',
'note' => 'Huomautus',
'confirm_done' => 'Kirjaa huolto',
'recorded' => 'Huolto :name kirjattu.',
@@ -209,7 +208,7 @@ return [
'cancel' => 'Merkitse perutuksi',
'cancel_named' => 'Merkitse perutuksi: :name :at',
'cancel_title' => 'Merkitäänkö huolto perutuksi?',
- 'cancel_text' => 'Huoltokirjaus jää historiaan perutuksi merkittynä, eikä se enää nollaa huoltovälin kertymää.',
+ 'cancel_text' => 'Huoltokirjaus jää historiaan perutuksi merkittynä, eikä se enää nollaa huoltoväliä.',
'cancelled' => 'Huolto :name merkitty perutuksi.',
'errors' => [
'needs_interval' => 'Anna laskuriin perustuva huoltoväli, aikaan perustuva huoltoväli tai molemmat.',
@@ -218,7 +217,7 @@ return [
'counter' => 'Valitse koneen laskuri.',
'period_count' => 'Anna jakso kokonaislukuna 1–365.',
'warning' => 'Anna ennakkovaroitus prosentteina 1–99.',
- 'reading' => 'Anna lukema nollana tai suurempana lukuna, enintään kolme desimaalia.',
+ 'usage' => 'Anna työn kulutus nollaa suurempana lukuna, esim. 350, enintään kolme desimaalia.',
],
],
'console' => [
@@ -274,7 +273,9 @@ return [
'undo' => 'Peru viimeisin kirjaus',
'reason_required' => 'Anna syy, kun tehtävää ei ole valittu.',
'counters_and_maintenance' => 'Laskurit ja huollot',
- 'latest' => 'Viimeisin lukema :reading',
+ 'latest' => 'Laskuri nyt :reading',
+ 'usage' => ':counter: työn kulutus (:unit)',
+ 'hour_suggestion' => 'Ehdotus: kirjaa :hours h laskuriin :counter. Vahvista painamalla Kirjaa kulutus.',
],
'process' => [
'title' => 'Valmistusprosessi',
diff --git a/lang/fi/users.php b/lang/fi/users.php
index cb356a7..4070b90 100644
--- a/lang/fi/users.php
+++ b/lang/fi/users.php
@@ -86,6 +86,47 @@ return [
'supervisor_has_interns' => 'Käyttäjä on aktiivisten harjoittelijoiden vastuuhenkilö. Vaihda harjoittelijoille ensin uusi vastuuhenkilö.',
],
+ 'pin' => [
+ 'title' => 'Konsolin PIN-koodi',
+ 'intro' => 'Koneen konekäyttöliittymässä voit vaihtaa käyttäjäksi omalla PIN-koodillasi ilman sähköpostia ja salasanaa. PIN-koodilla avattu istunto toimii vain konekäyttöliittymässä.',
+ 'is_set' => 'Sinulla on PIN-koodi.',
+ 'not_set' => 'Sinulla ei ole vielä PIN-koodia.',
+ 'current_password' => 'Nykyinen salasana',
+ 'pin' => 'Uusi PIN-koodi',
+ 'pin_hint' => '4–6 numeroa.',
+ 'pin_confirmation' => 'PIN-koodi uudelleen',
+ 'save' => 'Tallenna PIN-koodi',
+ 'remove' => 'Poista PIN-koodi',
+ 'saved' => 'PIN-koodi tallennettu.',
+ 'removed' => 'PIN-koodi poistettu.',
+ 'errors' => [
+ 'pin' => 'Anna PIN-koodiksi 4–6 numeroa.',
+ 'confirmation' => 'PIN-koodit eivät ole samat.',
+ 'password' => 'Salasana ei ole oikein.',
+ ],
+ ],
+ 'console_login' => [
+ 'title' => 'Kirjaudu konekäyttöliittymään',
+ 'intro' => 'Konekäyttöliittymällä on oma kirjautumisensa. Tavallinen käyttöliittymä samassa selaimessa ei muutu.',
+ 'with_pin' => 'PIN-koodilla',
+ 'with_password' => 'Sähköpostilla ja salasanalla',
+ ],
+ 'pin_switch' => [
+ 'title' => 'Vaihda käyttäjä',
+ 'user' => 'Kuka olet?',
+ 'pin' => 'PIN-koodi',
+ 'keypad' => 'Numeronäppäimet',
+ 'clear' => 'Tyhjennä',
+ 'backspace' => 'Poista viimeinen numero',
+ 'submit' => 'Kirjaudu',
+ 'no_users' => 'Kenelläkään ei ole vielä PIN-koodia. PIN-koodin voi asettaa profiilivalikosta.',
+ 'with_password' => 'Kirjaudu sähköpostilla ja salasanalla',
+ 'errors' => [
+ 'user' => 'Valitse nimesi.',
+ 'pin' => 'PIN-koodi ei ole oikein.',
+ 'locked' => 'Liian monta väärää yritystä. Yritä uudelleen :minutes min kuluttua tai kirjaudu salasanalla.',
+ ],
+ ],
'password_mail' => [
'subject' => 'Aseta salasana',
'greeting' => 'Hei!',
diff --git a/resources/views/components/profile-menu.blade.php b/resources/views/components/profile-menu.blade.php
index a024024..bc625d8 100644
--- a/resources/views/components/profile-menu.blade.php
+++ b/resources/views/components/profile-menu.blade.php
@@ -92,6 +92,15 @@