EV3-428 Statisztika

This commit is contained in:
E98Developer 2026-07-07 19:07:34 +02:00
parent e119c4ae4a
commit 6758317599
4 changed files with 53 additions and 1 deletions

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); 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');

View File

@ -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) {

View File

@ -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')}}',

View File

@ -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',