Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/Actions/CRM/Customer/UI/GetCustomerShowcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use App\Enums\Accounting\CreditTransaction\CreditTransactionReasonEnum;
use App\Enums\Accounting\CreditTransaction\CreditTransactionTypeEnum;
use App\Enums\Catalogue\Shop\ShopTypeEnum;
use App\Enums\UI\NotesEnum;

class GetCustomerShowcase
{
Expand Down Expand Up @@ -136,12 +137,12 @@ public function handle(Customer $customer): array
]
],
'internal_note' => [
"label" => __("Private"),
"label" => NotesEnum::INTERNAL->label(),
"note" => $customer->internal_notes ?? '',
"information" => __("This note is only visible to staff members. Staff can communicate with each other about the customer."),
"editable" => true,
"bgColor" => "#FF7DBD",
"field" => "internal_notes"
"field" => "internal_notes",
...NotesEnum::INTERNAL->boilerPlate()
],
'update_route' => [
'name' => 'grp.models.customer.update',
Expand Down
33 changes: 24 additions & 9 deletions app/Actions/CRM/Customer/UI/ShowCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
use App\Models\Catalogue\Shop;
use App\Models\CRM\Customer;
use App\Models\SysAdmin\Organisation;
use Arr;
use Inertia\Inertia;
use Inertia\Response;
use Lorisleiva\Actions\ActionRequest;
use App\Actions\Helpers\SalesChannel\GetSalesChannelOptions;
use App\Actions\Traits\HasGrData;
use App\Enums\UI\NotesEnum;
use Illuminate\Support\Arr;

class ShowCustomer extends OrgAction
{
Expand Down Expand Up @@ -275,21 +276,35 @@ public function getCustomerNotes(Customer $customer): array
return [
"note_list" => [
[
"label" => __("Private"),
"label" => NotesEnum::INTERNAL->label(),
"note" => $customer->internal_notes ?? '',
"information" => __("This note is only visible to staff members. Staff can communicate with each other about the customer."),
"editable" => true,
"bgColor" => "#FF7DBD",
"field" => "internal_notes"
"field" => "internal_notes",
...NotesEnum::INTERNAL->boilerPlate()
],
[
"label" => __("Sticky Note For Delivery Notes").' ('.__("Private").')',
"label" => __("Warehouse Note (Permanent)"),
"note" => $customer->warehouse_internal_notes ?? '',
"information" => __("Will be put as Order private note everytime the Order submitted. Visible only to customer service and warehouse's staff."),
"information" => __("Will be put on every Order private note. Visible only to customer service and warehouse's staff."),
"editable" => true,
"bgColor" => "#FCF4A3",
"field" => "warehouse_internal_notes"
"field" => "warehouse_internal_notes",
...NotesEnum::WAREHOUSE->boilerPlate()
]
],
"temporary_note" => [
"label" => NotesEnum::WAREHOUSE_TEMPORARY->label(),
"note" => $customer->warehouse_temporary_notes ?? '',
"information" => __("Will be put on the next Order private note"),
"editable" => true,
"field" => "warehouse_temporary_notes",
"updateRoute" => [
'name' => 'grp.models.customer.update',
'parameters' => [
'customer' => $customer->id
]
],
...NotesEnum::WAREHOUSE_TEMPORARY->boilerPlate()
]
];
}
Expand Down Expand Up @@ -339,7 +354,7 @@ public function getBreadcrumbs(string $routeName, array $routeParameters, string
$suffix
),
),

'grp.org.shops.show.crm.customers.show',
'grp.org.shops.show.crm.customers.edit',
'grp.org.shops.show.crm.customers.show.customer_sales_channels.index',
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/CRM/Customer/UpdateCustomer.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public function handle(Customer $customer, array $modelData): Customer
MatchCustomerProspects::run($customer);
}

if (Arr::hasAny($changes, ['internal_notes', 'warehouse_internal_notes'])) {
if (Arr::hasAny($changes, ['internal_notes', 'warehouse_internal_notes', 'warehouse_temporary_notes'])) {
$customer->auditEvent = AuditEventEnum::CUSTOMER_NOTE->value;
$customer->isCustomEvent = true;

Expand Down Expand Up @@ -352,6 +352,7 @@ public function rules(): array
'internal_notes' => ['sometimes', 'nullable', 'string'],
'warehouse_internal_notes' => ['sometimes', 'nullable', 'string'],
'warehouse_public_notes' => ['sometimes', 'nullable', 'string'],
'warehouse_temporary_notes' => ['sometimes', 'nullable', 'string'],
'tax_number' => ['sometimes', 'nullable', 'array'],
'tags' => ['sometimes', 'array'],
'email_subscriptions' => ['sometimes', 'array'],
Expand All @@ -370,7 +371,6 @@ public function rules(): array
'gr_extended_until' => ['sometimes', 'nullable', 'date'],
'fiscal_name' => ['sometimes', 'nullable', 'string', 'max:255'],
'is_vip' => ['sometimes', 'boolean'],

];

if ($this?->asAction) {
Expand Down
21 changes: 11 additions & 10 deletions app/Actions/Dispatching/DeliveryNote/UI/ShowDeliveryNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use App\Enums\Dispatching\DeliveryNoteItem\DeliveryNoteItemStateEnum;
use App\Enums\Ordering\Platform\PlatformTypeEnum;
use App\Enums\UI\Dispatch\DeliveryNoteTabsEnum;
use App\Enums\UI\NotesEnum;
use App\Http\Resources\CRM\CustomerResource;
use App\Http\Resources\Dispatching\DeliveryNoteItemsResource;
use App\Http\Resources\Dispatching\DeliveryNoteItemsStateHandlingResource;
Expand Down Expand Up @@ -1399,28 +1400,28 @@ public function getDeliveryNoteNotes(DeliveryNote $deliveryNote): array
return [
"note_list" => [
[
"label" => __("Shipping label message").' ('.__("Customer").')',
"label" => NotesEnum::SHIPPING_LABEL->label(),
"note" => $deliveryNote->shipping_notes ?? '',
"information" => __("Note from crm. First 34 char. Will be printed on the shipping label."),
"editable" => true,
"bgColor" => "#38bdf8",
"field" => "shipping_notes"
"editable" => false,
"field" => "shipping_notes",
...NotesEnum::SHIPPING_LABEL->boilerPlate()
],
[
"label" => __("Customer's note"),
"label" => NotesEnum::CUSTOMER->label(),
"note" => $deliveryNote->customer_notes ?? '',
"information" => __("This note is from customer in the platform. Not editable."),
"editable" => false,
"bgColor" => "#FF7DBD",
"field" => "customer_notes"
"field" => "customer_notes",
...NotesEnum::CUSTOMER->boilerPlate()
],
[
"label" => __("Private warehouse note"),
"label" => NotesEnum::WAREHOUSE->label(),
"note" => $deliveryNote->private_warehouse_note ?? '',
"information" => __("This note is only visible to staff members. You can communicate each other about the order."),
"editable" => true,
"bgColor" => "#FFD8A8",
"field" => "private_warehouse_note"
"field" => "private_warehouse_note",
...NotesEnum::WAREHOUSE->boilerPlate()
]
]
];
Expand Down
31 changes: 16 additions & 15 deletions app/Actions/Ordering/Order/UI/ShowOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use App\Enums\Ordering\Order\OrderPayStatusEnum;
use App\Enums\Ordering\Order\OrderStateEnum;
use App\Enums\Ordering\Platform\PlatformTypeEnum;
use App\Enums\UI\NotesEnum;
use App\Enums\UI\Ordering\OrdersBacklogTabsEnum;
use App\Enums\UI\Ordering\OrderTabsEnum;
use App\Http\Resources\Accounting\InvoicesResource;
Expand Down Expand Up @@ -187,45 +188,45 @@ public function getOrderNotes(Order $order): array
return [
"note_list" => [
[
"label" => __("Shipping label message") . ' (' . __("Customer") . ')',
"label" => NotesEnum::SHIPPING_LABEL->label(),
"note" => $order->shipping_notes ?? '',
"information" => __("Note from crm. First 34 char. Will be printed on the shipping label."),
"editable" => true,
"bgColor" => "#38bdf8",
"field" => "shipping_notes"
"field" => "shipping_notes",
...NotesEnum::SHIPPING_LABEL->boilerPlate()
],
[
"label" => __("Customer"),
"label" => NotesEnum::CUSTOMER->label(),
"note" => $order->customer_notes ?? '',
"information" => __("This note is from customer in the platform. Not editable."),
"editable" => false,
"bgColor" => "#FF7DBD",
"field" => "customer_notes"
"field" => "customer_notes",
...NotesEnum::CUSTOMER->boilerPlate()
],
[
"label" => __("Public"),
"label" => NotesEnum::PUBLIC->label(),
"note" => $order->public_notes ?? '',
"information" => __("This note will be visible to public, both staff and the customer can see."),
"editable" => true,
"warning" => __('Customer can see this note'),
"bgColor" => "#94DB84",
"field" => "public_notes"
"field" => "public_notes",
...NotesEnum::PUBLIC->boilerPlate()
],
[
"label" => __("Private CRM note"),
"label" => NotesEnum::INTERNAL->label(),
"note" => $order->internal_notes ?? '',
"information" => __("This note is only visible to staff members in the order. It is not shown in the delivery note."),
"editable" => true,
"bgColor" => "#FCF4A3",
"field" => "internal_notes"
"field" => "internal_notes",
...NotesEnum::INTERNAL->boilerPlate()
],
[
"label" => __("Private warehouse note"),
"label" => NotesEnum::WAREHOUSE->label(),
"note" => $order->private_warehouse_note ?? '',
"information" => __("This note is only visible to staff members and is shown in the delivery note."),
"editable" => true,
"bgColor" => "#FFD8A8",
"field" => "private_warehouse_note"
"field" => "private_warehouse_note",
...NotesEnum::WAREHOUSE->boilerPlate()
]
]
];
Expand Down
9 changes: 8 additions & 1 deletion app/Actions/Ordering/Order/UpdateState/SubmitOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Actions\Comms\Email\SendNewOrderEmailToSubscribers;
use App\Actions\CRM\Customer\Hydrators\CustomerHydrateBasket;
use App\Actions\CRM\Customer\Hydrators\CustomerHydrateTrafficSource;
use App\Actions\CRM\Customer\UpdateCustomer;
use App\Actions\Dropshipping\CustomerClient\Hydrators\CustomerClientHydrateBasket;
use App\Actions\Dropshipping\CustomerSalesChannel\Hydrators\CustomerSalesChannelsHydrateOrders;
use App\Actions\Ordering\Order\HasOrderHydrators;
Expand Down Expand Up @@ -69,7 +70,7 @@ public function handle(Order $order): Order
$modelData = [
'state' => OrderStateEnum::SUBMITTED,
'status' => OrderStatusEnum::PROCESSING,
'private_warehouse_note' => collect([$order->private_warehouse_note, $order->customer->warehouse_internal_notes])
'private_warehouse_note' => collect([$order->private_warehouse_note, $order->customer->warehouse_internal_notes, $order->customer->warehouse_temporary_notes])
->filter()
->unique()
->implode(' — ') ?: null,
Expand Down Expand Up @@ -113,6 +114,12 @@ public function handle(Order $order): Order
}

$this->update($order, $modelData);

if ($order->customer->warehouse_temporary_notes) {
UpdateCustomer::make()->action($order->customer, [
'warehouse_temporary_notes' => null
]);
}

if ($order->shop->masterShop) {
$order->shop->masterShop->orderingStats->update(
Expand Down
71 changes: 71 additions & 0 deletions app/Enums/UI/NotesEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php

/*
* Author Louis Perez
* Created on 27-08-2026-12h-03m
* GitHub: https://github.com/louis-perez
* Copyright 2026
*/

namespace App\Enums\UI;

use Illuminate\Support\Arr;

enum NotesEnum: string
{
case SHIPPING_LABEL = 'shipping';
case CUSTOMER = 'customer';
case PUBLIC = 'public';
case INTERNAL = 'internal';
case WAREHOUSE = 'warehouse';
case WAREHOUSE_TEMPORARY = 'warehouse_temporary';
case CREDIT_TRANSACTION = 'credit_transaction';


public function label(): string
{
return match ($this) {
self::SHIPPING_LABEL => __("Shippings Label (From Customer)"),
self::CUSTOMER => __("Customer Instructions"),
self::PUBLIC => __("Public Note"),
self::INTERNAL => __("CRMs Note (Private)"),
self::WAREHOUSE => __("Warehouse Note (Private)"),
self::WAREHOUSE_TEMPORARY => __("Warehouse Note (Temporary)"),
self::CREDIT_TRANSACTION => __("Credit Transaction Note"),
};
}

public function boilerPlate(array $excludedKeys = ['textColor']): array
{
return Arr::except(match ($this) {
self::SHIPPING_LABEL => [
"bgColor" => "#93C5FD",
"textColor" => "#93C5FD",
],
self::CUSTOMER => [
"bgColor" => "#599FF0",
"textColor" => "#599FF0",
],
self::PUBLIC => [
"bgColor" => "#AAAAAA",
"textColor" => "#AAAAAA",
],
self::INTERNAL => [
"bgColor" => "#D8B4FE",
"textColor" => "#D8B4FE",
],
self::WAREHOUSE => [
"bgColor" => "#FCD34D",
"textColor" => "#FCD34D",
],
self::WAREHOUSE_TEMPORARY => [
"bgColor" => "#FF9C62",
"textColor" => "#FF9C62",
],
self::CREDIT_TRANSACTION => [
"bgColor" => "#B873F5",
"textColor" => "#B873F5",
],
}, $excludedKeys);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customers', function (Blueprint $table) {
$table->text('warehouse_temporary_notes')->nullable();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('warehouse_temporary_notes');
});
}
};
Loading