Compare commits

..

5 Commits

Author SHA1 Message Date
E98Developer
5477b953a8 mod EV3-442 Profitcenter ütemezés 2. 2026-07-16 08:53:09 +02:00
E98Developer
558a99970a FIX EV3-445 Termékmodul- egy termék keresése, latinise null problem 2026-07-14 14:30:23 +02:00
E98Developer
50ebbbbd74 EV3-445 Termékmodul- egy termék keresése part 1 2026-07-14 10:09:38 +02:00
E98Developer
6758317599 EV3-428 Statisztika 2026-07-07 19:07:34 +02:00
E98Developer
e119c4ae4a ADD EV3-358 statisztika modul bővítése aktuális ár megjelenítéssel phase 7 test pdf create 2026-07-06 22:04:28 +02:00
12 changed files with 148 additions and 14 deletions

View File

@ -3,9 +3,33 @@
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Pages;
use App\Filament\Resources\ProfitCenterSupplierSchedules\ProfitCenterSupplierScheduleResource;
use App\Models\ProfitCenterSupplierSchedule;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
class CreateProfitCenterSupplierSchedule extends CreateRecord
{
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;
}
}

View File

@ -6,12 +6,38 @@
use Filament\Actions\DeleteAction;
use Filament\Actions\ForceDeleteAction;
use Filament\Actions\RestoreAction;
use Filament\Forms\Components\Select;
use Filament\Resources\Pages\EditRecord;
use Filament\Schemas\Schema;
class EditProfitCenterSupplierSchedule extends EditRecord
{
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
{
return [

View File

@ -2,6 +2,7 @@
namespace App\Filament\Resources\ProfitCenterSupplierSchedules\Schemas;
use App\Models\ProfitCenter;
use Filament\Forms\Components\Select;
use Filament\Schemas\Schema;
@ -13,8 +14,9 @@ public static function configure(Schema $schema): Schema
->components([
Select::make('profit_center_id')
->label('Profit Center')
->relationship('profitCenter', 'name')
->options(ProfitCenter::orderBy('name')->pluck('name', 'id'))
->searchable()
->multiple()
->required(),
Select::make('supplier_id')
->label('Beszállító')

View File

@ -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. */
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.
*
@ -74,6 +77,13 @@ public function onNextDeliveryDateChanged(?string $date): void
$this->refreshRecords();
}
#[On('delivery-schedule-changed')]
public function onDeliveryScheduleChanged(?int $deliveryScheduleId): void
{
$this->previewDeliveryScheduleId = $deliveryScheduleId;
$this->refreshRecords();
}
protected function loadRecordFromFilter(): void
{
if ($this->record instanceof ProfitCenterSupplierSchedule) {
@ -114,11 +124,19 @@ public function fetchEvents(array $info): array
$events = [];
// 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(
$this->record->profitCenter,
$this->record->supplier,
$start,
$end
$end,
$assignment
);
foreach ($deliveryDates as $date) {

View File

@ -149,6 +149,31 @@ private function getStatPriceChange(Request $request): JsonResponse
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
{
$page = $request->get('page');

View File

@ -105,7 +105,6 @@ public function index(): View|Response|JsonResponse
if (\request()->input('w') == 1) {
$testOrderId = 16497; // heti
$testOrderId = 16467; // heti
$testOrderId = 16507; // heti
// $testOrderId=16512; //heti
@ -113,7 +112,7 @@ public function index(): View|Response|JsonResponse
$testOrderId = 12140; // napi
$testOrderId = 16506; // napi
$testOrderId = 16571; // napi
$testOrderId = 16571; // napi
//$testOrderId = 308676; // napi
$testOrderId = 307975; // napi
}

View File

@ -4,6 +4,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Kalnoy\Nestedset\NodeTrait;
@ -32,6 +33,11 @@ class ProductGroup extends Model
protected ?array $needsId = null;
public function products(): HasMany
{
return $this->hasMany(Product::class, 'product_group_id');
}
private function getNodeToArray($node, $needChild, $maxDepth = 999)
{
if ($this->needsId) {

View File

@ -26,7 +26,7 @@ public function __construct(
* 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.
*/
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();
@ -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)
if ($assignment === null) {
$assignment = ProfitCenterSupplierSchedule::where('profit_center_id', $pc->id)
->where('supplier_id', $supplier->id)
->with('deliverySchedule')
->first();
}
// 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) {
@ -91,14 +93,14 @@ public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date
*
* @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();
$current = $start->copy()->startOfDay();
$end = $end->copy()->startOfDay();
while ($current <= $end) {
if ($this->isDeliveryDay($pc, $supplier, $current)) {
if ($this->isDeliveryDay($pc, $supplier, $current, $assignment)) {
$dates->push($current->copy());
}
$current->addDay();

View File

@ -119,7 +119,10 @@ window.ProductAdmin=function (options,ProductItem) {
{
"targets": 1,
"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 ] }
@ -171,6 +174,7 @@ window.ProductAdmin=function (options,ProductItem) {
ajax: {
url: Opts.URL.getProductSearch,
dataType: 'json',
delay: 300,
data: function(params) {
return {
term: params.term || '',
@ -472,7 +476,10 @@ window.ProductAdmin=function (options,ProductItem) {
{
"targets": 1,
"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 ] }

View File

@ -197,6 +197,10 @@ window.select2CreateTag=function (params){
}
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);
console.error(xhr);
console.error(ajaxOptions);

View File

@ -169,6 +169,7 @@
URL: {
getDataTableContent: '',
getProductSearch:'',
getProductGroupSearch:'',
getStat:'',
index: '',
show: '',
@ -219,7 +220,25 @@
root.container=$(Opts.containerCssSelector);
root.container.hide();
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'));
root.container.find('select.productSelect').select2({
placeholder: '...',
@ -745,6 +764,7 @@ className: 'dt-body-right',
URL: {
show:'{{route('admin.statistics.show',"%id%")}}',
getProductSearch:'{{route('admin.statistics.getProductSearch')}}',
getProductGroupSearch:'{{route('admin.statistics.getProductGroupSearch')}}',
getStat:'{{route('admin.statistics.getStat')}}',
//getProductGroupHTML:'{{route('admin.priceListProfitCenter.getProductGroupHTML')}}',

View File

@ -163,6 +163,7 @@
// Route::get('getDataTableContent',[SupplierControllerAdmin::class,'getDataTableContent'])->name('getDataTableContent');
// dd('hello');
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::resource('/', StatisticsController::class)->only([
'index', 'show',