EV3-428 Statisztika
This commit is contained in:
parent
e119c4ae4a
commit
6758317599
@ -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');
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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')}}',
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user