Commit Graph
550 Commits
Author SHA1 Message Date
Jeppe Bundgaard 3115856fc8 Remove redundant return statement in Shelly relay control logic 2025-12-16 11:41:00 +01:00
Jeppe Bundgaard 3eef3b45c4 Add customer number validation and bypass mechanism for self-serve lane operations
- Introduced customer number validation during STOP command to ensure the lane's customer matches the provided customer number.
- Added a flag and methods to bypass customer number validation when authorized.
- Updated routes to set the bypass flag for users with appropriate permissions.
- Included customer number in command arguments for enhanced validation.
2025-12-16 11:40:41 +01:00
Jeppe Bundgaard b6371455ca Enforce command-specific permissions for self-serve lane operations and update related tests 2025-12-15 16:00:00 +01:00
Jeppe Bundgaard 46c7a2f2cd Add http-client.env.json for HTTP client test environment configuration 2025-12-15 10:34:48 +01:00
Jeppe Bundgaard fff5637fe6 Refactor self-serve.http tests to use dynamic variables for API URL, customer number, license plate, and lane ID 2025-12-15 10:34:42 +01:00
Jeppe Bundgaard 4e1404f070 Add invoices-pdf.http test for invoice PDF endpoint validation 2025-12-15 10:33:14 +01:00
Jeppe Bundgaard d0bd305b0b Add orders-potential-duplicates.http test for endpoint validation 2025-12-15 10:32:16 +01:00
Jeppe Bundgaard 761096495a Update numberplatescans.http to use dynamic variables for API URL, plate, bay ID, and authorization token 2025-12-15 10:30:59 +01:00
Jeppe Bundgaard 06e0f58ce2 Fix mismatched array brackets in plateScansRoute response structure 2025-12-15 10:25:47 +01:00
Jeppe Bundgaard 5a71889b26 Add support for optional bayId in license plate scans
- Updated `plateScansRoute` to handle an optional `bay_id` parameter in plate scan requests.
- Extended `plate_scans_o` object to include `bay_id` property and related database operations.
- Enhanced `add` method to validate and process `bayId` if provided.
2025-12-15 10:14:00 +01:00
Jeppe Bundgaard 9c9df0f1f4 Validate access and booking status for retrieving invoice PDFs
- Added validation to ensure the user owns the invoice and it has been booked before generating the PDF.
- Updated logic to retrieve and store booked invoice PDFs using the correct `booked_invoice_id`.
- Improved error handling for unauthorized access and unbooked invoices.
2025-12-10 14:22:37 +01:00
Jeppe Bundgaard f8af8cae46 Add lane management extensions to department functionality
- Introduced `getLanes` method in `departments_o` to retrieve associated lanes.
- Extended `department_lanes_o` with `getLaneStatus` and `getDepartmentLanes` methods for lane data handling.
- Updated guest route to support `include_lanes` parameter, enabling retrieval of lanes and their statuses for departments.
- Enhanced response structure with lane information when requested.
2025-12-09 14:38:59 +01:00
Jeppe Bundgaard 3cbce2a68f Add detailed customer booking notifications with message formatting
- Enhanced booking notifications to include comprehensive customer and booking details.
- Implemented message formatting for clarity: customer info, date, vehicle(s), items, references, PO, and pickup status.
- Improved notification structure by integrating branding name into messages.
2025-12-09 10:58:34 +01:00
Jeppe Bundgaard 68e93fdd9d Add relay_machine_id property to department_lanes_o object and extend related functionality
- Introduced `relay_machine_id` to `department_lanes_o` for managing Shelly relay associated with machines.
- Updated `add` method and database interactions to support the new property.
- Included `relay_machine_id` in `asArray` and field initialization logic.
- Enhanced `departmentLanesRoute` to handle `relay_machine_id` via API for creation and updates.
2025-12-09 10:26:32 +01:00
Jeppe Bundgaard 1b914b546e Add minute-based billing and lane management extensions to self-serve module
- Introduced `selfserve_lane_command_arguments` class for managing lane command parameters (e.g., customer number, license plate).
- Added traits for handling lane timer, invoice generation, license plate, and customer number management.
- Implemented minute-based billing logic with `selfserve_minute_product_c` configuration.
- Enhanced `selfserve_lane` with new behaviors: command arguments, invoicing, and time handling.
- Added `/modules/self-serve/lane/command` route for executing lane commands (START, STOP, RESET).
- Updated `/modules/self-serve/lane/status` route to include additional lane details (wash start, elapsed time, license plate, etc.).
- Improved Shelly device relay control for port management.
2025-12-08 23:05:35 +01:00
Jeppe Bundgaard cc6639e61b Introduce self-serve module with lane management functionality
- Added `selfserve_lane` class to handle self-serve lane operations.
- Implemented commands (START, STOP, RESET) and states (IDLE, IN_WASH, FAULT, etc.) for lane lifecycle.
- Introduced traits for managing lane status, mode, state, caching, and port control.
- Added enums for cohesive type definitions (`selfserve_lane_command`, `selfserve_lane_status`, `selfserve_lane_state`, etc.).
- Configured `/modules/self-serve/lane/status` route to expose lane state and status via API.
- Linked self-serve configuration via `selfserve_c` and `selfserve_enabled_c` for module toggling.
- Integrated lane caching logic with Redis for performance improvements.
- Updated `index.php` to include the self-serve module.
2025-12-08 15:34:40 +01:00
Jeppe Bundgaard d3d3657dfd Generate and attach wash certificate to orders
- Added `generateWashCertificate` method to `orders_o` for wash certificate PDF generation and attachment.
- Introduced `OTHER_TYPE_WASH_CERTIFICATE` constant in `attachment_content` for new attachment type.
- Added `/order/wash-certificate` route to provide wash certificate generation functionality via API.
2025-12-03 08:45:13 +01:00
Jeppe Bundgaard 3c46ee86ec Add routes for worker version management
- Introduced `/worker/version` route to retrieve current worker target version.
- Added `/worker/update-version` route to update worker target version with permission and parameter validation.
2025-12-01 15:01:25 +01:00
Jeppe Bundgaard b45e270fed Skip transactions not included in invoicing
- Updated `customer_vehicles_o` to exclude transactions not marked for invoicing during processing.
2025-12-01 13:20:07 +01:00
Jeppe Bundgaard d2f82b83ed Validate subscription price distribution and skip excluded transactions in invoicing
- Enforce validation to ensure department distribution matches total subscription price.
- Skip transactions not included in invoicing for improved accuracy.
- Uncomment permission checks in specific routes.
2025-12-01 13:19:59 +01:00
Jeppe Bundgaard d3a8d0d83d Add enabled property to accounts_o
- Introduced `$enabled` property to `accounts_o` for managing account status.
- Updated property initialization and `asArray` method to include `enabled`.
2025-11-28 10:48:59 +01:00
Jeppe Bundgaard ce51feb9ab Add caching logic to accounts_o and enhance asArray method
- Implemented cache invalidation in `objectChanged` method.
- Enhanced `asArray` method with caching support and type casting.
- Added cache expiration and retrieval logic to improve performance.
2025-11-28 10:44:03 +01:00
Jeppe Bundgaard 935af48b44 Add $asArrayCacheKey property to db_object_t for caching support
- Introduced `$asArrayCacheKey` as a dedicated property for `asArray` method caching.
2025-11-28 10:43:44 +01:00
Jeppe Bundgaard 1cdaa230d8 Add accounts_o object for account management
- Implemented `accounts_o` class with account properties (`phone`, `country_code`, `name`, etc.).
- Added `add` method for creating new account entries with input sanitization and default values.
- Introduced `asArray` method for converting object data into array format.
- Included property initialization in `getObjectProperties` for `accounts_o` object.
- Set up table structure and placeholders for caching logic in `objectChanged`.
2025-11-28 10:32:52 +01:00
Jeppe Bundgaard 8302b05028 Add cashier name retrieval and caching logic to orders processing
- Introduced `getCashierName` method in `users_o` for cashier name retrieval.
- Added caching for cashier names with dedicated expiration settings.
- Updated `ordersRoute` to include cashier names in order details.
- Added `$cashierNameCacheExpiration` property in `db_object_t` for centralized cache control.
2025-11-27 15:08:07 +01:00
Jeppe Bundgaard 542596b5a0 Refactor customer email retrieval logic in booking and email handling
- Replace direct wash certificate email retrieval with `getWashCertificateEmail` method.
- Fallback to default email if no certificate-specific email exists.
- Adjust email assignment in booking notifications to use consistent logic.
2025-11-27 10:50:49 +01:00
Jeppe Bundgaard 2ec936225c Refactor booking notifications and product restriction logic
- Enable department notification for new bookings.
- Enhance Slack notification details for bookings, including customer, vehicle, and items.
- Replace `isGuest` with `isProductDetailsRestricted` for better clarity in `productsRoute`.
- Adjust product parsing to handle restricted product details consistently.
2025-11-27 10:25:53 +01:00
Jeppe Bundgaard 667947fcda Add guest user handling and product filtering in productsRoute
- Implement guest-specific product redactions (e.g., hide names, reset prices).
- Refactor `parseProduct` to include guest context for dynamic response handling.
- Add authentication checks and guest user handling for accurate permission validation.
- Update logging to include guest or user context in actions.
- Adjust product and addon parsing for consistent guest visibility.
2025-11-26 13:29:53 +01:00
Jeppe Bundgaard 7961217a91 Add isAuthenticated method to route_t for user authentication check 2025-11-26 13:29:40 +01:00
Jeppe Bundgaard ecd44a455a - Add Redis mget method and cache management improvements
- Update cache expiration times for `economicCustomerName` and `isBooked` objects
- Introduce `getCachedForMultipleObjects` for batch cache retrieval
- Optimize `isBooked` with optional caching and update to store results
- Implement `getCustomerNames` in `users_o` with caching for bulk name retrieval
- Refactor customer transaction handling in `InvoicingPeriodRoute` for efficiency
- Filter orders excluded from invoicing in `collected_order_invoices_o`
2025-11-26 10:01:24 +01:00
Jeppe Bundgaard 7e9c456074 Deprecate book_wash_f methods with exception messages
- Added deprecation exceptions in `beforeSave` to guide users to the new booking page and updated booking object usage.
2025-11-25 15:27:56 +01:00
Jeppe Bundgaard 3dba2dedac Add isIncludedInInvoicing method and implement invoicing exclusions
- Introduced `isIncludedInInvoicing` in `orders_o` to check department-based invoicing exclusions.
- Updated routes and methods to skip orders excluded from invoicing.
- Refined transaction and order handling to respect invoicing settings, ensuring correct filtering.
2025-11-25 14:39:49 +01:00
Jeppe Bundgaard 537582e44d Add isExcludedFromInvoicing method to departments_o
- Introduced `isExcludedFromInvoicing` to check if a department is excluded from invoicing.
- Ensured selected department validation before retrieving exclusion status.
2025-11-25 13:04:57 +01:00
Jeppe Bundgaard 449908c833 Handle null values consistently and add deleted_at checks in vehiclesRoute queries
- Updated `db_object_t` to treat both `null` and string `'null'` as null values for filtering.
- Added `deleted_at IS NULL` condition in `vehiclesRoute` booking-related queries to exclude soft-deleted entries.
2025-11-24 15:48:15 +01:00
Jeppe Bundgaard 36d902d833 Add department-based filtering to vehicle search
- Introduced optional `department` parameter in `vehiclesRoute` for filtering booked registrations.
- Validated `department` input to ensure existence and access rights.
- Updated `getBookedRegs` to support dynamic filtering with department-specific criteria.
2025-11-24 13:23:44 +01:00
Jeppe Bundgaard 67927f8ab8 Refactor booking logic and table references for order_bookings
- Updated booking-related queries to use `order_bookings_o` for improved consistency and clarity.
- Replaced `regNrTraekker`/`regNrTrailer` with `reg_1`/`reg_2` in queries and results.
- Added `NULL` condition handling in `db_object_t` to support filtering by null field values.
- Enhanced booking data extraction with renamed fields (`reference_number` → `reference`, `notes` → `note`).
2025-11-20 15:54:00 +01:00
Jeppe Bundgaard 6d49befd22 Add /guest/departments endpoint for paginated department retrieval
- Introduced `GET /guest/departments` in `guestRoute` to fetch departments with pagination.
- Limited response to include only `id` and `name` fields for streamlined output.
2025-11-20 13:13:16 +01:00
Jeppe Bundgaard b4f208d30d Increase default pagination limit in customerSearchRoute from 10 to 100 2025-11-19 13:35:10 +01:00
Jeppe Bundgaard 0cf7b99440 Add conditional validation and default handling for email and phone parameters in authRoute
- Introduced parameter checks to ensure validation only occurs if fields are set and non-empty.
- Added default values for missing `email` and `phone` fields to improve robustness.
- Adjusted logic to use `companyPhone` and default email (`jb@truckwash.dk`) when applicable.
2025-11-19 13:28:29 +01:00
Jeppe Bundgaard eb1dec1d0e Refactor order update logic into updateOrder method
- Moved redundant order update logic to a centralized `updateOrder` method for better code reuse.
- Simplified route definitions in `ordersRoute` by delegating updates to the new `updateOrder` method.
- Added `NoReturn` attribute for improved type hinting and error handling.
2025-11-18 12:32:44 +01:00
Jeppe Bundgaard 32de29127a Fix product price typecasting and improve product parsing in productsRoute
- Corrected typecasting for product prices to ensure consistent integer values.
- Enhanced product parsing logic for better modularity and data handling in `productsRoute`.
2025-11-18 11:06:33 +01:00
Jeppe Bundgaard bdfce96500 Comment out permission check in /guest/cvr/search for future removal. 2025-11-17 18:24:11 +01:00
Jeppe Bundgaard dfeffed63f Optimize product retrieval by department categories and improve filtering in productsRoute
- Refactored `getAllProductInDepartmentCategories` in `departments_o` using `array_reduce` for cleaner and more efficient category loop.
- Enhanced `productsRoute` to filter department-specific products using IDs for stricter matching.
2025-11-17 14:17:05 +01:00
Jeppe Bundgaard 2d121c67cd Add product retrieval by department categories and typecasting fixes
- Added methods in `department_categories_o`, `departments_o`, and `categories_o` to retrieve products associated with department categories.
- Updated `productsRoute` and `superuserDepartmentRoute` to fetch department-specific products.
- Fixed typecasting in product price assignments for improved data consistency.
2025-11-17 14:10:25 +01:00
Jeppe Bundgaard 5b01644c0a Add CVR handling to guest and auth routes with virkdata integration
- Introduced `/guest/cvr/search` endpoint in `guestRoute` for company search using CVR.
- Added `/auth/register/cvr` endpoint in `authRoute` to handle CVR-based registration with validation.
- Enhanced `virkdata` with `searchCompanies` and improved response handling for search requests.
- Updated E-conomic integration to check for existing CVR registrations and create new customers where needed.
2025-11-17 13:20:12 +01:00
Jeppe Bundgaard a22fc3fab0 Add support for including additional product categories in exterior washes
- Adjusted `productsRoute` to include products from categories "1" and "3" when category "6" is requested.
- Merged additional products to ensure comprehensive category listings.
2025-11-13 12:32:15 +01:00
Jeppe Bundgaard 01528280a6 Add guest endpoint for validating customer number existence
- Introduced `POST /guest/validation/customer-number` in `guestRoute` to validate customer number existence.
- Implemented checks for required parameter format and range.
- Integrated `users_o` to verify if the customer number exists.
2025-11-13 10:02:58 +01:00
Jeppe Bundgaard e45ab68959 Add admin endpoint for fetching customer names and enhance order booking object with parsed product names
- Introduced `GET /admin/customer/name` endpoint in `userRoute` to retrieve customer names by user ID.
- Enhanced `order_bookings_o` with product name parsing for booking items.
- Added `customer_name` retrieval to `asArray` method in `order_bookings_o`.
- Implemented private `parseProductNames` method for item details parsing in `order_bookings_o`.
2025-11-12 13:21:22 +01:00
Jeppe Bundgaard 0b566ee725 Add validation for required file parameters in file_server.php
- Added checks for missing file name and file extension.
- Improved error handling with descriptive messages for missing parameters.
2025-11-11 15:39:03 +01:00
Jeppe Bundgaard 5193038bea Send wash certificate email to customers during order bookings
- Added `sendWashCertificateToCustomer` method in `order_bookings_o` to handle email sending for wash certificates.
- Implemented `sendWashCertificateEmailToCustomer` in `email` to generate and attach wash certificate PDFs.
- Updated attachment permission logic in `ordersRoute` and `db_object_t`.
- Changed `object_attachments_o` property types and handling for improved attachment processing.
2025-11-11 15:32:10 +01:00