Compare commits
5 Commits
834f64a011
...
5477b953a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5477b953a8 | ||
|
|
558a99970a | ||
|
|
50ebbbbd74 | ||
|
|
6758317599 | ||
|
|
e119c4ae4a |
@ -3,9 +3,33 @@
|
|||||||
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Pages;
|
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\ProfitCenterSupplierSchedules\ProfitCenterSupplierScheduleResource;
|
use App\Filament\Resources\ProfitCenterSupplierSchedules\ProfitCenterSupplierScheduleResource;
|
||||||
|
use App\Models\ProfitCenterSupplierSchedule;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class CreateProfitCenterSupplierSchedule extends CreateRecord
|
class CreateProfitCenterSupplierSchedule extends CreateRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = ProfitCenterSupplierScheduleResource::class;
|
protected static string $resource = ProfitCenterSupplierScheduleResource::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Több profit center esetén minden egyes profit centerhez külön rekordot hoz létre.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
protected function handleRecordCreation(array $data): Model
|
||||||
|
{
|
||||||
|
$profitCenterIds = (array) $data['profit_center_id'];
|
||||||
|
|
||||||
|
$lastRecord = null;
|
||||||
|
|
||||||
|
foreach ($profitCenterIds as $profitCenterId) {
|
||||||
|
$lastRecord = ProfitCenterSupplierSchedule::create([
|
||||||
|
'profit_center_id' => $profitCenterId,
|
||||||
|
'supplier_id' => $data['supplier_id'],
|
||||||
|
'delivery_schedule_id' => $data['delivery_schedule_id'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lastRecord;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,38 @@
|
|||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\ForceDeleteAction;
|
use Filament\Actions\ForceDeleteAction;
|
||||||
use Filament\Actions\RestoreAction;
|
use Filament\Actions\RestoreAction;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
class EditProfitCenterSupplierSchedule extends EditRecord
|
class EditProfitCenterSupplierSchedule extends EditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = ProfitCenterSupplierScheduleResource::class;
|
protected static string $resource = ProfitCenterSupplierScheduleResource::class;
|
||||||
|
|
||||||
|
public function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Select::make('profit_center_id')
|
||||||
|
->label('Profit Center')
|
||||||
|
->relationship('profitCenter', 'name')
|
||||||
|
->searchable()
|
||||||
|
->required(),
|
||||||
|
Select::make('supplier_id')
|
||||||
|
->label('Beszállító')
|
||||||
|
->relationship('supplier', 'name')
|
||||||
|
->searchable()
|
||||||
|
->required(),
|
||||||
|
Select::make('delivery_schedule_id')
|
||||||
|
->label('Szállítási sablon')
|
||||||
|
->relationship('deliverySchedule', 'name')
|
||||||
|
->searchable()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn ($state, $livewire) => $livewire->dispatch('delivery-schedule-changed', deliveryScheduleId: $state))
|
||||||
|
->required(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Schemas;
|
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Schemas;
|
||||||
|
|
||||||
|
use App\Models\ProfitCenter;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
@ -13,8 +14,9 @@ public static function configure(Schema $schema): Schema
|
|||||||
->components([
|
->components([
|
||||||
Select::make('profit_center_id')
|
Select::make('profit_center_id')
|
||||||
->label('Profit Center')
|
->label('Profit Center')
|
||||||
->relationship('profitCenter', 'name')
|
->options(ProfitCenter::orderBy('name')->pluck('name', 'id'))
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->multiple()
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('supplier_id')
|
Select::make('supplier_id')
|
||||||
->label('Beszállító')
|
->label('Beszállító')
|
||||||
|
|||||||
@ -33,6 +33,9 @@ class DeliveryCalendarWidget extends FullCalendarWidget
|
|||||||
/** Következő szállítási nap dátuma (YYYY-MM-DD formátum), kék kiemeléshez. */
|
/** Következő szállítási nap dátuma (YYYY-MM-DD formátum), kék kiemeléshez. */
|
||||||
public ?string $nextDeliveryDate = null;
|
public ?string $nextDeliveryDate = null;
|
||||||
|
|
||||||
|
/** Előnézeti szállítási sablon ID (edit oldalon, mentés előtti változás). */
|
||||||
|
public ?int $previewDeliveryScheduleId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inaktív (nem választható) napok listája.
|
* Inaktív (nem választható) napok listája.
|
||||||
*
|
*
|
||||||
@ -74,6 +77,13 @@ public function onNextDeliveryDateChanged(?string $date): void
|
|||||||
$this->refreshRecords();
|
$this->refreshRecords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[On('delivery-schedule-changed')]
|
||||||
|
public function onDeliveryScheduleChanged(?int $deliveryScheduleId): void
|
||||||
|
{
|
||||||
|
$this->previewDeliveryScheduleId = $deliveryScheduleId;
|
||||||
|
$this->refreshRecords();
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadRecordFromFilter(): void
|
protected function loadRecordFromFilter(): void
|
||||||
{
|
{
|
||||||
if ($this->record instanceof ProfitCenterSupplierSchedule) {
|
if ($this->record instanceof ProfitCenterSupplierSchedule) {
|
||||||
@ -114,11 +124,19 @@ public function fetchEvents(array $info): array
|
|||||||
$events = [];
|
$events = [];
|
||||||
|
|
||||||
// 1. Szállítási napok – zöld háttér
|
// 1. Szállítási napok – zöld háttér
|
||||||
|
$assignment = $this->record;
|
||||||
|
if ($this->previewDeliveryScheduleId && $this->previewDeliveryScheduleId !== $this->record->delivery_schedule_id) {
|
||||||
|
$assignment = clone $this->record;
|
||||||
|
$assignment->delivery_schedule_id = $this->previewDeliveryScheduleId;
|
||||||
|
$assignment->setRelation('deliverySchedule', \App\Models\DeliverySchedule::find($this->previewDeliveryScheduleId));
|
||||||
|
}
|
||||||
|
|
||||||
$deliveryDates = $service->getAvailableDeliveryDates(
|
$deliveryDates = $service->getAvailableDeliveryDates(
|
||||||
$this->record->profitCenter,
|
$this->record->profitCenter,
|
||||||
$this->record->supplier,
|
$this->record->supplier,
|
||||||
$start,
|
$start,
|
||||||
$end
|
$end,
|
||||||
|
$assignment
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($deliveryDates as $date) {
|
foreach ($deliveryDates as $date) {
|
||||||
|
|||||||
@ -149,6 +149,31 @@ private function getStatPriceChange(Request $request): JsonResponse
|
|||||||
return \response()->json(['function' => __FUNCTION__, 'parameters' => $this->Service->getStatisticsParameters(), 'ret' => $ret, 'success' => true], 200);
|
return \response()->json(['function' => __FUNCTION__, 'parameters' => $this->Service->getStatisticsParameters(), 'ret' => $ret, 'success' => true], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProductGroupSearch(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$query = ProductGroup::query()
|
||||||
|
->where('name', 'LIKE', '%' . $request->get('term') . '%');
|
||||||
|
|
||||||
|
if ($request->get('supplierId')) {
|
||||||
|
$supplierIds = $request->get('supplierId');
|
||||||
|
$query->whereHas('products', function ($q) use ($supplierIds) {
|
||||||
|
$q->whereIn('supplier_id', $supplierIds);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$items = $query->orderBy('name')->get(['id', 'name'])->map(function ($group) {
|
||||||
|
return [
|
||||||
|
'id' => $group->id,
|
||||||
|
'text' => $group->name,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'results' => $items,
|
||||||
|
'pagination' => ['more' => false],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function getProductSearch(Request $request): JsonResponse
|
public function getProductSearch(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$page = $request->get('page');
|
$page = $request->get('page');
|
||||||
|
|||||||
@ -105,7 +105,6 @@ public function index(): View|Response|JsonResponse
|
|||||||
if (\request()->input('w') == 1) {
|
if (\request()->input('w') == 1) {
|
||||||
$testOrderId = 16497; // heti
|
$testOrderId = 16497; // heti
|
||||||
$testOrderId = 16467; // heti
|
$testOrderId = 16467; // heti
|
||||||
|
|
||||||
$testOrderId = 16507; // heti
|
$testOrderId = 16507; // heti
|
||||||
// $testOrderId=16512; //heti
|
// $testOrderId=16512; //heti
|
||||||
|
|
||||||
@ -113,7 +112,7 @@ public function index(): View|Response|JsonResponse
|
|||||||
$testOrderId = 12140; // napi
|
$testOrderId = 12140; // napi
|
||||||
$testOrderId = 16506; // napi
|
$testOrderId = 16506; // napi
|
||||||
$testOrderId = 16571; // napi
|
$testOrderId = 16571; // napi
|
||||||
$testOrderId = 16571; // napi
|
//$testOrderId = 308676; // napi
|
||||||
$testOrderId = 307975; // napi
|
$testOrderId = 307975; // napi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Kalnoy\Nestedset\NodeTrait;
|
use Kalnoy\Nestedset\NodeTrait;
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ class ProductGroup extends Model
|
|||||||
|
|
||||||
protected ?array $needsId = null;
|
protected ?array $needsId = null;
|
||||||
|
|
||||||
|
public function products(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Product::class, 'product_group_id');
|
||||||
|
}
|
||||||
|
|
||||||
private function getNodeToArray($node, $needChild, $maxDepth = 999)
|
private function getNodeToArray($node, $needChild, $maxDepth = 999)
|
||||||
{
|
{
|
||||||
if ($this->needsId) {
|
if ($this->needsId) {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public function __construct(
|
|||||||
* 3. Általános override (az összes PC-re vonatkozó)
|
* 3. Általános override (az összes PC-re vonatkozó)
|
||||||
* Ha egyetlen szinten sem található override, folytatódik a normál kiértékelés.
|
* Ha egyetlen szinten sem található override, folytatódik a normál kiértékelés.
|
||||||
*/
|
*/
|
||||||
public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date): bool
|
public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date, ?ProfitCenterSupplierSchedule $assignment = null): bool
|
||||||
{
|
{
|
||||||
$date = $date->startOfDay();
|
$date = $date->startOfDay();
|
||||||
|
|
||||||
@ -42,10 +42,12 @@ public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PC-hez rendelt szállítási sablon lekérése (2. és 5. prioritáshoz egyaránt szükséges)
|
// PC-hez rendelt szállítási sablon lekérése (2. és 5. prioritáshoz egyaránt szükséges)
|
||||||
$assignment = ProfitCenterSupplierSchedule::where('profit_center_id', $pc->id)
|
if ($assignment === null) {
|
||||||
->where('supplier_id', $supplier->id)
|
$assignment = ProfitCenterSupplierSchedule::where('profit_center_id', $pc->id)
|
||||||
->with('deliverySchedule')
|
->where('supplier_id', $supplier->id)
|
||||||
->first();
|
->with('deliverySchedule')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Prioritás: DeliverySchedule-specifikus felülbírálás (a PC-hez rendelt szállítási sablon alapján)
|
// 2. Prioritás: DeliverySchedule-specifikus felülbírálás (a PC-hez rendelt szállítási sablon alapján)
|
||||||
if ($assignment && $assignment->delivery_schedule_id) {
|
if ($assignment && $assignment->delivery_schedule_id) {
|
||||||
@ -91,14 +93,14 @@ public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date
|
|||||||
*
|
*
|
||||||
* @return Collection<Carbon>
|
* @return Collection<Carbon>
|
||||||
*/
|
*/
|
||||||
public function getAvailableDeliveryDates(ProfitCenter $pc, Supplier $supplier, Carbon $start, Carbon $end): Collection
|
public function getAvailableDeliveryDates(ProfitCenter $pc, Supplier $supplier, Carbon $start, Carbon $end, ?ProfitCenterSupplierSchedule $assignment = null): Collection
|
||||||
{
|
{
|
||||||
$dates = collect();
|
$dates = collect();
|
||||||
$current = $start->copy()->startOfDay();
|
$current = $start->copy()->startOfDay();
|
||||||
$end = $end->copy()->startOfDay();
|
$end = $end->copy()->startOfDay();
|
||||||
|
|
||||||
while ($current <= $end) {
|
while ($current <= $end) {
|
||||||
if ($this->isDeliveryDay($pc, $supplier, $current)) {
|
if ($this->isDeliveryDay($pc, $supplier, $current, $assignment)) {
|
||||||
$dates->push($current->copy());
|
$dates->push($current->copy());
|
||||||
}
|
}
|
||||||
$current->addDay();
|
$current->addDay();
|
||||||
|
|||||||
@ -119,7 +119,10 @@ window.ProductAdmin=function (options,ProductItem) {
|
|||||||
{
|
{
|
||||||
"targets": 1,
|
"targets": 1,
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
return type === "sort" ? data.latinise() : data;
|
if (type === "sort") {
|
||||||
|
return (data && typeof data === 'string') ? data.latinise() : (data ?? '');
|
||||||
|
}
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//{ "visible": false, "targets": [ 0 ] }
|
//{ "visible": false, "targets": [ 0 ] }
|
||||||
@ -171,6 +174,7 @@ window.ProductAdmin=function (options,ProductItem) {
|
|||||||
ajax: {
|
ajax: {
|
||||||
url: Opts.URL.getProductSearch,
|
url: Opts.URL.getProductSearch,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
delay: 300,
|
||||||
data: function(params) {
|
data: function(params) {
|
||||||
return {
|
return {
|
||||||
term: params.term || '',
|
term: params.term || '',
|
||||||
@ -472,7 +476,10 @@ window.ProductAdmin=function (options,ProductItem) {
|
|||||||
{
|
{
|
||||||
"targets": 1,
|
"targets": 1,
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
return type === "sort" ? data.latinise() : data;
|
if (type === "sort") {
|
||||||
|
return (data && typeof data === 'string') ? data.latinise() : (data ?? '');
|
||||||
|
}
|
||||||
|
return data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//{ "visible": false, "targets": [ 0 ] }
|
//{ "visible": false, "targets": [ 0 ] }
|
||||||
|
|||||||
@ -197,6 +197,10 @@ window.select2CreateTag=function (params){
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.ajaxErrorHandler= function (xhr, ajaxOptions, thrownError){
|
window.ajaxErrorHandler= function (xhr, ajaxOptions, thrownError){
|
||||||
|
if (thrownError === 'abort' || xhr.status === 0) {
|
||||||
|
console.warn('AJAX kérés megszakítva (abort), hiba nem jelenik meg.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
debug(this);
|
debug(this);
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
console.error(ajaxOptions);
|
console.error(ajaxOptions);
|
||||||
|
|||||||
@ -169,6 +169,7 @@
|
|||||||
URL: {
|
URL: {
|
||||||
getDataTableContent: '',
|
getDataTableContent: '',
|
||||||
getProductSearch:'',
|
getProductSearch:'',
|
||||||
|
getProductGroupSearch:'',
|
||||||
getStat:'',
|
getStat:'',
|
||||||
index: '',
|
index: '',
|
||||||
show: '',
|
show: '',
|
||||||
@ -219,7 +220,25 @@
|
|||||||
root.container=$(Opts.containerCssSelector);
|
root.container=$(Opts.containerCssSelector);
|
||||||
root.container.hide();
|
root.container.hide();
|
||||||
root.resultContainer=$(Opts.resultContainerSelector);
|
root.resultContainer=$(Opts.resultContainerSelector);
|
||||||
root.container.find('select.supplierSelect, select.profitCenterSelect, select.productGroupSelect, select.producerSelect, select.hooreycaNamesSelect, select.specialOfferSelect').select2();
|
root.container.find('select.supplierSelect, select.profitCenterSelect, select.producerSelect, select.hooreycaNamesSelect, select.specialOfferSelect').select2();
|
||||||
|
root.container.find('select.productGroupSelect').select2({
|
||||||
|
placeholder: '...',
|
||||||
|
allowClear: true,
|
||||||
|
ajax: {
|
||||||
|
url: Opts.URL.getProductGroupSearch,
|
||||||
|
dataType: 'json',
|
||||||
|
data: function(params) {
|
||||||
|
return {
|
||||||
|
term: params.term || '',
|
||||||
|
supplierId: root.container.find('select.supplierSelect').val(),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
cache: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
root.container.find('select.supplierSelect').on('change', function() {
|
||||||
|
root.container.find('select.productGroupSelect').val(null).trigger('change');
|
||||||
|
});
|
||||||
debug(root.container.find('select.product'));
|
debug(root.container.find('select.product'));
|
||||||
root.container.find('select.productSelect').select2({
|
root.container.find('select.productSelect').select2({
|
||||||
placeholder: '...',
|
placeholder: '...',
|
||||||
@ -745,6 +764,7 @@ className: 'dt-body-right',
|
|||||||
URL: {
|
URL: {
|
||||||
show:'{{route('admin.statistics.show',"%id%")}}',
|
show:'{{route('admin.statistics.show',"%id%")}}',
|
||||||
getProductSearch:'{{route('admin.statistics.getProductSearch')}}',
|
getProductSearch:'{{route('admin.statistics.getProductSearch')}}',
|
||||||
|
getProductGroupSearch:'{{route('admin.statistics.getProductGroupSearch')}}',
|
||||||
getStat:'{{route('admin.statistics.getStat')}}',
|
getStat:'{{route('admin.statistics.getStat')}}',
|
||||||
//getProductGroupHTML:'{{route('admin.priceListProfitCenter.getProductGroupHTML')}}',
|
//getProductGroupHTML:'{{route('admin.priceListProfitCenter.getProductGroupHTML')}}',
|
||||||
|
|
||||||
|
|||||||
@ -163,6 +163,7 @@
|
|||||||
// Route::get('getDataTableContent',[SupplierControllerAdmin::class,'getDataTableContent'])->name('getDataTableContent');
|
// Route::get('getDataTableContent',[SupplierControllerAdmin::class,'getDataTableContent'])->name('getDataTableContent');
|
||||||
// dd('hello');
|
// dd('hello');
|
||||||
Route::get('getProductSearch', [StatisticsController::class, 'getProductSearch'])->name('getProductSearch');
|
Route::get('getProductSearch', [StatisticsController::class, 'getProductSearch'])->name('getProductSearch');
|
||||||
|
Route::get('getProductGroupSearch', [StatisticsController::class, 'getProductGroupSearch'])->name('getProductGroupSearch');
|
||||||
Route::post('getStat', [StatisticsController::class, 'getStat'])->name('getStat');
|
Route::post('getStat', [StatisticsController::class, 'getStat'])->name('getStat');
|
||||||
Route::resource('/', StatisticsController::class)->only([
|
Route::resource('/', StatisticsController::class)->only([
|
||||||
'index', 'show',
|
'index', 'show',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user