Compare commits
No commits in common. "5477b953a8cf99e104e71ab045862b27cd8d58d8" and "834f64a0114b7a12f6d7ffb4a9aede94b10d7107" have entirely different histories.
5477b953a8
...
834f64a011
@ -3,33 +3,9 @@
|
|||||||
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,38 +6,12 @@
|
|||||||
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,7 +2,6 @@
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -14,9 +13,8 @@ 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')
|
||||||
->options(ProfitCenter::orderBy('name')->pluck('name', 'id'))
|
->relationship('profitCenter', 'name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->multiple()
|
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('supplier_id')
|
Select::make('supplier_id')
|
||||||
->label('Beszállító')
|
->label('Beszállító')
|
||||||
|
|||||||
@ -33,9 +33,6 @@ 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.
|
||||||
*
|
*
|
||||||
@ -77,13 +74,6 @@ 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) {
|
||||||
@ -124,19 +114,11 @@ 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,31 +149,6 @@ 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,6 +105,7 @@ 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
|
||||||
|
|
||||||
@ -112,7 +113,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 = 308676; // napi
|
$testOrderId = 16571; // napi
|
||||||
$testOrderId = 307975; // napi
|
$testOrderId = 307975; // napi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -33,11 +32,6 @@ 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, ?ProfitCenterSupplierSchedule $assignment = null): bool
|
public function isDeliveryDay(ProfitCenter $pc, Supplier $supplier, Carbon $date): bool
|
||||||
{
|
{
|
||||||
$date = $date->startOfDay();
|
$date = $date->startOfDay();
|
||||||
|
|
||||||
@ -42,12 +42,10 @@ 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)
|
||||||
if ($assignment === null) {
|
|
||||||
$assignment = ProfitCenterSupplierSchedule::where('profit_center_id', $pc->id)
|
$assignment = ProfitCenterSupplierSchedule::where('profit_center_id', $pc->id)
|
||||||
->where('supplier_id', $supplier->id)
|
->where('supplier_id', $supplier->id)
|
||||||
->with('deliverySchedule')
|
->with('deliverySchedule')
|
||||||
->first();
|
->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) {
|
||||||
@ -93,14 +91,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, ?ProfitCenterSupplierSchedule $assignment = null): Collection
|
public function getAvailableDeliveryDates(ProfitCenter $pc, Supplier $supplier, Carbon $start, Carbon $end): 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, $assignment)) {
|
if ($this->isDeliveryDay($pc, $supplier, $current)) {
|
||||||
$dates->push($current->copy());
|
$dates->push($current->copy());
|
||||||
}
|
}
|
||||||
$current->addDay();
|
$current->addDay();
|
||||||
|
|||||||
@ -119,10 +119,7 @@ window.ProductAdmin=function (options,ProductItem) {
|
|||||||
{
|
{
|
||||||
"targets": 1,
|
"targets": 1,
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
if (type === "sort") {
|
return type === "sort" ? data.latinise() : data;
|
||||||
return (data && typeof data === 'string') ? data.latinise() : (data ?? '');
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//{ "visible": false, "targets": [ 0 ] }
|
//{ "visible": false, "targets": [ 0 ] }
|
||||||
@ -174,7 +171,6 @@ 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 || '',
|
||||||
@ -476,10 +472,7 @@ window.ProductAdmin=function (options,ProductItem) {
|
|||||||
{
|
{
|
||||||
"targets": 1,
|
"targets": 1,
|
||||||
"render": function ( data, type, row ) {
|
"render": function ( data, type, row ) {
|
||||||
if (type === "sort") {
|
return type === "sort" ? data.latinise() : data;
|
||||||
return (data && typeof data === 'string') ? data.latinise() : (data ?? '');
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//{ "visible": false, "targets": [ 0 ] }
|
//{ "visible": false, "targets": [ 0 ] }
|
||||||
|
|||||||
@ -197,10 +197,6 @@ 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,7 +169,6 @@
|
|||||||
URL: {
|
URL: {
|
||||||
getDataTableContent: '',
|
getDataTableContent: '',
|
||||||
getProductSearch:'',
|
getProductSearch:'',
|
||||||
getProductGroupSearch:'',
|
|
||||||
getStat:'',
|
getStat:'',
|
||||||
index: '',
|
index: '',
|
||||||
show: '',
|
show: '',
|
||||||
@ -220,25 +219,7 @@
|
|||||||
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.producerSelect, select.hooreycaNamesSelect, select.specialOfferSelect').select2();
|
root.container.find('select.supplierSelect, select.profitCenterSelect, select.productGroupSelect, 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: '...',
|
||||||
@ -764,7 +745,6 @@ 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,7 +163,6 @@
|
|||||||
// 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